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

Unified Diff: compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java

Issue 10725002: Validate the target of break and continue statments from within a switch (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: # Created 8 years, 6 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: compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java
diff --git a/compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java b/compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java
index faa57aec7b3b40ee5087fed4ca904897856b1e47..1fc2ae102f8a3b4adffd58c2b66ac06d0c65416c 100644
--- a/compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java
+++ b/compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java
@@ -972,6 +972,54 @@ public class ResolverTest extends ResolverTestCase {
ErrorExpectation.errEx(ResolverErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT, 5, 3, 2));
}
+ public void test_breakInSwitch() {
+ resolveAndTest(Joiner.on("\n").join(
+ "class Object {}",
+ "foo() {",
+ " switch(1) {",
+ " a: case 0:",
+ " break a;",
+ " }",
+ "}"),
+ ErrorExpectation.errEx(ResolverErrorCode.BREAK_LABEL_RESOLVES_TO_CASE_OR_DEFAULT, 5, 14, 1));
+ }
+
+ public void test_continueInSwitch1() {
+ resolveAndTest(Joiner.on("\n").join(
+ "class Object {}",
+ "foo() {",
+ " switch(1) {",
+ " a: case 0:",
+ " continue a;",
+ " }",
+ "}"));
+ }
+
+ public void test_continueInSwitch2() {
+ resolveAndTest(Joiner.on("\n").join(
+ "class Object {}",
+ "foo() {",
+ " switch(1) {",
+ " case 0:",
+ " continue a;",
+ " a: case 1:",
+ " break;",
+ " }",
+ "}"));
+ }
+
+ public void test_continueInSwitch3() {
+ resolveAndTest(Joiner.on("\n").join(
+ "class Object {}",
+ "foo() {",
+ " a: switch(1) {",
+ " case 0:",
+ " continue a;",
+ " }",
+ "}"),
+ ErrorExpectation.errEx(ResolverErrorCode.CONTINUE_LABEL_RESOLVES_TO_SWITCH, 5, 17, 1));
+ }
+
public void test_new_noSuchType() throws Exception {
resolveAndTest(Joiner.on("\n").join(
"class Object {}",
« no previous file with comments | « compiler/java/com/google/dart/compiler/resolver/ResolverErrorCode.java ('k') | tests/co19/co19-compiler.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698