OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 code_transformers.test.resolver_test; | 5 library code_transformers.test.resolver_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:barback/barback.dart'; | 9 import 'package:barback/barback.dart'; |
10 import 'package:code_transformers/resolver.dart'; | 10 import 'package:code_transformers/resolver.dart'; |
11 import 'package:code_transformers/tests.dart'; | 11 import 'package:code_transformers/tests.dart'; |
12 import 'package:unittest/compact_vm_config.dart'; | 12 import 'package:unittest/compact_vm_config.dart'; |
13 import 'package:unittest/unittest.dart'; | 13 import 'package:unittest/unittest.dart'; |
14 | 14 |
15 main() { | 15 main() { |
16 useCompactVMConfiguration(); | 16 useCompactVMConfiguration(); |
| 17 group('mock sdk', () { |
| 18 resolverTests(new Resolvers.fromMock({ |
| 19 'dart:core': 'library dart.core;\nclass Object {}', |
| 20 'dart:async': 'library dart.async;', |
| 21 'dart:html': 'library dart.html;', |
| 22 })); |
| 23 }); |
| 24 |
| 25 group('real sdk', () { |
| 26 resolverTests(new Resolvers(testingDartSdkDirectory)); |
| 27 }); |
| 28 } |
| 29 |
| 30 resolverTests(Resolvers resolvers) { |
17 var entryPoint = new AssetId('a', 'web/main.dart'); | 31 var entryPoint = new AssetId('a', 'web/main.dart'); |
18 var resolvers = new Resolvers(testingDartSdkDirectory); | |
19 | |
20 Future validateResolver({Map<String, String> inputs, validator(Resolver), | 32 Future validateResolver({Map<String, String> inputs, validator(Resolver), |
21 List<String> messages: const[]}) { | 33 List<String> messages: const[]}) { |
22 return applyTransformers( | 34 return applyTransformers( |
23 [[new TestTransformer(resolvers, entryPoint, validator)]], | 35 [[new TestTransformer(resolvers, entryPoint, validator)]], |
24 inputs: inputs, | 36 inputs: inputs, |
25 messages: messages); | 37 messages: messages); |
26 } | 38 } |
27 | 39 |
28 group('Resolver', () { | 40 group('Resolver', () { |
29 | 41 |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 | 368 |
357 // TODO(nweiz): This should just take an AssetId when barback <0.13.0 support | 369 // TODO(nweiz): This should just take an AssetId when barback <0.13.0 support |
358 // is dropped. | 370 // is dropped. |
359 Future<bool> isPrimary(idOrAsset) { | 371 Future<bool> isPrimary(idOrAsset) { |
360 var id = idOrAsset is AssetId ? idOrAsset : idOrAsset.id; | 372 var id = idOrAsset is AssetId ? idOrAsset : idOrAsset.id; |
361 return new Future.value(id == primary); | 373 return new Future.value(id == primary); |
362 } | 374 } |
363 | 375 |
364 applyResolver(Transform transform, Resolver resolver) => validator(resolver); | 376 applyResolver(Transform transform, Resolver resolver) => validator(resolver); |
365 } | 377 } |
OLD | NEW |