changeset 26216:96b6b69a1575

* inputname.m: Fix tests for new argument; new tests.
author John W. Eaton <jwe@octave.org>
date Wed, 12 Dec 2018 22:32:26 -0500
parents 39e84bf92d18
children 31267a10f8a9
files scripts/miscellaneous/inputname.m
diffstat 1 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/miscellaneous/inputname.m	Wed Dec 12 22:02:02 2018 -0500
+++ b/scripts/miscellaneous/inputname.m	Wed Dec 12 22:32:26 2018 -0500
@@ -40,7 +40,7 @@
 
 function name = inputname (n, ids_only = true)
 
-  if (nargin > 2)
+  if (nargin < 1 || nargin > 2)
     print_usage ();
   endif
 
@@ -83,11 +83,17 @@
 %!assert (inputname (-1), "")
 %!assert (inputname (1), "")
 
-%!function r = __foo__ (x, y)
+%!function r = __foo1__ (x, y)
 %!  r = inputname (2);
 %!endfunction
-%!assert (__foo__ (pi, e), "e")
-%!assert (feval (@__foo__, pi, e), "e")
+%!assert (__foo1__ (pi, e), "e")
+%!assert (feval (@__foo1__, pi, e), "e")
+
+%!function r = __foo2__ (x, y)
+%!  r = inputname (2, false);
+%!endfunction
+%!assert (__foo2__ (pi+1, 2+2), "2 + 2")
+%!assert (feval (@__foo2__, pi, pi/2), "pi / 2")
 
 %!error inputname ()
-%!error inputname (1,2)
+%!error inputname (1,2,3)