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

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

Issue 1031283002: BuildLibraryConstructorsTask to build all constructors of all library classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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/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 d4548205439a4c63264053a087947d2e3c30295f..c03b51d4d183782e865f673010cb3cd5c6a13c0e 100644
--- a/pkg/analyzer/test/src/task/dart_test.dart
+++ b/pkg/analyzer/test/src/task/dart_test.dart
@@ -38,6 +38,7 @@ main() {
runReflectiveTests(BuildExportSourceClosureTaskTest);
runReflectiveTests(BuildExportNamespaceTaskTest);
runReflectiveTests(BuildFunctionTypeAliasesTaskTest);
+ runReflectiveTests(BuildLibraryConstructorsTaskTest);
runReflectiveTests(BuildLibraryElementTaskTest);
runReflectiveTests(BuildPublicNamespaceTaskTest);
runReflectiveTests(BuildTypeProviderTaskTest);
@@ -698,6 +699,40 @@ typedef int F(NoSuchType p);
}
@reflectiveTest
+class BuildLibraryConstructorsTaskTest extends _AbstractDartTaskTest {
+ test_perform() {
+ Source source = _newSource('/test.dart', '''
+class B {
+ B(int i);
+}
+class M1 {}
+class M2 {}
+
+class C2 = C1 with M2;
+class C1 = B with M1;
+class C3 = B with M2;
+''');
+ _computeResult(source, LIBRARY_ELEMENT6);
+ expect(task, new isInstanceOf<BuildLibraryConstructorsTask>());
+ LibraryElement libraryElement = outputs[LIBRARY_ELEMENT6];
+ // C1
+ {
+ ClassElement classElement = libraryElement.getType('C2');
+ List<ConstructorElement> constructors = classElement.constructors;
+ expect(constructors, hasLength(1));
+ expect(constructors[0].parameters, hasLength(1));
+ }
+ // C3
+ {
+ ClassElement classElement = libraryElement.getType('C3');
+ List<ConstructorElement> constructors = classElement.constructors;
+ expect(constructors, hasLength(1));
+ expect(constructors[0].parameters, hasLength(1));
+ }
+ }
+}
+
+@reflectiveTest
class BuildLibraryElementTaskTest extends _AbstractDartTaskTest {
Source librarySource;
CompilationUnit libraryUnit;
@@ -747,7 +782,7 @@ part of lib;
part of lib;
'''
});
- expect(outputs, hasLength(4));
+ expect(outputs, hasLength(5));
// simple outputs
expect(outputs[BUILD_LIBRARY_ERRORS], isEmpty);
expect(outputs[IS_LAUNCHABLE], isFalse);
@@ -789,6 +824,28 @@ part of lib;
(libraryUnit.directives[2] as PartDirective).element, same(secondPart));
}
+ test_perform_classElements() {
+ _performBuildTask({
+ '/lib.dart': '''
+library lib;
+part 'part1.dart';
+part 'part2.dart';
+class A {}
+''',
+ '/part1.dart': '''
+part of lib;
+class B {}
+''',
+ '/part2.dart': '''
+part of lib;
+class C {}
+'''
+ });
+ List<ClassElement> classElements = outputs[CLASS_ELEMENTS];
+ List<String> classNames = classElements.map((c) => c.displayName).toList();
+ expect(classNames, unorderedEquals(['A', 'B', 'C']));
+ }
+
test_perform_error_missingLibraryDirectiveWithPart_hasCommon() {
_performBuildTask({
'/lib.dart': '''
@@ -1269,6 +1326,7 @@ class _AbstractDartTaskTest extends EngineTestCase {
taskManager.addTaskDescriptor(ParseDartTask.DESCRIPTOR);
taskManager.addTaskDescriptor(BuildClassConstructorsTask.DESCRIPTOR);
taskManager.addTaskDescriptor(BuildCompilationUnitElementTask.DESCRIPTOR);
+ taskManager.addTaskDescriptor(BuildLibraryConstructorsTask.DESCRIPTOR);
taskManager.addTaskDescriptor(BuildLibraryElementTask.DESCRIPTOR);
taskManager.addTaskDescriptor(BuildPublicNamespaceTask.DESCRIPTOR);
taskManager.addTaskDescriptor(BuildDirectiveElementsTask.DESCRIPTOR);
« no previous file with comments | « pkg/analyzer/lib/task/dart.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698