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

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: Rename ResultComputedEvent -> ComputedResult. 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
« no previous file with comments | « pkg/analyzer/test/generated/engine_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 ddca9826228a77aa4f37bb12656c610380fb872d..f6b759f13ac7af0c4879b054cd60088094d52e4d 100644
--- a/pkg/analyzer/test/src/context/context_test.dart
+++ b/pkg/analyzer/test/src/context/context_test.dart
@@ -783,6 +783,37 @@ 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>();
+ // 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());
+ });
+ // 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'));
+ // TODO(scheglov) uncomment after computing all RESOLVED_UNIT(s)
+// expect(resolvedUnitUris, contains('dart:core'));
+ expect(resolvedUnitUris, contains('file:///test.dart'));
+ }
+
void fail_performAnalysisTask_IOException() {
TestSource source = _addSourceWithException2("/test.dart", "library test;");
int oldTimestamp = context.getModificationStamp(source);
« no previous file with comments | « pkg/analyzer/test/generated/engine_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698