| 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/ast.dart'; | 8 import 'package:analyzer/src/generated/ast.dart'; |
| 9 import 'package:analyzer/src/generated/engine.dart' | 9 import 'package:analyzer/src/generated/engine.dart' |
| 10 show AnalysisContext, CacheState, RetentionPriority; | 10 show AnalysisContext, CacheState, RetentionPriority; |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 expect(entry.getState(result1), CacheState.ERROR); | 268 expect(entry.getState(result1), CacheState.ERROR); |
| 269 expect(entry.getState(result2), CacheState.ERROR); | 269 expect(entry.getState(result2), CacheState.ERROR); |
| 270 expect(entry.getState(result3), CacheState.VALID); | 270 expect(entry.getState(result3), CacheState.VALID); |
| 271 expect(entry.getValue(result1), 1); | 271 expect(entry.getValue(result1), 1); |
| 272 expect(entry.getValue(result2), 2); | 272 expect(entry.getValue(result2), 2); |
| 273 expect(entry.getValue(result3), 30); | 273 expect(entry.getValue(result3), 30); |
| 274 } | 274 } |
| 275 | 275 |
| 276 test_setErrorState_invalidateDependent() { | 276 test_setErrorState_invalidateDependent() { |
| 277 AnalysisCache cache = createCache(); | 277 AnalysisCache cache = createCache(); |
| 278 AnalysisTarget target = new TestSource(); | 278 AnalysisTarget target1 = new TestSource('/a.dart'); |
| 279 CacheEntry entry = new CacheEntry(); | 279 AnalysisTarget target2 = new TestSource('/b.dart'); |
| 280 cache.put(target, entry); | 280 CacheEntry entry1 = new CacheEntry(); |
| 281 CacheEntry entry2 = new CacheEntry(); |
| 282 cache.put(target1, entry1); |
| 283 cache.put(target2, entry2); |
| 281 ResultDescriptor result1 = new ResultDescriptor('result1', -1); | 284 ResultDescriptor result1 = new ResultDescriptor('result1', -1); |
| 282 ResultDescriptor result2 = new ResultDescriptor('result2', -2); | 285 ResultDescriptor result2 = new ResultDescriptor('result2', -2); |
| 283 ResultDescriptor result3 = new ResultDescriptor('result3', -3); | 286 ResultDescriptor result3 = new ResultDescriptor('result3', -3); |
| 284 ResultDescriptor result4 = new ResultDescriptor('result4', -4); | 287 ResultDescriptor result4 = new ResultDescriptor('result4', -4); |
| 285 // set results, all of them are VALID | 288 // set results, all of them are VALID |
| 286 entry.setValue(result1, 111, TargetedResult.EMPTY_LIST, null); | 289 entry1.setValue(result1, 111, TargetedResult.EMPTY_LIST, null); |
| 287 entry.setValue(result2, 222, [new TargetedResult(target, result1)], null); | 290 entry2.setValue(result2, 222, [new TargetedResult(target1, result1)], null); |
| 288 entry.setValue(result3, 333, [new TargetedResult(target, result2)], null); | 291 entry2.setValue(result3, 333, [new TargetedResult(target2, result2)], null); |
| 289 entry.setValue(result4, 444, [], null); | 292 entry2.setValue(result4, 444, [], null); |
| 290 expect(entry.getState(result1), CacheState.VALID); | 293 expect(entry1.getState(result1), CacheState.VALID); |
| 291 expect(entry.getState(result2), CacheState.VALID); | 294 expect(entry2.getState(result2), CacheState.VALID); |
| 292 expect(entry.getState(result3), CacheState.VALID); | 295 expect(entry2.getState(result3), CacheState.VALID); |
| 293 expect(entry.getState(result4), CacheState.VALID); | 296 expect(entry2.getState(result4), CacheState.VALID); |
| 294 expect(entry.getValue(result1), 111); | 297 expect(entry1.getValue(result1), 111); |
| 295 expect(entry.getValue(result2), 222); | 298 expect(entry2.getValue(result2), 222); |
| 296 expect(entry.getValue(result3), 333); | 299 expect(entry2.getValue(result3), 333); |
| 297 expect(entry.getValue(result4), 444); | 300 expect(entry2.getValue(result4), 444); |
| 298 // set error state | 301 // set error state |
| 299 CaughtException exception = new CaughtException(null, null); | 302 CaughtException exception = new CaughtException(null, null); |
| 300 entry.setErrorState(exception, <ResultDescriptor>[result1]); | 303 entry1.setErrorState(exception, <ResultDescriptor>[result1]); |
| 301 // result2 and result3 are invalidated, result4 is intact | 304 // result2 and result3 are invalidated, result4 is intact |
| 302 expect(entry.getState(result1), CacheState.ERROR); | 305 expect(entry1.getState(result1), CacheState.ERROR); |
| 303 expect(entry.getState(result2), CacheState.ERROR); | 306 expect(entry2.getState(result2), CacheState.ERROR); |
| 304 expect(entry.getState(result3), CacheState.ERROR); | 307 expect(entry2.getState(result3), CacheState.ERROR); |
| 305 expect(entry.getState(result4), CacheState.VALID); | 308 expect(entry2.getState(result4), CacheState.VALID); |
| 306 expect(entry.getValue(result1), -1); | 309 expect(entry1.getValue(result1), -1); |
| 307 expect(entry.getValue(result2), -2); | 310 expect(entry2.getValue(result2), -2); |
| 308 expect(entry.getValue(result3), -3); | 311 expect(entry2.getValue(result3), -3); |
| 309 expect(entry.getValue(result4), 444); | 312 expect(entry2.getValue(result4), 444); |
| 313 expect(entry1.exception, exception); |
| 314 expect(entry2.exception, exception); |
| 310 } | 315 } |
| 311 | 316 |
| 312 test_setErrorState_noDescriptors() { | 317 test_setErrorState_noDescriptors() { |
| 313 CaughtException exception = new CaughtException(null, null); | 318 CaughtException exception = new CaughtException(null, null); |
| 314 CacheEntry entry = new CacheEntry(); | 319 CacheEntry entry = new CacheEntry(); |
| 315 expect(() { | 320 expect(() { |
| 316 entry.setErrorState(exception, <ResultDescriptor>[]); | 321 entry.setErrorState(exception, <ResultDescriptor>[]); |
| 317 }, throwsArgumentError); | 322 }, throwsArgumentError); |
| 318 } | 323 } |
| 319 | 324 |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 return new UniversalCachePartition(null, 8, policy); | 657 return new UniversalCachePartition(null, 8, policy); |
| 653 } | 658 } |
| 654 | 659 |
| 655 void test_contains() { | 660 void test_contains() { |
| 656 UniversalCachePartition partition = | 661 UniversalCachePartition partition = |
| 657 new UniversalCachePartition(null, 8, null); | 662 new UniversalCachePartition(null, 8, null); |
| 658 TestSource source = new TestSource(); | 663 TestSource source = new TestSource(); |
| 659 expect(partition.contains(source), isTrue); | 664 expect(partition.contains(source), isTrue); |
| 660 } | 665 } |
| 661 } | 666 } |
| OLD | NEW |