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

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

Issue 2289283003: An AnalysisTarget is a priority one if its Source is in prioritySources. (Closed)
Patch Set: Created 4 years, 4 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/lib/src/context/cache.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/cache_test.dart
diff --git a/pkg/analyzer/test/src/context/cache_test.dart b/pkg/analyzer/test/src/context/cache_test.dart
index 387eae9d5e35a815c677ee9fb2a0fd786ce147e9..fca2cbdc2aabaedb8ec3dbb40b9792cf3961e373 100644
--- a/pkg/analyzer/test/src/context/cache_test.dart
+++ b/pkg/analyzer/test/src/context/cache_test.dart
@@ -44,7 +44,7 @@ class AbstractCacheTest {
void setUp() {
context = new _InternalAnalysisContextMock();
- when(context.priorityTargets).thenReturn([]);
+ when(context.prioritySources).thenReturn([]);
cache = createCache(context: context);
when(context.analysisCache).thenReturn(cache);
}
@@ -771,6 +771,43 @@ class CacheEntryTest extends AbstractCacheTest {
}
}
+ test_setValue_flushResults_keepForPrioritySources() {
+ ResultCachingPolicy cachingPolicy = new SimpleResultCachingPolicy(2, 2);
+ ResultDescriptor newResult(String name) =>
+ new ResultDescriptor(name, null, cachingPolicy: cachingPolicy);
+ ResultDescriptor descriptor1 = newResult('result1');
+ ResultDescriptor descriptor2 = newResult('result2');
+ ResultDescriptor descriptor3 = newResult('result3');
+ TestSource source1 = new TestSource('/a.dart');
+ TestSource source2 = new TestSource('/b.dart');
+ TestSource source3 = new TestSource('/c.dart');
+ AnalysisTarget target1 =
+ new _TestAnalysisTarget(librarySource: source1, source: source1);
+ AnalysisTarget target2 =
+ new _TestAnalysisTarget(librarySource: source2, source: source2);
+ AnalysisTarget target3 =
+ new _TestAnalysisTarget(librarySource: source3, source: source3);
+ CacheEntry entry1 = new CacheEntry(target1);
+ CacheEntry entry2 = new CacheEntry(target2);
+ CacheEntry entry3 = new CacheEntry(target3);
+ cache.put(entry1);
+ cache.put(entry2);
+ cache.put(entry3);
+
+ // Set two results.
+ entry1.setValue(descriptor1, 1, TargetedResult.EMPTY_LIST);
+ entry2.setValue(descriptor2, 2, TargetedResult.EMPTY_LIST);
+ expect(entry1.getState(descriptor1), CacheState.VALID);
+ expect(entry2.getState(descriptor2), CacheState.VALID);
+
+ // Make source1 priority, so result2 is flushed instead.
+ when(context.prioritySources).thenReturn([source1]);
+ entry3.setValue(descriptor3, 3, TargetedResult.EMPTY_LIST);
+ expect(entry1.getState(descriptor1), CacheState.VALID);
+ expect(entry2.getState(descriptor2), CacheState.FLUSHED);
+ expect(entry3.getState(descriptor3), CacheState.VALID);
+ }
+
test_setValue_keepDependent() {
AnalysisTarget target = new TestSource();
CacheEntry entry = new CacheEntry(target);
@@ -1266,9 +1303,7 @@ class _KeepContinueDelta implements Delta {
}
class _TestAnalysisTarget implements AnalysisTarget {
- @override
- Source get librarySource => null;
-
- @override
- Source get source => null;
+ final Source librarySource;
+ final Source source;
+ _TestAnalysisTarget({this.librarySource, this.source});
}
« no previous file with comments | « pkg/analyzer/lib/src/context/cache.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698