OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 | 6 |
7 break1(int x, int y, int ew, int ez) { | 7 break1(int x, int y, int ew, int ez) { |
8 int w = 1; | 8 int w = 1; |
9 int z = 0; | 9 int z = 0; |
10 bk1: if (x == 2) { | 10 bk1: |
| 11 if (x == 2) { |
11 z = 1; | 12 z = 1; |
12 if (y == 3) { | 13 if (y == 3) { |
13 w = 2; | 14 w = 2; |
14 break bk1; | 15 break bk1; |
15 } else { | 16 } else { |
16 w = 3; | 17 w = 3; |
17 } | 18 } |
18 } else { | 19 } else { |
19 z = 2; | 20 z = 2; |
20 if (y == 3) { | 21 if (y == 3) { |
21 w = 4; | 22 w = 4; |
22 } else { | 23 } else { |
23 w = 5; | 24 w = 5; |
24 break bk1; | 25 break bk1; |
25 } | 26 } |
26 break bk1; | 27 break bk1; |
27 } | 28 } |
28 Expect.equals(ew, w); | 29 Expect.equals(ew, w); |
29 Expect.equals(ez, z); | 30 Expect.equals(ez, z); |
30 } | 31 } |
31 | 32 |
32 break2(int x, int y, int ew, int ez) { | 33 break2(int x, int y, int ew, int ez) { |
33 int w = 1; | 34 int w = 1; |
34 int z = 0; | 35 int z = 0; |
35 bk1: do { | 36 bk1: |
| 37 do { |
36 if (x == 2) { | 38 if (x == 2) { |
37 z = 1; | 39 z = 1; |
38 if (y == 3) { | 40 if (y == 3) { |
39 w = 2; | 41 w = 2; |
40 break bk1; | 42 break bk1; |
41 } else { | 43 } else { |
42 w = 3; | 44 w = 3; |
43 } | 45 } |
44 } else { | 46 } else { |
45 z = 2; | 47 z = 2; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } | 80 } |
79 break; | 81 break; |
80 } | 82 } |
81 } while (false); | 83 } while (false); |
82 Expect.equals(ew, w); | 84 Expect.equals(ew, w); |
83 Expect.equals(ez, z); | 85 Expect.equals(ez, z); |
84 } | 86 } |
85 | 87 |
86 obscureBreaks(x) { | 88 obscureBreaks(x) { |
87 bool result = true; | 89 bool result = true; |
88 bar: do { | 90 bar: |
| 91 do { |
89 if (x == 1) { | 92 if (x == 1) { |
90 foo: break; | 93 foo: |
| 94 break; |
91 } else if (x == 2) { | 95 } else if (x == 2) { |
92 foo: break bar; | 96 foo: |
| 97 break bar; |
93 } else if (x == 3) { | 98 } else if (x == 3) { |
94 bar: break; | 99 bar: |
| 100 break; |
95 } else if (x == 4) { | 101 } else if (x == 4) { |
96 break bar; | 102 break bar; |
97 } else { | 103 } else { |
98 result = false; | 104 result = false; |
99 } | 105 } |
100 } while (false); | 106 } while (false); |
101 return result; | 107 return result; |
102 } | 108 } |
103 | 109 |
104 ifBreaks(x, y) { | 110 ifBreaks(x, y) { |
105 int res = 2; | 111 int res = 2; |
106 foo: if (x == 1) bar: { | 112 foo: |
107 if (y == 2) { | 113 if (x == 1) |
108 res = 4; | 114 bar: |
109 break foo; | 115 { |
110 } else if (y == 3) { | 116 if (y == 2) { |
111 res = 5; | 117 res = 4; |
112 break bar; | 118 break foo; |
113 } | 119 } else if (y == 3) { |
114 res = 3; | 120 res = 5; |
115 } else baz: { | 121 break bar; |
116 if (y == 2) { | 122 } |
117 res = 7; | 123 res = 3; |
118 break foo; | 124 } |
119 } else if (y == 3) { | 125 else |
120 res = 8; | 126 baz: |
121 break baz; | 127 { |
122 } | 128 if (y == 2) { |
123 res = 6; | 129 res = 7; |
124 } | 130 break foo; |
| 131 } else if (y == 3) { |
| 132 res = 8; |
| 133 break baz; |
| 134 } |
| 135 res = 6; |
| 136 } |
125 return res; | 137 return res; |
126 } | 138 } |
127 | 139 |
128 main() { | 140 main() { |
129 break1(2, 3, 2, 1); | 141 break1(2, 3, 2, 1); |
130 break1(2, 4, 3, 1); | 142 break1(2, 4, 3, 1); |
131 break1(3, 3, 4, 2); | 143 break1(3, 3, 4, 2); |
132 break1(3, 4, 5, 2); | 144 break1(3, 4, 5, 2); |
133 break2(2, 3, 2, 1); | 145 break2(2, 3, 2, 1); |
134 break2(2, 4, 3, 1); | 146 break2(2, 4, 3, 1); |
135 break2(3, 3, 4, 2); | 147 break2(3, 3, 4, 2); |
136 break2(3, 4, 5, 2); | 148 break2(3, 4, 5, 2); |
137 break3(2, 3, 2, 1); | 149 break3(2, 3, 2, 1); |
138 break3(2, 4, 3, 1); | 150 break3(2, 4, 3, 1); |
139 break3(3, 3, 4, 2); | 151 break3(3, 3, 4, 2); |
140 break3(3, 4, 5, 2); | 152 break3(3, 4, 5, 2); |
141 Expect.isTrue(obscureBreaks(1), "1"); | 153 Expect.isTrue(obscureBreaks(1), "1"); |
142 Expect.isTrue(obscureBreaks(2), "2"); | 154 Expect.isTrue(obscureBreaks(2), "2"); |
143 Expect.isTrue(obscureBreaks(3), "3"); | 155 Expect.isTrue(obscureBreaks(3), "3"); |
144 Expect.isTrue(obscureBreaks(4), "4"); | 156 Expect.isTrue(obscureBreaks(4), "4"); |
145 Expect.isFalse(obscureBreaks(5), "5"); | 157 Expect.isFalse(obscureBreaks(5), "5"); |
146 Expect.equals(3, ifBreaks(1, 4)); | 158 Expect.equals(3, ifBreaks(1, 4)); |
147 Expect.equals(4, ifBreaks(1, 2)); | 159 Expect.equals(4, ifBreaks(1, 2)); |
148 Expect.equals(5, ifBreaks(1, 3)); | 160 Expect.equals(5, ifBreaks(1, 3)); |
149 Expect.equals(6, ifBreaks(2, 4)); | 161 Expect.equals(6, ifBreaks(2, 4)); |
150 Expect.equals(7, ifBreaks(2, 2)); | 162 Expect.equals(7, ifBreaks(2, 2)); |
151 Expect.equals(8, ifBreaks(2, 3)); | 163 Expect.equals(8, ifBreaks(2, 3)); |
152 } | 164 } |
OLD | NEW |