omdl
v0.5
OpenSCAD Mechanical Design Library
|
General utilities. More...
Files | |
file | utilities.scad |
Miscellaneous utilities. | |
file | validation.scad |
Result validation functions. | |
function | stack (b=0, t=0) |
Format the function call stack as a string. More... | |
function | validate (d, cv, t, ev, p=4, pf=false) |
Compare a computed test value with an known good result. More... | |
General utilities.
function stack | ( | b | = 0 , |
t | = 0 |
||
) |
Format the function call stack as a string.
b | <decimal> The stack index bottom offset. Include function names above this offset. |
t | <decimal> The stack index top offset. Include function names below this offset. |
b
is greater than the current number of function instances (ie: bo > $parent_modules-1
). "root()"
when the function call stack is empty (ie: at the root of the script). function validate | ( | d | , |
cv | , | ||
t | , | ||
ev | , | ||
p | = 4 , |
||
pf | = false |
||
) |
Compare a computed test value with an known good result.
d | <string> A description. |
cv | <value> A computed value to validate. |
t | <string|boolean> The validation type. |
ev | <value> The expected good value. |
p | <number> A numerical precision for approximate comparisons. |
pf | <boolean> Result reported as a pass or fail boolean value. |
validation types | pass if (else fail) |
---|---|
"almost" | cv almost equals ev |
"equals" | cv equals ev |
"not" | cv not equal to ev |
"true" | true | cv is true |
"false" | false | cv is false |
Example
Result
p
. This specifies the number of digits of precision for each numerical comparison. A passing result indicates that cv
equals ev
to the number of decimal digits specified by p
. The comparison is performed by the function almost_equal.