annotate test/args.tst @ 20614:10ec79b47808

use new string_value method to handle value extraction errors * __voronoi__.cc, chol.cc, colamd.cc, fftw.cc: Use new string_value method.
author John W. Eaton <jwe@octave.org>
date Thu, 08 Oct 2015 18:15:56 -0400
parents 4197fc428c7d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19731
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
1 ## Copyright (C) 2006-2015 John W. Eaton
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
2 ##
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
3 ## This file is part of Octave.
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
4 ##
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
6 ## under the terms of the GNU General Public License as published by
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
8 ## your option) any later version.
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
9 ##
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
13 ## General Public License for more details.
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
14 ##
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
15 ## You should have received a copy of the GNU General Public License
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
17 ## <http://www.gnu.org/licenses/>.
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
18
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
19 ########################################
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
20 ## No inputs or no outputs
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
21
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
22 ## no input or output arguments
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
23 %!function f ()
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
24 %! assert (nargin, 0);
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
25 %! assert (nargout, 0);
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
26 %!endfunction
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
27 %!test
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
28 %! f;
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
29
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
30 ## one input with two possible inputs
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
31 %!function f (x, y)
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
32 %! assert (nargin, 1);
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
33 %! assert (nargout, 0);
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
34 %!endfunction
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
35 %!test
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
36 %! f (1);
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
37
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
38 ## no inputs, one of multiple outputs
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
39 %!function [x, y] = f ()
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
40 %! assert (nargin, 0);
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
41 %! assert (nargout, 1);
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
42 %! x = 2;
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
43 %!endfunction
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
44 %!test
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
45 %! assert (f (), 2);
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
46
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
47 ## one of multiple inputs, one of multiple outputs
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
48 %!function [x, y] = f (a, b)
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
49 %! assert (nargin, 1);
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
50 %! assert (nargout, 1);
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
51 %! x = a;
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
52 %!endfunction
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
53 %!test
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
54 %! assert (f (1), 1);
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
55
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
56 ########################################
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
57 ## Varargin, varargout
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
58
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
59 ## varargin and varargout with no inputs or outputs
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
60 %!function [varargout] = f (varargin)
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
61 %! assert (nargin, 0);
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
62 %! assert (nargout, 0);
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
63 %!endfunction
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
64 %!test
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
65 %! f;
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
66
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
67 ## varargin and varargout with one input
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
68 %!function [varargout] = f (x, varargin)
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
69 %! assert (nargin, 1);
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
70 %! assert (nargout, 0);
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
71 %!endfunction
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
72 %!test
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
73 %! f (1);
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
74
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
75 ## varargin and varargout with one output
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
76 %!function [x, varargout] = f (varargin)
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
77 %! assert (nargin, 0);
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
78 %! assert (nargout, 1);
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
79 %! x = 2;
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
80 %!endfunction
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
81 %!test
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
82 %! assert (f (), 2);
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
83
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
84 ## varargin and varargout with one input and output
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
85 %!function [varargout] = f (varargin)
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
86 %! assert (nargin, 1);
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
87 %! assert (nargout, 1);
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
88 %! varargout{1} = varargin{1};
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
89 %!endfunction
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
90 %!test
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
91 %! assert (f (1), 1);
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
92
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
93 ## multiple inputs, multiple outputs, but not all of either
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
94 ## WARNING: The original test did not assign the outputs, it just
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
95 ## requested them, and I think that is supposed to be an error. It also
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
96 ## still has a non-assigned output argument.
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
97 %!function [x, y, z] = f (a, b, c, d, e)
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
98 %! assert (nargin, 4);
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
99 %! assert (nargout, 2);
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
100 %! x = a;
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
101 %! y = b;
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
102 %!endfunction
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
103 %!test
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
104 %! [s, t] = f (1, 2, 3, 4);
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
105 %! assert ([s t], [1 2]);
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
106
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
107 ## Fully used varargin and varargout
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
108 %!function [varargout] = f (varargin)
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
109 %! assert (nargin, 3);
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
110 %! assert (nargout, 4);
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
111 %! varargout{1} = varargin{1};
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
112 %! varargout{2} = varargin{2};
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
113 %! varargout{3} = varargin{3};
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
114 %! varargout{4} = 4;
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
115 %!endfunction
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
116 %!test
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
117 %! [s, t, u, v] = f (1, 2, 3);
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
118 %! assert ([s t u v], [1 2 3 4]);
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
119
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
120 ## Test default arguments
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
121 ## numeric
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
122 %!function f (x = 0)
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
123 %! assert (x, 0);
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
124 %!endfunction
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
125 %!test
17314
7f27a3cbdb41 Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents: 16030
diff changeset
126 %! f()
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
127
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
128 ## numeric vector (spaces)
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
129 %!function f (x = [0 1 2])
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
130 %! assert (x, [0 1 2]);
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
131 %!endfunction
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
132 %!test
17314
7f27a3cbdb41 Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents: 16030
diff changeset
133 %! f()
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
134
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
135 ## numeric vector (range)
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
136 %!function f (x = 1:3)
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
137 %! assert (x, 1:3);
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
138 %!endfunction
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
139 %!test
17314
7f27a3cbdb41 Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents: 16030
diff changeset
140 %! f()
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
141
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
142 ## numeric vector (commas)
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
143 %!function f (x = [0,1,2])
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
144 %! assert (x, [0 1 2]);
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
145 %!endfunction
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
146 %!test
17314
7f27a3cbdb41 Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents: 16030
diff changeset
147 %! f()
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
148
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
149 ## numeric vector (commas and spaces)
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
150 %!function f (x = [0, 1, 2])
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
151 %! assert (x, [0 1 2]);
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
152 %!endfunction
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
153 %!test
17314
7f27a3cbdb41 Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents: 16030
diff changeset
154 %! f()
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
155
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
156 ## numeric matrix
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
157 %!function f (x = [0, 1, 2;3, 4, 5])
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
158 %! assert (x, [0 1 2;3 4 5]);
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
159 %!endfunction
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
160 %!test
17314
7f27a3cbdb41 Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents: 16030
diff changeset
161 %! f()
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
162
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
163 ## empty cell
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
164 %!function f (x = {})
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
165 %! assert (x, {});
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
166 %!endfunction
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
167 %!test
17314
7f27a3cbdb41 Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents: 16030
diff changeset
168 %! f()
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
169
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
170 ## full cell
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
171 %!function f (x = {1})
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
172 %! assert (x, {1});
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
173 %!endfunction
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
174 %!test
17314
7f27a3cbdb41 Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents: 16030
diff changeset
175 %! f()
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
176
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
177 ## many cells
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
178 %!function f (x = {1 'a' "b" 2.0 struct("a", 3)})
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
179 %! assert (x, {1 'a' "b" 2.0 struct("a", 3)});
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
180 %!endfunction
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
181 %!test
17314
7f27a3cbdb41 Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents: 16030
diff changeset
182 %! f()
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
183
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
184 ## struct
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
185 %!function f (x = struct("a", 3))
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
186 %! assert (x, struct ("a", 3));
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
187 %!endfunction
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
188 %!test
17314
7f27a3cbdb41 Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents: 16030
diff changeset
189 %! f()
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
190
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
191 ## char (double quotes)
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
192 %!function f (x = "a")
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
193 %! assert (x, "a");
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
194 %!endfunction
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
195 %!test
17314
7f27a3cbdb41 Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents: 16030
diff changeset
196 %! f()
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
197
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
198 ## char (single quotes)
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
199 %!function f (x = 'a')
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
200 %! assert (x, "a");
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
201 %!endfunction
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
202 %!test
17314
7f27a3cbdb41 Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents: 16030
diff changeset
203 %! f()
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
204
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
205 ## char (string, double quotes)
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
206 %!function f (x = "abc123")
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
207 %! assert (x, "abc123");
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
208 %!endfunction
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
209 %!test
17314
7f27a3cbdb41 Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents: 16030
diff changeset
210 %! f()
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
211
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
212 ## char (string, double quotes, punctuation)
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
213 %!function f (x = "abc123`1234567890-=~!@#$%^&*()_+[]{}|;':\",./<>?\\")
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
214 %! assert (x, "abc123`1234567890-=~!@#$%^&*()_+[]{}|;':\",./<>?\\");
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
215 %!endfunction
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
216 %!test
17314
7f27a3cbdb41 Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents: 16030
diff changeset
217 %! f()
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
218
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
219 ## Function handle (builtin)
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
220 %!function f (x = @sin)
8805
065a05eb148a test_args.m: don't use assert to test for function handles
John W. Eaton <jwe@octave.org>
parents: 7775
diff changeset
221 %! finfo = functions (x);
065a05eb148a test_args.m: don't use assert to test for function handles
John W. Eaton <jwe@octave.org>
parents: 7775
diff changeset
222 %! fname = finfo.function;
065a05eb148a test_args.m: don't use assert to test for function handles
John W. Eaton <jwe@octave.org>
parents: 7775
diff changeset
223 %! assert (isa (x, "function_handle") && strcmp (fname, "sin"));
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
224 %!endfunction
8805
065a05eb148a test_args.m: don't use assert to test for function handles
John W. Eaton <jwe@octave.org>
parents: 7775
diff changeset
225 %!test
17314
7f27a3cbdb41 Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents: 16030
diff changeset
226 %! f()
7775
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
227
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
228 ## Function handle (anonymous)
c10d77387d96 test_args: update function argument tests
bill@denney.ws
parents: 7017
diff changeset
229 %!function f (x = @(x) x.^2)
8805
065a05eb148a test_args.m: don't use assert to test for function handles
John W. Eaton <jwe@octave.org>
parents: 7775
diff changeset
230 %! finfo = functions (x);
065a05eb148a test_args.m: don't use assert to test for function handles
John W. Eaton <jwe@octave.org>
parents: 7775
diff changeset
231 %! ftype = finfo.type;
065a05eb148a test_args.m: don't use assert to test for function handles
John W. Eaton <jwe@octave.org>
parents: 7775
diff changeset
232 %! assert (isa (x, "function_handle") && strcmp (ftype, "anonymous"));
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
233 %!endfunction
8805
065a05eb148a test_args.m: don't use assert to test for function handles
John W. Eaton <jwe@octave.org>
parents: 7775
diff changeset
234 %!test
17314
7f27a3cbdb41 Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents: 16030
diff changeset
235 %! f()
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
236