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

Side by Side Diff: test/testing.dart

Issue 1395643004: remove most of the StrongOptions (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: rebase Created 5 years, 2 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 | « test/checker/inferred_type_test.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 dev_compiler.src.testing; 5 library dev_compiler.src.testing;
6 6
7 import 'dart:mirrors'; 7 import 'dart:mirrors';
8 import 'package:analyzer/file_system/file_system.dart'; 8 import 'package:analyzer/file_system/file_system.dart';
9 import 'package:analyzer/file_system/memory_file_system.dart'; 9 import 'package:analyzer/file_system/memory_file_system.dart';
10 import 'package:analyzer/src/generated/ast.dart'; 10 import 'package:analyzer/src/generated/ast.dart';
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 /// 66 ///
67 /// testChecker({ 67 /// testChecker({
68 /// '/main.dart': ''' 68 /// '/main.dart': '''
69 /// testMethod() { 69 /// testMethod() {
70 /// dynamic x = /*warning:Box*/3; 70 /// dynamic x = /*warning:Box*/3;
71 /// } 71 /// }
72 /// ''' 72 /// '''
73 /// }); 73 /// });
74 /// 74 ///
75 void testChecker(String name, Map<String, String> testFiles, 75 void testChecker(String name, Map<String, String> testFiles,
76 {String sdkDir, 76 {String sdkDir, customUrlMappings: const {}}) {
77 customUrlMappings: const {},
78 relaxedCasts: true,
79 inferDownwards: StrongModeOptions.inferDownwardsDefault,
80 inferTransitively: StrongModeOptions.inferTransitivelyDefault}) {
81 test(name, () { 77 test(name, () {
82 expect(testFiles.containsKey('/main.dart'), isTrue, 78 expect(testFiles.containsKey('/main.dart'), isTrue,
83 reason: '`/main.dart` is missing in testFiles'); 79 reason: '`/main.dart` is missing in testFiles');
84 80
85 var provider = createTestResourceProvider(testFiles); 81 var provider = createTestResourceProvider(testFiles);
86 var uriResolver = new TestUriResolver(provider); 82 var uriResolver = new TestUriResolver(provider);
87 // Enable task model strong mode 83 // Enable task model strong mode
88 AnalysisEngine.instance.useTaskModel = true; 84 AnalysisEngine.instance.useTaskModel = true;
89 var context = AnalysisEngine.instance.createAnalysisContext(); 85 var context = AnalysisEngine.instance.createAnalysisContext();
90 context.analysisOptions.strongMode = true; 86 context.analysisOptions.strongMode = true;
91 context.sourceFactory = createSourceFactory( 87 context.sourceFactory = createSourceFactory(
92 new SourceResolverOptions( 88 new SourceResolverOptions(
93 customUrlMappings: customUrlMappings, 89 customUrlMappings: customUrlMappings,
94 useMockSdk: sdkDir == null, 90 useMockSdk: sdkDir == null,
95 dartSdkPath: sdkDir), 91 dartSdkPath: sdkDir),
96 fileResolvers: [uriResolver]); 92 fileResolvers: [uriResolver]);
97 93
98 var checker = new StrongChecker( 94 var checker =
99 context, 95 new StrongChecker(context, new StrongModeOptions(hints: true));
100 new StrongModeOptions(
101 relaxedCasts: relaxedCasts,
102 inferDownwards: inferDownwards,
103 inferTransitively: inferTransitively,
104 hints: true));
105 96
106 // Run the checker on /main.dart. 97 // Run the checker on /main.dart.
107 var mainSource = uriResolver.resolveAbsolute(new Uri.file('/main.dart')); 98 var mainSource = uriResolver.resolveAbsolute(new Uri.file('/main.dart'));
108 var initialLibrary = 99 var initialLibrary =
109 context.resolveCompilationUnit2(mainSource, mainSource); 100 context.resolveCompilationUnit2(mainSource, mainSource);
110 101
111 // Extract expectations from the comments in the test files, and 102 // Extract expectations from the comments in the test files, and
112 // check that all errors we emit are included in the expected map. 103 // check that all errors we emit are included in the expected map.
113 var allLibraries = reachableLibraries(initialLibrary.element.library); 104 var allLibraries = reachableLibraries(initialLibrary.element.library);
114 for (var lib in allLibraries) { 105 for (var lib in allLibraries) {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 expect(tokens[1], "should", reason: 'invalid error descriptor'); 267 expect(tokens[1], "should", reason: 'invalid error descriptor');
277 expect(tokens[2], "be", reason: 'invalid error descriptor'); 268 expect(tokens[2], "be", reason: 'invalid error descriptor');
278 if (tokens[0] == "pass") return null; 269 if (tokens[0] == "pass") return null;
279 // TODO(leafp) For now, we just use whatever the current expectation is, 270 // TODO(leafp) For now, we just use whatever the current expectation is,
280 // eventually we could do more automated reporting here. 271 // eventually we could do more automated reporting here.
281 return _parse(tokens[0]); 272 return _parse(tokens[0]);
282 } 273 }
283 274
284 String toString() => '$level $typeName'; 275 String toString() => '$level $typeName';
285 } 276 }
OLDNEW
« no previous file with comments | « test/checker/inferred_type_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698