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

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

Issue 1149893004: Add and use AnalysisCache.sources getter. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 7 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/cache_test.dart
diff --git a/pkg/analyzer/test/src/context/cache_test.dart b/pkg/analyzer/test/src/context/cache_test.dart
index f093931059f89867317e21c65fa702964fde4f8b..94ae434c211328a01ce3da9489f6ca994692cbba 100644
--- a/pkg/analyzer/test/src/context/cache_test.dart
+++ b/pkg/analyzer/test/src/context/cache_test.dart
@@ -183,6 +183,29 @@ class AnalysisCacheTest extends AbstractCacheTest {
}
expect(cache.size(), size);
}
+
+ void test_sources() {
+ AnalysisTarget source1 = new TestSource('1.dart');
+ AnalysisTarget source2 = new TestSource('2.dart');
+ AnalysisTarget target1 = new _TestAnalysisTarget();
+ // no entries
+ expect(cache.sources, isEmpty);
+ // add source1
+ cache.put(new CacheEntry(source1));
+ expect(cache.sources, unorderedEquals([source1]));
+ // add target1
+ cache.put(new CacheEntry(target1));
+ expect(cache.sources, unorderedEquals([source1]));
+ // add source2
+ cache.put(new CacheEntry(source2));
+ expect(cache.sources, unorderedEquals([source1, source2]));
+ // remove source1
+ cache.remove(source1);
+ expect(cache.sources, unorderedEquals([source2]));
+ // remove source2
+ cache.remove(source2);
+ expect(cache.sources, isEmpty);
+ }
}
@reflectiveTest
@@ -842,3 +865,8 @@ class _InternalAnalysisContextMock extends TypedMock
implements InternalAnalysisContext {
noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
}
+
+class _TestAnalysisTarget implements AnalysisTarget {
Brian Wilkerson 2015/05/21 13:52:31 Don't we already have this class somewhere?
+ @override
+ Source get source => null;
+}
« pkg/analyzer/lib/src/context/cache.dart ('K') | « pkg/analyzer/lib/src/context/context.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698