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

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

Issue 1166983005: Ensure types are resolved for combined import/export closures. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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 | « 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 9b3a0b7f7d7f63de8a450e12b850bd7aa931c458..ac1be9fb0a5ac20f63be44feef43ee5ca7a39dda 100644
--- a/pkg/analyzer/test/src/task/dart_test.dart
+++ b/pkg/analyzer/test/src/task/dart_test.dart
@@ -1181,6 +1181,40 @@ library lib_d;
}
}
+ test_perform_importExportClosure() {
+ Source sourceA = newSource('/a.dart', '''
+library lib_a;
+''');
+ Source sourceB = newSource('/b.dart', '''
+library lib_b;
+export 'a.dart';
+''');
+ Source sourceC = newSource('/c.dart', '''
+library lib_c;
+import 'b.dart';
+''');
+ Source coreSource = context.sourceFactory.resolveUri(null, 'dart:core');
+ // c.dart
+ {
+ _computeResult(sourceC, IMPORT_EXPORT_SOURCE_CLOSURE);
+ expect(task, new isInstanceOf<BuildSourceClosuresTask>());
+ List<Source> closure = outputs[IMPORT_EXPORT_SOURCE_CLOSURE];
+ expect(closure, contains(sourceA));
+ expect(closure, contains(sourceB));
+ expect(closure, contains(sourceC));
+ expect(closure, contains(coreSource));
+ }
+ // b.dart
+ {
+ _computeResult(sourceB, IMPORT_EXPORT_SOURCE_CLOSURE);
+ expect(task, new isInstanceOf<BuildSourceClosuresTask>());
+ List<Source> closure = outputs[IMPORT_EXPORT_SOURCE_CLOSURE];
+ expect(closure, contains(sourceA));
+ expect(closure, contains(sourceB));
+ expect(closure, contains(coreSource));
+ }
+ }
+
test_perform_isClient_false() {
Source sourceA = newSource('/a.dart', '''
library lib_a;
@@ -2137,11 +2171,6 @@ class B {}''');
expect(outputs[UNITS], hasLength(1));
}
- test_perform_computeSourceKind_noDirectives_noContainingLibraries() {
- _performParseTask('');
- expect(outputs[SOURCE_KIND], SourceKind.LIBRARY);
- }
-
test_perform_computeSourceKind_noDirectives_hasContainingLibraries() {
// Parse "lib.dart" to let the context know that "test.dart" is a part.
_computeResult(newSource('/lib.dart', r'''
@@ -2153,6 +2182,11 @@ part 'test.dart';
expect(outputs[SOURCE_KIND], SourceKind.PART);
}
+ test_perform_computeSourceKind_noDirectives_noContainingLibraries() {
+ _performParseTask('');
+ expect(outputs[SOURCE_KIND], SourceKind.LIBRARY);
+ }
+
test_perform_doesNotExist() {
_performParseTask(null);
expect(outputs, hasLength(8));
@@ -2326,6 +2360,42 @@ main(A a) {
errorListener.assertErrorsWithCodes(
<ErrorCode>[StaticTypeWarningCode.UNDEFINED_METHOD]);
}
+
+ 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_UNIT6);
+ expect(task, new isInstanceOf<ResolveReferencesTask>());
+ // validate
+ CompilationUnit unit = outputs[RESOLVED_UNIT6];
+ 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
« no previous file with comments | « 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