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

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

Issue 1215053003: Compute mixin application constructors in the ClassElement.constructors getter. (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/test/generated/resolver_test.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 c89e6e9e919229d0c38ca5e320714c899d540558..77db0102ae1678e21928cb2bf1e3b99ad289d503 100644
--- a/pkg/analyzer/test/src/task/dart_test.dart
+++ b/pkg/analyzer/test/src/task/dart_test.dart
@@ -28,14 +28,12 @@ import '../context/abstract_context.dart';
main() {
groupSep = ' | ';
- runReflectiveTests(BuildClassConstructorsTaskTest);
runReflectiveTests(BuildCompilationUnitElementTaskTest);
runReflectiveTests(BuildDirectiveElementsTaskTest);
runReflectiveTests(BuildEnumMemberElementsTaskTest);
runReflectiveTests(BuildSourceExportClosureTaskTest);
runReflectiveTests(BuildSourceImportExportClosureTaskTest);
runReflectiveTests(BuildExportNamespaceTaskTest);
- runReflectiveTests(BuildLibraryConstructorsTaskTest);
runReflectiveTests(BuildLibraryElementTaskTest);
runReflectiveTests(BuildPublicNamespaceTaskTest);
runReflectiveTests(BuildTypeProviderTaskTest);
@@ -59,112 +57,6 @@ main() {
}
@reflectiveTest
-class BuildClassConstructorsTaskTest extends _AbstractDartTaskTest {
- test_perform_ClassDeclaration_errors_mixinHasNoConstructors() {
- Source source = newSource('/test.dart', '''
-class B {
- B({x});
-}
-class M {}
-class C extends B with M {}
-''');
- LibraryElement libraryElement;
- {
- computeResult(source, LIBRARY_ELEMENT5);
- libraryElement = outputs[LIBRARY_ELEMENT5];
- }
- // prepare C
- ClassElement c = libraryElement.getType('C');
- expect(c, isNotNull);
- // build constructors
- computeResult(c, CONSTRUCTORS);
- expect(task, new isInstanceOf<BuildClassConstructorsTask>());
- _fillErrorListener(CONSTRUCTORS_ERRORS);
- errorListener.assertErrorsWithCodes(
- <ErrorCode>[CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS]);
- }
-
- test_perform_ClassDeclaration_explicitConstructors() {
- Source source = newSource('/test.dart', '''
-class B {
- B(p);
-}
-class C extends B {
- C(int a, String b) {}
-}
-''');
- LibraryElement libraryElement;
- {
- computeResult(source, LIBRARY_ELEMENT5);
- libraryElement = outputs[LIBRARY_ELEMENT5];
- }
- // prepare C
- ClassElement c = libraryElement.getType('C');
- expect(c, isNotNull);
- // build constructors
- computeResult(c, CONSTRUCTORS);
- expect(task, new isInstanceOf<BuildClassConstructorsTask>());
- // no errors
- expect(outputs[CONSTRUCTORS_ERRORS], isEmpty);
- // explicit constructor
- List<ConstructorElement> constructors = outputs[CONSTRUCTORS];
- expect(constructors, hasLength(1));
- expect(constructors[0].parameters, hasLength(2));
- }
-
- test_perform_ClassTypeAlias() {
- Source source = newSource('/test.dart', '''
-class B {
- B(int i);
-}
-class M1 {}
-class M2 {}
-
-class C2 = C1 with M2;
-class C1 = B with M1;
-''');
- LibraryElement libraryElement;
- {
- computeResult(source, LIBRARY_ELEMENT5);
- libraryElement = outputs[LIBRARY_ELEMENT5];
- }
- // prepare C2
- ClassElement class2 = libraryElement.getType('C2');
- expect(class2, isNotNull);
- // build constructors
- computeResult(class2, CONSTRUCTORS);
- expect(task, new isInstanceOf<BuildClassConstructorsTask>());
- List<ConstructorElement> constructors = outputs[CONSTRUCTORS];
- expect(constructors, hasLength(1));
- expect(constructors[0].parameters, hasLength(1));
- }
-
- test_perform_ClassTypeAlias_errors_mixinHasNoConstructors() {
- Source source = newSource('/test.dart', '''
-class B {
- B({x});
-}
-class M {}
-class C = B with M;
-''');
- LibraryElement libraryElement;
- {
- computeResult(source, LIBRARY_ELEMENT5);
- libraryElement = outputs[LIBRARY_ELEMENT5];
- }
- // prepare C
- ClassElement c = libraryElement.getType('C');
- expect(c, isNotNull);
- // build constructors
- computeResult(c, CONSTRUCTORS);
- expect(task, new isInstanceOf<BuildClassConstructorsTask>());
- _fillErrorListener(CONSTRUCTORS_ERRORS);
- errorListener.assertErrorsWithCodes(
- <ErrorCode>[CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS]);
- }
-}
-
-@reflectiveTest
class BuildCompilationUnitElementTaskTest extends _AbstractDartTaskTest {
Source source;
LibrarySpecificUnit target;
@@ -715,40 +607,6 @@ int topLevelB;
}
@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;
@@ -798,7 +656,7 @@ part of lib;
part of lib;
'''
});
- expect(outputs, hasLength(4));
+ expect(outputs, hasLength(3));
// simple outputs
expect(outputs[BUILD_LIBRARY_ERRORS], isEmpty);
expect(outputs[IS_LAUNCHABLE], isFalse);
@@ -839,28 +697,6 @@ 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': '''
@@ -2054,7 +1890,6 @@ class LibraryUnitErrorsTaskTest extends _AbstractDartTaskTest {
.buildInputs(new LibrarySpecificUnit(emptySource, emptySource));
expect(inputs, isNotNull);
expect(inputs.keys, unorderedEquals([
- LibraryUnitErrorsTask.CONSTRUCTORS_ERRORS_INPUT,
LibraryUnitErrorsTask.HINTS_INPUT,
LibraryUnitErrorsTask.RESOLVE_REFERENCES_ERRORS_INPUT,
LibraryUnitErrorsTask.RESOLVE_TYPE_NAMES_ERRORS_INPUT,
« no previous file with comments | « pkg/analyzer/test/generated/resolver_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698