-
-
Couldn't load subscription status.
- Fork 88
Port Multiply matrices tests to new format #559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Note: This port uses the existing tests, but I can add more or change them if desired. It seems like hTest's HTML-based testing flattens the matrix/vector when previewing the inputs and results. I'm not sure how to change the preview, but the test does execute correctly. To emulate failing being expected for the Incorrect Data tests, the solution I came up with is having |
✅ Deploy Preview for colorjs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
|
Post Script: I have re-implemented A gist of the typescript implementation. Let me know if you'd like such changes up-streamed. These changes fix the 2 ported tests that I skipped (vector with vector, and multiplying empty vectors). |
|
Thank you for working on this! For mathjs and the HTML testsuite there are two ways to do it:
|
|
This points out a very interesting use case for hTest: so far it assumes that you know in advance whether a test should pass or produce an error, but if your tests are simply comparing with the output from something else, you may not know. I’ll think of what’s the best way to address this use case in hTest. |
Given that the Node runner doesn’t output anything for passing tests, are they really useful? Should we remove them? I'll defer to the others. |
My first first attempt of this was applying a function to expect This would also mean that I recently watched a video with a python core developer taking about unit tests and he mentions the Capture Recipe that might be useful for this case: https://youtu.be/jSIsyMd2-RY?t=1451 Python Code: def capture(func, *args, **kwargs):
"Return a tuple with the returned exception and value."
try:
return [None, func(*args, **kwargs)]
except Exception as e:
return [type(e), None]I haven't used it before but it looks like it creates a structure for differentiating the error-free and error result from function calls which allows easier comparison. This could be useful with the |
|
Oh interesting. |
Thanks! I finally got this to work and so could clean up the variable and function definitions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
For color.js I'd say them passing automatically probably isn't useful. In the abstract though it does sound like a useful example of tests being used as supplemental documentation. For hTest in general it might be nice to intentionally specify that something shouldn't work or isn't supported and that failing test would mean some assumptions about the code or documentation need to be updated. Though this a good unit test does not necessarily make. If there was a good way to succinctly visualize what the intention is behind such tests then it may useful for quick reference (e.g. the old test format displaying the matrix structure highlights the results with context). But this would basically require adding a visualization framework/implementation to hTest. I'd say declarative and flexible unit testing is enough of a very good goal on its own. 😄 |
What I assumed could be the case is the same arguments that are given to But I'm only thinking of data being passed as arguments, not functions. I have much better intuitive sense of data manipulation tasks and pass by value arguments, but that is just my bias. I think one of the bigger benefits from a
My naive assumption would be |
I have a lot of thoughts, but I think this is not the right place for this discussion — would you mind opening an issue over at hTest so we could discuss this and flesh out the design? Thanks! |
An attempt at porting the Matrix Multiplication tests to the new format.
I wanted to try out hTest and thought working on #398 would be a good way to start.
I was hoping to use themath.jsmatrix multiplication methods as the test oracle, but I couldn't figure out how to get the dynamic loading in the HTML-based testing to properly import it.I've left comments for all of that code I used, just in case anyone else knows how to make that work.Feel free to edit this branch (maintainers) or fork it (everyone else).