Mercurial > hg > octave-nkf
changeset 12705:4972eb61c6d6
Fix bug with error() not accepting an empty struct input (Bug #33428).
* nargchk.m, nargoutchk.m: Return scalar empty struct if there is no error.
* error.cc: Accept empty struct as input with no error, per Matlab.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sat, 04 Jun 2011 16:10:38 -0700 |
parents | da6cbb752368 |
children | a5f4dad4ec27 |
files | scripts/general/nargchk.m scripts/general/nargoutchk.m src/error.cc |
diffstat | 3 files changed, 13 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/general/nargchk.m +++ b/scripts/general/nargchk.m @@ -56,11 +56,12 @@ if (strcmpi (outtype, "string")) msg = msg.message; elseif (isempty (msg.message)) - msg = struct ([]); + msg = struct (); endif endfunction + ## Tests %!shared stmin, stmax %! stmin = struct ("message", "not enough input arguments", @@ -73,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"), struct()) +%!assert (nargchk (0, 1, 1, "struct"), struct()) %!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,17 +55,13 @@ if (strcmpi (outtype, "string")) msg = msg.message; - else - if (isempty (msg.message)) - msg = struct ([]); - endif - ## FIXME: remove the error below if error is modified to accept - ## struct inputs - error ("nargoutchk: error does not yet support struct inputs"); + elseif (isempty (msg.message)) + msg = struct (); endif endfunction + ## Tests %!shared stmin, stmax %! stmin = struct ("message", "not enough output arguments", @@ -78,7 +74,7 @@ %!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 (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)