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

Unified Diff: compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java

Issue 10942019: Issue 2862. Report warning if switch/case does not end with break, continue, return or throw (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 | « compiler/java/com/google/dart/compiler/resolver/ResolverErrorCode.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
diff --git a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
index c7c0ee17ff1cdfad0652e170e97008ea34e0db53..584e6bf05e9a847655636022249c7327d9c808df 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -124,6 +124,7 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
" case 0: qwerty: {",
" break qwerty;",
" }",
+ " break;",
" }",
"}",
"");
@@ -437,6 +438,36 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
"");
assertErrors(libraryResult.getErrors());
}
+
+ /**
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=2862
+ */
+ public void test_switchCase_fallThrough() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "foo(int x) {",
+ " while (true) {",
+ " switch (x) {",
+ " case 0:",
+ " break;",
+ " case 1:",
+ " continue;",
+ " case 2:",
+ " return;",
+ " case 3:",
+ " throw new Exception();",
+ " case 4:",
+ " bar();",
+ " }",
+ " }",
+ "}",
+ "bar() {}",
+ "");
+ assertErrors(
+ libraryResult.getErrors(),
+ errEx(ResolverErrorCode.SWITCH_CASE_FALL_THROUGH, 14, 9, 6));
+ }
/**
* Language specification requires that factory should be declared in class. However declaring
« no previous file with comments | « compiler/java/com/google/dart/compiler/resolver/ResolverErrorCode.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698