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

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

Issue 2052553003: Add AnalysisCache.flush() utility method. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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/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 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);
« 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