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

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

Issue 2657533004: Update MockSdk to be more consistent with the actual SDK, switch x_Driver tests to it. (Closed)
Patch Set: Created 3 years, 10 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 12 matching lines...) Expand all
23 import 'package:analyzer/src/error/codes.dart'; 23 import 'package:analyzer/src/error/codes.dart';
24 import 'package:analyzer/src/generated/engine.dart' hide AnalysisResult; 24 import 'package:analyzer/src/generated/engine.dart' hide AnalysisResult;
25 import 'package:analyzer/src/generated/java_engine.dart'; 25 import 'package:analyzer/src/generated/java_engine.dart';
26 import 'package:analyzer/src/generated/resolver.dart'; 26 import 'package:analyzer/src/generated/resolver.dart';
27 import 'package:analyzer/src/generated/sdk.dart'; 27 import 'package:analyzer/src/generated/sdk.dart';
28 import 'package:analyzer/src/generated/source_io.dart'; 28 import 'package:analyzer/src/generated/source_io.dart';
29 import 'package:analyzer/src/generated/testing/ast_test_factory.dart'; 29 import 'package:analyzer/src/generated/testing/ast_test_factory.dart';
30 import 'package:analyzer/src/generated/testing/element_factory.dart'; 30 import 'package:analyzer/src/generated/testing/element_factory.dart';
31 import 'package:test/test.dart'; 31 import 'package:test/test.dart';
32 32
33 import '../src/dart/analysis/physical_sdk.dart' as physical_sdk; 33 import '../src/context/mock_sdk.dart';
34 import 'analysis_context_factory.dart'; 34 import 'analysis_context_factory.dart';
35 import 'test_support.dart'; 35 import 'test_support.dart';
36 36
37 /** 37 /**
38 * An AST visitor used to verify that all of the nodes in an AST structure that 38 * An AST visitor used to verify that all of the nodes in an AST structure that
39 * should have been resolved were resolved. 39 * should have been resolved were resolved.
40 */ 40 */
41 class ResolutionVerifier extends RecursiveAstVisitor<Object> { 41 class ResolutionVerifier extends RecursiveAstVisitor<Object> {
42 /** 42 /**
43 * A set containing nodes that are known to not be resolvable and should 43 * A set containing nodes that are known to not be resolvable and should
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 /** 648 /**
649 * Re-create the analysis context being used by the test with the either given 649 * Re-create the analysis context being used by the test with the either given
650 * [options] or [packages]. 650 * [options] or [packages].
651 */ 651 */
652 void resetWith({AnalysisOptions options, List<List<String>> packages}) { 652 void resetWith({AnalysisOptions options, List<List<String>> packages}) {
653 if (options != null && packages != null) { 653 if (options != null && packages != null) {
654 fail('Only packages or options can be specified.'); 654 fail('Only packages or options can be specified.');
655 } 655 }
656 if (enableNewAnalysisDriver) { 656 if (enableNewAnalysisDriver) {
657 options ??= new AnalysisOptionsImpl(); 657 options ??= new AnalysisOptionsImpl();
658 DartSdk sdk = 658 DartSdk sdk = new MockSdk(resourceProvider: resourceProvider)
659 options.strongMode ? physical_sdk.strongSdk : physical_sdk.sdk; 659 ..context.analysisOptions = options;
660 660
661 List<UriResolver> resolvers = <UriResolver>[ 661 List<UriResolver> resolvers = <UriResolver>[
662 new DartUriResolver(sdk), 662 new DartUriResolver(sdk),
663 new ResourceUriResolver(resourceProvider) 663 new ResourceUriResolver(resourceProvider)
664 ]; 664 ];
665 if (packages != null) { 665 if (packages != null) {
666 var packageMap = <String, List<Folder>>{}; 666 var packageMap = <String, List<Folder>>{};
667 packages.forEach((args) { 667 packages.forEach((args) {
668 String name = args[0]; 668 String name = args[0];
669 String path = 669 String path =
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 @override 788 @override
789 void setUp() { 789 void setUp() {
790 ElementFactory.flushStaticState(); 790 ElementFactory.flushStaticState();
791 super.setUp(); 791 super.setUp();
792 reset(); 792 reset();
793 } 793 }
794 794
795 @override 795 @override
796 void tearDown() { 796 void tearDown() {
797 analysisContext2 = null; 797 analysisContext2 = null;
798 AnalysisEngine.instance.clearCaches();
798 super.tearDown(); 799 super.tearDown();
799 } 800 }
800 801
801 /** 802 /**
802 * Verify that all of the identifiers in the compilation units associated with 803 * Verify that all of the identifiers in the compilation units associated with
803 * the given [sources] have been resolved. 804 * the given [sources] have been resolved.
804 */ 805 */
805 void verify(List<Source> sources) { 806 void verify(List<Source> sources) {
806 ResolutionVerifier verifier = new ResolutionVerifier(); 807 ResolutionVerifier verifier = new ResolutionVerifier();
807 for (Source source in sources) { 808 for (Source source in sources) {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 } 929 }
929 } 930 }
930 } 931 }
931 932
932 class TestAnalysisResult { 933 class TestAnalysisResult {
933 final Source source; 934 final Source source;
934 final CompilationUnit unit; 935 final CompilationUnit unit;
935 final List<AnalysisError> errors; 936 final List<AnalysisError> errors;
936 TestAnalysisResult(this.source, this.unit, this.errors); 937 TestAnalysisResult(this.source, this.unit, this.errors);
937 } 938 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/compile_time_error_code_test.dart ('k') | pkg/analyzer/test/src/context/mock_sdk.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698