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

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

Issue 1636113002: Serialize static constant field references. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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/summary_common.dart
diff --git a/pkg/analyzer/test/src/summary/summary_common.dart b/pkg/analyzer/test/src/summary/summary_common.dart
index ccbeac3c0c69a7ab04941e1491625761cd022aa1..22538d4753ed4ace6bbc215563645ad568d89ec9 100644
--- a/pkg/analyzer/test/src/summary/summary_common.dart
+++ b/pkg/analyzer/test/src/summary/summary_common.dart
@@ -2012,23 +2012,6 @@ const v = C;
]);
}
- test_constExpr_pushReference_class_field() {
- // TODO(scheglov) Not sure for to represent a field reference
- // using TypeRef.
-// UnlinkedVariable variable = serializeVariableText('''
-//class C {
-// static const int F = 1;
-//}
-//const v = C.F;
-//''');
-// _assertUnlinkedConst(variable.constExpr, operators: [
-// UnlinkedConstOperation.pushReference
-// ], references: [
-// (TypeRef r) => checkTypeRef(r, null, null, 'F',
-// expectedKind: ReferenceKind.classOrEnum, expectedPrefix: 'C')
-// ]);
- }
-
test_constExpr_pushReference_enum() {
UnlinkedVariable variable = serializeVariableText('''
enum C {V1, V2, V3}
@@ -2042,6 +2025,85 @@ const v = C;
]);
}
+ test_constExpr_pushReference_field() {
+ UnlinkedVariable variable = serializeVariableText('''
+class C {
+ static const int F = 1;
+}
+const v = C.F;
+''');
+ _assertUnlinkedConst(variable.constExpr, operators: [
+ UnlinkedConstOperation.pushReference
+ ], referenceValidators: [
+ (EntityRef r) => checkTypeRef(r, null, null, 'F',
+ expectedKind: ReferenceKind.constField,
+ prefixExpectations: [
+ new _PrefixExpectation(ReferenceKind.classOrEnum, 'C')
+ ])
+ ]);
+ }
+
+ test_constExpr_pushReference_field_imported() {
+ addNamedSource(
+ '/a.dart',
+ '''
+class C {
+ static const int F = 1;
+}
+''');
+ UnlinkedVariable variable = serializeVariableText('''
+import 'a.dart';
+const v = C.F;
+''');
+ _assertUnlinkedConst(variable.constExpr, operators: [
+ UnlinkedConstOperation.pushReference
+ ], referenceValidators: [
+ (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'F',
+ expectedKind: ReferenceKind.constField,
+ prefixExpectations: [
+ new _PrefixExpectation(ReferenceKind.classOrEnum, 'C')
+ ])
+ ]);
+ }
+
+ test_constExpr_pushReference_field_imported_withPrefix() {
+ addNamedSource(
+ '/a.dart',
+ '''
+class C {
+ static const int F = 1;
+}
+''');
+ UnlinkedVariable variable = serializeVariableText('''
+import 'a.dart' as p;
+const v = p.C.F;
+''');
+ _assertUnlinkedConst(variable.constExpr, operators: [
+ UnlinkedConstOperation.pushReference
+ ], referenceValidators: [
+ (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'F',
+ expectedKind: ReferenceKind.constField,
+ prefixExpectations: [
+ new _PrefixExpectation(ReferenceKind.classOrEnum, 'C'),
+ new _PrefixExpectation(ReferenceKind.prefix, 'p',
+ inLibraryDefiningUnit: true),
+ ])
+ ]);
+ }
+
+ test_constExpr_pushReference_topLevelVariable() {
+ UnlinkedVariable variable = serializeVariableText('''
+const int a = 1;
+const v = a;
+''');
+ _assertUnlinkedConst(variable.constExpr, operators: [
+ UnlinkedConstOperation.pushReference
+ ], referenceValidators: [
+ (EntityRef r) => checkTypeRef(r, null, null, 'a',
+ expectedKind: ReferenceKind.topLevelPropertyAccessor)
+ ]);
+ }
+
test_constExpr_pushReference_topLevelVariable_imported() {
addNamedSource('/a.dart', 'const int a = 1;');
UnlinkedVariable variable = serializeVariableText('''
@@ -2073,20 +2135,6 @@ const v = p.a;
]);
}
- test_constExpr_pushReference_topLevelVariable_local() {
- // TODO(scheglov) use `a + b`
- UnlinkedVariable variable = serializeVariableText('''
-const int a = 1;
-const v = a;
-''');
- _assertUnlinkedConst(variable.constExpr, operators: [
- UnlinkedConstOperation.pushReference
- ], referenceValidators: [
- (EntityRef r) => checkTypeRef(r, null, null, 'a',
- expectedKind: ReferenceKind.topLevelPropertyAccessor)
- ]);
- }
-
test_constExpr_pushString_adjacent() {
UnlinkedVariable variable =
serializeVariableText('const v = "aaa" "b" "ccc";');

Powered by Google App Engine
This is Rietveld 408576698