Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(400)

Side by Side Diff: pkg/analyzer/test/src/context/cache_test.dart

Issue 1129173003: Flush memento objects. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analyzer/lib/src/context/cache.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 ResultCachingPolicy cachingPolicy = new SimpleResultCachingPolicy(2, 2); 413 ResultCachingPolicy cachingPolicy = new SimpleResultCachingPolicy(2, 2);
414 ResultDescriptor descriptor1 = 414 ResultDescriptor descriptor1 =
415 new ResultDescriptor('result1', null, cachingPolicy: cachingPolicy); 415 new ResultDescriptor('result1', null, cachingPolicy: cachingPolicy);
416 ResultDescriptor descriptor2 = 416 ResultDescriptor descriptor2 =
417 new ResultDescriptor('result2', null, cachingPolicy: cachingPolicy); 417 new ResultDescriptor('result2', null, cachingPolicy: cachingPolicy);
418 ResultDescriptor descriptor3 = 418 ResultDescriptor descriptor3 =
419 new ResultDescriptor('result3', null, cachingPolicy: cachingPolicy); 419 new ResultDescriptor('result3', null, cachingPolicy: cachingPolicy);
420 AnalysisTarget target = new TestSource(); 420 AnalysisTarget target = new TestSource();
421 CacheEntry entry = new CacheEntry(); 421 CacheEntry entry = new CacheEntry();
422 cache.put(target, entry); 422 cache.put(target, entry);
423 Object memento1 = 'aaa';
423 { 424 {
424 entry.setValue(descriptor1, 1, TargetedResult.EMPTY_LIST, null); 425 entry.setValue(descriptor1, 1, TargetedResult.EMPTY_LIST, memento1);
425 expect(entry.getState(descriptor1), CacheState.VALID); 426 expect(entry.getState(descriptor1), CacheState.VALID);
427 expect(entry.getMemento(descriptor1), memento1);
426 } 428 }
427 { 429 {
428 entry.setValue(descriptor2, 2, TargetedResult.EMPTY_LIST, null); 430 entry.setValue(descriptor2, 2, TargetedResult.EMPTY_LIST, null);
429 expect(entry.getState(descriptor1), CacheState.VALID); 431 expect(entry.getState(descriptor1), CacheState.VALID);
430 expect(entry.getState(descriptor2), CacheState.VALID); 432 expect(entry.getState(descriptor2), CacheState.VALID);
431 } 433 }
432 { 434 {
433 entry.setValue(descriptor3, 3, TargetedResult.EMPTY_LIST, null); 435 entry.setValue(descriptor3, 3, TargetedResult.EMPTY_LIST, null);
434 expect(entry.getState(descriptor1), CacheState.FLUSHED); 436 expect(entry.getState(descriptor1), CacheState.FLUSHED);
435 expect(entry.getState(descriptor2), CacheState.VALID); 437 expect(entry.getState(descriptor2), CacheState.VALID);
436 expect(entry.getState(descriptor3), CacheState.VALID); 438 expect(entry.getState(descriptor3), CacheState.VALID);
439 expect(entry.getMemento(descriptor1), isNull);
437 } 440 }
438 } 441 }
439 442
440 test_setValue_invalidateDependent() { 443 test_setValue_invalidateDependent() {
441 AnalysisTarget target = new TestSource(); 444 AnalysisTarget target = new TestSource();
442 CacheEntry entry = new CacheEntry(); 445 CacheEntry entry = new CacheEntry();
443 cache.put(target, entry); 446 cache.put(target, entry);
444 ResultDescriptor result1 = new ResultDescriptor('result1', -1); 447 ResultDescriptor result1 = new ResultDescriptor('result1', -1);
445 ResultDescriptor result2 = new ResultDescriptor('result2', -2); 448 ResultDescriptor result2 = new ResultDescriptor('result2', -2);
446 ResultDescriptor result3 = new ResultDescriptor('result3', -3); 449 ResultDescriptor result3 = new ResultDescriptor('result3', -3);
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 713
711 @reflectiveTest 714 @reflectiveTest
712 class ResultDataTest extends EngineTestCase { 715 class ResultDataTest extends EngineTestCase {
713 test_creation() { 716 test_creation() {
714 String value = 'value'; 717 String value = 'value';
715 ResultData data = new ResultData(new ResultDescriptor('test', value)); 718 ResultData data = new ResultData(new ResultDescriptor('test', value));
716 expect(data, isNotNull); 719 expect(data, isNotNull);
717 expect(data.state, CacheState.INVALID); 720 expect(data.state, CacheState.INVALID);
718 expect(data.value, value); 721 expect(data.value, value);
719 } 722 }
723
724 test_flush() {
725 ResultDescriptor result = new ResultDescriptor('test', -1);
726 ResultData data = new ResultData(result);
727 data.state = CacheState.VALID;
728 data.value = 123;
729 data.memento = 'abc';
730 data.flush();
731 expect(data.state, CacheState.FLUSHED);
732 expect(data.value, -1);
733 expect(data.memento, isNull);
734 }
720 } 735 }
721 736
722 @reflectiveTest 737 @reflectiveTest
723 class SdkCachePartitionTest extends CachePartitionTest { 738 class SdkCachePartitionTest extends CachePartitionTest {
724 CachePartition createPartition() { 739 CachePartition createPartition() {
725 return new SdkCachePartition(null); 740 return new SdkCachePartition(null);
726 } 741 }
727 742
728 void test_contains_false() { 743 void test_contains_false() {
729 CachePartition partition = createPartition(); 744 CachePartition partition = createPartition();
(...skipping 20 matching lines...) Expand all
750 UniversalCachePartition partition = new UniversalCachePartition(null); 765 UniversalCachePartition partition = new UniversalCachePartition(null);
751 TestSource source = new TestSource(); 766 TestSource source = new TestSource();
752 expect(partition.contains(source), isTrue); 767 expect(partition.contains(source), isTrue);
753 } 768 }
754 } 769 }
755 770
756 class _InternalAnalysisContextMock extends TypedMock 771 class _InternalAnalysisContextMock extends TypedMock
757 implements InternalAnalysisContext { 772 implements InternalAnalysisContext {
758 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 773 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
759 } 774 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/context/cache.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698