Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 // Test nested switch statement using labels. | |
| 6 | |
| 7 library nested_switch_label; | |
| 8 | |
| 9 import "package:expect/expect.dart"; | |
| 10 | |
| 11 void main() { | |
| 12 doSwitch(0, ['0', '2:0', '1', 'default']); | |
| 13 doSwitch(2, ['2:2', '2:1', '2', '1', 'default']); | |
| 14 } | |
|
ngeoffray
2013/05/14 07:08:51
New line.
Johnni Winther
2013/05/17 07:03:04
Done.
| |
| 15 void doSwitch(int target, List expect) { | |
| 16 List list = []; | |
| 17 switch (target) { | |
| 18 outer0: case 0: | |
| 19 list.add('0'); | |
| 20 continue outer2; | |
| 21 outer1: case 1: | |
| 22 list.add('1'); | |
| 23 continue outerDefault; | |
| 24 outer2: case 2: | |
| 25 switch (target) { | |
| 26 inner0: case 0: | |
| 27 list.add('2:0'); | |
| 28 continue outer1; | |
| 29 inner2: case 2: | |
| 30 list.add('2:2'); | |
| 31 continue inner1; | |
| 32 inner1: case 1: | |
| 33 list.add('2:1'); | |
| 34 } | |
| 35 list.add('2'); | |
| 36 continue outer1; | |
| 37 outerDefault: default: | |
| 38 list.add('default'); | |
| 39 } | |
| 40 Expect.listEquals(expect, list); | |
| 41 } | |
| OLD | NEW |