| 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 test.src.task.driver_test; | 5 library test.src.task.driver_test; |
| 6 | 6 |
| 7 import 'package:analyzer/src/context/cache.dart'; | 7 import 'package:analyzer/src/context/cache.dart'; |
| 8 import 'package:analyzer/src/generated/engine.dart' | 8 import 'package:analyzer/src/generated/engine.dart' |
| 9 show | 9 show |
| 10 AnalysisContext, | 10 AnalysisContext, |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 expect(entry.getState(result3), CacheState.INVALID); | 589 expect(entry.getState(result3), CacheState.INVALID); |
| 590 expect(entry.getState(result4), CacheState.VALID); | 590 expect(entry.getState(result4), CacheState.VALID); |
| 591 expect(entry.getValue(result1), -1); | 591 expect(entry.getValue(result1), -1); |
| 592 expect(entry.getValue(result2), -2); | 592 expect(entry.getValue(result2), -2); |
| 593 expect(entry.getValue(result3), -3); | 593 expect(entry.getValue(result3), -3); |
| 594 expect(entry.getValue(result4), 444); | 594 expect(entry.getValue(result4), 444); |
| 595 // result4 is still valid, so the entry is still in the cache | 595 // result4 is still valid, so the entry is still in the cache |
| 596 expect(cache.get(target), entry); | 596 expect(cache.get(target), entry); |
| 597 } | 597 } |
| 598 | 598 |
| 599 test_setState_invalid_keepEmpty_ifExplicitlyAdded() { |
| 600 AnalysisTarget target = new TestSource('/a.dart'); |
| 601 CacheEntry entry = new CacheEntry(target); |
| 602 entry.explicitlyAdded = true; |
| 603 cache.put(entry); |
| 604 ResultDescriptor result = new ResultDescriptor('result1', -1); |
| 605 // set results, all of them are VALID |
| 606 entry.setValue(result, 111, TargetedResult.EMPTY_LIST); |
| 607 expect(entry.getState(result), CacheState.VALID); |
| 608 expect(entry.getValue(result), 111); |
| 609 // invalidate result, keep entry |
| 610 entry.setState(result, CacheState.INVALID); |
| 611 expect(cache.get(target), isNotNull); |
| 612 } |
| 613 |
| 599 test_setState_invalid_removeEmptyEntry() { | 614 test_setState_invalid_removeEmptyEntry() { |
| 600 AnalysisTarget target1 = new TestSource('/a.dart'); | 615 AnalysisTarget target1 = new TestSource('/a.dart'); |
| 601 AnalysisTarget target2 = new TestSource('/b.dart'); | 616 AnalysisTarget target2 = new TestSource('/b.dart'); |
| 602 CacheEntry entry1 = new CacheEntry(target1); | 617 CacheEntry entry1 = new CacheEntry(target1); |
| 603 CacheEntry entry2 = new CacheEntry(target2); | 618 CacheEntry entry2 = new CacheEntry(target2); |
| 604 cache.put(entry1); | 619 cache.put(entry1); |
| 605 cache.put(entry2); | 620 cache.put(entry2); |
| 606 ResultDescriptor result1 = new ResultDescriptor('result1', -1); | 621 ResultDescriptor result1 = new ResultDescriptor('result1', -1); |
| 607 ResultDescriptor result2 = new ResultDescriptor('result2', -2); | 622 ResultDescriptor result2 = new ResultDescriptor('result2', -2); |
| 608 ResultDescriptor result3 = new ResultDescriptor('result3', -3); | 623 ResultDescriptor result3 = new ResultDescriptor('result3', -3); |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1107 return DeltaResult.KEEP_CONTINUE; | 1122 return DeltaResult.KEEP_CONTINUE; |
| 1108 } | 1123 } |
| 1109 return DeltaResult.INVALIDATE; | 1124 return DeltaResult.INVALIDATE; |
| 1110 } | 1125 } |
| 1111 } | 1126 } |
| 1112 | 1127 |
| 1113 class _TestAnalysisTarget implements AnalysisTarget { | 1128 class _TestAnalysisTarget implements AnalysisTarget { |
| 1114 @override | 1129 @override |
| 1115 Source get source => null; | 1130 Source get source => null; |
| 1116 } | 1131 } |
| OLD | NEW |