Index: pkg/analyzer/test/src/task/dart_test.dart |
diff --git a/pkg/analyzer/test/src/task/dart_test.dart b/pkg/analyzer/test/src/task/dart_test.dart |
index 16f1696884f4209a1a7f6c78099be0c8577315cd..db342f92caebc8c1a64fa81c810c8e64e56bf3b4 100644 |
--- a/pkg/analyzer/test/src/task/dart_test.dart |
+++ b/pkg/analyzer/test/src/task/dart_test.dart |
@@ -49,6 +49,7 @@ main() { |
runReflectiveTests(LibraryErrorsReadyTaskTest); |
runReflectiveTests(LibraryUnitErrorsTaskTest); |
runReflectiveTests(ParseDartTaskTest); |
+ runReflectiveTests(PartiallyResolveReferencesTaskTest); |
runReflectiveTests(ResolveUnitTypeNamesTaskTest); |
runReflectiveTests(ResolveLibraryTypeNamesTaskTest); |
runReflectiveTests(ResolveReferencesTaskTest); |
@@ -2333,6 +2334,74 @@ class B {}'''); |
} |
@reflectiveTest |
+class PartiallyResolveReferencesTaskTest extends _AbstractDartTaskTest { |
+ test_perform() { |
+ Source source = newSource( |
+ '/test.dart', |
+ ''' |
+int a = b; |
+int b = c; |
+'''); |
+ LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
+ computeResult(target, RESOLVED_UNIT4_1); |
+ expect(task, new isInstanceOf<PartiallyResolveUnitReferencesTask>()); |
+ // Test the outputs |
+ CompilationUnit unit = outputs[RESOLVED_UNIT4_1]; |
+ expect(unit, same(outputs[RESOLVED_UNIT4_1])); |
+ // Test the state of the AST |
+ TopLevelVariableDeclaration a = unit.declarations[0]; |
+ VariableDeclaration variableA = a.variables.variables[0]; |
+ SimpleIdentifier initializer = variableA.initializer; |
+ expect(initializer.staticElement, isNotNull); |
+ // Test the error generation |
+ _fillErrorListener(PARTIALLY_RESOLVE_REFERENCES_ERRORS); |
+ errorListener.assertErrorsWithCodes( |
+ <ErrorCode>[StaticWarningCode.UNDEFINED_IDENTIFIER]); |
+ } |
+ |
+ test_perform_importExport() { |
+ newSource( |
+ '/a.dart', |
+ ''' |
+library a; |
+class A<T> { |
+ T m() {} |
+} |
+'''); |
+ newSource( |
+ '/b.dart', |
+ ''' |
+library b; |
+export 'a.dart'; |
+'''); |
+ Source sourceC = newSource( |
+ '/c.dart', |
+ ''' |
+library c; |
+import 'b.dart'; |
+main() { |
+ new A<int>().m(); |
+} |
+'''); |
+ computeResult(new LibrarySpecificUnit(sourceC, sourceC), RESOLVED_UNIT4_1); |
+ expect(task, new isInstanceOf<PartiallyResolveUnitReferencesTask>()); |
+ // validate |
+ CompilationUnit unit = outputs[RESOLVED_UNIT4_1]; |
+ expect(unit, isNotNull); |
+ |
+ FunctionDeclaration functionDeclaration = unit.declarations[0]; |
+ BlockFunctionBody body = functionDeclaration.functionExpression.body; |
+ List<Statement> statements = body.block.statements; |
+ ExpressionStatement statement = statements[0]; |
+ MethodInvocation invocation = statement.expression; |
+ MethodElement methodElement = invocation.methodName.staticElement; |
+ expect(methodElement, isNotNull); |
+ expect(methodElement.type, isNotNull); |
+ expect(methodElement.returnType.toString(), 'int'); |
+ } |
+} |
+ |
+@reflectiveTest |
class ResolveLibraryTypeNamesTaskTest extends _AbstractDartTaskTest { |
test_perform() { |
Source sourceLib = newSource( |