| 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 dev_compiler.src.testing; | 5 library dev_compiler.src.testing; |
| 6 | 6 |
| 7 import 'package:analyzer/file_system/file_system.dart'; | 7 import 'package:analyzer/file_system/file_system.dart'; |
| 8 import 'package:analyzer/file_system/memory_file_system.dart'; | 8 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 9 import 'package:analyzer/src/generated/ast.dart'; | 9 import 'package:analyzer/src/generated/ast.dart'; |
| 10 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext; | 10 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext; |
| (...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, | 49 CheckerResults testChecker(Map<String, String> testFiles, {String sdkDir, |
| 50 {bool allowConstCasts: true, String sdkDir, customUrlMappings: const {}, | 50 customUrlMappings: const {}, |
| 51 CheckerReporter createReporter(AnalysisContext context), | 51 CheckerReporter createReporter(AnalysisContext context), |
| 52 covariantGenerics: true, relaxedCasts: true, | 52 covariantGenerics: true, relaxedCasts: true, |
| 53 inferDownwards: RulesOptions.inferDownwardsDefault, | 53 inferDownwards: RulesOptions.inferDownwardsDefault, |
| 54 inferFromOverrides: ResolverOptions.inferFromOverridesDefault, | 54 inferFromOverrides: ResolverOptions.inferFromOverridesDefault, |
| 55 inferTransitively: ResolverOptions.inferTransitivelyDefault, | 55 inferTransitively: ResolverOptions.inferTransitivelyDefault, |
| 56 nonnullableTypes: TypeOptions.NONNULLABLE_TYPES, | 56 nonnullableTypes: TypeOptions.NONNULLABLE_TYPES, |
| 57 wrapClosures: RulesOptions.wrapClosuresDefault}) { | 57 wrapClosures: RulesOptions.wrapClosuresDefault}) { |
| 58 expect(testFiles.containsKey('/main.dart'), isTrue, | 58 expect(testFiles.containsKey('/main.dart'), isTrue, |
| 59 reason: '`/main.dart` is missing in testFiles'); | 59 reason: '`/main.dart` is missing in testFiles'); |
| 60 | 60 |
| 61 var provider = createTestResourceProvider(testFiles); | 61 var provider = createTestResourceProvider(testFiles); |
| 62 var uriResolver = new TestUriResolver(provider); | 62 var uriResolver = new TestUriResolver(provider); |
| 63 | 63 |
| 64 var options = new CompilerOptions( | 64 var options = new CompilerOptions( |
| 65 allowConstCasts: allowConstCasts, | |
| 66 covariantGenerics: covariantGenerics, | 65 covariantGenerics: covariantGenerics, |
| 67 relaxedCasts: relaxedCasts, | 66 relaxedCasts: relaxedCasts, |
| 68 inferDownwards: inferDownwards, | 67 inferDownwards: inferDownwards, |
| 69 inferFromOverrides: inferFromOverrides, | 68 inferFromOverrides: inferFromOverrides, |
| 70 inferTransitively: inferTransitively, | 69 inferTransitively: inferTransitively, |
| 71 nonnullableTypes: nonnullableTypes, | 70 nonnullableTypes: nonnullableTypes, |
| 72 wrapClosures: wrapClosures, | 71 wrapClosures: wrapClosures, |
| 73 useMockSdk: sdkDir == null, | 72 useMockSdk: sdkDir == null, |
| 74 dartSdkPath: sdkDir, | 73 dartSdkPath: sdkDir, |
| 75 runtimeDir: '/dev_compiler_runtime/', | 74 runtimeDir: '/dev_compiler_runtime/', |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 expect(tokens[1], "should", reason: 'invalid error descriptor'); | 300 expect(tokens[1], "should", reason: 'invalid error descriptor'); |
| 302 expect(tokens[2], "be", reason: 'invalid error descriptor'); | 301 expect(tokens[2], "be", reason: 'invalid error descriptor'); |
| 303 if (tokens[0] == "pass") return null; | 302 if (tokens[0] == "pass") return null; |
| 304 // TODO(leafp) For now, we just use whatever the current expectation is, | 303 // TODO(leafp) For now, we just use whatever the current expectation is, |
| 305 // eventually we could do more automated reporting here. | 304 // eventually we could do more automated reporting here. |
| 306 return _parse(tokens[0]); | 305 return _parse(tokens[0]); |
| 307 } | 306 } |
| 308 | 307 |
| 309 String toString() => '$level $type'; | 308 String toString() => '$level $type'; |
| 310 } | 309 } |
| OLD | NEW |