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

Side by Side Diff: pkg/analyzer/test/src/task/strong/strong_test_helper.dart

Issue 2093523002: fix #25573, add option to disable implicit dynamic (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Merge remote-tracking branch 'origin/master' into no_implicit_dynamic 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/test/src/task/strong/checker_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 // TODO(jmesserly): this file needs to be refactored, it's a port from 5 // TODO(jmesserly): this file needs to be refactored, it's a port from
6 // package:dev_compiler's tests 6 // package:dev_compiler's tests
7 library analyzer.test.src.task.strong.strong_test_helper; 7 library analyzer.test.src.task.strong.strong_test_helper;
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/token.dart'; 10 import 'package:analyzer/dart/ast/token.dart';
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 files.newFile(name, content); 47 files.newFile(name, content);
48 } 48 }
49 49
50 /// Run the checker on a program, staring from '/main.dart', and verifies that 50 /// Run the checker on a program, staring from '/main.dart', and verifies that
51 /// errors/warnings/hints match the expected value. 51 /// errors/warnings/hints match the expected value.
52 /// 52 ///
53 /// See [addFile] for more information about how to encode expectations in 53 /// See [addFile] for more information about how to encode expectations in
54 /// the file text. 54 /// the file text.
55 /// 55 ///
56 /// Returns the main resolved library. This can be used for further checks. 56 /// Returns the main resolved library. This can be used for further checks.
57 CompilationUnit check({bool implicitCasts: true}) { 57 CompilationUnit check({bool implicitCasts: true, bool implicitDynamic: true}) {
58 _checkCalled = true; 58 _checkCalled = true;
59 59
60 expect(files.getFile('/main.dart').exists, true, 60 expect(files.getFile('/main.dart').exists, true,
61 reason: '`/main.dart` is missing'); 61 reason: '`/main.dart` is missing');
62 62
63 var uriResolver = new _TestUriResolver(files); 63 var uriResolver = new _TestUriResolver(files);
64 // Enable task model strong mode 64 // Enable task model strong mode
65 var context = AnalysisEngine.instance.createAnalysisContext(); 65 var context = AnalysisEngine.instance.createAnalysisContext();
66 AnalysisOptionsImpl options = context.analysisOptions as AnalysisOptionsImpl; 66 AnalysisOptionsImpl options = context.analysisOptions as AnalysisOptionsImpl;
67 options.strongMode = true; 67 options.strongMode = true;
68 options.strongModeHints = true; 68 options.strongModeHints = true;
69 options.implicitCasts = implicitCasts; 69 options.implicitCasts = implicitCasts;
70 options.implicitDynamic = implicitDynamic;
70 var mockSdk = new MockSdk(); 71 var mockSdk = new MockSdk();
71 mockSdk.context.analysisOptions.strongMode = true; 72 mockSdk.context.analysisOptions.strongMode = true;
72 context.sourceFactory = 73 context.sourceFactory =
73 new SourceFactory([new DartUriResolver(mockSdk), uriResolver]); 74 new SourceFactory([new DartUriResolver(mockSdk), uriResolver]);
74 75
75 // Run the checker on /main.dart. 76 // Run the checker on /main.dart.
76 Source mainSource = uriResolver.resolveAbsolute(new Uri.file('/main.dart')); 77 Source mainSource = uriResolver.resolveAbsolute(new Uri.file('/main.dart'));
77 var initialLibrary = context.resolveCompilationUnit2(mainSource, mainSource); 78 var initialLibrary = context.resolveCompilationUnit2(mainSource, mainSource);
78 79
79 var collector = new _ErrorCollector(context); 80 var collector = new _ErrorCollector(context);
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 395
395 @override 396 @override
396 Source resolveAbsolute(Uri uri, [Uri actualUri]) { 397 Source resolveAbsolute(Uri uri, [Uri actualUri]) {
397 if (uri.scheme == 'package') { 398 if (uri.scheme == 'package') {
398 return (provider.getResource('/packages/' + uri.path) as File) 399 return (provider.getResource('/packages/' + uri.path) as File)
399 .createSource(uri); 400 .createSource(uri);
400 } 401 }
401 return super.resolveAbsolute(uri, actualUri); 402 return super.resolveAbsolute(uri, actualUri);
402 } 403 }
403 } 404 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/task/strong/checker_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698