FTEST: Octave function test routine
AbstractI 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 InfoIf you experience problems downloading a file, check if you have the proper application to view it first. In case of further problems read the IDEAS help page. Note that these files are not on the IDEAS site. Please be patient as the files may be large.
Bibliographic InfoSoftware component provided by in its series Octave codes with number C042505.
Programming language: Octave
Date of creation: 16 Apr 2000
Date of revision:
Contact details of provider:
For technical questions regarding this item, or to correct its authors, title, abstract, bibliographic or download information, contact: ().
If references are entirely missing, you can add them using this form.