Mercurial > octave
annotate test/func.tst @ 31554:1d410367802c
maint: Merge stable to default.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Sat, 26 Nov 2022 18:51:28 +0100 |
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:
30287
diff
changeset
|
3 ## Copyright (C) 2008-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/>. |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
7 ## |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
8 ## This file is part of Octave. |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
9 ## |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24467
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
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:
24467
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. |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
14 ## |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
15 ## Octave is distributed in the hope that it will be useful, but |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
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. |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
19 ## |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
20 ## You should have received a copy of the GNU General Public License |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
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:
24467
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 ######################################################################## |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
25 |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
26 ## This piece of test code ensures that all operations which work on |
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
27 ## dimensions alone (squeeze, triu, etc.) work for all objects and |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
28 ## preserve type. Even if the object is an empty matrix. This code is |
24467
2dc926274bce
func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
29 ## not to check that the function itself returns the correct result, |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
30 ## just that the results are consistent for all types. |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
31 |
7618
3209a584e1ac
Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents:
7613
diff
changeset
|
32 %!function __fntestfunc__ (fn, mn, varargin) |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
33 %! typ = {"double", "complex", "logical", "sparse", "complex sparse", ... |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
34 %! "logical sparse", "int8", "int16", "int32", "int64", "uint8", ... |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
35 %! "uint16", "uint32", "uint64", "char", "cell", "struct", ... |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
36 %! "single", "single complex"}; |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
37 %! |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7618
diff
changeset
|
38 %! cmplx = [2, 5, 18]; |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
39 %! nlogical = [3, 6]; |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
40 %! ninteger = [7, 8, 9, 10, 11, 12, 13, 14]; |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
41 %! nsparse = [4, 5, 6]; |
7618
3209a584e1ac
Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents:
7613
diff
changeset
|
42 %! skip = {}; |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
43 %! |
7618
3209a584e1ac
Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents:
7613
diff
changeset
|
44 %! if (length (varargin) > 0 && iscell (varargin{1})) |
3209a584e1ac
Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents:
7613
diff
changeset
|
45 %! skip = varargin{1}; |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
46 %! varargin(1) = []; |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
47 %! endif |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
48 %! |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
49 %! for i = 1 : length (typ) |
7618
3209a584e1ac
Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents:
7613
diff
changeset
|
50 %! if (any (strcmp (skip, typ {i}))) |
3209a584e1ac
Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents:
7613
diff
changeset
|
51 %! continue; |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
52 %! endif |
7618
3209a584e1ac
Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents:
7613
diff
changeset
|
53 %! m = mn; |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
54 %! |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
55 %! if (any (nsparse == i)) |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
56 %! if (ndims (m) > 2) |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
57 %! sz = size (m); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
58 %! m = reshape (m, [sz(1), prod(sz(2:end))]); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
59 %! endif |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
60 %! if (any (cmplx == i)) |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
61 %! m = sparse ((1 + 1i) * m); |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
62 %! else |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
63 %! m = sparse (m); |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
64 %! endif |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
65 %! else |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
66 %! if (any (cmplx == i)) |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
67 %! m = (1 + 1i) * m; |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
68 %! endif |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
69 %! endif |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
70 %! if (any (nlogical == i)) |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
71 %! m = cast (m, "logical"); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
72 %! endif |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
73 %! if (any (ninteger == i)) |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
74 %! m = cast (m, typ{i}); |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
75 %! endif |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
76 %! if (strcmp (typ{i}, "cell")) |
7618
3209a584e1ac
Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents:
7613
diff
changeset
|
77 %! m = num2cell (m); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
78 %! elseif (strcmp (typ{i}, "struct")) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
79 %! m = struct ("fld", num2cell (m)); |
7618
3209a584e1ac
Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents:
7613
diff
changeset
|
80 %! endif |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
81 %! |
7618
3209a584e1ac
Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents:
7613
diff
changeset
|
82 %! y = feval (fn, m, varargin{:}); |
3209a584e1ac
Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents:
7613
diff
changeset
|
83 %! y2 = feval (fn, reshape (mn, size (m)), varargin{:}); |
28923
3f8e1fa0eed2
maint: Use space after '!' logical not operator.
Rik <rik@octave.org>
parents:
28907
diff
changeset
|
84 %! if (! strcmp (class (y), class (m)) || |
3f8e1fa0eed2
maint: Use space after '!' logical not operator.
Rik <rik@octave.org>
parents:
28907
diff
changeset
|
85 %! issparse (y) != issparse (m) || ! size_equal (y, y2)) |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
86 %! error ("failed for type %s\n", typ{i}); |
7618
3209a584e1ac
Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents:
7613
diff
changeset
|
87 %! endif |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
88 %! if (!(strcmp (typ{i}, "cell") || strcmp (typ{i}, "struct")) && |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
89 %! any (vec (cast (real (y), "double")) != |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
90 %! vec (feval (fn , cast (real (m), "double"), varargin{:})))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
91 %! error ("failed for type %s\n", typ{i}); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
92 %! endif |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
93 %! endfor |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
94 %!endfunction |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
95 |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
96 %!shared m0, m1, m2, m3 |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
97 %! m0 = [1:5]; |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
98 %! m1 = reshape ([1 : 30], [5, 6]); |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
99 %! m2 = reshape ([1 : 30], [5, 1, 6]); |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
100 %! m3 = []; |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
101 |
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
102 %!test |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
103 %! __fntestfunc__ ("triu", m1, {"struct"}); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
104 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
105 %! __fntestfunc__ ("triu", m1, {"struct"}, -1); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
106 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
107 %! __fntestfunc__ ("triu", m1, {"struct"}, 1); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
108 %!test |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
109 %! __fntestfunc__ ("triu", m3, {"struct"}); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
110 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
111 %! __fntestfunc__ ("tril", m1, {"struct"}); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
112 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
113 %! __fntestfunc__ ("tril", m1, {"struct"}, -1); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
114 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
115 %! __fntestfunc__ ("tril", m1, {"struct"}, 1); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
116 %!test |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
117 %! __fntestfunc__ ("tril", m3, {"struct"}); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
118 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
119 %! __fntestfunc__ ("squeeze", m2); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
120 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
121 %! __fntestfunc__ ("squeeze", m3); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
122 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
123 %! __fntestfunc__ ("permute", m1, [2, 1]); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
124 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
125 %! __fntestfunc__ ("permute", m2, {"sparse", "logical sparse", "complex sparse"}, [3, 1, 2]); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
126 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
127 %! __fntestfunc__ ("permute", m3, [2, 1]); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
128 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
129 %! __fntestfunc__ ("ipermute", m1, [2, 1]); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
130 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
131 %! __fntestfunc__ ("ipermute", m2, {"sparse", "logical sparse", "complex sparse"}, [3, 1, 2]); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
132 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
133 %! __fntestfunc__ ("ipermute", m3, [2, 1]); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
134 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
135 %! __fntestfunc__ ("shiftdim", m2, 1); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
136 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
137 %! __fntestfunc__ ("shiftdim", m2, {"sparse", "logical sparse", "complex sparse"}, -1); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
138 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
139 %! __fntestfunc__ ("shiftdim", m3, 1); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
140 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
141 %! __fntestfunc__ ("circshift", m2, 1); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
142 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
143 %! __fntestfunc__ ("circshift", m2, [1, -1]); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
144 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
145 %! __fntestfunc__ ("circshift", m3, 1); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
146 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
147 %! __fntestfunc__ ("reshape", m2, [6, 5]); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
148 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
149 %! __fntestfunc__ ("reshape", m3, [1, 0]); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
150 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
151 %! __fntestfunc__ ("diag", m0, {"struct"}); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
152 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
153 %! __fntestfunc__ ("diag", m0, {"struct"}, 1); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
154 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
155 %! __fntestfunc__ ("diag", m0, {"struct"}, -1); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
156 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
157 %! __fntestfunc__ ("diag", m1, {"struct"}); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
158 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
159 %! __fntestfunc__ ("diag", m1, {"struct"}, 1); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
160 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
161 %! __fntestfunc__ ("diag", m1, {"struct"}, -1); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
162 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
163 %! __fntestfunc__ ("diag", m3, {"struct"}); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
164 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
165 %! __fntestfunc__ ("fliplr", m1); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
166 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
167 %! __fntestfunc__ ("fliplr", m3); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
168 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
169 %! __fntestfunc__ ("flipud", m1); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
170 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
171 %! __fntestfunc__ ("flipud", m3); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
172 %!test |
25759
ecdced9fe445
flipdim.m: Make m-file a legacy function.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
173 %! __fntestfunc__ ("flip", m1, 2); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
174 %!test |
25759
ecdced9fe445
flipdim.m: Make m-file a legacy function.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
175 %! __fntestfunc__ ("flip", m3, 2); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
176 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
177 %! __fntestfunc__ ("transpose", m1); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
178 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
179 %! __fntestfunc__ ("transpose", m3); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
180 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
181 %! __fntestfunc__ ("ctranspose", m1); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
182 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
183 %! __fntestfunc__ ("ctranspose", m3); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
184 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
185 %! __fntestfunc__ ("rot90", m1); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
186 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
187 %! __fntestfunc__ ("rot90", m1, 2); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
188 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
189 %! __fntestfunc__ ("rot90", m1, -1); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
190 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
191 %! __fntestfunc__ ("rot90", m3); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
192 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
193 %! __fntestfunc__ ("rotdim", m2, 1, [1, 2]); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
194 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
195 %! __fntestfunc__ ("rotdim", m2, 2, [1, 2]); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
196 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
197 %! __fntestfunc__ ("rotdim", m2, -1, [1, 2]); |
7613
4fc7c16ee564
Add tests for preservation of type for functions that work on dimensions of the matrices
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
198 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
199 %! __fntestfunc__ ("rotdim", m3, 1, [1, 2]); |
24467
2dc926274bce
func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
200 |
24691
b658e0fa0cb3
maint: Remove trailing whitespace from files.
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
201 ## Check for error if function parameter is made persistent |
24467
2dc926274bce
func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
202 %!function retval = __fnpersist1__ (in1) |
2dc926274bce
func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
203 %! persistent retval; |
24691
b658e0fa0cb3
maint: Remove trailing whitespace from files.
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
204 %! |
24467
2dc926274bce
func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
205 %! retval = 1; |
2dc926274bce
func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
206 %!endfunction |
2dc926274bce
func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
207 |
2dc926274bce
func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
208 %!function retval = __fnpersist2__ (in1) |
2dc926274bce
func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
209 %! persistent in1; |
24691
b658e0fa0cb3
maint: Remove trailing whitespace from files.
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
210 %! |
24467
2dc926274bce
func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
211 %! retval = in1; |
2dc926274bce
func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
212 %!endfunction |
2dc926274bce
func.tst: Add tests for error if function parameter is declared persistent.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
213 |
28907
11f1207111c5
maint: Don't use semicolon at end of single-line BIST tests.
Rik <rik@octave.org>
parents:
28791
diff
changeset
|
214 %!error <can't make function parameter retval persistent> __fnpersist1__ (1) |
11f1207111c5
maint: Don't use semicolon at end of single-line BIST tests.
Rik <rik@octave.org>
parents:
28791
diff
changeset
|
215 %!error <can't make function parameter in1 persistent> __fnpersist2__ (1) |
28791
d6eb50288af7
test: Add interpreter BIST test for nargin/nargout validation of functions.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
216 |
d6eb50288af7
test: Add interpreter BIST test for nargin/nargout validation of functions.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
217 ## Check nargin, nargout validation by interpreter |
d6eb50288af7
test: Add interpreter BIST test for nargin/nargout validation of functions.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
218 %!function __fn_nargout0__ (in1) |
d6eb50288af7
test: Add interpreter BIST test for nargin/nargout validation of functions.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
219 %!endfunction |
d6eb50288af7
test: Add interpreter BIST test for nargin/nargout validation of functions.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
220 %!function [out1] = __fn_nargin2__ (in1, in2) |
d6eb50288af7
test: Add interpreter BIST test for nargin/nargout validation of functions.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
221 %!endfunction |
30287 | 222 %!function [out1] = __fn_nargin0__ () |
223 %!endfunction | |
224 %!function [] = __fn_narginout0__ () | |
225 %!endfunction | |
226 %!function __fn_no_arg_list__ | |
227 %!endfunction | |
28791
d6eb50288af7
test: Add interpreter BIST test for nargin/nargout validation of functions.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
228 |
d6eb50288af7
test: Add interpreter BIST test for nargin/nargout validation of functions.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
229 %!error <function called with too many outputs> r = __fn_nargout0__ () |
d6eb50288af7
test: Add interpreter BIST test for nargin/nargout validation of functions.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
230 %!error <function called with too many inputs> r = __fn_nargin2__ (1,2,3) |
30287 | 231 %!error <function called with too many inputs> r = __fn_nargin0__ (1) |
232 %!error <function called with too many inputs> __fn_narginout0__ (1) | |
233 %!error <function called with too many outputs> r = __fn_narginout0__ () | |
234 %!error <function called with too many inputs> __fn_no_arg_list__ (1) | |
235 %!error <function called with too many outputs> r = __fn_no_arg_list__ () |