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}) |
5838
|
9 ## Return the text defining @var{n}-th input to the function. |
5837
|
10 ## @end deftypefn |
|
11 |
|
12 function s = inputname (n) |
5838
|
13 s = evalin ("caller", sprintf ("deblank (argn(%d,:));", n)); |
5837
|
14 endfunction |
|
15 |
|
16 ## Warning: heap big magic in the following tests!!! |
|
17 ## The test function builds a private context for each |
|
18 ## test, with only the specified values shared between |
|
19 ## them. It does this using the following template: |
|
20 ## |
|
21 ## function [<shared>] = testfn(<shared>) |
|
22 ## <test> |
|
23 ## |
|
24 ## To test inputname, I need a function context invoked |
|
25 ## with known parameter names. So define a couple of |
|
26 ## shared parameters, et voila!, the test is trivial. |
|
27 %!shared hello,worldly |
|
28 %!assert(inputname(1),'hello'); |
|
29 %!assert(inputname(2),'worldly'); |