Mercurial > hg > octave-nkf
view scripts/miscellaneous/inputname.m @ 5965:290420f503b2
[project @ 2006-08-24 19:01:16 by jwe]
author | jwe |
---|---|
date | Thu, 24 Aug 2006 19:01:17 +0000 |
parents | 376e02b2ce70 |
children | 93c65f2a5668 |
line wrap: on
line source
## Copyright (C) 2004 Paul Kienzle ## ## This file is part of Octave. ## ## This program is free software and is in the public domain ## -*- texinfo -*- ## @deftypefn {Function File} {} inputname (@var{n}) ## Return the text defining @var{n}-th input to the function. ## @end deftypefn function s = inputname (n) s = evalin ("caller", sprintf ("deblank (argn(%d,:));", n)); endfunction ## Warning: heap big magic in the following tests!!! ## The test function builds a private context for each ## test, with only the specified values shared between ## them. It does this using the following template: ## ## function [<shared>] = testfn(<shared>) ## <test> ## ## To test inputname, I need a function context invoked ## with known parameter names. So define a couple of ## shared parameters, et voila!, the test is trivial. %!shared hello,worldly %!assert(inputname(1),'hello'); %!assert(inputname(2),'worldly');