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

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

Issue 1687173002: Test summarization of redirected factory constructors from imported libraries. (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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/summary/summary_common.dart
diff --git a/pkg/analyzer/test/src/summary/summary_common.dart b/pkg/analyzer/test/src/summary/summary_common.dart
index 364a2328a2c52721f40fdf06c2108ae1d7423407..8a0c47d564a6ebff9b60495005e38be8d44ab81a 100644
--- a/pkg/analyzer/test/src/summary/summary_common.dart
+++ b/pkg/analyzer/test/src/summary/summary_common.dart
@@ -3213,6 +3213,134 @@ class D<T, U> extends C<U, T> {
checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2);
}
+ test_constructor_redirected_factory_named_imported() {
+ addNamedSource(
+ '/foo.dart',
+ '''
+import 'test.dart';
+class D extends C {
+ D.named() : super._();
+}
+''');
+ String text = '''
+import 'foo.dart';
+class C {
+ factory C() = D.named;
+ C._();
+}
+''';
+ UnlinkedExecutable executable =
+ serializeClassText(text, className: 'C').executables[0];
+ expect(executable.isRedirectedConstructor, isTrue);
+ expect(executable.isFactory, isTrue);
+ expect(executable.redirectedConstructorName, isEmpty);
+ checkTypeRef(executable.redirectedConstructor, null, null, 'named',
+ expectedKind: ReferenceKind.constructor,
+ prefixExpectations: [
+ new _PrefixExpectation(ReferenceKind.classOrEnum, 'D',
+ absoluteUri: absUri('/foo.dart'), relativeUri: 'foo.dart')
+ ]);
+ }
+
+ test_constructor_redirected_factory_named_imported_generic() {
+ addNamedSource(
+ '/foo.dart',
+ '''
+import 'test.dart';
+class D<T, U> extends C<U, T> {
+ D.named() : super._();
+}
+''');
+ String text = '''
+import 'foo.dart';
+class C<T, U> {
+ factory C() = D<U, T>.named;
+ C._();
+}
+''';
+ UnlinkedExecutable executable =
+ serializeClassText(text, className: 'C').executables[0];
+ expect(executable.isRedirectedConstructor, isTrue);
+ expect(executable.isFactory, isTrue);
+ expect(executable.redirectedConstructorName, isEmpty);
+ checkTypeRef(executable.redirectedConstructor, null, null, 'named',
+ expectedKind: ReferenceKind.constructor,
+ prefixExpectations: [
+ new _PrefixExpectation(ReferenceKind.classOrEnum, 'D',
+ numTypeParameters: 2,
+ absoluteUri: absUri('/foo.dart'),
+ relativeUri: 'foo.dart')
+ ],
+ allowTypeParameters: true);
+ checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1);
+ checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2);
+ }
+
+ test_constructor_redirected_factory_named_prefixed() {
+ addNamedSource(
+ '/foo.dart',
+ '''
+import 'test.dart';
+class D extends C {
+ D.named() : super._();
+}
+''');
+ String text = '''
+import 'foo.dart' as foo;
+class C {
+ factory C() = foo.D.named;
+ C._();
+}
+''';
+ UnlinkedExecutable executable =
+ serializeClassText(text, className: 'C').executables[0];
+ expect(executable.isRedirectedConstructor, isTrue);
+ expect(executable.isFactory, isTrue);
+ expect(executable.redirectedConstructorName, isEmpty);
+ checkTypeRef(executable.redirectedConstructor, null, null, 'named',
+ expectedKind: ReferenceKind.constructor,
+ prefixExpectations: [
+ new _PrefixExpectation(ReferenceKind.classOrEnum, 'D',
+ absoluteUri: absUri('/foo.dart'), relativeUri: 'foo.dart'),
+ new _PrefixExpectation(ReferenceKind.prefix, 'foo')
+ ]);
+ }
+
+ test_constructor_redirected_factory_named_prefixed_generic() {
+ addNamedSource(
+ '/foo.dart',
+ '''
+import 'test.dart';
+class D<T, U> extends C<U, T> {
+ D.named() : super._();
+}
+''');
+ String text = '''
+import 'foo.dart' as foo;
+class C<T, U> {
+ factory C() = foo.D<U, T>.named;
+ C._();
+}
+''';
+ UnlinkedExecutable executable =
+ serializeClassText(text, className: 'C').executables[0];
+ expect(executable.isRedirectedConstructor, isTrue);
+ expect(executable.isFactory, isTrue);
+ expect(executable.redirectedConstructorName, isEmpty);
+ checkTypeRef(executable.redirectedConstructor, null, null, 'named',
+ expectedKind: ReferenceKind.constructor,
+ prefixExpectations: [
+ new _PrefixExpectation(ReferenceKind.classOrEnum, 'D',
+ numTypeParameters: 2,
+ absoluteUri: absUri('/foo.dart'),
+ relativeUri: 'foo.dart'),
+ new _PrefixExpectation(ReferenceKind.prefix, 'foo')
+ ],
+ allowTypeParameters: true);
+ checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1);
+ checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2);
+ }
+
test_constructor_redirected_factory_unnamed() {
String text = '''
class C {
@@ -3252,6 +3380,113 @@ class D<T, U> extends C<U, T> {
checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2);
}
+ test_constructor_redirected_factory_unnamed_imported() {
+ addNamedSource(
+ '/foo.dart',
+ '''
+import 'test.dart';
+class D extends C {
+ D() : super._();
+}
+''');
+ String text = '''
+import 'foo.dart';
+class C {
+ factory C() = D;
+ C._();
+}
+''';
+ UnlinkedExecutable executable =
+ serializeClassText(text, className: 'C').executables[0];
+ expect(executable.isRedirectedConstructor, isTrue);
+ expect(executable.isFactory, isTrue);
+ expect(executable.redirectedConstructorName, isEmpty);
+ checkTypeRef(
+ executable.redirectedConstructor, absUri('/foo.dart'), 'foo.dart', 'D');
+ }
+
+ test_constructor_redirected_factory_unnamed_imported_generic() {
+ addNamedSource(
+ '/foo.dart',
+ '''
+import 'test.dart';
+class D<T, U> extends C<U, T> {
+ D() : super._();
+}
+''');
+ String text = '''
+import 'foo.dart';
+class C<T, U> {
+ factory C() = D<U, T>;
+ C._();
+}
+''';
+ UnlinkedExecutable executable =
+ serializeClassText(text, className: 'C').executables[0];
+ expect(executable.isRedirectedConstructor, isTrue);
+ expect(executable.isFactory, isTrue);
+ expect(executable.redirectedConstructorName, isEmpty);
+ checkTypeRef(
+ executable.redirectedConstructor, absUri('/foo.dart'), 'foo.dart', 'D',
+ allowTypeParameters: true, numTypeParameters: 2);
+ checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1);
+ checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2);
+ }
+
+ test_constructor_redirected_factory_unnamed_prefixed() {
+ addNamedSource(
+ '/foo.dart',
+ '''
+import 'test.dart';
+class D extends C {
+ D() : super._();
+}
+''');
+ String text = '''
+import 'foo.dart' as foo;
+class C {
+ factory C() = foo.D;
+ C._();
+}
+''';
+ UnlinkedExecutable executable =
+ serializeClassText(text, className: 'C').executables[0];
+ expect(executable.isRedirectedConstructor, isTrue);
+ expect(executable.isFactory, isTrue);
+ expect(executable.redirectedConstructorName, isEmpty);
+ checkTypeRef(
+ executable.redirectedConstructor, absUri('/foo.dart'), 'foo.dart', 'D',
+ expectedPrefix: 'foo');
+ }
+
+ test_constructor_redirected_factory_unnamed_prefixed_generic() {
+ addNamedSource(
+ '/foo.dart',
+ '''
+import 'test.dart';
+class D<T, U> extends C<U, T> {
+ D() : super._();
+}
+''');
+ String text = '''
+import 'foo.dart' as foo;
+class C<T, U> {
+ factory C() = foo.D<U, T>;
+ C._();
+}
+''';
+ UnlinkedExecutable executable =
+ serializeClassText(text, className: 'C').executables[0];
+ expect(executable.isRedirectedConstructor, isTrue);
+ expect(executable.isFactory, isTrue);
+ expect(executable.redirectedConstructorName, isEmpty);
+ checkTypeRef(
+ executable.redirectedConstructor, absUri('/foo.dart'), 'foo.dart', 'D',
+ allowTypeParameters: true, numTypeParameters: 2, expectedPrefix: 'foo');
+ checkParamTypeRef(executable.redirectedConstructor.typeArguments[0], 1);
+ checkParamTypeRef(executable.redirectedConstructor.typeArguments[1], 2);
+ }
+
test_constructor_redirected_thisInvocation_named() {
String text = '''
class C {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698