-
Notifications
You must be signed in to change notification settings - Fork 129
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
Add validation tests for all functions. #102
Comments
I have included parameter validation tests on every API function and module of a library I am working on. To simplify the task, I have written another file (checks.scad) to be used by the API file including a bunch of test functions like: function is_3Dvec(v) = (0*v==[0,0,0]); Besides, checks.dat has 3 main functions to issue console error, warns and info messages like: function assert_msg(org, msg ) = ... assert_msg() is the base of parameter validation. The parameter org is a string containing the caller name. In warn_msg() and info_msg(), the parameter msg is a simple string. In assert_msg(), the msg parameter is a list with one element for each caller function parameter and where each element in the list is a pair of a boolean value and a string. A typical usage is: function add2vectors(v1, v2) = The result of add= add2vectors([0,0], [0,1,0]) would be the console message: ERROR in function add2vectors: ERROR: Assertion '_and(x)' failed in file checks.scad, line 37 Hope it helps. |
I suggest that we seek for a standardization of error messages to easy the user's task of identifying his/her error in the args. I have been trying to do it but it is already inconsistent. I have found many different styles of error message. Some questions to consider:
|
Basically duplicate of #231 |
All functions should have validation tests.
The text was updated successfully, but these errors were encountered: