Mercurial > hg > octave-terminal
changeset 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 | 213c791292a6 |
children | fe6e2afcd9ee |
files | scripts/general/nargchk.m scripts/general/nargoutchk.m |
diffstat | 2 files changed, 13 insertions(+), 12 deletions(-) [+] |
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)
--- a/scripts/general/nargoutchk.m +++ b/scripts/general/nargoutchk.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 output arguments", %! "identifier", "Octave:nargoutchk:not-enough-outputs"); %! stmax = struct ("message", "too many output arguments", @@ -74,7 +74,8 @@ %!assert (nargoutchk (0, 1, 2), "too many output arguments") %!assert (nargoutchk (0, 1, 2, "string"), "too many output arguments") ## Struct outputs -#%!assert (nargoutchk (0, 1, 0, "struct"), struct()) -#%!assert (nargoutchk (0, 1, 1, "struct"), struct()) -#%!assert (nargoutchk (1, 1, 0, "struct"), stmin) -#%!assert (nargoutchk (0, 1, 2, "struct"), stmax) +%!assert (nargoutchk (0, 1, 0, "struct"), stnul) +%!assert (nargoutchk (0, 1, 1, "struct"), stnul) +%!assert (nargoutchk (1, 1, 0, "struct"), stmin) +%!assert (nargoutchk (0, 1, 2, "struct"), stmax) +