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

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

Issue 2134283002: When validating cache consistency, skip sources in content cache. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « pkg/analyzer/lib/src/context/context.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 analyzer.test.src.context.context_test; 5 library analyzer.test.src.context.context_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 String path2 = '/test2.dart'; 441 String path2 = '/test2.dart';
442 Source source1 = resourceProvider.newFile(path1, '// 1-1').createSource(); 442 Source source1 = resourceProvider.newFile(path1, '// 1-1').createSource();
443 Source source2 = resourceProvider.newFile(path2, '// 2-1').createSource(); 443 Source source2 = resourceProvider.newFile(path2, '// 2-1').createSource();
444 context.applyChanges( 444 context.applyChanges(
445 new ChangeSet()..addedSource(source1)..addedSource(source2)); 445 new ChangeSet()..addedSource(source1)..addedSource(source2));
446 // Same modification times. 446 // Same modification times.
447 expect( 447 expect(
448 validator.sourceModificationTimesComputed([source1, source2], 448 validator.sourceModificationTimesComputed([source1, source2],
449 [source1.modificationStamp, source2.modificationStamp]), 449 [source1.modificationStamp, source2.modificationStamp]),
450 isFalse); 450 isFalse);
451 // Add overlay
452 context.setContents(source1, '// 1-2');
453 expect(
454 validator.sourceModificationTimesComputed([source1, source2],
455 [source1.modificationStamp + 1, source2.modificationStamp]),
456 isFalse);
457 context.setContents(source1, null);
451 // Different modification times. 458 // Different modification times.
452 expect( 459 expect(
453 validator.sourceModificationTimesComputed([source1, source2], 460 validator.sourceModificationTimesComputed([source1, source2],
454 [source1.modificationStamp + 1, source2.modificationStamp]), 461 [source1.modificationStamp + 1, source2.modificationStamp]),
455 isTrue); 462 isTrue);
456 } 463 }
457 464
458 void test_cacheConsistencyValidator_getSources() { 465 void test_cacheConsistencyValidator_getSources() {
459 CacheConsistencyValidator validator = context.cacheConsistencyValidator; 466 CacheConsistencyValidator validator = context.cacheConsistencyValidator;
460 // Add sources. 467 // Add sources.
461 MemoryResourceProvider resourceProvider = new MemoryResourceProvider(); 468 MemoryResourceProvider resourceProvider = new MemoryResourceProvider();
462 String path1 = '/test1.dart'; 469 String path1 = '/test1.dart';
463 String path2 = '/test2.dart'; 470 String path2 = '/test2.dart';
464 Source source1 = resourceProvider.newFile(path1, '// 1-1').createSource(); 471 Source source1 = resourceProvider.newFile(path1, '// 1-1').createSource();
465 Source source2 = resourceProvider.newFile(path2, '// 2-1').createSource(); 472 Source source2 = resourceProvider.newFile(path2, '// 2-1').createSource();
466 context.applyChanges( 473 context.applyChanges(
467 new ChangeSet()..addedSource(source1)..addedSource(source2)); 474 new ChangeSet()..addedSource(source1)..addedSource(source2));
468 // No overlays. 475 // Verify.
469 expect(validator.getSourcesToComputeModificationTimes(),
470 unorderedEquals([source1, source2]));
471 // Add an overlay.
472 context.setContents(source1, '// 1-2');
473 expect(validator.getSourcesToComputeModificationTimes(),
474 unorderedEquals([source2]));
475 // Remove an overlay.
476 context.setContents(source1, null);
477 expect(validator.getSourcesToComputeModificationTimes(), 476 expect(validator.getSourcesToComputeModificationTimes(),
478 unorderedEquals([source1, source2])); 477 unorderedEquals([source1, source2]));
479 } 478 }
480 479
481 void test_computeDocumentationComment_class_block() { 480 void test_computeDocumentationComment_class_block() {
482 String comment = "/** Comment */"; 481 String comment = "/** Comment */";
483 Source source = addSource( 482 Source source = addSource(
484 "/test.dart", 483 "/test.dart",
485 """ 484 """
486 $comment 485 $comment
(...skipping 3489 matching lines...) Expand 10 before | Expand all | Expand 10 after
3976 * Initialize the visitor. 3975 * Initialize the visitor.
3977 */ 3976 */
3978 _ElementGatherer(); 3977 _ElementGatherer();
3979 3978
3980 @override 3979 @override
3981 void visitElement(Element element) { 3980 void visitElement(Element element) {
3982 elements[element] = element; 3981 elements[element] = element;
3983 super.visitElement(element); 3982 super.visitElement(element);
3984 } 3983 }
3985 } 3984 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/context/context.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698