| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 void test_get() { | 60 void test_get() { |
| 61 AnalysisTarget target = new TestSource(); | 61 AnalysisTarget target = new TestSource(); |
| 62 expect(cache.get(target), isNull); | 62 expect(cache.get(target), isNull); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void test_getContextFor() { | 65 void test_getContextFor() { |
| 66 AnalysisTarget target = new TestSource(); | 66 AnalysisTarget target = new TestSource(); |
| 67 expect(cache.getContextFor(target), context); | 67 expect(cache.getContextFor(target), context); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void test_getState_hasEntry_flushed() { |
| 71 ResultDescriptor result = new ResultDescriptor('result', -1); |
| 72 AnalysisTarget target = new TestSource(); |
| 73 CacheEntry entry = new CacheEntry(target); |
| 74 cache.put(entry); |
| 75 entry.setState(result, CacheState.FLUSHED); |
| 76 expect(cache.getState(target, result), CacheState.FLUSHED); |
| 77 } |
| 78 |
| 79 void test_getState_hasEntry_valid() { |
| 80 ResultDescriptor result = new ResultDescriptor('result', -1); |
| 81 AnalysisTarget target = new TestSource(); |
| 82 CacheEntry entry = new CacheEntry(target); |
| 83 cache.put(entry); |
| 84 entry.setValue(result, '', []); |
| 85 expect(cache.getState(target, result), CacheState.VALID); |
| 86 } |
| 87 |
| 88 void test_getState_noEntry() { |
| 89 ResultDescriptor result = new ResultDescriptor('result', -1); |
| 90 AnalysisTarget target = new TestSource(); |
| 91 expect(cache.getState(target, result), CacheState.INVALID); |
| 92 } |
| 93 |
| 94 void test_getValue_hasEntry_valid() { |
| 95 ResultDescriptor result = new ResultDescriptor('result', -1); |
| 96 AnalysisTarget target = new TestSource(); |
| 97 CacheEntry entry = new CacheEntry(target); |
| 98 cache.put(entry); |
| 99 entry.setValue(result, 111, []); |
| 100 expect(cache.getValue(target, result), 111); |
| 101 } |
| 102 |
| 103 void test_getValue_noEntry() { |
| 104 ResultDescriptor result = new ResultDescriptor('result', -1); |
| 105 AnalysisTarget target = new TestSource(); |
| 106 expect(cache.getValue(target, result), -1); |
| 107 } |
| 108 |
| 70 void test_iterator() { | 109 void test_iterator() { |
| 71 AnalysisTarget target = new TestSource(); | 110 AnalysisTarget target = new TestSource(); |
| 72 CacheEntry entry = new CacheEntry(target); | 111 CacheEntry entry = new CacheEntry(target); |
| 73 cache.put(entry); | 112 cache.put(entry); |
| 74 MapIterator<AnalysisTarget, CacheEntry> iterator = cache.iterator(); | 113 MapIterator<AnalysisTarget, CacheEntry> iterator = cache.iterator(); |
| 75 expect(iterator.moveNext(), isTrue); | 114 expect(iterator.moveNext(), isTrue); |
| 76 expect(iterator.key, same(target)); | 115 expect(iterator.key, same(target)); |
| 77 expect(iterator.value, same(entry)); | 116 expect(iterator.value, same(entry)); |
| 78 expect(iterator.moveNext(), isFalse); | 117 expect(iterator.moveNext(), isFalse); |
| 79 } | 118 } |
| (...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 UniversalCachePartition partition = new UniversalCachePartition(null); | 880 UniversalCachePartition partition = new UniversalCachePartition(null); |
| 842 TestSource source = new TestSource(); | 881 TestSource source = new TestSource(); |
| 843 expect(partition.isResponsibleFor(source), isTrue); | 882 expect(partition.isResponsibleFor(source), isTrue); |
| 844 } | 883 } |
| 845 } | 884 } |
| 846 | 885 |
| 847 class _InternalAnalysisContextMock extends TypedMock | 886 class _InternalAnalysisContextMock extends TypedMock |
| 848 implements InternalAnalysisContext { | 887 implements InternalAnalysisContext { |
| 849 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 888 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 850 } | 889 } |
| OLD | NEW |