Mercurial > hg > octave-nkf
annotate test/prefer.tst @ 20803:56333f6df823
ls.m: Produce listing with 1 file per line if nargout > 0 (bug #46002).
HG: Enter commit message. Lines beginning with 'HG:' are removed.
HG: Leave message empty to abort commit.
HG: --
HG: user: Lachlan Andrew <lachlanbis@gmail.com>
HG: branch 'default'
* ls.m: Add '-1' to arguments on non-PC platforms so that file listing is one
per line.
author | Lachlan Andrew <lachlanbis@gmail.com> |
---|---|
date | Fri, 09 Oct 2015 19:29:28 -0700 |
parents | 4197fc428c7d |
children |
rev | line source |
---|---|
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19470
diff
changeset
|
1 ## Copyright (C) 2006-2015 John W. Eaton |
7016 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7 ## the Free Software Foundation; either version 3 of the License, or (at | |
8 ## your option) any later version. | |
9 ## | |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
16 ## along with Octave; see the file COPYING. If not, see | |
17 ## <http://www.gnu.org/licenses/>. | |
18 | |
5590 | 19 %!test |
20 %! m = [3 2]; | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
21 %! assert (all (m == (3:-1:2))); |
5590 | 22 |
23 %!test | |
24 %! m = [3, | |
25 %! 2]; | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
26 %! assert (all (m == (3:-1:2)')); |
5590 | 27 |
28 %!test | |
29 %! a = 2; | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
30 %! assert ([a - 1], 1); |
5590 | 31 |
32 %!test | |
33 %! m = [3,2]; | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
34 %! fail ("[m ']"); |
5590 | 35 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
36 %!assert (all ([3 2] == (3:-1:2))); |
5590 | 37 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
38 %!assert (all ([3, 2] == (3:-1:2))); |
5590 | 39 |
40 %!test | |
41 %! m = [3,2]; | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
42 %! assert (all ([m (1)] == (3:-1:1))); |
5590 | 43 |
44 %!test | |
45 %! m = [3,2]; | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
46 %! assert ([m(1)],3); |
5590 | 47 |
48 %!test | |
49 %! a = 2; | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
50 %! assert ([a- 1], 1); |
5590 | 51 |
52 %!test | |
53 %! a = 1; | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
54 %! assert (all ([a -1] == (1:-2:-1))); |
5590 | 55 |
56 %!test | |
5781 | 57 %! wsn = warning ("query", "Octave:str-to-num"); |
58 %! warning ("off", "Octave:str-to-num"); | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
59 %! assert ("d" + 0, 100); |
5781 | 60 %! warning (wsn.state, "Octave:str-to-num"); |
5590 | 61 |
62 %!test | |
5781 | 63 %! wsn = warning ("query", "Octave:str-to-num"); |
64 %! warning ("on", "Octave:str-to-num"); | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
65 %! fail ("'d' + 0", "warning"); |
5781 | 66 %! warning (wsn.state, "Octave:str-to-num"); |
5590 | 67 |
68 %!test | |
19214
cf24eef5051d
prefer.tst: Fix typo "Ocave" warning ID.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
69 %! wir = warning ("query", "Octave:imag-to-real"); |
cf24eef5051d
prefer.tst: Fix typo "Ocave" warning ID.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
70 %! warning ("off", "Octave:imag-to-real"); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
71 %! assert (eye (1+i), 1); |
19214
cf24eef5051d
prefer.tst: Fix typo "Ocave" warning ID.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
72 %! warning (wir.state, "Octave:imag-to-real"); |
5590 | 73 |
74 %!test | |
19214
cf24eef5051d
prefer.tst: Fix typo "Ocave" warning ID.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
75 %! wir = warning ("query", "Octave:imag-to-real"); |
cf24eef5051d
prefer.tst: Fix typo "Ocave" warning ID.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
76 %! warning ("on", "Octave:imag-to-real"); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
77 %! fail ("eye (1+i)", "warning"); |
19214
cf24eef5051d
prefer.tst: Fix typo "Ocave" warning ID.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
78 %! warning (wir.state, "Octave:imag-to-real"); |
5590 | 79 |
80 %!test | |
5781 | 81 %! wrre = warning ("query", "Octave:resize-on-range-error"); |
82 %! warning ("off", "Octave:resize-on-range-error"); | |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
83 %! clear a; |
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
84 %! a(2) = 1; a(3) = 2; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
85 %! assert (all (a == [0,1,2])); |
5781 | 86 %! warning (wrre.state, "Octave:resize-on-range-error"); |
5590 | 87 |
88 %!test | |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
89 %! clear a; |
5590 | 90 %! a(1) = 1; a(2) = 2; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
91 %! assert (all (a == [1,2])); |
5590 | 92 |
93 %!test | |
5794 | 94 %! ped = print_empty_dimensions (); |
95 %! print_empty_dimensions (0); | |
5590 | 96 %! a = cell (1, 1); |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8583
diff
changeset
|
97 %! b = type ("-q", "a"); |
8583
27b2db6ff0d7
test/test_prefer.m: update test to reflect new API of the 'type' function.
sh@sh-t400
parents:
8281
diff
changeset
|
98 %! assert (!isempty (findstr (b{1}, "[]"))); |
27b2db6ff0d7
test/test_prefer.m: update test to reflect new API of the 'type' function.
sh@sh-t400
parents:
8281
diff
changeset
|
99 %! assert (isempty (findstr (b{1} ,"[](0x0)"))); |
5794 | 100 %! print_empty_dimensions (ped); |
5590 | 101 |
102 %!test | |
5794 | 103 %! ped = print_empty_dimensions (); |
104 %! print_empty_dimensions (1); | |
5590 | 105 %! a = cell (1, 1); |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8583
diff
changeset
|
106 %! b = type ("-q", "a"); |
8583
27b2db6ff0d7
test/test_prefer.m: update test to reflect new API of the 'type' function.
sh@sh-t400
parents:
8281
diff
changeset
|
107 %! assert (!isempty (findstr (b{1}, "[](0x0)"))); |
5794 | 108 %! print_empty_dimensions (ped); |
5590 | 109 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
110 %!assert (all (size (inv ([])) == [0, 0])); |
5590 | 111 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
112 %!assert (all (svd ([]) == zeros (0, 1))); |
5590 | 113 |
114 %!test | |
5794 | 115 %! sp = save_precision (); |
116 %! save_precision (1); | |
5590 | 117 %! x = pi; |
19470
6ca096827123
Use tempname() rather than tmpnam() in core Octave.
Rik <rik@octave.org>
parents:
19214
diff
changeset
|
118 %! nm = tempname (); |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
119 %! save ("-text", nm, "x"); |
5590 | 120 %! clear x; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
121 %! load (nm); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
122 %! unlink (nm); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
123 %! assert (x,3); |
5794 | 124 %! save_precision (sp); |
5590 | 125 |
126 %!test | |
5794 | 127 %! sp = save_precision (); |
128 %! save_precision (5); | |
5590 | 129 %! x = pi; |
19470
6ca096827123
Use tempname() rather than tmpnam() in core Octave.
Rik <rik@octave.org>
parents:
19214
diff
changeset
|
130 %! nm = tempname (); |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
131 %! save ("-text", nm, "x"); |
5590 | 132 %! clear x; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
133 %! load (nm); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
134 %! unlink (nm); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
135 %! assert (x, 3.1416); |
5794 | 136 %! save_precision (sp); |
5590 | 137 |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
138 %% FIXME: How to capture standard output for comparison? |
5590 | 139 %!function f () |
140 %! 1 | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
141 %!endfunction |
5590 | 142 %!#test |
5794 | 143 %! sf = silent_functions (); |
144 %! silent_functions (0); | |
5590 | 145 %! f |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
146 %! assert (??); |
5794 | 147 %! silent_functions (sf); |
5590 | 148 |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
149 %% FIXME: Same problem as above!!! |
5590 | 150 %!function f () |
151 %! 1 | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
152 %!endfunction |
5590 | 153 %!#test |
5794 | 154 %! sf = silent_functions (); |
155 %! silent_functions (1); | |
5590 | 156 %! f |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
157 %! assert (??); |
5794 | 158 %! silent_functions (sf); |
5590 | 159 |
160 %!test | |
5781 | 161 %! wndz = warning ("query", "Octave:neg-dim-as-zero"); |
162 %! warning ("on", "Octave:neg-dim-as-zero"); | |
19214
cf24eef5051d
prefer.tst: Fix typo "Ocave" warning ID.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
163 %! fail ("eye (-1) == []", "warning", "converting negative dimension"); |
5781 | 164 %! warning (wndz.state, "Octave:neg-dim-as-zero"); |
5590 | 165 |
166 %!test | |
5781 | 167 %! wndz = warning ("query", "Octave:neg-dim-as-zero"); |
168 %! warning ("off", "Octave:neg-dim-as-zero"); | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
169 %! assert (all (size (eye (-1)) == [0, 0])); |
5781 | 170 %! warning (wndz.state, "Octave:neg-dim-as-zero"); |
5590 | 171 |
172 %!test | |
5781 | 173 %! watv = warning ("query", "Octave:assign-as-truth-value"); |
174 %! warning ("on", "Octave:assign-as-truth-value"); | |
19214
cf24eef5051d
prefer.tst: Fix typo "Ocave" warning ID.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
175 %! fail ("if (x = 1) 1; endif", "warning", "assignment used as truth value"); |
5781 | 176 %! warning (watv.state, "Octave:assign-as-truth-value"); |
5590 | 177 |
178 %!test | |
5781 | 179 %! wdbz = warning ("query", "Octave:divide-by-zero"); |
180 %! warning ("off", "Octave:divide-by-zero"); | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
181 %! assert (isinf (1/0)); |
5781 | 182 %! warning (wdbz.state, "Octave:divide-by-zero"); |
5590 | 183 |
184 %!test | |
5781 | 185 %! wdbz = warning ("query", "Octave:divide-by-zero"); |
186 %! warning ("on", "Octave:divide-by-zero"); | |
5590 | 187 %! a = 1; |
188 %! b = 0; | |
19214
cf24eef5051d
prefer.tst: Fix typo "Ocave" warning ID.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
189 %! fail ("isinf (a/b);", "warning", "division by zero"); |
5781 | 190 %! warning (wdbz.state, "Octave:divide-by-zero"); |
5590 | 191 |