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

Unified Diff: compiler/javatests/com/google/dart/compiler/parser/SyntaxTest.java

Issue 10534065: In analyzer, catch use of continue and break in inappropriate places (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Refactored a bit, handle break inside function definition 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/parser/SyntaxTest.java
diff --git a/compiler/javatests/com/google/dart/compiler/parser/SyntaxTest.java b/compiler/javatests/com/google/dart/compiler/parser/SyntaxTest.java
index ea7012e7cf00e7118200f4b1f790af480423ac7d..8e9e8f5e03f55f9b82a5db278f2ddcb9f195d2be 100644
--- a/compiler/javatests/com/google/dart/compiler/parser/SyntaxTest.java
+++ b/compiler/javatests/com/google/dart/compiler/parser/SyntaxTest.java
@@ -531,4 +531,24 @@ public class SyntaxTest extends AbstractParserTest {
ParserErrorCode.SUPER_CANNOT_BE_USED_AS_THE_SECOND_OPERAND, 13, 14,
ParserErrorCode.SUPER_CANNOT_BE_USED_AS_THE_SECOND_OPERAND, 15, 13);
}
+
+ public void testBreakOutsideLoop() throws Exception {
+ parseUnit("phony_lone_super_expression1.dart",
scheglov 2012/06/09 19:15:53 super expression?
+ Joiner.on("\n").join(
+ "class A {",
+ " method() {",
+ " while (true) { break; }", // ok
+ " break;", // bad
+ " L1: break L1;", // ok
+ " while (true) { continue; }", // ok
+ " continue;", // bad
+ " L2: continue L2;", // bad
+ " while (true) { int f() { break; }; }", // bad
+ " }",
+ "}"),
+ ParserErrorCode.BREAK_OUTSIDE_OF_LOOP, 4, 10,
+ ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP, 7, 13,
+ ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP, 8, 18,
+ ParserErrorCode.BREAK_OUTSIDE_OF_LOOP, 9, 35);
+ }
}
« no previous file with comments | « compiler/javatests/com/google/dart/compiler/parser/ClassesInterfaces.dart ('k') | tests/co19/co19-compiler.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698