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

Unified Diff: pkg/analyzer/test/src/dart/analysis/byte_store_test.dart

Issue 2524693003: Fix MemoryCachingByteStore._evict after an unsuccessful get. (Closed)
Patch Set: Stop storing null Created 4 years, 1 month 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/dart/analysis/byte_store.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/dart/analysis/byte_store_test.dart
diff --git a/pkg/analyzer/test/src/dart/analysis/byte_store_test.dart b/pkg/analyzer/test/src/dart/analysis/byte_store_test.dart
index 20998631f997759ece7f3978d0f4f095852632d4..9da3f0b6a9ebba19c30f059bd1b0e5b36cf29115 100644
--- a/pkg/analyzer/test/src/dart/analysis/byte_store_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/byte_store_test.dart
@@ -15,6 +15,35 @@ main() {
@reflectiveTest
class MemoryCachingByteStoreTest {
+ test_get_notFound_evict() {
+ var store = new _TestByteStore();
+ var cachingStore = new MemoryCachingByteStore(store, 100);
+
+ // Request '1'. Nothing found.
+ cachingStore.get('1');
+
+ // Add enough data to the store to force an eviction.
+ cachingStore.put('2', _b(40));
+ cachingStore.put('3', _b(40));
+ cachingStore.put('4', _b(40));
+ }
+
+ test_get_notFound_retry() {
+ var mockStore = new _TestByteStore();
+ var baseStore = new MemoryCachingByteStore(mockStore, 1000);
+ var cachingStore = new MemoryCachingByteStore(baseStore, 100);
+
+ // Request '1'. Nothing found.
+ expect(cachingStore.get('1'), isNull);
+
+ // Add data to the base store, bypassing the caching store.
+ baseStore.put('1', _b(40));
+
+ // Request '1' again. The previous `null` result should not have been
+ // cached.
+ expect(cachingStore.get('1'), isNotNull);
+ }
+
test_get_put_evict() {
var store = new _TestByteStore();
var cachingStore = new MemoryCachingByteStore(store, 100);
« no previous file with comments | « pkg/analyzer/lib/src/dart/analysis/byte_store.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698