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/source/package_map_resolver.dart'; | 9 import 'package:analyzer/source/package_map_resolver.dart'; |
10 import 'package:analyzer/src/context/cache.dart'; | 10 import 'package:analyzer/src/context/cache.dart'; |
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 entry.setValue(result2, 222, [new TargetedResult(target, result1)]); | 694 entry.setValue(result2, 222, [new TargetedResult(target, result1)]); |
695 entry.setValue(result3, 333, [new TargetedResult(target, result2)]); | 695 entry.setValue(result3, 333, [new TargetedResult(target, result2)]); |
696 expect(entry.getState(result1), CacheState.VALID); | 696 expect(entry.getState(result1), CacheState.VALID); |
697 expect(entry.getState(result2), CacheState.VALID); | 697 expect(entry.getState(result2), CacheState.VALID); |
698 expect(entry.getState(result3), CacheState.VALID); | 698 expect(entry.getState(result3), CacheState.VALID); |
699 // result2 depends on result1 | 699 // result2 depends on result1 |
700 expect(entry.getResultData(result1).dependentResults, | 700 expect(entry.getResultData(result1).dependentResults, |
701 unorderedEquals([new TargetedResult(target, result2)])); | 701 unorderedEquals([new TargetedResult(target, result2)])); |
702 expect(entry.getResultData(result2).dependedOnResults, | 702 expect(entry.getResultData(result2).dependedOnResults, |
703 unorderedEquals([new TargetedResult(target, result1)])); | 703 unorderedEquals([new TargetedResult(target, result1)])); |
| 704 // record invalidated results |
| 705 Set<TargetedResult> reportedInvalidatedResults = new Set<TargetedResult>(); |
| 706 cache.onResultInvalidated.listen((InvalidatedResult invalidatedResult) { |
| 707 reportedInvalidatedResults.add(new TargetedResult( |
| 708 invalidatedResult.entry.target, invalidatedResult.descriptor)); |
| 709 }); |
704 // invalidate result2 with Delta: keep result2, invalidate result3 | 710 // invalidate result2 with Delta: keep result2, invalidate result3 |
705 entry.setState(result2, CacheState.INVALID, | 711 entry.setState(result2, CacheState.INVALID, |
706 delta: new _KeepContinueDelta(target, result2)); | 712 delta: new _KeepContinueDelta(target, result2)); |
707 expect(entry.getState(result1), CacheState.VALID); | 713 expect(entry.getState(result1), CacheState.VALID); |
708 expect(entry.getState(result2), CacheState.VALID); | 714 expect(entry.getState(result2), CacheState.VALID); |
709 expect(entry.getState(result3), CacheState.INVALID); | 715 expect(entry.getState(result3), CacheState.INVALID); |
710 // result2 still depends on result1 | 716 // result2 still depends on result1 |
711 expect(entry.getResultData(result1).dependentResults, | 717 expect(entry.getResultData(result1).dependentResults, |
712 unorderedEquals([new TargetedResult(target, result2)])); | 718 unorderedEquals([new TargetedResult(target, result2)])); |
713 expect(entry.getResultData(result2).dependedOnResults, | 719 expect(entry.getResultData(result2).dependedOnResults, |
714 unorderedEquals([new TargetedResult(target, result1)])); | 720 unorderedEquals([new TargetedResult(target, result1)])); |
| 721 // (target, result3) was reported as invalidated |
| 722 // (target, result2) was NOT reported |
| 723 expect(reportedInvalidatedResults, |
| 724 unorderedEquals([new TargetedResult(target, result3)])); |
715 } | 725 } |
716 | 726 |
717 test_setState_valid() { | 727 test_setState_valid() { |
718 AnalysisTarget target = new TestSource(); | 728 AnalysisTarget target = new TestSource(); |
719 ResultDescriptor result = new ResultDescriptor('test', null); | 729 ResultDescriptor result = new ResultDescriptor('test', null); |
720 CacheEntry entry = new CacheEntry(target); | 730 CacheEntry entry = new CacheEntry(target); |
721 expect(() => entry.setState(result, CacheState.VALID), throwsArgumentError); | 731 expect(() => entry.setState(result, CacheState.VALID), throwsArgumentError); |
722 } | 732 } |
723 | 733 |
724 test_setValue() { | 734 test_setValue() { |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1249 } | 1259 } |
1250 } | 1260 } |
1251 | 1261 |
1252 class _TestAnalysisTarget implements AnalysisTarget { | 1262 class _TestAnalysisTarget implements AnalysisTarget { |
1253 @override | 1263 @override |
1254 Source get librarySource => null; | 1264 Source get librarySource => null; |
1255 | 1265 |
1256 @override | 1266 @override |
1257 Source get source => null; | 1267 Source get source => null; |
1258 } | 1268 } |
OLD | NEW |