Skip to content

__test__

testfun · scripts/testfun/__test__.m

Run the self-tests embedded in a file.

test NAME test (NAME, MODE, FID) [N, NMAX, NXFAIL, NBUG, NSKIP, NRTSKIP, NREGRESSION] = test (…)

Tests are the "%!" comment blocks of the M-file (or C++ source or test file) NAME: assert, test, xtest, testif, error, warning, fail, shared and function blocks. MODE is "quiet", "normal" (default), "verbose", "explain" (print the legend of the report markers) or "grabdemo" (return the demo code and the block boundaries). FID receives the report.

With one output the result is true unless a test failed unexpectedly. With several outputs the counts are returned and every test is run.