Chromium Code Reviews| 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 } | 176 } |
| 177 | 177 |
| 178 void test_size() { | 178 void test_size() { |
| 179 int size = 4; | 179 int size = 4; |
| 180 for (int i = 0; i < size; i++) { | 180 for (int i = 0; i < size; i++) { |
| 181 AnalysisTarget target = new TestSource("/test$i.dart"); | 181 AnalysisTarget target = new TestSource("/test$i.dart"); |
| 182 cache.put(new CacheEntry(target)); | 182 cache.put(new CacheEntry(target)); |
| 183 } | 183 } |
| 184 expect(cache.size(), size); | 184 expect(cache.size(), size); |
| 185 } | 185 } |
| 186 | |
| 187 void test_sources() { | |
| 188 AnalysisTarget source1 = new TestSource('1.dart'); | |
| 189 AnalysisTarget source2 = new TestSource('2.dart'); | |
| 190 AnalysisTarget target1 = new _TestAnalysisTarget(); | |
| 191 // no entries | |
| 192 expect(cache.sources, isEmpty); | |
| 193 // add source1 | |
| 194 cache.put(new CacheEntry(source1)); | |
| 195 expect(cache.sources, unorderedEquals([source1])); | |
| 196 // add target1 | |
| 197 cache.put(new CacheEntry(target1)); | |
| 198 expect(cache.sources, unorderedEquals([source1])); | |
| 199 // add source2 | |
| 200 cache.put(new CacheEntry(source2)); | |
| 201 expect(cache.sources, unorderedEquals([source1, source2])); | |
| 202 // remove source1 | |
| 203 cache.remove(source1); | |
| 204 expect(cache.sources, unorderedEquals([source2])); | |
| 205 // remove source2 | |
| 206 cache.remove(source2); | |
| 207 expect(cache.sources, isEmpty); | |
| 208 } | |
| 186 } | 209 } |
| 187 | 210 |
| 188 @reflectiveTest | 211 @reflectiveTest |
| 189 class CacheEntryTest extends AbstractCacheTest { | 212 class CacheEntryTest extends AbstractCacheTest { |
| 190 test_explicitlyAdded() { | 213 test_explicitlyAdded() { |
| 191 AnalysisTarget target = new TestSource(); | 214 AnalysisTarget target = new TestSource(); |
| 192 CacheEntry entry = new CacheEntry(target); | 215 CacheEntry entry = new CacheEntry(target); |
| 193 expect(entry.explicitlyAdded, false); | 216 expect(entry.explicitlyAdded, false); |
| 194 entry.explicitlyAdded = true; | 217 entry.explicitlyAdded = true; |
| 195 expect(entry.explicitlyAdded, true); | 218 expect(entry.explicitlyAdded, true); |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 835 UniversalCachePartition partition = new UniversalCachePartition(null); | 858 UniversalCachePartition partition = new UniversalCachePartition(null); |
| 836 TestSource source = new TestSource(); | 859 TestSource source = new TestSource(); |
| 837 expect(partition.isResponsibleFor(source), isTrue); | 860 expect(partition.isResponsibleFor(source), isTrue); |
| 838 } | 861 } |
| 839 } | 862 } |
| 840 | 863 |
| 841 class _InternalAnalysisContextMock extends TypedMock | 864 class _InternalAnalysisContextMock extends TypedMock |
| 842 implements InternalAnalysisContext { | 865 implements InternalAnalysisContext { |
| 843 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 866 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 844 } | 867 } |
| 868 | |
| 869 class _TestAnalysisTarget implements AnalysisTarget { | |
|
Brian Wilkerson
2015/05/21 13:52:31
Don't we already have this class somewhere?
| |
| 870 @override | |
| 871 Source get source => null; | |
| 872 } | |
| OLD | NEW |