5590
|
1 %% Automatically generated from DejaGNU files |
|
2 |
|
3 %% test/octave.test/switch/switch-1.m |
|
4 %!test |
|
5 %! a = 1; |
|
6 %! b = 2; |
|
7 %! c = 3; |
|
8 %! |
|
9 %! switch 0 case 1 x = a; case 2 x = b; otherwise x = c; endswitch |
|
10 %! switch 1 case 1 y = a; case 2 y = b; otherwise y = c; endswitch |
|
11 %! switch 2 case 1 z = a; case 2 z = b; otherwise z = c; endswitch |
|
12 %! switch 3 case 1 p = a; case 2 p = b; otherwise p = c; endswitch |
|
13 %! |
|
14 %! assert(x == c && y == a && z == b && p == c); |
|
15 |
|
16 %% test/octave.test/switch/switch-2.m |
|
17 %!test |
|
18 %! a = 1; |
|
19 %! b = 2; |
|
20 %! c = 3; |
|
21 %! |
|
22 %! x = zeros (1, 4); |
|
23 %! |
|
24 %! k = 1; |
|
25 %! |
|
26 %! for i = 0:3 |
|
27 %! switch (i) |
|
28 %! case a |
|
29 %! x(k) = a; |
|
30 %! case b |
|
31 %! x(k) = b; |
|
32 %! otherwise |
|
33 %! x(k) = c; |
|
34 %! endswitch |
|
35 %! k++; |
|
36 %! endfor |
|
37 %! |
|
38 %! assert(all (x == [3, 1, 2, 3])); |
|
39 |
|
40 %% test/octave.test/switch/switch-3.m |
|
41 %!test |
|
42 %! a = 1; |
|
43 %! b = 2; |
|
44 %! c = 3; |
|
45 %! |
|
46 %! x = zeros (1, 4); |
|
47 %! |
|
48 %! k = 1; |
|
49 %! |
|
50 %! for i = 0:3 |
|
51 %! switch (i) |
|
52 %! case a |
|
53 %! x(k) = a; |
|
54 %! endswitch |
|
55 %! k++; |
|
56 %! endfor |
|
57 %! |
|
58 %! assert(all (x == [0, 1, 0, 0])); |
|
59 |
|
60 %% test/octave.test/switch/switch-4.m |
|
61 %!error <syntax error> eval("switch endswitch"); |
|
62 |
|
63 %% test/octave.test/switch/switch-5.m |
|
64 %!error <syntax error> eval("switch case endswitch"); |
|
65 |
|
66 %% test/octave.test/switch/switch-6.m |
|
67 %!error <syntax error> eval("switch 1 default 1; endswitch"); |
|
68 |