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: if (x == 2) { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 break bar; | 96 break bar; |
97 } else { | 97 } else { |
98 result = false; | 98 result = false; |
99 } | 99 } |
100 } while (false); | 100 } while (false); |
101 return result; | 101 return result; |
102 } | 102 } |
103 | 103 |
104 ifBreaks(x, y) { | 104 ifBreaks(x, y) { |
105 int res = 2; | 105 int res = 2; |
106 foo: if (x == 1) bar: { | 106 foo: if (x == 1) |
107 if (y == 2) { | 107 bar: { |
108 res = 4; | 108 if (y == 2) { |
109 break foo; | 109 res = 4; |
110 } else if (y == 3) { | 110 break foo; |
111 res = 5; | 111 } else if (y == 3) { |
112 break bar; | 112 res = 5; |
113 } | 113 break bar; |
114 res = 3; | 114 } |
115 } else baz: { | 115 res = 3; |
116 if (y == 2) { | 116 } |
117 res = 7; | 117 else |
118 break foo; | 118 baz: { |
119 } else if (y == 3) { | 119 if (y == 2) { |
120 res = 8; | 120 res = 7; |
121 break baz; | 121 break foo; |
122 } | 122 } else if (y == 3) { |
123 res = 6; | 123 res = 8; |
124 } | 124 break baz; |
| 125 } |
| 126 res = 6; |
| 127 } |
125 return res; | 128 return res; |
126 } | 129 } |
127 | 130 |
128 main() { | 131 main() { |
129 break1(2, 3, 2, 1); | 132 break1(2, 3, 2, 1); |
130 break1(2, 4, 3, 1); | 133 break1(2, 4, 3, 1); |
131 break1(3, 3, 4, 2); | 134 break1(3, 3, 4, 2); |
132 break1(3, 4, 5, 2); | 135 break1(3, 4, 5, 2); |
133 break2(2, 3, 2, 1); | 136 break2(2, 3, 2, 1); |
134 break2(2, 4, 3, 1); | 137 break2(2, 4, 3, 1); |
135 break2(3, 3, 4, 2); | 138 break2(3, 3, 4, 2); |
136 break2(3, 4, 5, 2); | 139 break2(3, 4, 5, 2); |
137 break3(2, 3, 2, 1); | 140 break3(2, 3, 2, 1); |
138 break3(2, 4, 3, 1); | 141 break3(2, 4, 3, 1); |
139 break3(3, 3, 4, 2); | 142 break3(3, 3, 4, 2); |
140 break3(3, 4, 5, 2); | 143 break3(3, 4, 5, 2); |
141 Expect.isTrue(obscureBreaks(1), "1"); | 144 Expect.isTrue(obscureBreaks(1), "1"); |
142 Expect.isTrue(obscureBreaks(2), "2"); | 145 Expect.isTrue(obscureBreaks(2), "2"); |
143 Expect.isTrue(obscureBreaks(3), "3"); | 146 Expect.isTrue(obscureBreaks(3), "3"); |
144 Expect.isTrue(obscureBreaks(4), "4"); | 147 Expect.isTrue(obscureBreaks(4), "4"); |
145 Expect.isFalse(obscureBreaks(5), "5"); | 148 Expect.isFalse(obscureBreaks(5), "5"); |
146 Expect.equals(3, ifBreaks(1, 4)); | 149 Expect.equals(3, ifBreaks(1, 4)); |
147 Expect.equals(4, ifBreaks(1, 2)); | 150 Expect.equals(4, ifBreaks(1, 2)); |
148 Expect.equals(5, ifBreaks(1, 3)); | 151 Expect.equals(5, ifBreaks(1, 3)); |
149 Expect.equals(6, ifBreaks(2, 4)); | 152 Expect.equals(6, ifBreaks(2, 4)); |
150 Expect.equals(7, ifBreaks(2, 2)); | 153 Expect.equals(7, ifBreaks(2, 2)); |
151 Expect.equals(8, ifBreaks(2, 3)); | 154 Expect.equals(8, ifBreaks(2, 3)); |
152 } | 155 } |
OLD | NEW |