I wrote ftest, which extracts lines starting with ##! and evaluates them with eval(). It doesn't cope with syntax errors elegantly. E.g., usage: r = mod(x,y) Compute modulo function, handling negative number correctly; i.e., mod(-1,3) is 2, not -1 as rem(-1,3) returns. function r=mod(x,y) if nargin != 2, usage("r=mod(x,y)"); endif r = x - floor(x./y).*y; endfunction ! if mod(5,3) != 2, disp("mod fails for positive a"); endif ! if mod(-5,3) != 1, disp("mod fails for negative a"); endif ! if mod(0,3) != 0, disp("mod fails for a=0"); endif ! if !isempty(mod([],[])), disp("mod fails for empty"); endif ! if any(mod([-5 5 0],[3 3 3]) != [1 2 0]), ! disp("mod fails for columns"); endif ! if any(mod([-5 5 0]',[3 3 3]') != [1 2 0]'), ! disp("mod fails for rows"); endif ! if any(any(mod([-5 5; 0 3],[3 3 ; 3 1]) != [1 2 ; 0 0])), ! disp("mod fails for matrices"); endif
Download Info
To download:
If you experience problems downloading a file, check if you have the
proper application to
view it first. Information about this may be contained
in the File-Format links below. In case of further problems read
the IDEAS help
file. Note that these files are not on the IDEAS
site. Please be patient as the files may be large.
Publisher Info
Software component provided by in its series Octave codes with number
C042505.