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

Side by Side Diff: lib/src/testing.dart

Issue 1038213003: Downward inference (Closed) Base URL: git@github.com:dart-lang/dart-dev-compiler.git@master
Patch Set: Small fixes Created 5 years, 8 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) 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 'package:analyzer/src/generated/ast.dart'; 7 import 'package:analyzer/src/generated/ast.dart';
8 import 'package:analyzer/src/generated/element.dart'; 8 import 'package:analyzer/src/generated/element.dart';
9 import 'package:analyzer/src/generated/engine.dart' show TimestampedData; 9 import 'package:analyzer/src/generated/engine.dart' show TimestampedData;
10 import 'package:analyzer/src/generated/source.dart'; 10 import 'package:analyzer/src/generated/source.dart';
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 /// '/main.dart': ''' 45 /// '/main.dart': '''
46 /// testMethod() { 46 /// testMethod() {
47 /// dynamic x = /*warning:Box*/3; 47 /// dynamic x = /*warning:Box*/3;
48 /// } 48 /// }
49 /// ''' 49 /// '''
50 /// }); 50 /// });
51 /// 51 ///
52 CheckerResults testChecker(Map<String, String> testFiles, 52 CheckerResults testChecker(Map<String, String> testFiles,
53 {bool allowConstCasts: true, String sdkDir, CheckerReporter reporter, 53 {bool allowConstCasts: true, String sdkDir, CheckerReporter reporter,
54 covariantGenerics: true, relaxedCasts: true, 54 covariantGenerics: true, relaxedCasts: true,
55 inferDownwards: RulesOptions.inferDownwardsDefault,
55 inferFromOverrides: ResolverOptions.inferFromOverridesDefault, 56 inferFromOverrides: ResolverOptions.inferFromOverridesDefault,
56 inferTransitively: ResolverOptions.inferTransitivelyDefault, 57 inferTransitively: ResolverOptions.inferTransitivelyDefault,
57 nonnullableTypes: TypeOptions.NONNULLABLE_TYPES}) { 58 nonnullableTypes: TypeOptions.NONNULLABLE_TYPES}) {
58 expect(testFiles.containsKey('/main.dart'), isTrue, 59 expect(testFiles.containsKey('/main.dart'), isTrue,
59 reason: '`/main.dart` is missing in testFiles'); 60 reason: '`/main.dart` is missing in testFiles');
60 61
61 // Create a resolver that can load test files from memory. 62 // Create a resolver that can load test files from memory.
62 var testUriResolver = new TestUriResolver(testFiles); 63 var testUriResolver = new TestUriResolver(testFiles);
63 var options = new CompilerOptions( 64 var options = new CompilerOptions(
64 allowConstCasts: allowConstCasts, 65 allowConstCasts: allowConstCasts,
65 covariantGenerics: covariantGenerics, 66 covariantGenerics: covariantGenerics,
66 relaxedCasts: relaxedCasts, 67 relaxedCasts: relaxedCasts,
68 inferDownwards: inferDownwards,
67 inferFromOverrides: inferFromOverrides, 69 inferFromOverrides: inferFromOverrides,
68 inferTransitively: inferTransitively, 70 inferTransitively: inferTransitively,
69 nonnullableTypes: nonnullableTypes, 71 nonnullableTypes: nonnullableTypes,
70 useMockSdk: sdkDir == null, 72 useMockSdk: sdkDir == null,
71 dartSdkPath: sdkDir, 73 dartSdkPath: sdkDir,
72 runtimeDir: '/dev_compiler_runtime/', 74 runtimeDir: '/dev_compiler_runtime/',
73 entryPointFile: '/main.dart'); 75 entryPointFile: '/main.dart');
74 var resolver = sdkDir == null 76 var resolver = sdkDir == null
75 ? new TypeResolver.fromMock(mockSdkSources, options, 77 ? new TypeResolver.fromMock(mockSdkSources, options,
76 otherResolvers: [testUriResolver]) 78 otherResolvers: [testUriResolver])
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 338
337 SourceSpan spanFor(AstNode node) { 339 SourceSpan spanFor(AstNode node) {
338 final begin = node is AnnotatedNode 340 final begin = node is AnnotatedNode
339 ? node.firstTokenAfterCommentAndMetadata.offset 341 ? node.firstTokenAfterCommentAndMetadata.offset
340 : node.offset; 342 : node.offset;
341 return _file.span(begin, node.end); 343 return _file.span(begin, node.end);
342 } 344 }
343 345
344 String toString() => '[$runtimeType: $uri]'; 346 String toString() => '[$runtimeType: $uri]';
345 } 347 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698