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

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

Issue 1650833002: Resynthesize type references. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: emove SimpleIdentifier.staticType check. 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 7ff458dc35c45e156fc6349b61c2dc28f5af1a21..b079d8234cac9bc2b32e7266c73eb09b5f3888fa 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_test.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_test.dart
@@ -242,7 +242,6 @@ class ResynthTest extends ResolverTestCase {
compareConstantExpressions(r, o.expression, desc);
} else if (o is SimpleIdentifier && r is SimpleIdentifier) {
expect(r.name, o.name);
Paul Berry 2016/02/01 16:11:40 Leave a comment here explaining why we shouldn't c
- compareTypes(r.staticType, o.staticType, desc);
compareElements(r.staticElement, o.staticElement, desc);
} else if (o is PrefixedIdentifier) {
// We don't resynthesize prefixed identifiers.
@@ -599,7 +598,9 @@ class ResynthTest extends ResolverTestCase {
VariableElementImpl original, String desc) {
compareElements(resynthesized, original, desc);
compareTypes(resynthesized.type, original.type, desc);
- if (shouldCompareConstValues) {
+ // TODO(scheglov) implement and validate other constant variable types
+ if (shouldCompareConstValues &&
+ original is ConstTopLevelVariableElementImpl) {
compareConstantExpressions(resynthesized.constantInitializer,
original.constantInitializer, desc);
}
@@ -1006,6 +1007,57 @@ class E {}''');
checkLibrary('class C {} class D {}');
}
+ test_const_reference_type() {
+ shouldCompareConstValues = true;
+ checkLibrary(r'''
+class C {}
+class D<T> {}
+enum E {a, b, c}
+typedef F(int a, String b);
+const vDynamic = dynamic;
+const vNull = Null;
+const vObject = Object;
+const vClass = C;
+const vGenericClass = D;
+const vEnum = E;
+const vFunctionTypeAlias = F;
+''');
+ }
+
+ test_const_reference_type_imported() {
+ shouldCompareConstValues = true;
+ addLibrarySource(
+ '/a.dart',
+ r'''
+class C {}
+enum E {a, b, c}
+typedef F(int a, String b);
+''');
+ checkLibrary(r'''
+import 'a.dart';
+const vClass = C;
+const vEnum = E;
+const vFunctionTypeAlias = F;
+''');
+ }
+
+ test_const_reference_type_imported_withPrefix() {
+ shouldCompareConstValues = true;
+ addLibrarySource(
+ '/a.dart',
+ r'''
+class C {}
+enum E {a, b, c}
+typedef F(int a, String b);
+''');
+ checkLibrary(r'''
+import 'a.dart' as p;
+const vClass = p.C;
+const vEnum = p.E;
+const vFunctionTypeAlias = p.F;
+''');
+ }
+
test_const_topLevel_binary() {
shouldCompareConstValues = true;
checkLibrary(r'''

Powered by Google App Engine
This is Rietveld 408576698