FTEST: Octave function test routine
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
|Date of creation:||16 Apr 2000|
|Contact details of provider:|
When requesting a correction, please mention this item's handle: RePEc:cod:octave:c042505. See general information about how to correct material in RePEc.
For technical questions regarding this item, or to correct its authors, title, abstract, bibliographic or download information, contact: ()
If you have authored this item and are not yet registered with RePEc, we encourage you to do it here. This allows to link your profile to this item. It also allows you to accept potential citations to this item that we are uncertain about.
If references are entirely missing, you can add them using this form.
If the full references list an item that is present in RePEc, but the system did not link to it, you can help with this form.
If you know of missing items citing this one, you can help us creating those links by adding the relevant references in the same way as above, for each refering item. If you are a registered author of this item, you may also want to check the "citations" tab in your profile, as there may be some citations waiting for confirmation.
Please note that corrections may take a couple of weeks to filter through the various RePEc services.