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

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

Issue 1674793002: Test summarizing of constants that refer to top level functions. (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 cf12003c4e2b38d502ddbab0a31be4f228e4b15f..4d04fe21ffa9f00d2bea12d0fc3c34aefa420a43 100644
--- a/pkg/analyzer/test/src/summary/summary_common.dart
+++ b/pkg/analyzer/test/src/summary/summary_common.dart
@@ -2459,6 +2459,59 @@ const v = p.C.m;
]);
}
+ test_constExpr_pushReference_topLevelFunction() {
+ UnlinkedVariable variable = serializeVariableText('''
+f() {}
+const v = f;
+''');
+ _assertUnlinkedConst(variable.constExpr, operators: [
+ UnlinkedConstOperation.pushReference
+ ], referenceValidators: [
+ (EntityRef r) => checkTypeRef(r, null, null, 'f',
+ expectedKind: ReferenceKind.topLevelFunction)
+ ]);
+ }
+
+ test_constExpr_pushReference_topLevelFunction_imported() {
+ addNamedSource(
+ '/a.dart',
+ '''
+f() {}
+''');
+ UnlinkedVariable variable = serializeVariableText('''
+import 'a.dart';
+const v = f;
+''');
+ _assertUnlinkedConst(variable.constExpr, operators: [
+ UnlinkedConstOperation.pushReference
+ ], referenceValidators: [
+ (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'f',
+ expectedKind: ReferenceKind.topLevelFunction)
+ ]);
+ }
+
+ test_constExpr_pushReference_topLevelFunction_imported_withPrefix() {
+ addNamedSource(
+ '/a.dart',
+ '''
+f() {}
+''');
+ UnlinkedVariable variable = serializeVariableText('''
+import 'a.dart' as p;
+const v = p.f;
+''');
+ _assertUnlinkedConst(variable.constExpr, operators: [
+ UnlinkedConstOperation.pushReference
+ ], referenceValidators: [
+ (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'f',
+ expectedKind: ReferenceKind.topLevelFunction,
+ prefixExpectations: [
+ new _PrefixExpectation(ReferenceKind.prefix, 'p',
+ inLibraryDefiningUnit: true)
+ ])
+ ]);
+ }
+
test_constExpr_pushReference_topLevelVariable() {
UnlinkedVariable variable = serializeVariableText('''
const int a = 1;
« 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