OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library analyzer.test.src.context.cache_test; | 5 library analyzer.test.src.context.cache_test; |
6 | 6 |
7 import 'package:analyzer/file_system/file_system.dart'; | 7 import 'package:analyzer/file_system/file_system.dart'; |
8 import 'package:analyzer/file_system/memory_file_system.dart'; | 8 import 'package:analyzer/file_system/memory_file_system.dart'; |
9 import 'package:analyzer/file_system/physical_file_system.dart'; | 9 import 'package:analyzer/file_system/physical_file_system.dart'; |
10 import 'package:analyzer/source/package_map_resolver.dart'; | 10 import 'package:analyzer/source/package_map_resolver.dart'; |
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 // make idle | 926 // make idle |
927 List<TargetedResult> resultsToFlush = manager.madeIdle(); | 927 List<TargetedResult> resultsToFlush = manager.madeIdle(); |
928 expect(manager.maxSize, 3); | 928 expect(manager.maxSize, 3); |
929 expect(manager.recentlyUsed, results.skip(15 - 3)); | 929 expect(manager.recentlyUsed, results.skip(15 - 3)); |
930 expect(resultsToFlush, results.take(15 - 3)); | 930 expect(resultsToFlush, results.take(15 - 3)); |
931 } | 931 } |
932 | 932 |
933 test_new() { | 933 test_new() { |
934 expect(manager.maxActiveSize, 15); | 934 expect(manager.maxActiveSize, 15); |
935 expect(manager.maxIdleSize, 3); | 935 expect(manager.maxIdleSize, 3); |
936 expect(manager.maxSize, 3); | 936 expect(manager.maxSize, 15); |
937 expect(manager.currentSize, 0); | 937 expect(manager.currentSize, 0); |
938 expect(manager.recentlyUsed, isEmpty); | 938 expect(manager.recentlyUsed, isEmpty); |
939 } | 939 } |
940 | 940 |
941 test_resultAccessed() { | 941 test_resultAccessed() { |
942 ResultDescriptor descriptor1 = new ResultDescriptor('result1', null); | 942 ResultDescriptor descriptor1 = new ResultDescriptor('result1', null); |
943 ResultDescriptor descriptor2 = new ResultDescriptor('result2', null); | 943 ResultDescriptor descriptor2 = new ResultDescriptor('result2', null); |
944 ResultDescriptor descriptor3 = new ResultDescriptor('result3', null); | 944 ResultDescriptor descriptor3 = new ResultDescriptor('result3', null); |
945 AnalysisTarget target = new TestSource(); | 945 AnalysisTarget target = new TestSource(); |
946 TargetedResult result1 = new TargetedResult(target, descriptor1); | 946 TargetedResult result1 = new TargetedResult(target, descriptor1); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
987 manager.resultStored(result2, null); | 987 manager.resultStored(result2, null); |
988 expect(manager.currentSize, 2); | 988 expect(manager.currentSize, 2); |
989 expect(manager.recentlyUsed, orderedEquals([result1, result2])); | 989 expect(manager.recentlyUsed, orderedEquals([result1, result2])); |
990 // access result3, no-op | 990 // access result3, no-op |
991 manager.resultAccessed(result3); | 991 manager.resultAccessed(result3); |
992 expect(manager.currentSize, 2); | 992 expect(manager.currentSize, 2); |
993 expect(manager.recentlyUsed, orderedEquals([result1, result2])); | 993 expect(manager.recentlyUsed, orderedEquals([result1, result2])); |
994 } | 994 } |
995 | 995 |
996 test_resultStored() { | 996 test_resultStored() { |
| 997 CacheFlushManager manager = new CacheFlushManager( |
| 998 new SimpleResultCachingPolicy(3, 3), (AnalysisTarget target) => false); |
997 ResultDescriptor descriptor1 = new ResultDescriptor('result1', null); | 999 ResultDescriptor descriptor1 = new ResultDescriptor('result1', null); |
998 ResultDescriptor descriptor2 = new ResultDescriptor('result2', null); | 1000 ResultDescriptor descriptor2 = new ResultDescriptor('result2', null); |
999 ResultDescriptor descriptor3 = new ResultDescriptor('result3', null); | 1001 ResultDescriptor descriptor3 = new ResultDescriptor('result3', null); |
1000 ResultDescriptor descriptor4 = new ResultDescriptor('result4', null); | 1002 ResultDescriptor descriptor4 = new ResultDescriptor('result4', null); |
1001 AnalysisTarget target = new TestSource(); | 1003 AnalysisTarget target = new TestSource(); |
1002 TargetedResult result1 = new TargetedResult(target, descriptor1); | 1004 TargetedResult result1 = new TargetedResult(target, descriptor1); |
1003 TargetedResult result2 = new TargetedResult(target, descriptor2); | 1005 TargetedResult result2 = new TargetedResult(target, descriptor2); |
1004 TargetedResult result3 = new TargetedResult(target, descriptor3); | 1006 TargetedResult result3 = new TargetedResult(target, descriptor3); |
1005 TargetedResult result4 = new TargetedResult(target, descriptor4); | 1007 TargetedResult result4 = new TargetedResult(target, descriptor4); |
1006 manager.resultStored(result1, null); | 1008 manager.resultStored(result1, null); |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1300 } | 1302 } |
1301 return DeltaResult.INVALIDATE; | 1303 return DeltaResult.INVALIDATE; |
1302 } | 1304 } |
1303 } | 1305 } |
1304 | 1306 |
1305 class _TestAnalysisTarget implements AnalysisTarget { | 1307 class _TestAnalysisTarget implements AnalysisTarget { |
1306 final Source librarySource; | 1308 final Source librarySource; |
1307 final Source source; | 1309 final Source source; |
1308 _TestAnalysisTarget({this.librarySource, this.source}); | 1310 _TestAnalysisTarget({this.librarySource, this.source}); |
1309 } | 1311 } |
OLD | NEW |