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

Unified Diff: pkg/analysis_server/test/index/lru_cache_test.dart

Issue 329633002: Some clean ups for caching tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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
Index: pkg/analysis_server/test/index/lru_cache_test.dart
diff --git a/pkg/analysis_server/test/index/lru_cache_test.dart b/pkg/analysis_server/test/index/lru_cache_test.dart
index a1a448961ee0d8fce721bcdf1d5f47667b9c65a6..f397a5d49f11dc21d849eb86f4ce2981715b21bc 100644
--- a/pkg/analysis_server/test/index/lru_cache_test.dart
+++ b/pkg/analysis_server/test/index/lru_cache_test.dart
@@ -22,7 +22,7 @@ main() {
class _LRUCacheTest {
LRUCache<int, String> cache = new LRUCache<int, String>(3);
- void test_evict() {
+ void test_evict_notGet() {
List<int> evictedKeys = new List<int>();
List<String> evictedValues = new List<String>();
cache = new LRUCache<int, String>(3, (int key, String value) {
@@ -47,6 +47,31 @@ class _LRUCacheTest {
expect(evictedValues, contains('B'));
}
+ void test_evict_notPut() {
+ List<int> evictedKeys = new List<int>();
+ List<String> evictedValues = new List<String>();
+ cache = new LRUCache<int, String>(3, (int key, String value) {
+ evictedKeys.add(key);
+ evictedValues.add(value);
+ });
+ // fill
+ cache.put(1, 'A');
+ cache.put(2, 'B');
+ cache.put(3, 'C');
+ // put '1' and '3'
+ cache.put(1, 'AA');
+ cache.put(3, 'CC');
+ // put '4', evict '2'
+ cache.put(4, 'D');
+ expect(cache.get(1), 'AA');
+ expect(cache.get(2), isNull);
+ expect(cache.get(3), 'CC');
+ expect(cache.get(4), 'D');
+ // check eviction listener
+ expect(evictedKeys, contains(2));
+ expect(evictedValues, contains('B'));
+ }
+
void test_putGet() {
// fill
cache.put(1, 'A');
« no previous file with comments | « pkg/analysis_server/lib/src/index/page_node_manager.dart ('k') | pkg/analysis_server/test/index/page_node_manager_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698