Perform tests from the first file in the loadpath matching name.
test
can be called as a command or as a function. Called with a single argument name, the tests are run interactively and stop after the first error is encountered.With a second argument the tests which are performed and the amount of output is selected.
- 'quiet'
- Don't report all the tests as they happen, just the errors.
- 'normal'
- Report all tests as they happen, but don't do tests which require user interaction.
- 'verbose'
- Do tests which require user interaction.
The argument fid can be used to allow batch processing. Errors can be written to the already open file defined by fid, and hopefully when octave crashes this file will tell you what was happening when it did. You can use
stdout
if you want to see the results as they happen. You can also give a file name rather than an fid, in which case the contents of the file will be replaced with the log from the current test.Called with a single output argument success,
test
returns true if all of the tests were successful. Called with two output arguments n and max, the number of successful tests and the total number of tests in the file name are returned.If the second argument is the string 'grabdemo', the contents of the demo blocks are extracted but not executed. Code for all code blocks is concatenated and returned as code with idx being a vector of positions of the ends of the demo blocks.
If the second argument is 'explain', then name is ignored and an explanation of the line markers used is written to the file fid.
The following code
toeplitz ([1,2,3,4],[1,5,6])
Produces the following output
ans = 1 5 6 2 1 5 3 2 1 4 3 2
The following code
# multiline demo block t=[0:0.01:2*pi]; x=sin(t); plot(t,x); % you should now see a sine wave in your figure window
Produces the following figure
ans = 1 5 6 2 1 5 3 2 1 4 3 2
![]() |
The following code
a=3 # single line demo blocks work too
Produces the following output
a = 3
![]() |