OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Test switch statement using labels. | 5 // Test switch statement using labels. |
6 | 6 |
7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
8 | 8 |
9 void main() { | 9 void main() { |
10 doSwitch(0, [0, 2]); | 10 doSwitch(0, [0, 2]); |
11 doSwitch(1, [1]); | 11 doSwitch(1, [1]); |
12 doSwitch(2, [2]); | 12 doSwitch(2, [2]); |
13 doSwitch(3, [3, 1]); | 13 doSwitch(3, [3, 1]); |
14 } | 14 } |
15 | 15 |
16 void doSwitch(int target, List expect) { | 16 void doSwitch(int target, List expect) { |
17 List list = []; | 17 List list = []; |
18 switch (target) { | 18 switch (target) { |
19 case 0: | 19 case 0: |
20 list.add(0); | 20 list.add(0); |
21 continue case2; | 21 continue case2; |
22 case1: case 1: | 22 case1: |
23 list.add(1); | 23 case 1: |
24 break; | 24 list.add(1); |
25 case2: case 2: | 25 break; |
26 list.add(2); | 26 case2: |
27 break; | 27 case 2: |
28 case 3: | 28 list.add(2); |
29 list.add(3); | 29 break; |
30 continue case1; | 30 case 3: |
| 31 list.add(3); |
| 32 continue case1; |
31 } | 33 } |
32 Expect.listEquals(expect, list); | 34 Expect.listEquals(expect, list); |
33 } | 35 } |
OLD | NEW |