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

Side by Side Diff: pkg/analyzer/test/generated/resolver_test_case.dart

Issue 2628083002: Run more analysis tests with the new analysis driver. (Closed)
Patch Set: Created 3 years, 11 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) 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 library analyzer.test.generated.resolver_test_case; 5 library analyzer.test.generated.resolver_test_case;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; 10 import 'package:analyzer/dart/ast/standard_resolution_map.dart';
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 /** 510 /**
511 * Change the contents of the given [source] to the given [contents]. 511 * Change the contents of the given [source] to the given [contents].
512 */ 512 */
513 void changeSource(Source source, String contents) { 513 void changeSource(Source source, String contents) {
514 analysisContext2.setContents(source, contents); 514 analysisContext2.setContents(source, contents);
515 ChangeSet changeSet = new ChangeSet(); 515 ChangeSet changeSet = new ChangeSet();
516 changeSet.changedSource(source); 516 changeSet.changedSource(source);
517 analysisContext2.applyChanges(changeSet); 517 analysisContext2.applyChanges(changeSet);
518 } 518 }
519 519
520 Future<Null> computeAnalysisResult(Source source) async { 520 Future<TestAnalysisResult> computeAnalysisResult(Source source) async {
521 TestAnalysisResult analysisResult;
521 if (enableNewAnalysisDriver) { 522 if (enableNewAnalysisDriver) {
522 AnalysisResult result = await driver.getResult(source.fullName); 523 AnalysisResult result = await driver.getResult(source.fullName);
523 analysisResults[source] = 524 analysisResult =
524 new TestAnalysisResult(source, result.unit, result.errors); 525 new TestAnalysisResult(source, result.unit, result.errors);
525 } else { 526 } else {
526 analysisContext2.computeKindOf(source); 527 analysisContext2.computeKindOf(source);
527 List<Source> libraries = analysisContext2.getLibrariesContaining(source); 528 List<Source> libraries = analysisContext2.getLibrariesContaining(source);
528 if (libraries.length > 0) { 529 if (libraries.length > 0) {
529 CompilationUnit unit = 530 CompilationUnit unit =
530 analysisContext.resolveCompilationUnit2(source, libraries.first); 531 analysisContext.resolveCompilationUnit2(source, libraries.first);
531 List<AnalysisError> errors = analysisContext.computeErrors(source); 532 List<AnalysisError> errors = analysisContext.computeErrors(source);
532 analysisResults[source] = new TestAnalysisResult(source, unit, errors); 533 analysisResult = new TestAnalysisResult(source, unit, errors);
533 } 534 }
534 } 535 }
536 analysisResults[source] = analysisResult;
537 return analysisResult;
535 } 538 }
536 539
537 /** 540 /**
538 * Create a library element that represents a library named `"test"` containin g a single 541 * Create a library element that represents a library named `"test"` containin g a single
539 * empty compilation unit. 542 * empty compilation unit.
540 * 543 *
541 * @return the library element that was created 544 * @return the library element that was created
542 */ 545 */
543 LibraryElementImpl createDefaultTestLibrary() => 546 LibraryElementImpl createDefaultTestLibrary() =>
544 createTestLibrary(AnalysisContextFactory.contextWithCore(), "test"); 547 createTestLibrary(AnalysisContextFactory.contextWithCore(), "test");
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 912
910 SimpleIdentifier findIdentifier(String search) { 913 SimpleIdentifier findIdentifier(String search) {
911 SimpleIdentifier identifier = EngineTestCase.findNode( 914 SimpleIdentifier identifier = EngineTestCase.findNode(
912 testUnit, testCode, search, (node) => node is SimpleIdentifier); 915 testUnit, testCode, search, (node) => node is SimpleIdentifier);
913 return identifier; 916 return identifier;
914 } 917 }
915 918
916 Future<Null> resolveTestUnit(String code) async { 919 Future<Null> resolveTestUnit(String code) async {
917 testCode = code; 920 testCode = code;
918 testSource = addSource(testCode); 921 testSource = addSource(testCode);
919 LibraryElement library = resolve2(testSource); 922 TestAnalysisResult analysisResult = await computeAnalysisResult(testSource);
920 await computeAnalysisResult(testSource);
921 assertNoErrors(testSource); 923 assertNoErrors(testSource);
922 verify([testSource]); 924 verify([testSource]);
923 testUnit = resolveCompilationUnit(testSource, library); 925 testUnit = analysisResult.unit;
924 } 926 }
925 927
926 /** 928 /**
927 * Validates that [type] matches [expected]. 929 * Validates that [type] matches [expected].
928 * 930 *
929 * If [expected] is a string, validates that the type stringifies to that 931 * If [expected] is a string, validates that the type stringifies to that
930 * text. Otherwise, [expected] is used directly a [Matcher] to match the type. 932 * text. Otherwise, [expected] is used directly a [Matcher] to match the type.
931 */ 933 */
932 _expectType(DartType type, expected) { 934 _expectType(DartType type, expected) {
933 if (expected is String) { 935 if (expected is String) {
934 expect(type.toString(), expected); 936 expect(type.toString(), expected);
935 } else { 937 } else {
936 expect(type, expected); 938 expect(type, expected);
937 } 939 }
938 } 940 }
939 } 941 }
940 942
941 class TestAnalysisResult { 943 class TestAnalysisResult {
942 final Source source; 944 final Source source;
943 final CompilationUnit unit; 945 final CompilationUnit unit;
944 final List<AnalysisError> errors; 946 final List<AnalysisError> errors;
945 TestAnalysisResult(this.source, this.unit, this.errors); 947 TestAnalysisResult(this.source, this.unit, this.errors);
946 } 948 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/resolver_test.dart ('k') | pkg/analyzer/test/generated/static_type_analyzer_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698