Index: compiler/javatests/com/google/dart/compiler/CompilerTestCase.java |
diff --git a/compiler/javatests/com/google/dart/compiler/CompilerTestCase.java b/compiler/javatests/com/google/dart/compiler/CompilerTestCase.java |
index 3c2cd900ba6edcd21be9322fa86c20cc1e1d269b..21e9f2b83f5e5660c10323b51594cd6efa2e172c 100644 |
--- a/compiler/javatests/com/google/dart/compiler/CompilerTestCase.java |
+++ b/compiler/javatests/com/google/dart/compiler/CompilerTestCase.java |
@@ -6,6 +6,10 @@ package com.google.dart.compiler; |
import com.google.common.collect.Lists; |
import com.google.dart.compiler.CommandLineOptions.CompilerOptions; |
+import com.google.dart.compiler.ast.DartInvocation; |
+import com.google.dart.compiler.ast.DartNewExpression; |
+import com.google.dart.compiler.ast.DartNode; |
+import com.google.dart.compiler.ast.DartNodeTraverser; |
import com.google.dart.compiler.ast.DartUnit; |
import com.google.dart.compiler.ast.LibraryUnit; |
import com.google.dart.compiler.parser.DartParser; |
@@ -103,6 +107,10 @@ public abstract class CompilerTestCase extends TestCase { |
return compilationErrors; |
} |
+ public List<DartCompilationError> getTypeErrors() { |
+ return typeErrors; |
+ } |
+ |
/** |
* @param lib |
*/ |
@@ -343,4 +351,22 @@ public abstract class CompilerTestCase extends TestCase { |
} |
} |
} |
+ |
+ /** |
+ * @return the {@link DartInvocation} with given source. This is inaccurate approach, but good |
+ * enough for specific tests. |
+ */ |
+ protected static DartNewExpression findNewExpression(DartNode rootNode, final String sampleSource) { |
+ final DartNewExpression result[] = new DartNewExpression[1]; |
+ rootNode.accept(new DartNodeTraverser<Void>() { |
zundel
2011/12/05 21:26:45
To simplify, you can make DartNodeTraverser<DartNe
scheglov
2011/12/06 14:20:39
Does not work because of limitations of DartNodeTr
|
+ @Override |
+ public Void visitNewExpression(DartNewExpression node) { |
+ if (node.toSource().equals(sampleSource)) { |
+ result[0] = node; |
+ } |
+ return super.visitInvocation(node); |
+ } |
+ }); |
+ return result[0]; |
+ } |
} |