| OLD | NEW |
| 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 ddc.src.testing; | 5 library ddc.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 28 matching lines...) Expand all Loading... |
| 39 /// conversion, you can describe the test as follows: | 39 /// conversion, you can describe the test as follows: |
| 40 /// | 40 /// |
| 41 /// testChecker({ | 41 /// testChecker({ |
| 42 /// '/main.dart': ''' | 42 /// '/main.dart': ''' |
| 43 /// testMethod() { | 43 /// testMethod() { |
| 44 /// dynamic x = /*warning:Box*/3; | 44 /// dynamic x = /*warning:Box*/3; |
| 45 /// } | 45 /// } |
| 46 /// ''' | 46 /// ''' |
| 47 /// }); | 47 /// }); |
| 48 /// | 48 /// |
| 49 CheckerResults testChecker(Map<String, String> testFiles, {String sdkDir, | 49 CheckerResults testChecker(Map<String, String> testFiles, |
| 50 CheckerReporter reporter, covariantGenerics: true, relaxedCasts: true, | 50 {bool allowConstCasts: true, String sdkDir, CheckerReporter reporter, |
| 51 inferFromOverrides: true, inferStaticsFromIdentifiers: false, | 51 covariantGenerics: true, relaxedCasts: true, inferFromOverrides: true, |
| 52 inferInNonStableOrder: false}) { | 52 inferStaticsFromIdentifiers: false, inferInNonStableOrder: false}) { |
| 53 expect(testFiles.containsKey('/main.dart'), isTrue, | 53 expect(testFiles.containsKey('/main.dart'), isTrue, |
| 54 reason: '`/main.dart` is missing in testFiles'); | 54 reason: '`/main.dart` is missing in testFiles'); |
| 55 | 55 |
| 56 // Create a resolver that can load test files from memory. | 56 // Create a resolver that can load test files from memory. |
| 57 var testUriResolver = new _TestUriResolver(testFiles); | 57 var testUriResolver = new _TestUriResolver(testFiles); |
| 58 var options = new CompilerOptions( | 58 var options = new CompilerOptions( |
| 59 allowConstCasts: allowConstCasts, |
| 59 covariantGenerics: covariantGenerics, | 60 covariantGenerics: covariantGenerics, |
| 60 relaxedCasts: relaxedCasts, | 61 relaxedCasts: relaxedCasts, |
| 61 inferFromOverrides: inferFromOverrides, | 62 inferFromOverrides: inferFromOverrides, |
| 62 inferStaticsFromIdentifiers: inferStaticsFromIdentifiers, | 63 inferStaticsFromIdentifiers: inferStaticsFromIdentifiers, |
| 63 inferInNonStableOrder: inferInNonStableOrder); | 64 inferInNonStableOrder: inferInNonStableOrder); |
| 64 var resolver = sdkDir == null | 65 var resolver = sdkDir == null |
| 65 ? new TypeResolver.fromMock(mockSdkSources, options, | 66 ? new TypeResolver.fromMock(mockSdkSources, options, |
| 66 otherResolvers: [testUriResolver]) | 67 otherResolvers: [testUriResolver]) |
| 67 : new TypeResolver.fromDir(sdkDir, options, | 68 : new TypeResolver.fromDir(sdkDir, options, |
| 68 otherResolvers: [testUriResolver]); | 69 otherResolvers: [testUriResolver]); |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 | 303 |
| 303 SourceSpan spanFor(AstNode node) { | 304 SourceSpan spanFor(AstNode node) { |
| 304 final begin = node is AnnotatedNode | 305 final begin = node is AnnotatedNode |
| 305 ? node.firstTokenAfterCommentAndMetadata.offset | 306 ? node.firstTokenAfterCommentAndMetadata.offset |
| 306 : node.offset; | 307 : node.offset; |
| 307 return _file.span(begin, node.end); | 308 return _file.span(begin, node.end); |
| 308 } | 309 } |
| 309 | 310 |
| 310 String toString() => '[$runtimeType: $uri]'; | 311 String toString() => '[$runtimeType: $uri]'; |
| 311 } | 312 } |
| OLD | NEW |