OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 nested switch statement using labels. | 5 // Test nested switch statement using labels. |
6 | 6 |
7 library nested_switch_label; | 7 library nested_switch_label; |
8 | 8 |
9 import "package:expect/expect.dart"; | 9 import "package:expect/expect.dart"; |
10 | 10 |
11 void main() { | 11 void main() { |
12 doSwitch(0, ['0', '2:0', '1', 'default']); | 12 doSwitch(0, ['0', '2:0', '1', 'default']); |
13 doSwitch(2, ['2:2', '2:1', '2', '1', 'default']); | 13 doSwitch(2, ['2:2', '2:1', '2', '1', 'default']); |
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 outer0: case 0: | 19 outer0: |
20 list.add('0'); | 20 case 0: |
21 continue outer2; | 21 list.add('0'); |
22 outer1: case 1: | 22 continue outer2; |
23 list.add('1'); | 23 outer1: |
24 continue outerDefault; | 24 case 1: |
25 outer2: case 2: | 25 list.add('1'); |
26 switch (target) { | 26 continue outerDefault; |
27 inner0: case 0: | 27 outer2: |
28 list.add('2:0'); | 28 case 2: |
| 29 switch (target) { |
| 30 inner0: |
| 31 case 0: |
| 32 list.add('2:0'); |
| 33 continue outer1; |
| 34 inner2: |
| 35 case 2: |
| 36 list.add('2:2'); |
| 37 continue inner1; |
| 38 inner1: |
| 39 case 1: |
| 40 list.add('2:1'); |
| 41 } |
| 42 list.add('2'); |
29 continue outer1; | 43 continue outer1; |
30 inner2: case 2: | 44 outerDefault: |
31 list.add('2:2'); | 45 default: |
32 continue inner1; | 46 list.add('default'); |
33 inner1: case 1: | |
34 list.add('2:1'); | |
35 } | |
36 list.add('2'); | |
37 continue outer1; | |
38 outerDefault: default: | |
39 list.add('default'); | |
40 } | 47 } |
41 Expect.listEquals(expect, list); | 48 Expect.listEquals(expect, list); |
42 } | 49 } |
OLD | NEW |