5837
|
1 ## Copyright (C) 2004 Paul Kienzle |
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## This program is free software and is in the public domain |
|
6 |
|
7 ## -*- texinfo -*- |
|
8 ## @deftypefn {Function File} {} inputname (@var{n}) |
|
9 ## |
|
10 ## Return the text defining n-th input to the function. |
|
11 ## |
|
12 ## @end deftypefn |
|
13 |
|
14 function s = inputname (n) |
|
15 s = evalin ('caller', sprintf('deblank(argn(%d,:));', n)); |
|
16 endfunction |
|
17 |
|
18 ## Warning: heap big magic in the following tests!!! |
|
19 ## The test function builds a private context for each |
|
20 ## test, with only the specified values shared between |
|
21 ## them. It does this using the following template: |
|
22 ## |
|
23 ## function [<shared>] = testfn(<shared>) |
|
24 ## <test> |
|
25 ## |
|
26 ## To test inputname, I need a function context invoked |
|
27 ## with known parameter names. So define a couple of |
|
28 ## shared parameters, et voila!, the test is trivial. |
|
29 %!shared hello,worldly |
|
30 %!assert(inputname(1),'hello'); |
|
31 %!assert(inputname(2),'worldly'); |