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

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

Issue 10878088: Issue 4719. Mark inferred List/Map literal types as inferred. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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 41ae84be4da62875adb5d4bdab1aadf676c29054..42dab9da1536dc77c0763b6536e30ed4c2815ace 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -2778,7 +2778,7 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
}
public void test_typesPropagation_arrayLiteral_singleType() throws Exception {
- AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ final AnalyzeLibraryResult libraryResult = analyzeLibrary(
"// filler filler filler filler filler filler filler filler filler filler",
"main() {",
" var a = [1, 2, 3];",
@@ -2787,6 +2787,7 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
"");
assertErrors(libraryResult.getErrors());
assertInferredElementTypeString(testUnit, "v", "int");
+ assertNodeInferredTypeString("[1, 2, 3]", "List<int>");
}
public void test_typesPropagation_arrayLiteral_mixedTypes() throws Exception {
@@ -2811,7 +2812,8 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
"");
assertErrors(libraryResult.getErrors());
assertInferredElementTypeString(testUnit, "v", "int");
- }
+ assertNodeInferredTypeString("{'1': 1, ", "Map<String, int>");
+}
public void test_typesPropagation_mapLiteral_mixedTypes() throws Exception {
AnalyzeLibraryResult libraryResult = analyzeLibrary(
@@ -2825,6 +2827,20 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
assertInferredElementTypeString(testUnit, "v", "num");
}
+ private void assertNodeInferredTypeString(final String prefix, final String expectedType) {
+ testUnit.accept(new ASTVisitor<Void>() {
+ public Void visitExpression(DartExpression node) {
+ int nodeOffset = node.getSourceInfo().getOffset();
+ if (testSource.substring(nodeOffset).startsWith(prefix)) {
+ Type actualType = node.getType();
+ assertEquals(expectedType, actualType.toString());
+ assertTrue(actualType.isInferred());
+ }
+ return super.visitNode(node);
+ }
+ });
+ }
+
public void test_getType_binaryExpression() throws Exception {
analyzeLibrary(
"f(var arg) {",

Powered by Google App Engine
This is Rietveld 408576698