Skip to content

Commit

Permalink
update the TAP functions to use nargin explicit argument checking. Co…
Browse files Browse the repository at this point in the history
…mments are optional now
  • Loading branch information
Whiteknight committed Dec 7, 2009
1 parent 30a0d82 commit 32c43e3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
8 changes: 6 additions & 2 deletions toolbox/is.m
Expand Up @@ -3,5 +3,9 @@ function is(a, b, comment)
%% tests that the two values a and b are equal. Calls ok() to handle
%% the test output logic, so has all the same capabilities as that
%% function.
ok(a == b, comment);
endfunction
if nargin == 2
ok(a == b, comment);
else
ok(a == b);
endif
endfunction
7 changes: 6 additions & 1 deletion toolbox/nok.m
Expand Up @@ -9,5 +9,10 @@ function nok(bad, comment)
else
bad = 0;
end
ok(bad, comment);

if nargin == 2
ok(bad, comment);
else
ok(bad);
endif
endfunction
9 changes: 6 additions & 3 deletions toolbox/ok.m
Expand Up @@ -8,9 +8,12 @@ function ok(good, comment)
global _TAP_TEST_CNT; % the number of the current test

if good == 0
printf("not ok %d %s", _TAP_TEST_CNT, comment);
else
printf("ok %d %s", _TAP_TEST_CNT, comment);
printf("not ");
end
printf("ok %d", _TAP_TEST_CNT);

if nargin == 2
printf(" %s", comment);
end

if _TAP_TODO == 1
Expand Down

0 comments on commit 32c43e3

Please sign in to comment.