| 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 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 expect(entry.getValue(result1), 111); | 617 expect(entry.getValue(result1), 111); |
| 618 expect(entry.getValue(result2), 222); | 618 expect(entry.getValue(result2), 222); |
| 619 // set result1; result2 is intact | 619 // set result1; result2 is intact |
| 620 entry.setValue(result1, 1111, TargetedResult.EMPTY_LIST); | 620 entry.setValue(result1, 1111, TargetedResult.EMPTY_LIST); |
| 621 expect(entry.getState(result1), CacheState.VALID); | 621 expect(entry.getState(result1), CacheState.VALID); |
| 622 expect(entry.getState(result2), CacheState.VALID); | 622 expect(entry.getState(result2), CacheState.VALID); |
| 623 expect(entry.getValue(result1), 1111); | 623 expect(entry.getValue(result1), 1111); |
| 624 expect(entry.getValue(result2), 222); | 624 expect(entry.getValue(result2), 222); |
| 625 } | 625 } |
| 626 | 626 |
| 627 test_setValueIncremental() { |
| 628 AnalysisTarget target = new TestSource(); |
| 629 CacheEntry entry = new CacheEntry(target); |
| 630 cache.put(entry); |
| 631 ResultDescriptor result1 = new ResultDescriptor('result1', -1); |
| 632 ResultDescriptor result2 = new ResultDescriptor('result2', -2); |
| 633 ResultDescriptor result3 = new ResultDescriptor('result3', -3); |
| 634 // set results, all of them are VALID |
| 635 entry.setValue(result1, 111, TargetedResult.EMPTY_LIST); |
| 636 entry.setValue(result2, 222, [new TargetedResult(target, result1)]); |
| 637 entry.setValue(result3, 333, [new TargetedResult(target, result2)]); |
| 638 expect(entry.getState(result1), CacheState.VALID); |
| 639 expect(entry.getState(result2), CacheState.VALID); |
| 640 expect(entry.getState(result3), CacheState.VALID); |
| 641 expect(entry.getValue(result1), 111); |
| 642 expect(entry.getValue(result2), 222); |
| 643 expect(entry.getValue(result3), 333); |
| 644 // replace result1, keep "dependedOn", invalidate result3 |
| 645 entry.setValueIncremental(result2, 2222); |
| 646 expect(entry.getState(result1), CacheState.VALID); |
| 647 expect(entry.getState(result2), CacheState.VALID); |
| 648 expect(entry.getState(result3), CacheState.INVALID); |
| 649 expect(entry.getValue(result1), 111); |
| 650 expect(entry.getValue(result2), 2222); |
| 651 expect(entry.getValue(result3), -3); |
| 652 expect(entry.getResultData(result2).dependedOnResults, |
| 653 unorderedEquals([new TargetedResult(target, result1)])); |
| 654 } |
| 655 |
| 627 test_toString_empty() { | 656 test_toString_empty() { |
| 628 AnalysisTarget target = new TestSource(); | 657 AnalysisTarget target = new TestSource(); |
| 629 CacheEntry entry = new CacheEntry(target); | 658 CacheEntry entry = new CacheEntry(target); |
| 630 expect(entry.toString(), isNotNull); | 659 expect(entry.toString(), isNotNull); |
| 631 } | 660 } |
| 632 | 661 |
| 633 test_toString_nonEmpty() { | 662 test_toString_nonEmpty() { |
| 634 AnalysisTarget target = new TestSource(); | 663 AnalysisTarget target = new TestSource(); |
| 635 ResultDescriptor result = new ResultDescriptor('test', null); | 664 ResultDescriptor result = new ResultDescriptor('test', null); |
| 636 CacheEntry entry = new CacheEntry(target); | 665 CacheEntry entry = new CacheEntry(target); |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 | 951 |
| 923 class _InternalAnalysisContextMock extends TypedMock | 952 class _InternalAnalysisContextMock extends TypedMock |
| 924 implements InternalAnalysisContext { | 953 implements InternalAnalysisContext { |
| 925 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 954 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 926 } | 955 } |
| 927 | 956 |
| 928 class _TestAnalysisTarget implements AnalysisTarget { | 957 class _TestAnalysisTarget implements AnalysisTarget { |
| 929 @override | 958 @override |
| 930 Source get source => null; | 959 Source get source => null; |
| 931 } | 960 } |
| OLD | NEW |