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 'dart:mirrors'; | 7 import 'dart:mirrors'; |
8 import 'package:analyzer/file_system/file_system.dart'; | 8 import 'package:analyzer/file_system/file_system.dart'; |
9 import 'package:analyzer/file_system/memory_file_system.dart'; | 9 import 'package:analyzer/file_system/memory_file_system.dart'; |
10 import 'package:analyzer/src/generated/ast.dart'; | 10 import 'package:analyzer/src/generated/ast.dart'; |
(...skipping 20 matching lines...) Expand all Loading... |
31 final realSdkContext = createAnalysisContextWithSources( | 31 final realSdkContext = createAnalysisContextWithSources( |
32 new StrongModeOptions(), | 32 new StrongModeOptions(), |
33 new SourceResolverOptions( | 33 new SourceResolverOptions( |
34 dartSdkPath: getSdkDir().path, | 34 dartSdkPath: getSdkDir().path, |
35 customUrlMappings: { | 35 customUrlMappings: { |
36 'package:expect/expect.dart': _testCodegenPath('expect.dart'), | 36 'package:expect/expect.dart': _testCodegenPath('expect.dart'), |
37 'package:async_helper/async_helper.dart': | 37 'package:async_helper/async_helper.dart': |
38 _testCodegenPath('async_helper.dart'), | 38 _testCodegenPath('async_helper.dart'), |
39 'package:unittest/unittest.dart': _testCodegenPath('unittest.dart'), | 39 'package:unittest/unittest.dart': _testCodegenPath('unittest.dart'), |
40 'package:dom/dom.dart': _testCodegenPath('sunflower', 'dom.dart') | 40 'package:dom/dom.dart': _testCodegenPath('sunflower', 'dom.dart') |
41 }))..analysisOptions = (new AnalysisOptionsImpl()..cacheSize = 512); | 41 }))..analysisOptions.cacheSize = 512; |
42 | 42 |
43 String _testCodegenPath(String p1, [String p2]) => | 43 String _testCodegenPath(String p1, [String p2]) => |
44 path.join(testDirectory, 'codegen', p1, p2); | 44 path.join(testDirectory, 'codegen', p1, p2); |
45 | 45 |
46 final String testDirectory = | 46 final String testDirectory = |
47 path.dirname((reflectClass(_TestUtils).owner as LibraryMirror).uri.path); | 47 path.dirname((reflectClass(_TestUtils).owner as LibraryMirror).uri.path); |
48 | 48 |
49 class _TestUtils {} | 49 class _TestUtils {} |
50 | 50 |
51 /// Run the checker on a program with files contents as indicated in | 51 /// Run the checker on a program with files contents as indicated in |
(...skipping 27 matching lines...) Expand all Loading... |
79 inferDownwards: StrongModeOptions.inferDownwardsDefault, | 79 inferDownwards: StrongModeOptions.inferDownwardsDefault, |
80 inferFromOverrides: StrongModeOptions.inferFromOverridesDefault, | 80 inferFromOverrides: StrongModeOptions.inferFromOverridesDefault, |
81 inferTransitively: StrongModeOptions.inferTransitivelyDefault, | 81 inferTransitively: StrongModeOptions.inferTransitivelyDefault, |
82 nonnullableTypes: StrongModeOptions.NONNULLABLE_TYPES}) { | 82 nonnullableTypes: StrongModeOptions.NONNULLABLE_TYPES}) { |
83 test(name, () { | 83 test(name, () { |
84 expect(testFiles.containsKey('/main.dart'), isTrue, | 84 expect(testFiles.containsKey('/main.dart'), isTrue, |
85 reason: '`/main.dart` is missing in testFiles'); | 85 reason: '`/main.dart` is missing in testFiles'); |
86 | 86 |
87 var provider = createTestResourceProvider(testFiles); | 87 var provider = createTestResourceProvider(testFiles); |
88 var uriResolver = new TestUriResolver(provider); | 88 var uriResolver = new TestUriResolver(provider); |
| 89 // Enable task model strong mode |
| 90 AnalysisEngine.instance.useTaskModel = true; |
89 var context = AnalysisEngine.instance.createAnalysisContext(); | 91 var context = AnalysisEngine.instance.createAnalysisContext(); |
| 92 context.analysisOptions.strongMode = true; |
90 context.sourceFactory = createSourceFactory( | 93 context.sourceFactory = createSourceFactory( |
91 new SourceResolverOptions( | 94 new SourceResolverOptions( |
92 customUrlMappings: customUrlMappings, | 95 customUrlMappings: customUrlMappings, |
93 useMockSdk: sdkDir == null, | 96 useMockSdk: sdkDir == null, |
94 dartSdkPath: sdkDir), | 97 dartSdkPath: sdkDir), |
95 fileResolvers: [uriResolver]); | 98 fileResolvers: [uriResolver]); |
96 | 99 |
97 var checker = new StrongChecker( | 100 var checker = new StrongChecker( |
98 context, | 101 context, |
99 new StrongModeOptions( | 102 new StrongModeOptions( |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 expect(tokens[1], "should", reason: 'invalid error descriptor'); | 280 expect(tokens[1], "should", reason: 'invalid error descriptor'); |
278 expect(tokens[2], "be", reason: 'invalid error descriptor'); | 281 expect(tokens[2], "be", reason: 'invalid error descriptor'); |
279 if (tokens[0] == "pass") return null; | 282 if (tokens[0] == "pass") return null; |
280 // TODO(leafp) For now, we just use whatever the current expectation is, | 283 // TODO(leafp) For now, we just use whatever the current expectation is, |
281 // eventually we could do more automated reporting here. | 284 // eventually we could do more automated reporting here. |
282 return _parse(tokens[0]); | 285 return _parse(tokens[0]); |
283 } | 286 } |
284 | 287 |
285 String toString() => '$level $typeName'; | 288 String toString() => '$level $typeName'; |
286 } | 289 } |
OLD | NEW |