Chromium Code Reviews| Index: tests/language/infinite_switch_label_test.dart |
| diff --git a/tests/language/infinite_switch_label_test.dart b/tests/language/infinite_switch_label_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9a7caa494d4a9799d16947a278982bc3a04298f1 |
| --- /dev/null |
| +++ b/tests/language/infinite_switch_label_test.dart |
| @@ -0,0 +1,36 @@ |
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +// Test nested switch statement using labels. |
| + |
| +library nested_switch_label; |
| + |
| +import "package:expect/expect.dart"; |
| + |
| +void main() { |
| + Expect.throws(() => doSwitch(0), (list) { |
| + Expect.listEquals([0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], list); |
| + return true; |
| + }); |
| + Expect.throws(() => doSwitch(2), (list) { |
| + Expect.listEquals([2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], list); |
| + return true; |
| + }); |
| +} |
|
ngeoffray
2013/05/14 07:08:51
New line.
Johnni Winther
2013/05/17 07:03:04
Done.
|
| +void doSwitch(int target) { |
| + List list = []; |
| + switch (target) { |
| + l0: case 0: |
| + if (list.length > 10) throw list; |
| + list.add(0); |
| + continue l1; |
| + l1: case 1: |
| + if (list.length > 10) throw list; |
| + list.add(1); |
| + continue l0; |
| + default: |
| + list.add(2); |
| + continue l1; |
| + } |
| +} |