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

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

Issue 10854220: Set type for variables and type nodes (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
« no previous file with comments | « compiler/java/com/google/dart/compiler/type/TypeAnalyzer.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 1814ee784b54e4cf6c8da4d2b9db5fe03c6ef207..4e70c706fe1947f208fa3a63009ee7818c165e0b 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -3,6 +3,9 @@
// BSD-style license that can be found in the LICENSE file.
package com.google.dart.compiler.type;
+import static com.google.dart.compiler.common.ErrorExpectation.assertErrors;
+import static com.google.dart.compiler.common.ErrorExpectation.errEx;
+
import com.google.common.base.Joiner;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
@@ -19,6 +22,7 @@ import com.google.dart.compiler.MockArtifactProvider;
import com.google.dart.compiler.MockLibrarySource;
import com.google.dart.compiler.ast.ASTVisitor;
import com.google.dart.compiler.ast.DartClass;
+import com.google.dart.compiler.ast.DartDeclaration;
import com.google.dart.compiler.ast.DartExprStmt;
import com.google.dart.compiler.ast.DartExpression;
import com.google.dart.compiler.ast.DartField;
@@ -44,9 +48,6 @@ import com.google.dart.compiler.resolver.NodeElement;
import com.google.dart.compiler.resolver.ResolverErrorCode;
import com.google.dart.compiler.resolver.TypeErrorCode;
-import static com.google.dart.compiler.common.ErrorExpectation.assertErrors;
-import static com.google.dart.compiler.common.ErrorExpectation.errEx;
-
import java.io.Reader;
import java.io.StringReader;
import java.net.URI;
@@ -3618,6 +3619,68 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
libraryResult.getErrors(),
errEx(ResolverErrorCode.USE_ASSIGNMENT_ON_SETTER, 4, 3, 12));
}
+
+ /**
+ * Every {@link DartExpression} should have {@link Type} set. Just to don't guess this type at
+ * many other points in the Editor.
+ */
+ public void test_typeForEveryExpression_variable() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class A {}",
+ "process(x) {}",
+ "main() {",
+ " A aaa = new A();",
+ " process(aaa);",
+ "}");
+ DartUnit unit = libraryResult.getLibraryUnitResult().getUnit(getName());
+ unit.accept(new ASTVisitor<Void>() {
+ public Void visitIdentifier(DartIdentifier node) {
+ // ignore declaration
+ if (node.getParent() instanceof DartDeclaration) {
+ return null;
+ }
+ // check "aaa"
+ if (node.toString().equals("aaa")) {
+ Type type = node.getType();
+ assertNotNull(type);
+ assertEquals("A", type.toString());
+ }
+ return null;
+ }
+ });
+ }
+
+ /**
+ * Every {@link DartExpression} should have {@link Type} set. Just to don't guess this type at
+ * many other points in the Editor.
+ */
+ public void test_typeForEveryExpression_typeNode() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class AAA {",
+ " static foo() {}",
+ "}",
+ "main() {",
+ " AAA.foo();",
+ "}");
+ DartUnit unit = libraryResult.getLibraryUnitResult().getUnit(getName());
+ unit.accept(new ASTVisitor<Void>() {
+ public Void visitIdentifier(DartIdentifier node) {
+ // ignore declaration
+ if (node.getParent() instanceof DartDeclaration) {
+ return null;
+ }
+ // check "AAA"
+ if (node.toString().equals("AAA")) {
+ Type type = node.getType();
+ assertNotNull(type);
+ assertEquals("AAA", type.toString());
+ }
+ return null;
+ }
+ });
+ }
/**
* <p>
« no previous file with comments | « compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698