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

Unified Diff: pkg/front_end/test/src/byte_store/byte_store_test.dart

Issue 2998363002: Generalize LRU Cache to any objects. (Closed)
Patch Set: Created 3 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/front_end/lib/src/byte_store/cache.dart ('k') | pkg/front_end/test/src/byte_store/cache_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/test/src/byte_store/byte_store_test.dart
diff --git a/pkg/front_end/test/src/byte_store/byte_store_test.dart b/pkg/front_end/test/src/byte_store/byte_store_test.dart
index 328377afea36cc2fd685e0469e5dfe55ef01ecf0..28e77ace6671fe06dcd3874e0a4f3decb79e1ea4 100644
--- a/pkg/front_end/test/src/byte_store/byte_store_test.dart
+++ b/pkg/front_end/test/src/byte_store/byte_store_test.dart
@@ -8,7 +8,6 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
main() {
defineReflectiveSuite(() {
- defineReflectiveTests(BytesMemoryCacheTest);
defineReflectiveTests(MemoryCachingByteStoreTest);
defineReflectiveTests(NullByteStoreTest);
});
@@ -18,87 +17,6 @@ List<int> _b(int length) {
return new List<int>(length);
}
-@reflectiveTest
-class BytesMemoryCacheTest {
- test_get_notFound_evict() {
- var cache = new BytesMemoryCache(100);
-
- // Request '1'. Nothing found.
- expect(cache.get('1', _noBytes), isNull);
-
- // Add enough data to the store to force an eviction.
- cache.put('2', _b(40));
- cache.put('3', _b(40));
- cache.put('4', _b(40));
- }
-
- test_get_notFound_retry() {
- var cache = new BytesMemoryCache(100);
-
- // Request '1'. Nothing found.
- expect(cache.get('1', _noBytes), isNull);
-
- // Request '1' again.
- // The previous `null` result should not have been cached.
- expect(cache.get('1', () => _b(40)), isNotNull);
- }
-
- test_get_put_evict() {
- var cache = new BytesMemoryCache(100);
-
- // Keys: [1, 2].
- cache.put('1', _b(40));
- cache.put('2', _b(50));
-
- // Request '1', so now it is the most recently used.
- // Keys: [2, 1].
- cache.get('1', _noBytes);
-
- // 40 + 50 + 30 > 100
- // So, '2' is evicted.
- cache.put('3', _b(30));
- expect(cache.get('1', _noBytes), hasLength(40));
- expect(cache.get('2', _noBytes), isNull);
- expect(cache.get('3', _noBytes), hasLength(30));
- }
-
- test_put_evict_first() {
- var cache = new BytesMemoryCache(100);
-
- // 40 + 50 < 100
- cache.put('1', _b(40));
- cache.put('2', _b(50));
- expect(cache.get('1', _noBytes), hasLength(40));
- expect(cache.get('2', _noBytes), hasLength(50));
-
- // 40 + 50 + 30 > 100
- // So, '1' is evicted.
- cache.put('3', _b(30));
- expect(cache.get('1', _noBytes), isNull);
- expect(cache.get('2', _noBytes), hasLength(50));
- expect(cache.get('3', _noBytes), hasLength(30));
- }
-
- test_put_evict_firstAndSecond() {
- var cache = new BytesMemoryCache(100);
-
- // 10 + 80 < 100
- cache.put('1', _b(10));
- cache.put('2', _b(80));
- expect(cache.get('1', _noBytes), hasLength(10));
- expect(cache.get('2', _noBytes), hasLength(80));
-
- // 10 + 80 + 30 > 100
- // So, '1' and '2' are evicted.
- cache.put('3', _b(30));
- expect(cache.get('1', _noBytes), isNull);
- expect(cache.get('2', _noBytes), isNull);
- expect(cache.get('3', _noBytes), hasLength(30));
- }
-
- static List<int> _noBytes() => null;
-}
-
@reflectiveTest
class MemoryCachingByteStoreTest {
test_get_notFound_evict() {
« no previous file with comments | « pkg/front_end/lib/src/byte_store/cache.dart ('k') | pkg/front_end/test/src/byte_store/cache_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698