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

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

Issue 1652183002: Resynthesize top-level and class static property access 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/resynthesize_test.dart
diff --git a/pkg/analyzer/test/src/summary/resynthesize_test.dart b/pkg/analyzer/test/src/summary/resynthesize_test.dart
index 05c5fb087c0ef6e118755079dbe2b616fdb9af2d..9d90ee7061e184e12ab6e6957a9037ff74935ba6 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_test.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_test.dart
@@ -246,10 +246,14 @@ class ResynthTest extends ResolverTestCase {
// ConstantAstCloner does not copy static types, and constant values
// computer does not use static types. So, we don't set them during
// resynthesis and should not check them.
- } else if (o is PrefixedIdentifier) {
+ } else if (o is PrefixedIdentifier && r is SimpleIdentifier) {
// We don't resynthesize prefixed identifiers.
- // We use simple identifiers with correct elements and types.
- compareConstantExpressions(r as SimpleIdentifier, o.identifier, desc);
+ // We use simple identifiers with correct elements.
+ compareConstantExpressions(r, o.identifier, desc);
+ } else if (o is PropertyAccess && r is SimpleIdentifier) {
+ // We don't resynthesize property access.
+ // We use simple identifiers with correct elements.
+ compareConstantExpressions(r, o.propertyName, desc);
Paul Berry 2016/02/01 19:27:17 What about the case of: const x = 'foo';
scheglov 2016/02/01 19:42:18 We don't support 'length' resynthesizing yet.
} else if (o is NullLiteral) {
expect(r, new isInstanceOf<NullLiteral>(), reason: desc);
} else if (o is BooleanLiteral && r is BooleanLiteral) {
@@ -1010,6 +1014,80 @@ class E {}''');
checkLibrary('class C {} class D {}');
}
+ test_const_reference_staticField() {
+ shouldCompareConstValues = true;
+ checkLibrary(r'''
+class C {
+ static const int F = 42;
+}
+const V = C.F;
+''');
+ }
+
+ test_const_reference_staticField_imported() {
+ shouldCompareConstValues = true;
+ addLibrarySource(
+ '/a.dart',
+ r'''
+class C {
+ static const int F = 42;
+}
+''');
+ checkLibrary(r'''
+import 'a.dart';
+const V = C.F;
+''');
+ }
+
+ test_const_reference_staticField_imported_withPrefix() {
+ shouldCompareConstValues = true;
+ addLibrarySource(
+ '/a.dart',
+ r'''
+class C {
+ static const int F = 42;
+}
+''');
+ checkLibrary(r'''
+import 'a.dart' as p;
+const V = p.C.F;
+''');
+ }
+
+ test_const_reference_topLevelVariable() {
+ shouldCompareConstValues = true;
+ checkLibrary(r'''
+const A = 1;
+const B = A + 2;
+''');
+ }
+
+ test_const_reference_topLevelVariable_imported() {
+ shouldCompareConstValues = true;
+ addLibrarySource(
+ '/a.dart',
+ r'''
+const A = 1;
+''');
+ checkLibrary(r'''
+import 'a.dart';
+const B = A + 2;
+''');
+ }
+
+ test_const_reference_topLevelVariable_imported_withPrefix() {
+ shouldCompareConstValues = true;
+ addLibrarySource(
+ '/a.dart',
+ r'''
+const A = 1;
+''');
+ checkLibrary(r'''
+import 'a.dart' as p;
+const B = p.A + 2;
+''');
+ }
+
test_const_reference_type() {
shouldCompareConstValues = true;
checkLibrary(r'''

Powered by Google App Engine
This is Rietveld 408576698