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 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 954 } | 954 } |
| 955 } | 955 } |
| 956 | 956 |
| 957 abstract class CachePartitionTest extends EngineTestCase { | 957 abstract class CachePartitionTest extends EngineTestCase { |
| 958 CachePartition createPartition(); | 958 CachePartition createPartition(); |
| 959 | 959 |
| 960 void test_creation() { | 960 void test_creation() { |
| 961 expect(createPartition(), isNotNull); | 961 expect(createPartition(), isNotNull); |
| 962 } | 962 } |
| 963 | 963 |
| 964 void test_dispose() { | |
| 965 CachePartition partition = createPartition(); | |
| 966 Source source1 = new TestSource('/1.dart'); | |
| 967 Source source2 = new TestSource('/2.dart'); | |
| 968 CacheEntry entry1 = new CacheEntry(source1); | |
| 969 CacheEntry entry2 = new CacheEntry(source2); | |
| 970 // add two sources | |
| 971 partition.put(entry1); | |
| 972 partition.put(entry2); | |
| 973 expect(partition.sources, unorderedEquals([source1, source2])); | |
| 974 expect(partition.pathToSource, hasLength(2)); | |
| 975 // dispose, no sources | |
| 976 partition.dispose(); | |
| 977 expect(partition.sources, isEmpty); | |
| 978 expect(partition.pathToSource, isEmpty); | |
|
Brian Wilkerson
2015/12/01 14:50:17
expect(partition.entryMap, isEmpty); ?
| |
| 979 } | |
| 980 | |
| 964 void test_entrySet() { | 981 void test_entrySet() { |
| 965 CachePartition partition = createPartition(); | 982 CachePartition partition = createPartition(); |
| 966 AnalysisTarget target = new TestSource(); | 983 AnalysisTarget target = new TestSource(); |
| 967 CacheEntry entry = new CacheEntry(target); | 984 CacheEntry entry = new CacheEntry(target); |
| 968 partition.put(entry); | 985 partition.put(entry); |
| 969 Map<AnalysisTarget, CacheEntry> entryMap = partition.map; | 986 Map<AnalysisTarget, CacheEntry> entryMap = partition.entryMap; |
| 970 expect(entryMap, hasLength(1)); | 987 expect(entryMap, hasLength(1)); |
| 971 AnalysisTarget entryKey = entryMap.keys.first; | 988 AnalysisTarget entryKey = entryMap.keys.first; |
| 972 expect(entryKey, target); | 989 expect(entryKey, target); |
| 973 expect(entryMap[entryKey], entry); | 990 expect(entryMap[entryKey], entry); |
| 974 } | 991 } |
| 975 | 992 |
| 976 void test_get() { | 993 void test_get() { |
| 977 CachePartition partition = createPartition(); | 994 CachePartition partition = createPartition(); |
| 978 AnalysisTarget target = new TestSource(); | 995 AnalysisTarget target = new TestSource(); |
| 979 expect(partition.get(target), isNull); | 996 expect(partition.get(target), isNull); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1122 return DeltaResult.KEEP_CONTINUE; | 1139 return DeltaResult.KEEP_CONTINUE; |
| 1123 } | 1140 } |
| 1124 return DeltaResult.INVALIDATE; | 1141 return DeltaResult.INVALIDATE; |
| 1125 } | 1142 } |
| 1126 } | 1143 } |
| 1127 | 1144 |
| 1128 class _TestAnalysisTarget implements AnalysisTarget { | 1145 class _TestAnalysisTarget implements AnalysisTarget { |
| 1129 @override | 1146 @override |
| 1130 Source get source => null; | 1147 Source get source => null; |
| 1131 } | 1148 } |
| OLD | NEW |