Mercurial > hg > octave-nkf
annotate test/test_prefer.m @ 8746:5dd06f19e9be
handle commands in the lexer
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sun, 15 Feb 2009 23:49:15 -0500 |
parents | 27b2db6ff0d7 |
children | eb63fbe60fab |
rev | line source |
---|---|
7017 | 1 ## Copyright (C) 2006, 2007 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 %% Automatically generated from DejaGNU files |
20 | |
21 %% test/octave.test/prefer/prefer-1.m | |
22 %!test | |
23 %! m = [3 2]; | |
24 %! assert(all (m == (3:-1:2))); | |
25 | |
26 %% test/octave.test/prefer/prefer-2.m | |
27 %!test | |
28 %! m = [3, | |
29 %! 2]; | |
30 %! assert(all (m == (3:-1:2)')); | |
31 | |
32 %% test/octave.test/prefer/prefer-3.m | |
33 %!test | |
34 %! a = 2; | |
35 %! assert([a - 1],1); | |
36 | |
37 %% test/octave.test/prefer/prefer-4.m | |
38 %!test | |
39 %! m = [3,2]; | |
40 %! fail("[m ']"); | |
41 | |
42 %% test/octave.test/prefer/prefer-5.m | |
43 %!assert(all ([3 2] == (3:-1:2))); | |
44 | |
45 %% test/octave.test/prefer/prefer-6.m | |
46 %!assert(all ([3, 2] == (3:-1:2))); | |
47 | |
48 %% test/octave.test/prefer/prefer-7.m | |
49 %!test | |
50 %! m = [3,2]; | |
51 %! assert(all ([m (1)] == (3:-1:1))); | |
52 | |
53 %% test/octave.test/prefer/prefer-8.m | |
54 %!test | |
55 %! m = [3,2]; | |
56 %! assert([m(1)],3); | |
57 | |
58 %% test/octave.test/prefer/prefer-9.m | |
59 %!test | |
60 %! m = [3,2]; | |
61 %! assert(all ([m (1)] == (3:-1:1))); | |
62 | |
63 %% test/octave.test/prefer/prefer-10.m | |
64 %!test | |
65 %! a = 2; | |
66 %! assert([a- 1],1); | |
67 | |
68 %% test/octave.test/prefer/prefer-11.m | |
69 %!test | |
70 %! a = 1; | |
71 %! assert(all ([a -1] == (1:-2:-1))); | |
72 | |
73 %% test/octave.test/prefer/prefer-12.m | |
74 %!test | |
5781 | 75 %! wsn = warning ("query", "Octave:str-to-num"); |
76 %! warning ("off", "Octave:str-to-num"); | |
5590 | 77 %! assert("d" + 0,100); |
5781 | 78 %! warning (wsn.state, "Octave:str-to-num"); |
5590 | 79 |
80 %% test/octave.test/prefer/prefer-13.m | |
81 %!test | |
5781 | 82 %! wsn = warning ("query", "Octave:str-to-num"); |
83 %! warning ("on", "Octave:str-to-num"); | |
5590 | 84 %! fail("'d' + 0","warning"); |
5781 | 85 %! warning (wsn.state, "Octave:str-to-num"); |
5590 | 86 |
87 %% test/octave.test/prefer/prefer-14.m | |
88 %!test | |
5781 | 89 %! wir = warning ("query", "Ocave:imag-to-real"); |
90 %! warning ("off", "Ocave:imag-to-real"); | |
5590 | 91 %! assert(eye (1+i),1); |
5781 | 92 %! warning (wir.state, "Ocave:imag-to-real"); |
5590 | 93 |
94 %% test/octave.test/prefer/prefer-15.m | |
95 %!test | |
5781 | 96 %! wir = warning ("query", "Ocave:imag-to-real"); |
97 %! warning ("on", "Ocave:imag-to-real"); | |
5590 | 98 %! fail("eye (1+i)","warning"); |
5781 | 99 %! warning (wir.state, "Ocave:imag-to-real"); |
5590 | 100 |
101 %% test/octave.test/prefer/prefer-17.m | |
102 %!test | |
5781 | 103 %! wrre = warning ("query", "Octave:resize-on-range-error"); |
104 %! warning ("off", "Octave:resize-on-range-error"); | |
5590 | 105 %! clear a; |
106 %! a(2) = 1; a(3) = 2; | |
107 %! assert(all (a == [0,1,2])); | |
5781 | 108 %! warning (wrre.state, "Octave:resize-on-range-error"); |
5590 | 109 |
110 %% test/octave.test/prefer/prefer-18.m | |
111 %!test | |
112 %! clear a; | |
113 %! a(1) = 1; a(2) = 2; | |
114 %! assert(all (a == [1,2])); | |
115 | |
5775 | 116 %% FIXME How the hell do I test this one in test/assert |
5590 | 117 %% test/octave.test/prefer/prefer-19.m |
118 %!#test | |
5794 | 119 %! pid = print_answer_id_name (); |
120 %! print_answer_id_name (0); | |
5590 | 121 %! a = 1 |
5794 | 122 %! print_answer_id_name (pid); |
5590 | 123 |
5775 | 124 %% FIXME How the hell do I test this one in test/assert |
5590 | 125 %% test/octave.test/prefer/prefer-20.m |
126 %!#test | |
5794 | 127 %! pid = print_answer_id_name (); |
128 %! print_answer_id_name (1); | |
5590 | 129 %! a = 1 |
5794 | 130 %! print_answer_id_name (pid); |
5590 | 131 |
132 %% test/octave.test/prefer/prefer-21.m | |
133 %!test | |
5794 | 134 %! ped = print_empty_dimensions (); |
135 %! print_empty_dimensions (0); | |
5590 | 136 %! a = cell (1, 1); |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8583
diff
changeset
|
137 %! 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
|
138 %! 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
|
139 %! assert (isempty (findstr (b{1} ,"[](0x0)"))); |
5794 | 140 %! print_empty_dimensions (ped); |
5590 | 141 |
142 %% test/octave.test/prefer/prefer-22.m | |
143 %!test | |
5794 | 144 %! ped = print_empty_dimensions (); |
145 %! print_empty_dimensions (1); | |
5590 | 146 %! a = cell (1, 1); |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8583
diff
changeset
|
147 %! 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
|
148 %! assert (!isempty (findstr (b{1}, "[](0x0)"))); |
5794 | 149 %! print_empty_dimensions (ped); |
5590 | 150 |
151 %% test/octave.test/prefer/prefer-23.m | |
152 %!assert(all (size (inv ([])) == [0, 0])); | |
153 | |
154 %% test/octave.test/prefer/prefer-24.m | |
155 %!assert(all (svd ([]) == zeros (0, 1))); | |
156 | |
157 %% test/octave.test/prefer/prefer-27.m | |
158 %!test | |
5794 | 159 %! sp = save_precision (); |
160 %! save_precision (1); | |
5590 | 161 %! x = pi; |
162 %! nm = tmpnam(); | |
163 %! save("-text",nm,"x"); | |
164 %! clear x; | |
165 %! load(nm); | |
166 %! unlink(nm); | |
167 %! assert(x,3); | |
5794 | 168 %! save_precision (sp); |
5590 | 169 |
170 %% test/octave.test/prefer/prefer-28.m | |
171 %!test | |
5794 | 172 %! sp = save_precision (); |
173 %! save_precision (5); | |
5590 | 174 %! x = pi; |
175 %! nm = tmpnam(); | |
176 %! save("-text",nm,"x"); | |
177 %! clear x; | |
178 %! load(nm); | |
179 %! unlink(nm); | |
180 %! assert(x,3.1416); | |
5794 | 181 %! save_precision (sp); |
5590 | 182 |
5775 | 183 %% FIXME Same problem as above!!! |
5590 | 184 %% test/octave.test/prefer/prefer-29.m |
185 %!function f () | |
186 %! 1 | |
187 %!#test | |
5794 | 188 %! sf = silent_functions (); |
189 %! silent_functions (0); | |
5590 | 190 %! f |
191 %! assert(??); | |
5794 | 192 %! silent_functions (sf); |
5590 | 193 |
5775 | 194 %% FIXME Same problem as above!!! |
5590 | 195 %% test/octave.test/prefer/prefer-30.m |
196 %!function f () | |
197 %! 1 | |
198 %!#test | |
5794 | 199 %! sf = silent_functions (); |
200 %! silent_functions (1); | |
5590 | 201 %! f |
202 %! assert(??); | |
5794 | 203 %! silent_functions (sf); |
5590 | 204 |
205 %% test/octave.test/prefer/prefer-32.m | |
206 %!test | |
5781 | 207 %! wndz = warning ("query", "Octave:neg-dim-as-zero"); |
208 %! warning ("on", "Octave:neg-dim-as-zero"); | |
5590 | 209 %! fail("eye (-1) == []","warning"); |
5781 | 210 %! warning (wndz.state, "Octave:neg-dim-as-zero"); |
5590 | 211 |
212 %% test/octave.test/prefer/prefer-33.m | |
213 %!test | |
5781 | 214 %! wndz = warning ("query", "Octave:neg-dim-as-zero"); |
215 %! warning ("off", "Octave:neg-dim-as-zero"); | |
5590 | 216 %! assert(all (size (eye (-1)) == [0, 0])); |
5781 | 217 %! warning (wndz.state, "Octave:neg-dim-as-zero"); |
5590 | 218 |
219 %% test/octave.test/prefer/prefer-34.m | |
220 %!test | |
5781 | 221 %! watv = warning ("query", "Octave:assign-as-truth-value"); |
222 %! warning ("off", "Octave:assign-as-truth-value"); | |
5590 | 223 %! if (x = 1) 1; endif |
5781 | 224 %! warning (watv.state, "Octave:assign-as-truth-value"); |
5590 | 225 |
226 %% test/octave.test/prefer/prefer-35.m | |
227 %!test | |
5781 | 228 %! watv = warning ("query", "Octave:assign-as-truth-value"); |
229 %! warning ("on", "Octave:assign-as-truth-value"); | |
5590 | 230 %! fail("if (x = 1) 1; endif","warning"); |
5781 | 231 %! warning (watv.state, "Octave:assign-as-truth-value"); |
5590 | 232 |
233 %% test/octave.test/prefer/prefer-38.m | |
234 %!test | |
5781 | 235 %! wdbz = warning ("query", "Octave:divide-by-zero"); |
236 %! warning ("off", "Octave:divide-by-zero"); | |
5590 | 237 %! assert(isinf (1/0)); |
5781 | 238 %! warning (wdbz.state, "Octave:divide-by-zero"); |
5590 | 239 |
240 %% test/octave.test/prefer/prefer-39.m | |
241 %!test | |
5781 | 242 %! wdbz = warning ("query", "Octave:divide-by-zero"); |
243 %! warning ("on", "Octave:divide-by-zero"); | |
5590 | 244 %! a = 1; |
245 %! b = 0; | |
246 %! fail("isinf (a/b);","warning") | |
5781 | 247 %! warning (wdbz.state, "Octave:divide-by-zero"); |
5590 | 248 |