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

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

Issue 1839663003: More fixes to summary linking. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Test corner cases involving undefined names Created 4 years, 9 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 | « pkg/analyzer/test/src/summary/summarize_ast_test.dart ('k') | 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 69a1d295c424971e0a872a0f8b9155fe95318228..b0bc3f104de20dc83e642337c660f27035b2bacb 100644
--- a/pkg/analyzer/test/src/summary/summary_common.dart
+++ b/pkg/analyzer/test/src/summary/summary_common.dart
@@ -3945,6 +3945,27 @@ class D {
expect(findClass('D').executables[0].constCycleSlot, 0);
}
+ test_constructorCycle_referenceToClass() {
+ serializeLibraryText('''
+class C {
+ final x;
+ const C() : x = C;
+}
+''');
+ checkConstCycle('C', hasCycle: false);
+ }
+
+ test_constructorCycle_referenceToEnum() {
+ serializeLibraryText('''
+enum E { v }
+class C {
+ final x;
+ const C() : x = E;
+}
+''');
+ checkConstCycle('C', hasCycle: false);
+ }
+
test_constructorCycle_referenceToEnumValue() {
serializeLibraryText('''
enum E { v }
@@ -3967,6 +3988,110 @@ class C {
checkConstCycle('C', hasCycle: false);
}
+ test_constructorCycle_referenceToGenericParameter() {
+ // It's not valid Dart but we need to make sure it doesn't crash
+ // summary generation.
+ serializeLibraryText(
+ '''
+class C<T> {
+ final x;
+ const C() : x = T;
+}
+''',
+ allowErrors: true);
+ checkConstCycle('C', hasCycle: false);
+ }
+
+ test_constructorCycle_referenceToStaticMethod_inOtherClass() {
+ serializeLibraryText('''
+class C {
+ final x;
+ const C() : x = D.f;
+}
+class D {
+ static void f() {}
+}
+''');
+ checkConstCycle('C', hasCycle: false);
+ }
+
+ test_constructorCycle_referenceToStaticMethod_inSameClass() {
+ serializeLibraryText('''
+class C {
+ final x;
+ static void f() {}
+ const C() : x = f;
+}
+''');
+ checkConstCycle('C', hasCycle: false);
+ }
+
+ test_constructorCycle_referenceToTopLevelFunction() {
+ serializeLibraryText('''
+void f() {}
+class C {
+ final x;
+ const C() : x = f;
+}
+''');
+ checkConstCycle('C', hasCycle: false);
+ }
+
+ test_constructorCycle_referenceToTypedef() {
+ serializeLibraryText('''
+typedef F();
+class C {
+ final x;
+ const C() : x = F;
+}
+''');
+ checkConstCycle('C', hasCycle: false);
+ }
+
+ test_constructorCycle_referenceToUndefinedName() {
+ // It's not valid Dart but we need to make sure it doesn't crash
+ // summary generation.
+ serializeLibraryText(
+ '''
+class C {
+ final x;
+ const C() : x = foo;
+}
+''',
+ allowErrors: true);
+ checkConstCycle('C', hasCycle: false);
+ }
+
+ test_constructorCycle_referenceToUndefinedName_viaPrefix() {
+ // It's not valid Dart but we need to make sure it doesn't crash
+ // summary generation.
+ addNamedSource('/a.dart', '');
+ serializeLibraryText(
+ '''
+import 'a.dart' as a;
+class C {
+ final x;
+ const C() : x = a.foo;
+}
+''',
+ allowErrors: true);
+ }
+
+ test_constructorCycle_referenceToUndefinedName_viaPrefix_nonExistentFile() {
+ // It's not valid Dart but we need to make sure it doesn't crash
+ // summary generation.
+ allowMissingFiles = true;
+ serializeLibraryText(
+ '''
+import 'a.dart' as a;
+class C {
+ final x;
+ const C() : x = a.foo;
+}
+''',
+ allowErrors: true);
+ }
+
test_constructorCycle_viaFinalField() {
serializeLibraryText(
'''
@@ -4127,6 +4252,44 @@ const y = const C();
checkConstCycle('C');
}
+ test_constructorCycle_viaTopLevelVariable_imported() {
+ addNamedSource(
+ '/a.dart',
+ '''
+import 'test.dart';
+const y = const C();
+ ''');
+ serializeLibraryText(
+ '''
+import 'a.dart';
+class C {
+ final x;
+ const C() : x = y;
+}
+''',
+ allowErrors: true);
+ checkConstCycle('C');
+ }
+
+ test_constructorCycle_viaTopLevelVariable_importedViaPrefix() {
+ addNamedSource(
+ '/a.dart',
+ '''
+import 'test.dart';
+const y = const C();
+ ''');
+ serializeLibraryText(
+ '''
+import 'a.dart' as a;
+class C {
+ final x;
+ const C() : x = a.y;
+}
+''',
+ allowErrors: true);
+ checkConstCycle('C');
+ }
+
test_dependencies_export_to_export_unused() {
addNamedSource('/a.dart', 'export "b.dart";');
addNamedSource('/b.dart', '');
« no previous file with comments | « pkg/analyzer/test/src/summary/summarize_ast_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698