Mercurial > octave
changeset 26208:fc7b842daca1
use inputname function instead of argn automatic variable
* assert.m, test.m: Use inputname function instead of argn automatic
variable to get function argument names.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 12 Dec 2018 00:50:34 -0500 |
parents | b964092ad9f8 |
children | 33913d29bed4 |
files | scripts/testfun/assert.m scripts/testfun/test.m |
diffstat | 2 files changed, 7 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/testfun/assert.m Tue Dec 11 17:08:10 2018 -0800 +++ b/scripts/testfun/assert.m Wed Dec 12 00:50:34 2018 -0500 @@ -88,7 +88,7 @@ || isempty (cond) || ! all (cond(:))) if (nargin == 1) ## Perhaps, say which elements failed? - argin = ["(" strjoin(cellstr (argn), ",") ")"]; + argin = ["(" inputname(1) ")"]; error ("assert %s failed", argin); else error (varargin{:}); @@ -401,7 +401,11 @@ ## Print any errors if (! isempty (err.index)) - argin = ["(" strjoin(cellstr (argn), ",") ")"]; + arg_names = cell (nargin, 1); + for i = 1:nargin + arg_names{i} = inputname (i); + endfor + argin = ["(" strjoin(arg_names, ",") ")"]; if (! isempty (errmsg)) errmsg = [errmsg "\n"]; endif
--- a/scripts/testfun/test.m Tue Dec 11 17:08:10 2018 -0800 +++ b/scripts/testfun/test.m Wed Dec 12 00:50:34 2018 -0500 @@ -815,7 +815,7 @@ ## Create structure with fieldnames the name of the input variables. function s = var2struct (varargin) for i = 1:nargin - s.(deblank (argn(i,:))) = varargin{i}; + s.(inputname (i)) = varargin{i}; endfor endfunction