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/switch/switch-1.m |
|
22 %!test |
|
23 %! a = 1; |
|
24 %! b = 2; |
|
25 %! c = 3; |
|
26 %! |
|
27 %! switch 0 case 1 x = a; case 2 x = b; otherwise x = c; endswitch |
|
28 %! switch 1 case 1 y = a; case 2 y = b; otherwise y = c; endswitch |
|
29 %! switch 2 case 1 z = a; case 2 z = b; otherwise z = c; endswitch |
|
30 %! switch 3 case 1 p = a; case 2 p = b; otherwise p = c; endswitch |
|
31 %! |
|
32 %! assert(x == c && y == a && z == b && p == c); |
|
33 |
|
34 %% test/octave.test/switch/switch-2.m |
|
35 %!test |
|
36 %! a = 1; |
|
37 %! b = 2; |
|
38 %! c = 3; |
|
39 %! |
|
40 %! x = zeros (1, 4); |
|
41 %! |
|
42 %! k = 1; |
|
43 %! |
|
44 %! for i = 0:3 |
|
45 %! switch (i) |
|
46 %! case a |
|
47 %! x(k) = a; |
|
48 %! case b |
|
49 %! x(k) = b; |
|
50 %! otherwise |
|
51 %! x(k) = c; |
|
52 %! endswitch |
|
53 %! k++; |
|
54 %! endfor |
|
55 %! |
|
56 %! assert(all (x == [3, 1, 2, 3])); |
|
57 |
|
58 %% test/octave.test/switch/switch-3.m |
|
59 %!test |
|
60 %! a = 1; |
|
61 %! b = 2; |
|
62 %! c = 3; |
|
63 %! |
|
64 %! x = zeros (1, 4); |
|
65 %! |
|
66 %! k = 1; |
|
67 %! |
|
68 %! for i = 0:3 |
|
69 %! switch (i) |
|
70 %! case a |
|
71 %! x(k) = a; |
|
72 %! endswitch |
|
73 %! k++; |
|
74 %! endfor |
|
75 %! |
|
76 %! assert(all (x == [0, 1, 0, 0])); |
|
77 |
|
78 %% test/octave.test/switch/switch-4.m |
|
79 %!error <syntax error> eval("switch endswitch"); |
|
80 |
|
81 %% test/octave.test/switch/switch-5.m |
|
82 %!error <syntax error> eval("switch case endswitch"); |
|
83 |
|
84 %% test/octave.test/switch/switch-6.m |
|
85 %!error <syntax error> eval("switch 1 default 1; endswitch"); |
|
86 |