| 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 Expect.throws(() => doSwitch(0), (list) { | 12 Expect.throws(() => doSwitch(0), (list) { |
| 13 Expect.listEquals([0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], list); | 13 Expect.listEquals([0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], list); |
| 14 return true; | 14 return true; |
| 15 }); | 15 }); |
| 16 Expect.throws(() => doSwitch(2), (list) { | 16 Expect.throws(() => doSwitch(2), (list) { |
| 17 Expect.listEquals([2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], list); | 17 Expect.listEquals([2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], list); |
| 18 return true; | 18 return true; |
| 19 }); | 19 }); |
| 20 } | 20 } |
| 21 | 21 |
| 22 void doSwitch(int target) { | 22 void doSwitch(int target) { |
| 23 List list = []; | 23 List list = []; |
| 24 switch (target) { | 24 switch (target) { |
| 25 l0: case 0: | 25 l0: |
| 26 case 0: |
| 26 if (list.length > 10) throw list; | 27 if (list.length > 10) throw list; |
| 27 list.add(0); | 28 list.add(0); |
| 28 continue l1; | 29 continue l1; |
| 29 l1: case 1: | 30 l1: |
| 31 case 1: |
| 30 if (list.length > 10) throw list; | 32 if (list.length > 10) throw list; |
| 31 list.add(1); | 33 list.add(1); |
| 32 continue l0; | 34 continue l0; |
| 33 default: | 35 default: |
| 34 list.add(2); | 36 list.add(2); |
| 35 continue l1; | 37 continue l1; |
| 36 } | 38 } |
| 37 } | 39 } |
| OLD | NEW |