| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 /// ''' | 46 /// ''' |
| 47 /// }); | 47 /// }); |
| 48 /// | 48 /// |
| 49 CheckerResults testChecker(Map<String, String> testFiles, {String sdkDir, | 49 CheckerResults testChecker(Map<String, String> testFiles, {String sdkDir, |
| 50 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}) { | |
| 58 expect(testFiles.containsKey('/main.dart'), isTrue, | 57 expect(testFiles.containsKey('/main.dart'), isTrue, |
| 59 reason: '`/main.dart` is missing in testFiles'); | 58 reason: '`/main.dart` is missing in testFiles'); |
| 60 | 59 |
| 61 var provider = createTestResourceProvider(testFiles); | 60 var provider = createTestResourceProvider(testFiles); |
| 62 var uriResolver = new TestUriResolver(provider); | 61 var uriResolver = new TestUriResolver(provider); |
| 63 | 62 |
| 64 var options = new CompilerOptions( | 63 var options = new CompilerOptions( |
| 65 covariantGenerics: covariantGenerics, | 64 covariantGenerics: covariantGenerics, |
| 66 relaxedCasts: relaxedCasts, | 65 relaxedCasts: relaxedCasts, |
| 67 inferDownwards: inferDownwards, | 66 inferDownwards: inferDownwards, |
| 68 inferFromOverrides: inferFromOverrides, | 67 inferFromOverrides: inferFromOverrides, |
| 69 inferTransitively: inferTransitively, | 68 inferTransitively: inferTransitively, |
| 70 nonnullableTypes: nonnullableTypes, | 69 nonnullableTypes: nonnullableTypes, |
| 71 wrapClosures: wrapClosures, | |
| 72 useMockSdk: sdkDir == null, | 70 useMockSdk: sdkDir == null, |
| 73 dartSdkPath: sdkDir, | 71 dartSdkPath: sdkDir, |
| 74 runtimeDir: '/dev_compiler_runtime/', | 72 runtimeDir: '/dev_compiler_runtime/', |
| 75 entryPointFile: '/main.dart', | 73 entryPointFile: '/main.dart', |
| 76 customUrlMappings: customUrlMappings); | 74 customUrlMappings: customUrlMappings); |
| 77 | 75 |
| 78 var context = createAnalysisContext(options, fileResolvers: [uriResolver]); | 76 var context = createAnalysisContext(options, fileResolvers: [uriResolver]); |
| 79 | 77 |
| 80 // Run the checker on /main.dart. | 78 // Run the checker on /main.dart. |
| 81 var mainFile = new Uri.file('/main.dart'); | 79 var mainFile = new Uri.file('/main.dart'); |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 expect(tokens[1], "should", reason: 'invalid error descriptor'); | 298 expect(tokens[1], "should", reason: 'invalid error descriptor'); |
| 301 expect(tokens[2], "be", reason: 'invalid error descriptor'); | 299 expect(tokens[2], "be", reason: 'invalid error descriptor'); |
| 302 if (tokens[0] == "pass") return null; | 300 if (tokens[0] == "pass") return null; |
| 303 // TODO(leafp) For now, we just use whatever the current expectation is, | 301 // TODO(leafp) For now, we just use whatever the current expectation is, |
| 304 // eventually we could do more automated reporting here. | 302 // eventually we could do more automated reporting here. |
| 305 return _parse(tokens[0]); | 303 return _parse(tokens[0]); |
| 306 } | 304 } |
| 307 | 305 |
| 308 String toString() => '$level $type'; | 306 String toString() => '$level $type'; |
| 309 } | 307 } |
| OLD | NEW |