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

Side by Side Diff: pkg/analyzer/test/src/summary/summary_common.dart

Issue 1699243003: Serialize and resynthesize unresolved constant instance creations. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Add more tests. 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/dart/scanner/reader.dart'; 10 import 'package:analyzer/src/dart/scanner/reader.dart';
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 reference = checkReferenceIndex( 587 reference = checkReferenceIndex(
588 reference.prefixReference, 588 reference.prefixReference,
589 expectation.inLibraryDefiningUnit 589 expectation.inLibraryDefiningUnit
590 ? null 590 ? null
591 : expectation.absoluteUri ?? absoluteUri, 591 : expectation.absoluteUri ?? absoluteUri,
592 expectation.inLibraryDefiningUnit 592 expectation.inLibraryDefiningUnit
593 ? null 593 ? null
594 : expectation.relativeUri ?? relativeUri, 594 : expectation.relativeUri ?? relativeUri,
595 expectation.name, 595 expectation.name,
596 expectedKind: expectation.kind, 596 expectedKind: expectation.kind,
597 checkAstDerivedDataOverride: checkAstDerivedDataOverride,
597 expectedTargetUnit: expectedTargetUnit, 598 expectedTargetUnit: expectedTargetUnit,
598 linkedSourceUnit: linkedSourceUnit, 599 linkedSourceUnit: linkedSourceUnit,
599 unlinkedSourceUnit: unlinkedSourceUnit, 600 unlinkedSourceUnit: unlinkedSourceUnit,
600 numTypeParameters: expectation.numTypeParameters); 601 numTypeParameters: expectation.numTypeParameters);
601 } 602 }
602 expect(reference.prefixReference, 0); 603 expect(reference.prefixReference, 0);
603 } else { 604 } else {
604 expect(reference.prefixReference, 0); 605 expect(reference.prefixReference, 0);
605 } 606 }
606 } 607 }
(...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1962 ], referenceValidators: [ 1963 ], referenceValidators: [
1963 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C', 1964 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C',
1964 expectedKind: ReferenceKind.classOrEnum, 1965 expectedKind: ReferenceKind.classOrEnum,
1965 prefixExpectations: [ 1966 prefixExpectations: [
1966 new _PrefixExpectation(ReferenceKind.prefix, 'p', 1967 new _PrefixExpectation(ReferenceKind.prefix, 'p',
1967 inLibraryDefiningUnit: true) 1968 inLibraryDefiningUnit: true)
1968 ]) 1969 ])
1969 ]); 1970 ]);
1970 } 1971 }
1971 1972
1973 test_constExpr_invokeConstructor_unresolved_named() {
1974 UnlinkedVariable variable = serializeVariableText(
1975 '''
1976 class C {}
1977 const v = const C.foo();
1978 ''',
1979 allowErrors: true);
1980 _assertUnlinkedConst(variable.constExpr, operators: [
1981 UnlinkedConstOperation.invokeConstructor,
1982 ], ints: [
1983 0,
1984 0
1985 ], referenceValidators: [
1986 (EntityRef r) => checkTypeRef(r, null, null, 'foo',
1987 expectedKind: ReferenceKind.unresolved,
1988 checkAstDerivedDataOverride: true,
1989 prefixExpectations: [
1990 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C')
1991 ])
1992 ]);
1993 }
1994
1995 test_constExpr_invokeConstructor_unresolved_named2() {
1996 UnlinkedVariable variable = serializeVariableText(
1997 '''
1998 const v = const C.foo();
1999 ''',
2000 allowErrors: true);
2001 _assertUnlinkedConst(variable.constExpr, operators: [
2002 UnlinkedConstOperation.invokeConstructor,
2003 ], ints: [
2004 0,
2005 0
2006 ], referenceValidators: [
2007 (EntityRef r) => checkTypeRef(r, null, null, 'foo',
2008 expectedKind: ReferenceKind.unresolved,
2009 checkAstDerivedDataOverride: true,
2010 prefixExpectations: [
2011 new _PrefixExpectation(ReferenceKind.unresolved, 'C')
2012 ])
2013 ]);
2014 }
2015
2016 test_constExpr_invokeConstructor_unresolved_named_prefixed() {
2017 addNamedSource(
2018 '/a.dart',
2019 '''
2020 class C {
2021 }
2022 ''');
2023 UnlinkedVariable variable = serializeVariableText(
2024 '''
2025 import 'a.dart' as p;
2026 const v = const p.C.foo();
2027 ''',
2028 allowErrors: true);
2029 _assertUnlinkedConst(variable.constExpr, operators: [
2030 UnlinkedConstOperation.invokeConstructor,
2031 ], ints: [
2032 0,
2033 0
2034 ], referenceValidators: [
2035 (EntityRef r) => checkTypeRef(r, null, null, 'foo',
2036 expectedKind: ReferenceKind.unresolved,
2037 checkAstDerivedDataOverride: true,
2038 prefixExpectations: [
2039 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C',
2040 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'),
2041 new _PrefixExpectation(ReferenceKind.prefix, 'p',
2042 inLibraryDefiningUnit: true)
2043 ])
2044 ]);
2045 }
2046
2047 test_constExpr_invokeConstructor_unresolved_named_prefixed2() {
2048 addNamedSource('/a.dart', '');
2049 UnlinkedVariable variable = serializeVariableText(
2050 '''
2051 import 'a.dart' as p;
2052 const v = const p.C.foo();
2053 ''',
2054 allowErrors: true);
2055 _assertUnlinkedConst(variable.constExpr, operators: [
2056 UnlinkedConstOperation.invokeConstructor,
2057 ], ints: [
2058 0,
2059 0
2060 ], referenceValidators: [
2061 (EntityRef r) => checkTypeRef(r, null, null, 'foo',
2062 expectedKind: ReferenceKind.unresolved,
2063 checkAstDerivedDataOverride: true,
2064 prefixExpectations: [
2065 new _PrefixExpectation(ReferenceKind.unresolved, 'C'),
2066 new _PrefixExpectation(ReferenceKind.prefix, 'p',
2067 inLibraryDefiningUnit: true)
2068 ])
2069 ]);
2070 }
2071
2072 test_constExpr_invokeConstructor_unresolved_unnamed() {
2073 UnlinkedVariable variable = serializeVariableText(
2074 '''
2075 const v = const Foo();
2076 ''',
2077 allowErrors: true);
2078 _assertUnlinkedConst(variable.constExpr, operators: [
2079 UnlinkedConstOperation.invokeConstructor,
2080 ], ints: [
2081 0,
2082 0
2083 ], referenceValidators: [
2084 (EntityRef r) => checkTypeRef(r, null, null, 'Foo',
2085 expectedKind: ReferenceKind.unresolved,
2086 checkAstDerivedDataOverride: true)
2087 ]);
2088 }
2089
1972 test_constExpr_length_classConstField() { 2090 test_constExpr_length_classConstField() {
1973 UnlinkedVariable variable = serializeVariableText(''' 2091 UnlinkedVariable variable = serializeVariableText('''
1974 class C { 2092 class C {
1975 static const int length = 0; 2093 static const int length = 0;
1976 } 2094 }
1977 const int v = C.length; 2095 const int v = C.length;
1978 '''); 2096 ''');
1979 _assertUnlinkedConst(variable.constExpr, operators: [ 2097 _assertUnlinkedConst(variable.constExpr, operators: [
1980 UnlinkedConstOperation.pushReference 2098 UnlinkedConstOperation.pushReference
1981 ], referenceValidators: [ 2099 ], referenceValidators: [
(...skipping 4805 matching lines...) Expand 10 before | Expand all | Expand 10 after
6787 final String absoluteUri; 6905 final String absoluteUri;
6788 final String relativeUri; 6906 final String relativeUri;
6789 final int numTypeParameters; 6907 final int numTypeParameters;
6790 6908
6791 _PrefixExpectation(this.kind, this.name, 6909 _PrefixExpectation(this.kind, this.name,
6792 {this.inLibraryDefiningUnit: false, 6910 {this.inLibraryDefiningUnit: false,
6793 this.absoluteUri, 6911 this.absoluteUri,
6794 this.relativeUri, 6912 this.relativeUri,
6795 this.numTypeParameters: 0}); 6913 this.numTypeParameters: 0});
6796 } 6914 }
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