# HG changeset patch # User John W. Eaton # Date 1242402370 14400 # Node ID 1f47a9404d9304bd98e71c7eb9674c4f2da93cf0 # Parent a542fc1581759f1893ce83b60fabd35756da49e2 nargchk.m: don't generate error if output is struct diff -r a542fc158175 -r 1f47a9404d93 scripts/ChangeLog --- a/scripts/ChangeLog Fri May 15 11:31:50 2009 -0400 +++ b/scripts/ChangeLog Fri May 15 11:46:10 2009 -0400 @@ -1,3 +1,9 @@ +2009-05-15 John W. Eaton + + * general/nargchk.m: Don't generate error if output is struct. + Uncomment some additional tests. + From Alois Schloegl + 2009-05-14 Jaroslav Hajek * optimization/fminunc.m: Import the step adaptation strategy diff -r a542fc158175 -r 1f47a9404d93 scripts/general/nargchk.m --- a/scripts/general/nargchk.m Fri May 15 11:31:50 2009 -0400 +++ b/scripts/general/nargchk.m Fri May 15 11:46:10 2009 -0400 @@ -38,7 +38,7 @@ error ("nargchk: minargs must be <= maxargs"); elseif (nargin == 3) outtype = "string"; - elseif (! any (strcmpi (outtype, {"string" "struct"}))) + elseif (! any (strcmpi (outtype, {"string", "struct"}))) error ("nargchk: output type must be either string or struct"); elseif (! (isscalar (mina) && isscalar (maxa) && isscalar (narg))) error ("nargchk: mina, maxa, and narg must be scalars"); @@ -55,13 +55,8 @@ 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 ("nargchk: error does not yet support struct inputs"); + elseif (isempty (msg.message)) + msg = struct ([]); endif endfunction @@ -78,7 +73,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 (1, 1, 0, "struct"), stmin) -#%!assert (nargchk (0, 1, 2, "struct"), stmax) +%!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)