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

Unified Diff: pkg/analyzer/test/src/summary/resynthesize_test.dart

Issue 1686713002: Add support for redirectedConstructor to summaries. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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
Index: pkg/analyzer/test/src/summary/resynthesize_test.dart
diff --git a/pkg/analyzer/test/src/summary/resynthesize_test.dart b/pkg/analyzer/test/src/summary/resynthesize_test.dart
index a19d1fa1338c3035c5d0e4f9246ca2f4fb929edc..7b3a0bb76370571ab43e5f777cfadcb1627b8383 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_test.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_test.dart
@@ -428,9 +428,16 @@ class ResynthTest extends ResolverTestCase {
void compareConstructorElements(ConstructorElementImpl resynthesized,
ConstructorElementImpl original, String desc) {
compareExecutableElements(resynthesized, original, desc);
- compareConstAstLists(resynthesized.constantInitializers,
- original.constantInitializers, desc);
- // TODO(paulberry): test redirectedConstructor
+ if (original.isConst) {
+ compareConstAstLists(resynthesized.constantInitializers,
+ original.constantInitializers, desc);
+ }
+ if (original.redirectedConstructor == null) {
+ expect(resynthesized.redirectedConstructor, isNull, reason: desc);
+ } else {
+ compareElements(resynthesized.redirectedConstructor,
+ original.redirectedConstructor, desc);
+ }
}
void compareElementAnnotations(ElementAnnotationImpl resynthesized,
@@ -1897,6 +1904,138 @@ class C {
''');
}
+ test_constructor_redirected_factory_named() {
+ checkLibrary('''
+class C {
+ factory C() = D.named;
+ C._();
+}
+class D extends C {
+ D.named() : super._();
+}
+''');
+ }
+
+ test_constructor_redirected_factory_named_imported() {
+ addLibrarySource(
+ '/foo.dart',
+ '''
+import 'test.dart';
+class D extends C {
+ D.named() : super._();
+}
+''');
+ checkLibrary('''
+import 'foo.dart';
+class C {
+ factory C() = D.named;
+ C._();
+}
+''');
+ }
+
+ test_constructor_redirected_factory_named_prefixed() {
+ addLibrarySource(
+ '/foo.dart',
+ '''
+import 'test.dart';
+class D extends C {
+ D.named() : super._();
+}
+''');
+ checkLibrary('''
+import 'foo.dart' as foo;
+class C {
+ factory C() = foo.D.named;
+ C._();
+}
+''');
+ }
+
+ test_constructor_redirected_factory_unnamed() {
+ checkLibrary('''
+class C {
+ factory C() = D;
+ C._();
+}
+class D extends C {
+ D() : super._();
+}
+''');
+ }
+
+ test_constructor_redirected_factory_unnamed_imported() {
+ addLibrarySource(
+ '/foo.dart',
+ '''
+import 'test.dart';
+class D extends C {
+ D() : super._();
+}
+''');
+ checkLibrary('''
+import 'foo.dart';
+class C {
+ factory C() = D;
+ C._();
+}
+''');
+ }
+
+ test_constructor_redirected_factory_unnamed_prefixed() {
+ addLibrarySource(
+ '/foo.dart',
+ '''
+import 'test.dart';
+class D extends C {
+ D() : super._();
+}
+''');
+ checkLibrary('''
+import 'foo.dart' as foo;
+class C {
+ factory C() = foo.D;
+ C._();
+}
+''');
+ }
+
+ test_constructor_redirected_thisInvocation_named() {
+ checkLibrary('''
+class C {
+ C.named();
+ C() : this.named();
+}
+''');
+ }
+
+ test_constructor_redirected_thisInvocation_named_generic() {
+ checkLibrary('''
+class C<T> {
+ C.named();
+ C() : this.named();
+}
+''');
+ }
+
+ test_constructor_redirected_thisInvocation_unnamed() {
+ checkLibrary('''
+class C {
+ C();
+ C.named() : this();
+}
+''');
+ }
+
+ test_constructor_redirected_thisInvocation_unnamed_generic() {
+ checkLibrary('''
+class C<T> {
+ C();
+ C.named() : this();
+}
+''');
+ }
+
test_core() {
String uri = 'dart:core';
LibraryElementImpl original =
« no previous file with comments | « pkg/analyzer/lib/src/summary/summarize_elements.dart ('k') | pkg/analyzer/test/src/summary/summary_common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698