| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 CacheEntry entry = new CacheEntry(target); | 63 CacheEntry entry = new CacheEntry(target); |
| 64 cache.put(entry); | 64 cache.put(entry); |
| 65 // put values | 65 // put values |
| 66 entry.setValue(resultA, 'a', TargetedResult.EMPTY_LIST); | 66 entry.setValue(resultA, 'a', TargetedResult.EMPTY_LIST); |
| 67 entry.setValue(resultB, 'b', TargetedResult.EMPTY_LIST); | 67 entry.setValue(resultB, 'b', TargetedResult.EMPTY_LIST); |
| 68 expect(cache.getState(target, resultA), CacheState.VALID); | 68 expect(cache.getState(target, resultA), CacheState.VALID); |
| 69 expect(cache.getState(target, resultB), CacheState.VALID); | 69 expect(cache.getState(target, resultB), CacheState.VALID); |
| 70 expect(cache.getValue(target, resultA), 'a'); | 70 expect(cache.getValue(target, resultA), 'a'); |
| 71 expect(cache.getValue(target, resultB), 'b'); | 71 expect(cache.getValue(target, resultB), 'b'); |
| 72 // flush A | 72 // flush A |
| 73 cache.flush((target, result) => result == resultA); | 73 cache.flush((target) => true, (target, result) => result == resultA); |
| 74 expect(cache.getState(target, resultA), CacheState.FLUSHED); | 74 expect(cache.getState(target, resultA), CacheState.FLUSHED); |
| 75 expect(cache.getState(target, resultB), CacheState.VALID); | 75 expect(cache.getState(target, resultB), CacheState.VALID); |
| 76 expect(cache.getValue(target, resultA), isNull); | 76 expect(cache.getValue(target, resultA), isNull); |
| 77 expect(cache.getValue(target, resultB), 'b'); | 77 expect(cache.getValue(target, resultB), 'b'); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void test_get() { | 80 void test_get() { |
| 81 AnalysisTarget target = new TestSource(); | 81 AnalysisTarget target = new TestSource(); |
| 82 expect(cache.get(target), isNull); | 82 expect(cache.get(target), isNull); |
| 83 } | 83 } |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 CacheEntry entry = new CacheEntry(target); | 329 CacheEntry entry = new CacheEntry(target); |
| 330 cache.put(entry); | 330 cache.put(entry); |
| 331 // put values | 331 // put values |
| 332 entry.setValue(resultA, 'a', TargetedResult.EMPTY_LIST); | 332 entry.setValue(resultA, 'a', TargetedResult.EMPTY_LIST); |
| 333 entry.setValue(resultB, 'b', TargetedResult.EMPTY_LIST); | 333 entry.setValue(resultB, 'b', TargetedResult.EMPTY_LIST); |
| 334 expect(entry.getState(resultA), CacheState.VALID); | 334 expect(entry.getState(resultA), CacheState.VALID); |
| 335 expect(entry.getState(resultB), CacheState.VALID); | 335 expect(entry.getState(resultB), CacheState.VALID); |
| 336 expect(entry.getValue(resultA), 'a'); | 336 expect(entry.getValue(resultA), 'a'); |
| 337 expect(entry.getValue(resultB), 'b'); | 337 expect(entry.getValue(resultB), 'b'); |
| 338 // flush A | 338 // flush A |
| 339 entry.flush((target, result) => result == resultA); | 339 entry.flush((target) => true, (target, result) => result == resultA); |
| 340 expect(entry.getState(resultA), CacheState.FLUSHED); | 340 expect(entry.getState(resultA), CacheState.FLUSHED); |
| 341 expect(entry.getState(resultB), CacheState.VALID); | 341 expect(entry.getState(resultB), CacheState.VALID); |
| 342 expect(entry.getValue(resultA), isNull); | 342 expect(entry.getValue(resultA), isNull); |
| 343 expect(entry.getValue(resultB), 'b'); | 343 expect(entry.getValue(resultB), 'b'); |
| 344 } | 344 } |
| 345 | 345 |
| 346 test_getState() { | 346 test_getState() { |
| 347 AnalysisTarget target = new TestSource(); | 347 AnalysisTarget target = new TestSource(); |
| 348 ResultDescriptor result = new ResultDescriptor('test', null); | 348 ResultDescriptor result = new ResultDescriptor('test', null); |
| 349 CacheEntry entry = new CacheEntry(target); | 349 CacheEntry entry = new CacheEntry(target); |
| (...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1262 } | 1262 } |
| 1263 } | 1263 } |
| 1264 | 1264 |
| 1265 class _TestAnalysisTarget implements AnalysisTarget { | 1265 class _TestAnalysisTarget implements AnalysisTarget { |
| 1266 @override | 1266 @override |
| 1267 Source get librarySource => null; | 1267 Source get librarySource => null; |
| 1268 | 1268 |
| 1269 @override | 1269 @override |
| 1270 Source get source => null; | 1270 Source get source => null; |
| 1271 } | 1271 } |
| OLD | NEW |