Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Unified Diff: tests/language/infinite_switch_label_test.dart

Issue 14969004: Implement continue for switch. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments + status updated. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..9a89b91e0533492f316e81c67319e8b1d41fff95
--- /dev/null
+++ b/tests/language/infinite_switch_label_test.dart
@@ -0,0 +1,37 @@
+// 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;
+ });
+}
+
+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;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698