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 57ff94ea5d9e50cb02029007d88d964ba922c024..2726eefaf23296e50f19d736707f20220352eb42 100644 |
--- a/pkg/analyzer/test/src/context/cache_test.dart |
+++ b/pkg/analyzer/test/src/context/cache_test.dart |
@@ -52,6 +52,27 @@ class AnalysisCacheTest extends AbstractCacheTest { |
expect(cache, isNotNull); |
} |
+ test_flush() { |
+ AnalysisTarget target = new TestSource(); |
+ ResultDescriptor resultA = new ResultDescriptor('A', null); |
+ ResultDescriptor resultB = new ResultDescriptor('B', null); |
+ CacheEntry entry = new CacheEntry(target); |
+ cache.put(entry); |
+ // put values |
+ entry.setValue(resultA, 'a', TargetedResult.EMPTY_LIST); |
+ entry.setValue(resultB, 'b', TargetedResult.EMPTY_LIST); |
+ expect(cache.getState(target, resultA), CacheState.VALID); |
+ expect(cache.getState(target, resultB), CacheState.VALID); |
+ expect(cache.getValue(target, resultA), 'a'); |
+ expect(cache.getValue(target, resultB), 'b'); |
+ // flush A |
+ cache.flush((target, result) => result == resultA); |
+ expect(cache.getState(target, resultA), CacheState.FLUSHED); |
+ expect(cache.getState(target, resultB), CacheState.VALID); |
+ expect(cache.getValue(target, resultA), isNull); |
+ expect(cache.getValue(target, resultB), 'b'); |
+ } |
+ |
void test_get() { |
AnalysisTarget target = new TestSource(); |
expect(cache.get(target), isNull); |
@@ -297,6 +318,27 @@ class CacheEntryTest extends AbstractCacheTest { |
expect(entry.exception, isNull); |
} |
+ test_flush() { |
+ AnalysisTarget target = new TestSource(); |
+ ResultDescriptor resultA = new ResultDescriptor('A', null); |
+ ResultDescriptor resultB = new ResultDescriptor('B', null); |
+ CacheEntry entry = new CacheEntry(target); |
+ cache.put(entry); |
+ // put values |
+ entry.setValue(resultA, 'a', TargetedResult.EMPTY_LIST); |
+ entry.setValue(resultB, 'b', TargetedResult.EMPTY_LIST); |
+ expect(entry.getState(resultA), CacheState.VALID); |
+ expect(entry.getState(resultB), CacheState.VALID); |
+ expect(entry.getValue(resultA), 'a'); |
+ expect(entry.getValue(resultB), 'b'); |
+ // flush A |
+ entry.flush((target, result) => result == resultA); |
+ expect(entry.getState(resultA), CacheState.FLUSHED); |
+ expect(entry.getState(resultB), CacheState.VALID); |
+ expect(entry.getValue(resultA), isNull); |
+ expect(entry.getValue(resultB), 'b'); |
+ } |
+ |
test_getState() { |
AnalysisTarget target = new TestSource(); |
ResultDescriptor result = new ResultDescriptor('test', null); |