Mercurial > hg > octave-nkf
annotate test/prefer.tst @ 16030:1af8d21608b7
rename all test files in the test directory from test_X.m to X.tst
* Use - instead of _ for .tst file names. Fix all file lists in
module.mk and Makefile.am files.
* __run_test_suite__.m: Adapt to new naming convention.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 09 Feb 2013 21:35:55 -0500 |
parents | test/test_prefer.m@72c96de7a403 |
children | b1283d4c06c2 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
14131
diff
changeset
|
1 ## Copyright (C) 2006-2012 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/octave.test/prefer/prefer-1.m |
20 %!test | |
21 %! 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
|
22 %! assert (all (m == (3:-1:2))); |
5590 | 23 |
24 %% test/octave.test/prefer/prefer-2.m | |
25 %!test | |
26 %! m = [3, | |
27 %! 2]; | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
28 %! assert (all (m == (3:-1:2)')); |
5590 | 29 |
30 %% test/octave.test/prefer/prefer-3.m | |
31 %!test | |
32 %! a = 2; | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
33 %! assert ([a - 1], 1); |
5590 | 34 |
35 %% test/octave.test/prefer/prefer-4.m | |
36 %!test | |
37 %! 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
|
38 %! fail ("[m ']"); |
5590 | 39 |
40 %% test/octave.test/prefer/prefer-5.m | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
41 %!assert (all ([3 2] == (3:-1:2))); |
5590 | 42 |
43 %% test/octave.test/prefer/prefer-6.m | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
44 %!assert (all ([3, 2] == (3:-1:2))); |
5590 | 45 |
46 %% test/octave.test/prefer/prefer-7.m | |
47 %!test | |
48 %! 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
|
49 %! assert (all ([m (1)] == (3:-1:1))); |
5590 | 50 |
51 %% test/octave.test/prefer/prefer-8.m | |
52 %!test | |
53 %! 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
|
54 %! assert ([m(1)],3); |
5590 | 55 |
56 %% test/octave.test/prefer/prefer-10.m | |
57 %!test | |
58 %! a = 2; | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
59 %! assert ([a- 1], 1); |
5590 | 60 |
61 %% test/octave.test/prefer/prefer-11.m | |
62 %!test | |
63 %! a = 1; | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
64 %! assert (all ([a -1] == (1:-2:-1))); |
5590 | 65 |
66 %% test/octave.test/prefer/prefer-12.m | |
67 %!test | |
5781 | 68 %! wsn = warning ("query", "Octave:str-to-num"); |
69 %! 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
|
70 %! assert ("d" + 0, 100); |
5781 | 71 %! warning (wsn.state, "Octave:str-to-num"); |
5590 | 72 |
73 %% test/octave.test/prefer/prefer-13.m | |
74 %!test | |
5781 | 75 %! wsn = warning ("query", "Octave:str-to-num"); |
76 %! 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
|
77 %! fail ("'d' + 0", "warning"); |
5781 | 78 %! warning (wsn.state, "Octave:str-to-num"); |
5590 | 79 |
80 %% test/octave.test/prefer/prefer-14.m | |
81 %!test | |
5781 | 82 %! wir = warning ("query", "Ocave:imag-to-real"); |
83 %! warning ("off", "Ocave: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
|
84 %! assert (eye (1+i), 1); |
5781 | 85 %! warning (wir.state, "Ocave:imag-to-real"); |
5590 | 86 |
87 %% test/octave.test/prefer/prefer-15.m | |
88 %!test | |
5781 | 89 %! wir = warning ("query", "Ocave:imag-to-real"); |
90 %! warning ("on", "Ocave: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
|
91 %! fail ("eye (1+i)", "warning"); |
5781 | 92 %! warning (wir.state, "Ocave:imag-to-real"); |
5590 | 93 |
94 %% test/octave.test/prefer/prefer-17.m | |
95 %!test | |
5781 | 96 %! wrre = warning ("query", "Octave:resize-on-range-error"); |
97 %! warning ("off", "Octave:resize-on-range-error"); | |
5590 | 98 %! clear a; |
99 %! 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
|
100 %! assert (all (a == [0,1,2])); |
5781 | 101 %! warning (wrre.state, "Octave:resize-on-range-error"); |
5590 | 102 |
103 %% test/octave.test/prefer/prefer-18.m | |
104 %!test | |
105 %! clear a; | |
106 %! 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
|
107 %! assert (all (a == [1,2])); |
5590 | 108 |
109 %% test/octave.test/prefer/prefer-21.m | |
110 %!test | |
5794 | 111 %! ped = print_empty_dimensions (); |
112 %! print_empty_dimensions (0); | |
5590 | 113 %! a = cell (1, 1); |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8583
diff
changeset
|
114 %! 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
|
115 %! 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
|
116 %! assert (isempty (findstr (b{1} ,"[](0x0)"))); |
5794 | 117 %! print_empty_dimensions (ped); |
5590 | 118 |
119 %% test/octave.test/prefer/prefer-22.m | |
120 %!test | |
5794 | 121 %! ped = print_empty_dimensions (); |
122 %! print_empty_dimensions (1); | |
5590 | 123 %! a = cell (1, 1); |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8583
diff
changeset
|
124 %! 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
|
125 %! assert (!isempty (findstr (b{1}, "[](0x0)"))); |
5794 | 126 %! print_empty_dimensions (ped); |
5590 | 127 |
128 %% test/octave.test/prefer/prefer-23.m | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
129 %!assert (all (size (inv ([])) == [0, 0])); |
5590 | 130 |
131 %% test/octave.test/prefer/prefer-24.m | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
132 %!assert (all (svd ([]) == zeros (0, 1))); |
5590 | 133 |
134 %% test/octave.test/prefer/prefer-27.m | |
135 %!test | |
5794 | 136 %! sp = save_precision (); |
137 %! save_precision (1); | |
5590 | 138 %! x = pi; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
139 %! nm = tmpnam (); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
140 %! save("-text", nm, "x"); |
5590 | 141 %! clear x; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
142 %! load (nm); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
143 %! unlink (nm); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
144 %! assert (x,3); |
5794 | 145 %! save_precision (sp); |
5590 | 146 |
147 %% test/octave.test/prefer/prefer-28.m | |
148 %!test | |
5794 | 149 %! sp = save_precision (); |
150 %! save_precision (5); | |
5590 | 151 %! x = pi; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
152 %! nm = tmpnam (); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
153 %! save("-text", nm, "x"); |
5590 | 154 %! clear x; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
155 %! load (nm); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
156 %! unlink (nm); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
157 %! assert (x, 3.1416); |
5794 | 158 %! save_precision (sp); |
5590 | 159 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
160 %% FIXME: How to capture standard output for comparison? |
5590 | 161 %% test/octave.test/prefer/prefer-29.m |
162 %!function f () | |
163 %! 1 | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
164 %!endfunction |
5590 | 165 %!#test |
5794 | 166 %! sf = silent_functions (); |
167 %! silent_functions (0); | |
5590 | 168 %! f |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
169 %! assert (??); |
5794 | 170 %! silent_functions (sf); |
5590 | 171 |
5775 | 172 %% FIXME Same problem as above!!! |
5590 | 173 %% test/octave.test/prefer/prefer-30.m |
174 %!function f () | |
175 %! 1 | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
176 %!endfunction |
5590 | 177 %!#test |
5794 | 178 %! sf = silent_functions (); |
179 %! silent_functions (1); | |
5590 | 180 %! f |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
181 %! assert (??); |
5794 | 182 %! silent_functions (sf); |
5590 | 183 |
184 %% test/octave.test/prefer/prefer-32.m | |
185 %!test | |
5781 | 186 %! wndz = warning ("query", "Octave:neg-dim-as-zero"); |
187 %! warning ("on", "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
|
188 %! fail ("eye (-1) == []", "warning"); |
5781 | 189 %! warning (wndz.state, "Octave:neg-dim-as-zero"); |
5590 | 190 |
191 %% test/octave.test/prefer/prefer-33.m | |
192 %!test | |
5781 | 193 %! wndz = warning ("query", "Octave:neg-dim-as-zero"); |
194 %! 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
|
195 %! assert (all (size (eye (-1)) == [0, 0])); |
5781 | 196 %! warning (wndz.state, "Octave:neg-dim-as-zero"); |
5590 | 197 |
198 %% test/octave.test/prefer/prefer-34.m | |
199 %!test | |
5781 | 200 %! watv = warning ("query", "Octave:assign-as-truth-value"); |
201 %! warning ("off", "Octave:assign-as-truth-value"); | |
5590 | 202 %! if (x = 1) 1; endif |
5781 | 203 %! warning (watv.state, "Octave:assign-as-truth-value"); |
5590 | 204 |
205 %% test/octave.test/prefer/prefer-35.m | |
206 %!test | |
5781 | 207 %! watv = warning ("query", "Octave:assign-as-truth-value"); |
208 %! warning ("on", "Octave:assign-as-truth-value"); | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
209 %! fail ("if (x = 1) 1; endif", "warning"); |
5781 | 210 %! warning (watv.state, "Octave:assign-as-truth-value"); |
5590 | 211 |
212 %% test/octave.test/prefer/prefer-38.m | |
213 %!test | |
5781 | 214 %! wdbz = warning ("query", "Octave:divide-by-zero"); |
215 %! 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
|
216 %! assert (isinf (1/0)); |
5781 | 217 %! warning (wdbz.state, "Octave:divide-by-zero"); |
5590 | 218 |
219 %% test/octave.test/prefer/prefer-39.m | |
220 %!test | |
5781 | 221 %! wdbz = warning ("query", "Octave:divide-by-zero"); |
222 %! warning ("on", "Octave:divide-by-zero"); | |
5590 | 223 %! a = 1; |
224 %! b = 0; | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
225 %! fail ("isinf (a/b);", "warning") |
5781 | 226 %! warning (wdbz.state, "Octave:divide-by-zero"); |
5590 | 227 |