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 d7e0a589a8332abb27ec4495d480e703e2f97f9f..c45b6a9c2ef97afbfebfd981ebaa22e95a7a9047 100644 |
--- a/pkg/analyzer/test/src/context/context_test.dart |
+++ b/pkg/analyzer/test/src/context/context_test.dart |
@@ -1463,6 +1463,44 @@ main() {}'''); |
expect(context.isServerLibrary(source), isFalse); |
} |
+ void test_onResultInvalidated_removeSource() { |
+ Source source = addSource('/test.dart', 'main() {}'); |
+ bool listenerInvoked = false; |
+ context |
+ .onResultInvalidated(RESOLVED_UNIT) |
+ .listen((InvalidatedResultEvent event) { |
+ Source eventSource = event.target.source; |
+ expect(event.descriptor, RESOLVED_UNIT); |
+ expect(eventSource, source); |
+ listenerInvoked = true; |
+ }); |
+ _analyzeAll_assertFinished(); |
+ // apply changes |
+ expect(listenerInvoked, false); |
+ context.applyChanges(new ChangeSet()..removedSource(source)); |
+ // verify |
+ expect(listenerInvoked, isTrue); |
+ } |
+ |
+ void test_onResultInvalidated_setContents() { |
+ Source source = addSource('/test.dart', 'main() {}'); |
+ bool listenerInvoked = false; |
+ context |
+ .onResultInvalidated(RESOLVED_UNIT) |
+ .listen((InvalidatedResultEvent event) { |
+ Source eventSource = event.target.source; |
+ expect(event.descriptor, RESOLVED_UNIT); |
+ expect(eventSource, source); |
+ listenerInvoked = true; |
+ }); |
+ _analyzeAll_assertFinished(); |
+ // apply changes |
+ expect(listenerInvoked, false); |
+ context.setContents(source, 'class B {}'); |
+ // verify |
+ expect(listenerInvoked, isTrue); |
+ } |
+ |
void test_parseCompilationUnit_errors() { |
Source source = addSource("/lib.dart", "library {"); |
CompilationUnit compilationUnit = context.parseCompilationUnit(source); |