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

Unified Diff: frog/tests/leg_only/switch_test.dart

Issue 10387080: Accept more labels per switch case. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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
« no previous file with comments | « no previous file | lib/compiler/implementation/resolver.dart » ('j') | lib/compiler/implementation/resolver.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/tests/leg_only/switch_test.dart
diff --git a/frog/tests/leg_only/switch_test.dart b/frog/tests/leg_only/switch_test.dart
index 520e435b3bdf81d6c9c6e064242891e55d7d7c73..fb313c071a1b8cc0422278dac70212ad22c74656 100644
--- a/frog/tests/leg_only/switch_test.dart
+++ b/frog/tests/leg_only/switch_test.dart
@@ -21,9 +21,63 @@ switcher(val) {
return x;
}
+
+// Check unambiguated grammar allowing multiple lables per case/default.
+switcher2(val) {
+ var x = 0;
+ switch (val) {
+ foo:
+ bar:
+ case 1:
+ baz:
+ case 2:
+ fubar: {
+ x = 100;
+ break fubar;
+ }
+ break;
+ hest:
+ fisk:
+ case 3:
+ case 4:
+ svin:
+ default:
+ barber: {
+ if (val > 2) {
+ x = 200;
+ break;
+ } else {
+ // Enable when continue to switch-case is implemented.
+ continue hest; /// 03: compile-time error
+ }
+ }
+ }
+ return x;
+}
+
+
+badswitches(val) {
+ // Tests some badly formed switch bodies.
karlklose 2012/05/11 09:29:31 Tests -> Test.
Lasse Reichstein Nielsen 2012/05/11 14:17:09 Done.
+ // 01 - a label/statement without a following case/default.
+ // 02 - a label without a following case/default or statement.
+ switch (val) {
+ foo: break; /// 01: compile-time error
+ case 2: /// 02: compile-time error
+ foo: /// 02: continued
+ }
+}
+
main() {
Expect.equals(100, switcher(1));
Expect.equals(200, switcher(2));
Expect.equals(300, switcher(3));
Expect.equals(400, switcher(4));
+
+ Expect.equals(100, switcher2(1));
+ Expect.equals(100, switcher2(2));
+ Expect.equals(200, switcher2(3));
+ Expect.equals(200, switcher2(4));
+ Expect.equals(200, switcher2(5));
+
+ badswitches(42);
}
« no previous file with comments | « no previous file | lib/compiler/implementation/resolver.dart » ('j') | lib/compiler/implementation/resolver.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698