changeset 9204:1f47a9404d93

nargchk.m: don't generate error if output is struct
author John W. Eaton <jwe@octave.org>
date Fri, 15 May 2009 11:46:10 -0400
parents a542fc158175
children ba7f45642ffe
files scripts/ChangeLog scripts/general/nargchk.m
diffstat 2 files changed, 13 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,9 @@
+2009-05-15  John W. Eaton  <jwe@octave.org>
+
+	* general/nargchk.m: Don't generate error if output is struct.
+	Uncomment some additional tests.
+	From Alois Schloegl <alois.schloegl@tugraz.at>
+
 2009-05-14  Jaroslav Hajek  <highegg@gmail.com>
 
 	* optimization/fminunc.m: Import the step adaptation strategy
--- a/scripts/general/nargchk.m
+++ b/scripts/general/nargchk.m
@@ -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)