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

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

Issue 11029037: Fix for cascade sections SourceInfo (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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/javatests/com/google/dart/compiler/resolver/ResolverCompilerTest.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 c2ca8618ff53eb3d8f72a3fb17c25084dc7dd379..f153e21872094a1d5b295f6dffd11987d19edc93 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;
@@ -42,7 +45,6 @@ import com.google.dart.compiler.ast.DartTypeNode;
import com.google.dart.compiler.ast.DartUnaryExpression;
import com.google.dart.compiler.ast.DartUnit;
import com.google.dart.compiler.ast.DartUnqualifiedInvocation;
-import com.google.dart.compiler.common.SourceInfo;
import com.google.dart.compiler.parser.ParserErrorCode;
import com.google.dart.compiler.resolver.ClassElement;
import com.google.dart.compiler.resolver.Element;
@@ -55,16 +57,12 @@ 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;
import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
/**
* Variant of {@link TypeAnalyzerTest}, which is based on {@link CompilerTestCase}. It is probably
@@ -577,7 +575,7 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
DartUnit unit = libraryResult.getLibraryUnitResult().getUnits().iterator().next();
// "new I.foo()" - resolved, but we produce error.
{
- DartNewExpression newExpression = findExpression(unit, "new I.foo(0)");
+ DartNewExpression newExpression = findNodeBySource(unit, "new I.foo(0)");
DartNode constructorNode = newExpression.getElement().getNode();
assertEquals(true, constructorNode.toSource().contains("F.foo("));
}
@@ -3108,13 +3106,13 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
assertErrors(libraryResult.getErrors());
// v.f1() was resolved
{
- DartExpression expression = findExpression(testUnit, "v.f1()");
+ DartExpression expression = findNodeBySource(testUnit, "v.f1()");
assertNotNull(expression);
assertNotNull(expression.getElement());
}
// v.f2() was resolved
{
- DartExpression expression = findExpression(testUnit, "v.f1()");
+ DartExpression expression = findNodeBySource(testUnit, "v.f1()");
assertNotNull(expression);
assertNotNull(expression.getElement());
}
@@ -3397,7 +3395,7 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
assertErrors(libraryResult.getErrors());
DartUnit unit = libraryResult.getLibraryUnitResult().getUnit(getName());
// find == expression
- DartExpression expression = findExpression(unit, "new C() == new C()");
+ DartExpression expression = findNodeBySource(unit, "new C() == new C()");
assertNotNull(expression);
// validate == element
MethodElement equalsElement = (MethodElement) expression.getElement();
@@ -4394,7 +4392,11 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
"");
assertErrors(libraryResult.getErrors());
{
- DartPropertyAccess access = findNode(DartPropertyAccess.class, "f = 1");
+ DartPropertyAccess access = findNode(DartPropertyAccess.class, "..f = 1");
+ assertNotNull(access.getElement());
+ }
+ {
+ DartPropertyAccess access = findNode(DartPropertyAccess.class, "..f = 2");
assertNotNull(access.getElement());
}
}
@@ -4418,7 +4420,11 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
"");
assertErrors(libraryResult.getErrors());
{
- DartMethodInvocation invocation = findNode(DartMethodInvocation.class, "m(1)");
+ DartMethodInvocation invocation = findNode(DartMethodInvocation.class, "..m(1)");
+ assertNotNull(invocation.getElement());
+ }
+ {
+ DartMethodInvocation invocation = findNode(DartMethodInvocation.class, "..m(2)");
assertNotNull(invocation.getElement());
}
}
@@ -5329,24 +5335,4 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
result.getErrors(),
errEx(ResolverErrorCode.CANNOT_RESOLVE_METHOD, 4, 5, 3));
}
-
- private <T extends DartNode> T findNode(final Class<T> clazz, String pattern) {
- final int index = testSource.indexOf(pattern);
- assertTrue(index != -1);
- final AtomicReference<T> result = new AtomicReference<T>();
- testUnit.accept(new ASTVisitor<Void>() {
- @Override
- @SuppressWarnings("unchecked")
- public Void visitNode(DartNode node) {
- SourceInfo sourceInfo = node.getSourceInfo();
- if (sourceInfo.getOffset() <= index
- && index < sourceInfo.getEnd()
- && clazz.isInstance(node)) {
- result.set((T) node);
- }
- return super.visitNode(node);
- }
- });
- return result.get();
- }
}
« no previous file with comments | « compiler/javatests/com/google/dart/compiler/resolver/ResolverCompilerTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698