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

Unified Diff: pkg/analyzer/test/src/summary/resynthesize_test.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 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 d6c1b518076f3521f7bf60f3f1745df58dfbfbd6..cc93d8e1fc2302f69d6f389d8075c6fbc0ed0e9a 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_test.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_test.dart
@@ -477,6 +477,9 @@ class ResynthTest extends ResolverTestCase {
void compareConstructorElements(ConstructorElement resynthesized,
ConstructorElement original, String desc) {
+ if (original == null && resynthesized == null) {
+ return;
+ }
compareExecutableElements(resynthesized, original, desc);
if (original.isConst) {
ConstructorElementImpl resynthesizedImpl =
@@ -514,6 +517,10 @@ class ResynthTest extends ResolverTestCase {
if (oImpl == null && rImpl == null) {
return;
}
+ if (oImpl is PrefixElement) {
+ // TODO(scheglov) prefixes cannot be resynthesized
+ return;
+ }
expect(original, isNotNull);
expect(resynthesized, isNotNull);
expect(rImpl.runtimeType, oImpl.runtimeType);
@@ -833,6 +840,11 @@ class ResynthTest extends ResolverTestCase {
}
} else if (resynthesized is VoidTypeImpl && original is VoidTypeImpl) {
expect(resynthesized, same(original));
+ } else if (resynthesized is DynamicTypeImpl &&
+ original is UndefinedTypeImpl) {
+ // TODO(scheglov) In the strong mode constant variable like
+ // `var V = new Unresolved()` gets `UndefinedTypeImpl`, and it gets
+ // `DynamicTypeImpl` in the spec mode.
} else if (resynthesized.runtimeType != original.runtimeType) {
fail('Type mismatch: expected ${original.runtimeType},'
' got ${resynthesized.runtimeType} ($desc)');
@@ -1457,6 +1469,56 @@ const V = const p.C.named();
''');
}
+ test_const_invokeConstructor_named_unresolved() {
+ checkLibrary(
+ r'''
+class C {}
+const V = const C.named();
+''',
+ allowErrors: true);
+ }
+
+ test_const_invokeConstructor_named_unresolved2() {
+ checkLibrary(
+ r'''
+const V = const C.named();
+''',
+ allowErrors: true);
+ }
+
+ test_const_invokeConstructor_named_unresolved3() {
+ addLibrarySource(
+ '/a.dart',
+ r'''
+class C {
+}
+''');
+ checkLibrary(
+ r'''
+import 'a.dart' as p;
+const V = const p.C.named();
+''',
+ allowErrors: true);
+ }
+
+ test_const_invokeConstructor_named_unresolved4() {
+ addLibrarySource('/a.dart', '');
+ checkLibrary(
+ r'''
+import 'a.dart' as p;
+const V = const p.C.named();
+''',
+ allowErrors: true);
+ }
+
+ test_const_invokeConstructor_named_unresolved5() {
+ checkLibrary(
+ r'''
+const V = const p.C.named();
+''',
+ allowErrors: true);
+ }
+
test_const_invokeConstructor_unnamed() {
checkLibrary(r'''
class C {
@@ -1494,6 +1556,32 @@ const V = const p.C();
''');
}
+ test_const_invokeConstructor_unnamed_unresolved() {
+ checkLibrary(
+ r'''
+const V = const C();
+''',
+ allowErrors: true);
+ }
+
+ test_const_invokeConstructor_unnamed_unresolved2() {
+ addLibrarySource('/a.dart', '');
+ checkLibrary(
+ r'''
+import 'a.dart' as p;
+const V = const p.C();
+''',
+ allowErrors: true);
+ }
+
+ test_const_invokeConstructor_unnamed_unresolved3() {
+ checkLibrary(
+ r'''
+const V = const p.C();
+''',
+ allowErrors: true);
+ }
+
test_const_length_ofClassConstField() {
checkLibrary(r'''
class C {
« no previous file with comments | « pkg/analyzer/lib/src/summary/summarize_elements.dart ('k') | pkg/analyzer/test/src/summary/summary_common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698