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

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

Issue 2212093002: Fix for adding new elements into library cycles. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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
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 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 // The reason is that a.dart adds dependencies on (not existing) b.dart 480 // The reason is that a.dart adds dependencies on (not existing) b.dart
481 // results in cache. 481 // results in cache.
482 // Now a.dart does not have errors. 482 // Now a.dart does not have errors.
483 addSource('/b.dart', codeB); 483 addSource('/b.dart', codeB);
484 expect(getErrorsState(a), CacheState.INVALID); 484 expect(getErrorsState(a), CacheState.INVALID);
485 _performPendingAnalysisTasks(); 485 _performPendingAnalysisTasks();
486 expect(getErrorsState(a), CacheState.VALID); 486 expect(getErrorsState(a), CacheState.VALID);
487 expect(context.getErrors(a).errors, hasLength(0)); 487 expect(context.getErrors(a).errors, hasLength(0));
488 } 488 }
489 489
490 void test_applyChanges_addNewImport_invalidateLibraryCycle() {
491 context.analysisOptions =
492 new AnalysisOptionsImpl.from(context.analysisOptions)
493 ..strongMode = true;
494 Source embedder = addSource(
495 '/a.dart',
496 r'''
497 library a;
498 import 'b.dart';
499 //import 'c.dart';
500 ''');
501 addSource(
502 '/b.dart',
503 r'''
504 library b;
505 import 'a.dart';
506 ''');
507 addSource(
508 '/c.dart',
509 r'''
510 library c;
511 import 'b.dart';
512 ''');
513 _performPendingAnalysisTasks();
514 // Add a new import into a.dart, this should invalidate its library cycle.
515 // If it doesn't, we will get a task cycle exception.
516 context.setContents(
517 embedder,
518 r'''
519 library a;
520 import 'b.dart';
521 import 'c.dart';
522 ''');
523 _performPendingAnalysisTasks();
524 expect(context.getCacheEntry(embedder).exception, isNull);
525 }
526
490 void test_cacheConsistencyValidator_computed_deleted() { 527 void test_cacheConsistencyValidator_computed_deleted() {
491 CacheConsistencyValidator validator = context.cacheConsistencyValidator; 528 CacheConsistencyValidator validator = context.cacheConsistencyValidator;
492 var stat = PerformanceStatistics.cacheConsistencyValidationStatistics; 529 var stat = PerformanceStatistics.cacheConsistencyValidationStatistics;
493 stat.reset(); 530 stat.reset();
494 // Add sources. 531 // Add sources.
495 MemoryResourceProvider resourceProvider = new MemoryResourceProvider(); 532 MemoryResourceProvider resourceProvider = new MemoryResourceProvider();
496 String path1 = '/test1.dart'; 533 String path1 = '/test1.dart';
497 String path2 = '/test2.dart'; 534 String path2 = '/test2.dart';
498 Source source1 = resourceProvider.newFile(path1, '// 1-1').createSource(); 535 Source source1 = resourceProvider.newFile(path1, '// 1-1').createSource();
499 Source source2 = resourceProvider.newFile(path2, '// 2-1').createSource(); 536 Source source2 = resourceProvider.newFile(path2, '// 2-1').createSource();
(...skipping 4644 matching lines...) Expand 10 before | Expand all | Expand 10 after
5144 * Initialize the visitor. 5181 * Initialize the visitor.
5145 */ 5182 */
5146 _ElementGatherer(); 5183 _ElementGatherer();
5147 5184
5148 @override 5185 @override
5149 void visitElement(Element element) { 5186 void visitElement(Element element) {
5150 elements[element] = element; 5187 elements[element] = element;
5151 super.visitElement(element); 5188 super.visitElement(element);
5152 } 5189 }
5153 } 5190 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/element.dart ('k') | pkg/analyzer/test/src/task/dart_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698