154
edits
(→Writing tests: added known failures and best practices section) |
m (→Assert: added tolerance info) |
||
Line 101: | Line 101: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
These are actually a shorthand version of | These are actually a shorthand version of {{codeline|%!test assert (foo (bar))}}, and {{codeline|assert}} is simply an Octave function that throws an error when two arguments fail to compare. A tolerance can be added to {{codeline|assert}} to pass results that are numerically not exactly equal: | ||
{{codeline|%!test assert (foo (bar))}}, and {{codeline|assert}} is simply | <syntaxhighlight lang="Octave"> | ||
an Octave function that throws an error when two arguments fail to compare. | %!assert (pi, 3.14159) # test fails as "Abs err 2.6536e-06 exceeds tol 0 by 3e-06" | ||
%!assert (pi, 3.14159, 1e-5) # test passes | |||
</syntaxhighlight> | |||
=== Error / Warning === | === Error / Warning === |
edits