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

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

Issue 10515018: Issue 3269. Warning when 'case' is not type compatible with 'switch' expression (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add valid case expression in test 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/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 ac090626ba4e591e74a0b17e466ba71c365a8b19..e9987c98cb66ba9aea88579815b5ea0456278c9e 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -125,6 +125,28 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
}
/**
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=3269
+ */
+ public void test_switchExpression_case_typeMismatch() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "main() {",
+ " int v = 1;",
+ " switch (v) {",
+ " case 0: break;",
+ " case 'a': break;",
+ " case 12.3: break;",
+ " }",
+ "}",
+ "");
+ assertErrors(
+ libraryResult.getErrors(),
+ errEx(TypeErrorCode.TYPE_NOT_ASSIGNMENT_COMPATIBLE, 6, 10, 3),
+ errEx(TypeErrorCode.TYPE_NOT_ASSIGNMENT_COMPATIBLE, 7, 10, 4));
+ }
+
+ /**
* Language specification requires that factory should be declared in class. However declaring
* factory on top level should not cause exceptions in compiler.
* <p>

Powered by Google App Engine
This is Rietveld 408576698