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

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

Issue 1011933002: Handle type-inference on fields, consts, and inferable overrides (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 9 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 /// dynamic x = /*warning:Box*/3; 45 /// dynamic x = /*warning:Box*/3;
46 /// } 46 /// }
47 /// ''' 47 /// '''
48 /// }); 48 /// });
49 /// 49 ///
50 CheckerResults testChecker(Map<String, String> testFiles, 50 CheckerResults testChecker(Map<String, String> testFiles,
51 {bool allowConstCasts: true, String sdkDir, CheckerReporter reporter, 51 {bool allowConstCasts: true, String sdkDir, CheckerReporter reporter,
52 covariantGenerics: true, relaxedCasts: true, 52 covariantGenerics: true, relaxedCasts: true,
53 inferFromOverrides: ResolverOptions.inferFromOverridesDefault, 53 inferFromOverrides: ResolverOptions.inferFromOverridesDefault,
54 inferStaticsFromIdentifiers: ResolverOptions.inferStaticsFromIdentifiersDefa ult, 54 inferStaticsFromIdentifiers: ResolverOptions.inferStaticsFromIdentifiersDefa ult,
55 inferInNonStableOrder: ResolverOptions.inferInNonStableOrderDefault,
56 nonnullableTypes: TypeOptions.NONNULLABLE_TYPES}) { 55 nonnullableTypes: TypeOptions.NONNULLABLE_TYPES}) {
57 expect(testFiles.containsKey('/main.dart'), isTrue, 56 expect(testFiles.containsKey('/main.dart'), isTrue,
58 reason: '`/main.dart` is missing in testFiles'); 57 reason: '`/main.dart` is missing in testFiles');
59 58
60 // Create a resolver that can load test files from memory. 59 // Create a resolver that can load test files from memory.
61 var testUriResolver = new TestUriResolver(testFiles); 60 var testUriResolver = new TestUriResolver(testFiles);
62 var options = new CompilerOptions( 61 var options = new CompilerOptions(
63 allowConstCasts: allowConstCasts, 62 allowConstCasts: allowConstCasts,
64 covariantGenerics: covariantGenerics, 63 covariantGenerics: covariantGenerics,
65 relaxedCasts: relaxedCasts, 64 relaxedCasts: relaxedCasts,
66 inferFromOverrides: inferFromOverrides, 65 inferFromOverrides: inferFromOverrides,
67 inferStaticsFromIdentifiers: inferStaticsFromIdentifiers, 66 inferStaticsFromIdentifiers: inferStaticsFromIdentifiers,
68 inferInNonStableOrder: inferInNonStableOrder,
69 nonnullableTypes: nonnullableTypes, 67 nonnullableTypes: nonnullableTypes,
70 useMockSdk: sdkDir == null, 68 useMockSdk: sdkDir == null,
71 dartSdkPath: sdkDir, 69 dartSdkPath: sdkDir,
72 entryPointFile: '/main.dart'); 70 entryPointFile: '/main.dart');
73 var resolver = sdkDir == null 71 var resolver = sdkDir == null
74 ? new TypeResolver.fromMock(mockSdkSources, options, 72 ? new TypeResolver.fromMock(mockSdkSources, options,
75 otherResolvers: [testUriResolver]) 73 otherResolvers: [testUriResolver])
76 : new TypeResolver.fromDir(sdkDir, options, 74 : new TypeResolver.fromDir(sdkDir, options,
77 otherResolvers: [testUriResolver]); 75 otherResolvers: [testUriResolver]);
78 76
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 327
330 SourceSpan spanFor(AstNode node) { 328 SourceSpan spanFor(AstNode node) {
331 final begin = node is AnnotatedNode 329 final begin = node is AnnotatedNode
332 ? node.firstTokenAfterCommentAndMetadata.offset 330 ? node.firstTokenAfterCommentAndMetadata.offset
333 : node.offset; 331 : node.offset;
334 return _file.span(begin, node.end); 332 return _file.span(begin, node.end);
335 } 333 }
336 334
337 String toString() => '[$runtimeType: $uri]'; 335 String toString() => '[$runtimeType: $uri]';
338 } 336 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698