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

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

Issue 1181603004: Add AnalysisContext.onResultComputed(). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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/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 ddca9826228a77aa4f37bb12656c610380fb872d..3fc43dc83677111b48bfe2fe9a7f3b7d1eda58f3 100644
--- a/pkg/analyzer/test/src/context/context_test.dart
+++ b/pkg/analyzer/test/src/context/context_test.dart
@@ -783,6 +783,43 @@ void g() { f(null); }''');
reason: "htmlSource has an error");
}
+ void test_performAnalysisTask_onResultComputed() {
+ Set<String> libraryElementUris = new Set<String>();
+ Set<String> parsedUnitUris = new Set<String>();
+ Set<String> resolvedUnitUris = new Set<String>();
+ Set<String> resolvedUnitNoConstUris = new Set<String>();
+ // listen
+ context.onResultComputed(LIBRARY_ELEMENT).listen((event) {
+ Source librarySource = event.target;
+ libraryElementUris.add(librarySource.uri.toString());
+ });
+ context.onResultComputed(PARSED_UNIT).listen((event) {
+ Source source = event.target;
+ parsedUnitUris.add(source.uri.toString());
+ });
+ context.onResultComputed(RESOLVED_UNIT).listen((event) {
+ LibrarySpecificUnit target = event.target;
+ Source librarySource = target.library;
+ resolvedUnitUris.add(librarySource.uri.toString());
+ });
+ context.onResultComputed(RESOLVED_UNIT_NO_CONSTANTS).listen((event) {
+ LibrarySpecificUnit target = event.target;
+ Source librarySource = target.library;
+ resolvedUnitNoConstUris.add(librarySource.uri.toString());
+ });
+ // analyze
+ addSource('/test.dart', 'main() {}');
+ _analyzeAll_assertFinished();
+ // verify
+ expect(libraryElementUris, contains('dart:core'));
+ expect(libraryElementUris, contains('file:///test.dart'));
+ expect(parsedUnitUris, contains('dart:core'));
+ expect(parsedUnitUris, contains('file:///test.dart'));
+ expect(resolvedUnitUris, contains('file:///test.dart'));
+ expect(resolvedUnitNoConstUris, contains('dart:core'));
+ expect(resolvedUnitNoConstUris, contains('file:///test.dart'));
+ }
+
void fail_performAnalysisTask_IOException() {
TestSource source = _addSourceWithException2("/test.dart", "library test;");
int oldTimestamp = context.getModificationStamp(source);

Powered by Google App Engine
This is Rietveld 408576698