OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'package:analyzer/dart/element/element.dart'; | 5 import 'package:analyzer/dart/element/element.dart'; |
| 6 import 'package:analyzer/src/generated/error.dart'; |
6 import 'package:analyzer/src/generated/source.dart'; | 7 import 'package:analyzer/src/generated/source.dart'; |
7 import 'package:analyzer/src/summary/incremental_cache.dart'; | 8 import 'package:analyzer/src/summary/incremental_cache.dart'; |
8 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
9 | 10 |
| 11 import '../../generated/test_support.dart'; |
10 import '../../reflective_tests.dart'; | 12 import '../../reflective_tests.dart'; |
11 import '../abstract_single_unit.dart'; | 13 import '../abstract_single_unit.dart'; |
12 | 14 |
13 main() { | 15 main() { |
14 groupSep = ' | '; | 16 groupSep = ' | '; |
15 runReflectiveTests(IncrementalCacheTest); | 17 runReflectiveTests(IncrementalCacheTest); |
16 } | 18 } |
17 | 19 |
18 /** | 20 /** |
19 * TODO(scheglov) write more tests for invalidation. | 21 * TODO(scheglov) write more tests for invalidation. |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 void test_getLibraryClosureBundles_onlyLibrary() { | 114 void test_getLibraryClosureBundles_onlyLibrary() { |
113 putTestLibrary(r''' | 115 putTestLibrary(r''' |
114 main() {} | 116 main() {} |
115 '''); | 117 '''); |
116 // the cache is empty, no bundles | 118 // the cache is empty, no bundles |
117 List<LibraryBundleWithId> bundles = | 119 List<LibraryBundleWithId> bundles = |
118 cache.getLibraryClosureBundles(testSource); | 120 cache.getLibraryClosureBundles(testSource); |
119 expect(bundles, isNotNull); | 121 expect(bundles, isNotNull); |
120 } | 122 } |
121 | 123 |
| 124 void test_getSourceErrorsInLibrary_library() { |
| 125 verifyNoTestUnitErrors = false; |
| 126 putTestLibrary(r''' |
| 127 main() { |
| 128 int unusedVar = 42; |
| 129 } |
| 130 '''); |
| 131 List<AnalysisError> computedErrors = context.computeErrors(testSource); |
| 132 cache.putSourceErrorsInLibrary(testSource, testSource, computedErrors); |
| 133 List<AnalysisError> readErrors = |
| 134 cache.getSourceErrorsInLibrary(testSource, testSource); |
| 135 new GatheringErrorListener() |
| 136 ..addAll(readErrors) |
| 137 ..assertErrors(computedErrors); |
| 138 } |
| 139 |
| 140 void test_getSourceErrorsInLibrary_part() { |
| 141 verifyNoTestUnitErrors = false; |
| 142 Source partSource = addSource( |
| 143 '/foo.dart', |
| 144 r''' |
| 145 main() { |
| 146 int unusedVar = 42; |
| 147 } |
| 148 '''); |
| 149 putTestLibrary(r''' |
| 150 library lib; |
| 151 part 'foo.dart'; |
| 152 '''); |
| 153 List<AnalysisError> computedErrors = context.computeErrors(partSource); |
| 154 cache.putSourceErrorsInLibrary(testSource, partSource, computedErrors); |
| 155 List<AnalysisError> readErrors = |
| 156 cache.getSourceErrorsInLibrary(testSource, partSource); |
| 157 new GatheringErrorListener() |
| 158 ..addAll(readErrors) |
| 159 ..assertErrors(computedErrors); |
| 160 } |
| 161 |
122 void test_getSourceKind_library() { | 162 void test_getSourceKind_library() { |
123 putTestLibrary(r''' | 163 putTestLibrary(r''' |
124 main() {} | 164 main() {} |
125 '''); | 165 '''); |
126 expect(cache.getSourceKind(testSource), SourceKind.LIBRARY); | 166 expect(cache.getSourceKind(testSource), SourceKind.LIBRARY); |
127 } | 167 } |
128 | 168 |
129 void test_getSourceKind_library_usedAsPart() { | 169 void test_getSourceKind_library_usedAsPart() { |
130 verifyNoTestUnitErrors = false; | 170 verifyNoTestUnitErrors = false; |
131 Source fooSource = addSource( | 171 Source fooSource = addSource( |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 @override | 218 @override |
179 List<int> get(String key) { | 219 List<int> get(String key) { |
180 return map[key]; | 220 return map[key]; |
181 } | 221 } |
182 | 222 |
183 @override | 223 @override |
184 void put(String key, List<int> bytes) { | 224 void put(String key, List<int> bytes) { |
185 map[key] = bytes; | 225 map[key] = bytes; |
186 } | 226 } |
187 } | 227 } |
OLD | NEW |