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

Unified Diff: pkg/analyzer/test/src/context/context_test.dart

Issue 2124413002: When in-body incremantal resolution is performed, it should update REFERENCED_NAMES. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Add test for removing a reference. Created 4 years, 5 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/generated/incremental_resolver_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/context/context_test.dart
diff --git a/pkg/analyzer/test/src/context/context_test.dart b/pkg/analyzer/test/src/context/context_test.dart
index 583bc1f10ff3e41ea550677432451d9a86994228..83a9a3d6e5efc1f310646b7d4593b5788f7bdb83 100644
--- a/pkg/analyzer/test/src/context/context_test.dart
+++ b/pkg/analyzer/test/src/context/context_test.dart
@@ -3103,6 +3103,97 @@ class C {}
expect(context.getErrors(b).errors, hasLength(1));
}
+ void test_sequence_inBodyChange_addRef_deltaChange() {
+ Source a = addSource(
+ '/a.dart',
+ r'''
+class A {
+}
+''');
+ Source b = addSource(
+ '/b.dart',
+ r'''
+import 'a.dart';
+main(A a) {
+}
+''');
+ _performPendingAnalysisTasks();
+ expect(context.getErrors(b).errors, hasLength(0));
+ // Update b.dart: in-body incremental change - start referencing 'foo'.
+ // Should update referenced names.
+ context.setContents(
+ b,
+ r'''
+import 'a.dart';
+main(A a) {
+ a.foo;
+}
+''');
+ _performPendingAnalysisTasks();
+ expect(context.getErrors(b).errors, hasLength(1));
+ // Update a.dart: add A.foo
+ // b.dart is invalid, because it references 'foo'.
+ context.setContents(
+ a,
+ r'''
+class A {
+ int foo;
+}
+''');
+ _assertValidForChangedLibrary(a);
+ _assertInvalid(a, LIBRARY_ERRORS_READY);
+ _assertValidForDependentLibrary(b);
+ _assertInvalid(b, LIBRARY_ERRORS_READY);
+ _assertInvalidUnits(b, RESOLVED_UNIT4);
+ // No errors after analysis.
+ _performPendingAnalysisTasks();
+ expect(context.getErrors(b).errors, hasLength(0));
+ }
+
+ void test_sequence_inBodyChange_removeRef_deltaChange() {
+ Source a = addSource(
+ '/a.dart',
+ r'''
+class A {
+}
+''');
+ Source b = addSource(
+ '/b.dart',
+ r'''
+import 'a.dart';
+main(A a) {
+ a.foo;
+}
+''');
+ _performPendingAnalysisTasks();
+ expect(context.getErrors(b).errors, hasLength(1));
+ // Update b.dart: in-body incremental change - stop referencing 'foo'.
+ // Should update referenced names.
+ context.setContents(
+ b,
+ r'''
+import 'a.dart';
+main(A a) {
+}
+''');
+ _performPendingAnalysisTasks();
+ expect(context.getErrors(b).errors, hasLength(0));
+ // Update a.dart: add A.foo
+ // b.dart is still valid, because it does references 'foo' anymore.
+ context.setContents(
+ a,
+ r'''
+class A {
+ int foo;
+}
+''');
+ _assertValidForChangedLibrary(a);
+ _assertInvalid(a, LIBRARY_ERRORS_READY);
+ _assertValidForDependentLibrary(b);
+ _assertValidAllLibraryUnitResults(b);
+ _assertValid(b, LIBRARY_ERRORS_READY);
+ }
+
void test_sequence_noChange_thenChange() {
Source a = addSource(
'/a.dart',
« no previous file with comments | « pkg/analyzer/test/generated/incremental_resolver_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698