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

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

Issue 10942020: Issue 5215. Invocation identical(x,y) is compile-time constant (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
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..dd742fbcc247149c225e589dfbf9221350307573 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
@@ -1338,6 +1369,18 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
errEx(ResolverErrorCode.CANNOT_ASSIGN_TO_FINAL, 11, 3, 1),
errEx(TypeErrorCode.FIELD_IS_FINAL, 13, 5, 1));
}
+
+ public void test_identicalFunction() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ getName(),
+ makeCode(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "const A = 1;",
+ "const B = 2;",
+ "const C = identical(A, B);",
+ ""));
+ assertErrors(libraryResult.getErrors());
+ }
/**
* It is a compile-time error to use type variables in "const" instance creation.

Powered by Google App Engine
This is Rietveld 408576698