Mercurial > octave
annotate test/args.tst @ 31214:19bd1953fc1d stable
GitHub-CI: Remove ubuntu-18.04 runners from build matrix.
* .github/workflow/make.yaml (ubuntu): GitHub-hosted runners for ubuntu-18.04
are being deprecated. Remove them from build matrix. See also:
https://github.com/actions/runner-images/issues/6002
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Tue, 30 Aug 2022 11:16:27 +0200 |
parents | 796f54d4ddbf |
children | 597f3ee61a48 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 ######################################################################## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 ## |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
3 ## Copyright (C) 2006-2022 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
4 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 ## See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
7016 | 7 ## |
8 ## This file is part of Octave. | |
9 ## | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
7016 | 11 ## under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 ## (at your option) any later version. |
7016 | 14 ## |
15 ## Octave is distributed in the hope that it will be useful, but | |
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
18 ## GNU General Public License for more details. |
7016 | 19 ## |
20 ## You should have received a copy of the GNU General Public License | |
21 ## along with Octave; see the file COPYING. If not, see | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 ## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 ######################################################################## |
7016 | 25 |
7775 | 26 ######################################## |
27 ## No inputs or no outputs | |
5590 | 28 |
7775 | 29 ## no input or output arguments |
5590 | 30 %!function f () |
7775 | 31 %! assert (nargin, 0); |
32 %! 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
|
33 %!endfunction |
5590 | 34 %!test |
35 %! f; | |
36 | |
7775 | 37 ## one input with two possible inputs |
5590 | 38 %!function f (x, y) |
7775 | 39 %! assert (nargin, 1); |
40 %! 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
|
41 %!endfunction |
5590 | 42 %!test |
43 %! f (1); | |
44 | |
7775 | 45 ## no inputs, one of multiple outputs |
5590 | 46 %!function [x, y] = f () |
7775 | 47 %! assert (nargin, 0); |
48 %! assert (nargout, 1); | |
5590 | 49 %! x = 2; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
50 %!endfunction |
5590 | 51 %!test |
7775 | 52 %! assert (f (), 2); |
5590 | 53 |
7775 | 54 ## one of multiple inputs, one of multiple outputs |
5590 | 55 %!function [x, y] = f (a, b) |
7775 | 56 %! assert (nargin, 1); |
57 %! assert (nargout, 1); | |
5590 | 58 %! x = a; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
59 %!endfunction |
5590 | 60 %!test |
7775 | 61 %! assert (f (1), 1); |
62 | |
63 ######################################## | |
64 ## Varargin, varargout | |
5590 | 65 |
7775 | 66 ## varargin and varargout with no inputs or outputs |
5590 | 67 %!function [varargout] = f (varargin) |
7775 | 68 %! assert (nargin, 0); |
69 %! 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
|
70 %!endfunction |
5590 | 71 %!test |
72 %! f; | |
73 | |
7775 | 74 ## varargin and varargout with one input |
5590 | 75 %!function [varargout] = f (x, varargin) |
7775 | 76 %! assert (nargin, 1); |
77 %! 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
|
78 %!endfunction |
5590 | 79 %!test |
80 %! f (1); | |
81 | |
7775 | 82 ## varargin and varargout with one output |
5590 | 83 %!function [x, varargout] = f (varargin) |
7775 | 84 %! assert (nargin, 0); |
85 %! assert (nargout, 1); | |
5590 | 86 %! x = 2; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
87 %!endfunction |
5590 | 88 %!test |
7775 | 89 %! assert (f (), 2); |
5590 | 90 |
7775 | 91 ## varargin and varargout with one input and output |
5590 | 92 %!function [varargout] = f (varargin) |
7775 | 93 %! assert (nargin, 1); |
94 %! assert (nargout, 1); | |
95 %! 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
|
96 %!endfunction |
5590 | 97 %!test |
7775 | 98 %! assert (f (1), 1); |
5590 | 99 |
7775 | 100 ## multiple inputs, multiple outputs, but not all of either |
101 ## WARNING: The original test did not assign the outputs, it just | |
102 ## requested them, and I think that is supposed to be an error. It also | |
103 ## still has a non-assigned output argument. | |
5590 | 104 %!function [x, y, z] = f (a, b, c, d, e) |
7775 | 105 %! assert (nargin, 4); |
106 %! assert (nargout, 2); | |
107 %! x = a; | |
108 %! y = b; | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
109 %!endfunction |
5590 | 110 %!test |
111 %! [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
|
112 %! assert ([s t], [1 2]); |
5590 | 113 |
7775 | 114 ## Fully used varargin and varargout |
5590 | 115 %!function [varargout] = f (varargin) |
7775 | 116 %! assert (nargin, 3); |
117 %! assert (nargout, 4); | |
118 %! varargout{1} = varargin{1}; | |
119 %! varargout{2} = varargin{2}; | |
120 %! varargout{3} = varargin{3}; | |
5590 | 121 %! 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
|
122 %!endfunction |
5590 | 123 %!test |
124 %! [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
|
125 %! assert ([s t u v], [1 2 3 4]); |
7775 | 126 |
28193
56c209ff0a08
improve handling of ans assignment with wrapper functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
127 ## Wrapper functions |
56c209ff0a08
improve handling of ans assignment with wrapper functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
128 %!function [x, y, z] = f (varargin) |
56c209ff0a08
improve handling of ans assignment with wrapper functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
129 %! assert (nargin, 0); |
56c209ff0a08
improve handling of ans assignment with wrapper functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
130 %! assert (nargout, 0); |
56c209ff0a08
improve handling of ans assignment with wrapper functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
131 %! x = 3; |
56c209ff0a08
improve handling of ans assignment with wrapper functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
132 %! y = 2; |
56c209ff0a08
improve handling of ans assignment with wrapper functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
133 %! z = 1; |
56c209ff0a08
improve handling of ans assignment with wrapper functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
134 %!endfunction |
56c209ff0a08
improve handling of ans assignment with wrapper functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
135 %!function varargout = wrapper_1 (varargin) |
56c209ff0a08
improve handling of ans assignment with wrapper functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
136 %! assert (nargout, 0); |
56c209ff0a08
improve handling of ans assignment with wrapper functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
137 %! [varargout{1:nargout}] = f (); |
56c209ff0a08
improve handling of ans assignment with wrapper functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
138 %!endfunction |
56c209ff0a08
improve handling of ans assignment with wrapper functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
139 %!function varargout = wrapper_2 (varargin) |
56c209ff0a08
improve handling of ans assignment with wrapper functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
140 %! assert (nargout, 0); |
56c209ff0a08
improve handling of ans assignment with wrapper functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
141 %! varargout = cell (1, nargout); |
56c209ff0a08
improve handling of ans assignment with wrapper functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
142 %! [varargout{1:nargout}] = f (); |
56c209ff0a08
improve handling of ans assignment with wrapper functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
143 %!endfunction |
56c209ff0a08
improve handling of ans assignment with wrapper functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
144 %!function varargout = wrapper_3 (varargin) |
56c209ff0a08
improve handling of ans assignment with wrapper functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
145 %! assert (nargout, 0); |
56c209ff0a08
improve handling of ans assignment with wrapper functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
146 %! varargout = cell (1, nargout); |
56c209ff0a08
improve handling of ans assignment with wrapper functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
147 %! [varargout{:}] = f (); |
56c209ff0a08
improve handling of ans assignment with wrapper functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
148 %!endfunction |
56c209ff0a08
improve handling of ans assignment with wrapper functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
149 %!test |
56c209ff0a08
improve handling of ans assignment with wrapper functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
150 %! wrapper_1 (); |
56c209ff0a08
improve handling of ans assignment with wrapper functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
151 %! assert (ans, 3); |
56c209ff0a08
improve handling of ans assignment with wrapper functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
152 %! wrapper_2 (); |
56c209ff0a08
improve handling of ans assignment with wrapper functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
153 %! assert (ans, 3); |
56c209ff0a08
improve handling of ans assignment with wrapper functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
154 %! wrapper_3 (); |
56c209ff0a08
improve handling of ans assignment with wrapper functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
155 %! assert (ans, 3); |
56c209ff0a08
improve handling of ans assignment with wrapper functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
156 |
7775 | 157 ## Test default arguments |
158 ## numeric | |
159 %!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
|
160 %! assert (x, 0); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
161 %!endfunction |
7775 | 162 %!test |
17314
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
163 %! f() |
7775 | 164 |
165 ## numeric vector (spaces) | |
166 %!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
|
167 %! 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
|
168 %!endfunction |
7775 | 169 %!test |
17314
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
170 %! f() |
7775 | 171 |
172 ## numeric vector (range) | |
173 %!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
|
174 %! 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
|
175 %!endfunction |
7775 | 176 %!test |
17314
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
177 %! f() |
7775 | 178 |
179 ## numeric vector (commas) | |
180 %!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
|
181 %! 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
|
182 %!endfunction |
7775 | 183 %!test |
17314
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
184 %! f() |
7775 | 185 |
186 ## numeric vector (commas and spaces) | |
187 %!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
|
188 %! 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
|
189 %!endfunction |
7775 | 190 %!test |
17314
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
191 %! f() |
7775 | 192 |
193 ## numeric matrix | |
194 %!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
|
195 %! 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
|
196 %!endfunction |
7775 | 197 %!test |
17314
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
198 %! f() |
7775 | 199 |
200 ## empty cell | |
201 %!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
|
202 %! assert (x, {}); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
203 %!endfunction |
7775 | 204 %!test |
17314
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
205 %! f() |
5590 | 206 |
7775 | 207 ## full cell |
208 %!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
|
209 %! assert (x, {1}); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
210 %!endfunction |
7775 | 211 %!test |
17314
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
212 %! f() |
7775 | 213 |
214 ## many cells | |
215 %!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
|
216 %! 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
|
217 %!endfunction |
7775 | 218 %!test |
17314
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
219 %! f() |
7775 | 220 |
221 ## struct | |
28916
ec591c500fa4
maint: Use Octave convention of space after function name in test/.
Rik <rik@octave.org>
parents:
28193
diff
changeset
|
222 %!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
|
223 %! 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
|
224 %!endfunction |
7775 | 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 | 227 |
228 ## char (double quotes) | |
229 %!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
|
230 %! assert (x, "a"); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
231 %!endfunction |
7775 | 232 %!test |
17314
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
233 %! f() |
7775 | 234 |
235 ## char (single quotes) | |
236 %!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
|
237 %! assert (x, "a"); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
238 %!endfunction |
7775 | 239 %!test |
17314
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
240 %! f() |
7775 | 241 |
242 ## char (string, double quotes) | |
243 %!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
|
244 %! assert (x, "abc123"); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
245 %!endfunction |
7775 | 246 %!test |
17314
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
247 %! f() |
7775 | 248 |
249 ## char (string, double quotes, punctuation) | |
250 %!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
|
251 %! 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
|
252 %!endfunction |
7775 | 253 %!test |
17314
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
254 %! f() |
7775 | 255 |
256 ## Function handle (builtin) | |
257 %!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
|
258 %! 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
|
259 %! fname = finfo.function; |
25803
23483673ba43
Use is_function_handle instead of isa (x, "function_handle").
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
260 %! assert (is_function_handle (x) && 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
|
261 %!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
|
262 %!test |
17314
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
263 %! f() |
7775 | 264 |
265 ## Function handle (anonymous) | |
266 %!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
|
267 %! 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
|
268 %! ftype = finfo.type; |
25803
23483673ba43
Use is_function_handle instead of isa (x, "function_handle").
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
269 %! assert (is_function_handle (x) && 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
|
270 %!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
|
271 %!test |
17314
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
272 %! f() |