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

Unified Diff: pkg/analyzer/test/src/task/dart_test.dart

Issue 1321523002: Add a task to partially resolve a compilation unit (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 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
« pkg/analyzer/lib/src/task/dart.dart ('K') | « pkg/analyzer/lib/src/task/dart.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(
« pkg/analyzer/lib/src/task/dart.dart ('K') | « pkg/analyzer/lib/src/task/dart.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698