Mercurial > hg > octave-nkf
diff scripts/general/nargchk.m @ 12865:a4d1581f9e72
Return correct struct for nargchk, nargoutchk (Bug #33808).
* nargchk.m, nargoutchk.m: Return struct with message and identifier fields
when number of arguments is valid, not just an empty struct.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Wed, 20 Jul 2011 10:41:59 -0700 |
parents | 4972eb61c6d6 |
children | 49553ea11764 |
line wrap: on
line diff
--- a/scripts/general/nargchk.m +++ b/scripts/general/nargchk.m @@ -55,15 +55,15 @@ if (strcmpi (outtype, "string")) msg = msg.message; - elseif (isempty (msg.message)) - msg = struct (); endif endfunction ## Tests -%!shared stmin, stmax +%!shared stnul, stmin, stmax +%! stnul = struct ("message", "", +%! "identifier", ""); %! stmin = struct ("message", "not enough input arguments", %! "identifier", "Octave:nargchk:not-enough-inputs"); %! stmax = struct ("message", "too many input arguments", @@ -74,7 +74,7 @@ %!assert (nargchk (0, 1, 2), "too many input arguments") %!assert (nargchk (0, 1, 2, "string"), "too many input arguments") ## Struct outputs -%!assert (nargchk (0, 1, 0, "struct"), struct()) -%!assert (nargchk (0, 1, 1, "struct"), struct()) +%!assert (nargchk (0, 1, 0, "struct"), stnul) +%!assert (nargchk (0, 1, 1, "struct"), stnul) %!assert (nargchk (1, 1, 0, "struct"), stmin) %!assert (nargchk (0, 1, 2, "struct"), stmax)