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

Side by Side Diff: pkg/analyzer/test/src/summary/summary_common.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 unified diff | Download patch
« no previous file with comments | « pkg/analyzer/test/src/summary/resynthesize_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.test.src.summary.summary_common; 5 library analyzer.test.src.summary.summary_common;
6 6
7 import 'package:analyzer/analyzer.dart'; 7 import 'package:analyzer/analyzer.dart';
8 import 'package:analyzer/dart/ast/ast.dart'; 8 import 'package:analyzer/dart/ast/ast.dart';
9 import 'package:analyzer/dart/element/element.dart'; 9 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/src/generated/engine.dart'; 10 import 'package:analyzer/src/generated/engine.dart';
(...skipping 2728 matching lines...) Expand 10 before | Expand all | Expand 10 after
2739 } 2739 }
2740 2740
2741 test_constructor() { 2741 test_constructor() {
2742 String text = 'class C { C(); }'; 2742 String text = 'class C { C(); }';
2743 UnlinkedExecutable executable = 2743 UnlinkedExecutable executable =
2744 findExecutable('', executables: serializeClassText(text).executables); 2744 findExecutable('', executables: serializeClassText(text).executables);
2745 expect(executable.kind, UnlinkedExecutableKind.constructor); 2745 expect(executable.kind, UnlinkedExecutableKind.constructor);
2746 expect(executable.returnType, isNull); 2746 expect(executable.returnType, isNull);
2747 expect(executable.isExternal, isFalse); 2747 expect(executable.isExternal, isFalse);
2748 expect(executable.nameOffset, text.indexOf('C();')); 2748 expect(executable.nameOffset, text.indexOf('C();'));
2749 expect(executable.isRedirectedConstructor, isFalse);
2750 expect(executable.redirectedConstructor, isNull);
2751 expect(executable.redirectedConstructorName, isEmpty);
2749 } 2752 }
2750 2753
2751 test_constructor_anonymous() { 2754 test_constructor_anonymous() {
2752 UnlinkedExecutable executable = findExecutable('', 2755 UnlinkedExecutable executable = findExecutable('',
2753 executables: serializeClassText('class C { C(); }').executables); 2756 executables: serializeClassText('class C { C(); }').executables);
2754 expect(executable.name, isEmpty); 2757 expect(executable.name, isEmpty);
2755 } 2758 }
2756 2759
2757 test_constructor_const() { 2760 test_constructor_const() {
2758 UnlinkedExecutable executable = findExecutable('', 2761 UnlinkedExecutable executable = findExecutable('',
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
3155 expect(ctor.parameters[0].inferredTypeSlot, 0); 3158 expect(ctor.parameters[0].inferredTypeSlot, 0);
3156 } 3159 }
3157 3160
3158 test_constructor_param_inferred_type_implicit() { 3161 test_constructor_param_inferred_type_implicit() {
3159 UnlinkedExecutable ctor = 3162 UnlinkedExecutable ctor =
3160 serializeClassText('class C { C(v); }').executables[0]; 3163 serializeClassText('class C { C(v); }').executables[0];
3161 expect(ctor.kind, UnlinkedExecutableKind.constructor); 3164 expect(ctor.kind, UnlinkedExecutableKind.constructor);
3162 expect(ctor.parameters[0].inferredTypeSlot, 0); 3165 expect(ctor.parameters[0].inferredTypeSlot, 0);
3163 } 3166 }
3164 3167
3168 test_constructor_redirected_factory_named() {
3169 String text = '''
3170 class C {
3171 factory C() = D.named;
3172 C._();
3173 }
3174 class D extends C {
3175 D.named() : super._();
3176 }
3177 ''';
3178 UnlinkedExecutable executable =
3179 serializeClassText(text, className: 'C').executables[0];
3180 expect(executable.isRedirectedConstructor, isTrue);
3181 expect(executable.isFactory, isTrue);
3182 expect(executable.redirectedConstructorName, isEmpty);
3183 checkTypeRef(executable.redirectedConstructor, null, null, 'named',
3184 expectedKind: ReferenceKind.constructor,
3185 prefixExpectations: [
3186 new _PrefixExpectation(ReferenceKind.classOrEnum, 'D')
3187 ]);
3188 }
3189
3190 test_constructor_redirected_factory_unnamed() {
3191 String text = '''
3192 class C {
3193 factory C() = D;
3194 C._();
3195 }
3196 class D extends C {
3197 D() : super._();
3198 }
3199 ''';
3200 UnlinkedExecutable executable =
3201 serializeClassText(text, className: 'C').executables[0];
3202 expect(executable.isRedirectedConstructor, isTrue);
3203 expect(executable.isFactory, isTrue);
3204 expect(executable.redirectedConstructorName, isEmpty);
3205 checkTypeRef(executable.redirectedConstructor, null, null, 'D');
3206 }
3207
3208 test_constructor_redirected_thisInvocation_named() {
3209 String text = '''
3210 class C {
3211 C() : this.named();
3212 C.named();
3213 }
3214 ''';
3215 UnlinkedExecutable executable =
3216 serializeClassText(text, className: 'C').executables[0];
3217 expect(executable.isRedirectedConstructor, isTrue);
3218 expect(executable.isFactory, isFalse);
3219 expect(executable.redirectedConstructorName, 'named');
3220 expect(executable.redirectedConstructor, isNull);
3221 }
3222
3223 test_constructor_redirected_thisInvocation_unnamed() {
3224 String text = '''
3225 class C {
3226 C.named() : this();
3227 C();
3228 }
3229 ''';
3230 UnlinkedExecutable executable =
3231 serializeClassText(text, className: 'C').executables[0];
3232 expect(executable.isRedirectedConstructor, isTrue);
3233 expect(executable.isFactory, isFalse);
3234 expect(executable.redirectedConstructorName, isEmpty);
3235 expect(executable.redirectedConstructor, isNull);
3236 }
3237
3165 test_constructor_return_type() { 3238 test_constructor_return_type() {
3166 UnlinkedExecutable executable = findExecutable('', 3239 UnlinkedExecutable executable = findExecutable('',
3167 executables: serializeClassText('class C { C(); }').executables); 3240 executables: serializeClassText('class C { C(); }').executables);
3168 expect(executable.returnType, isNull); 3241 expect(executable.returnType, isNull);
3169 } 3242 }
3170 3243
3171 test_constructor_return_type_parameterized() { 3244 test_constructor_return_type_parameterized() {
3172 UnlinkedExecutable executable = findExecutable('', 3245 UnlinkedExecutable executable = findExecutable('',
3173 executables: serializeClassText('class C<T, U> { C(); }').executables); 3246 executables: serializeClassText('class C<T, U> { C(); }').executables);
3174 expect(executable.returnType, isNull); 3247 expect(executable.returnType, isNull);
(...skipping 2830 matching lines...) Expand 10 before | Expand all | Expand 10 after
6005 final String absoluteUri; 6078 final String absoluteUri;
6006 final String relativeUri; 6079 final String relativeUri;
6007 final int numTypeParameters; 6080 final int numTypeParameters;
6008 6081
6009 _PrefixExpectation(this.kind, this.name, 6082 _PrefixExpectation(this.kind, this.name,
6010 {this.inLibraryDefiningUnit: false, 6083 {this.inLibraryDefiningUnit: false,
6011 this.absoluteUri, 6084 this.absoluteUri,
6012 this.relativeUri, 6085 this.relativeUri,
6013 this.numTypeParameters: 0}); 6086 this.numTypeParameters: 0});
6014 } 6087 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/summary/resynthesize_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698