OLD | NEW |
---|---|
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 barback.test.transformer.bad; | 5 library barback.test.transformer.bad; |
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:barback/src/utils.dart'; | 10 import 'package:barback/src/utils.dart'; |
11 | 11 |
12 import 'mock.dart'; | 12 import 'mock.dart'; |
13 | 13 |
14 /// A transformer that throws an exception when run, after generating the | 14 /// A lazy transformer that throw an exception after [dryRun]. |
Bob Nystrom
2014/01/30 19:33:44
throw -> throws
nweiz
2014/01/31 03:43:27
Done.
| |
15 /// given outputs. | 15 class LazyBadTransformer extends MockTransformer implements LazyTransformer { |
16 class BadTransformer extends MockTransformer { | 16 /// The error [this] throws. |
17 /// The error it throws. | |
18 static const ERROR = "I am a bad transformer!"; | 17 static const ERROR = "I am a bad transformer!"; |
19 | 18 |
20 /// The list of asset names that it should output. | 19 /// The asset name that [this] should output. |
21 final List<String> outputs; | 20 final String output; |
22 | 21 |
23 BadTransformer(this.outputs); | 22 LazyBadTransformer(this.output); |
24 | 23 |
25 Future<bool> doIsPrimary(Asset asset) => new Future.value(true); | 24 Future<bool> doIsPrimary(Asset asset) => new Future.value(true); |
26 | 25 |
27 Future doApply(Transform transform) { | 26 Future doApply(Transform transform) { |
28 return newFuture(() { | 27 return newFuture(() { |
29 // Create the outputs first. | 28 var id = new AssetId.parse(output); |
30 for (var output in outputs) { | 29 transform.addOutput(new Asset.fromString(id, output)); |
31 var id = new AssetId.parse(output); | 30 }); |
32 transform.addOutput(new Asset.fromString(id, output)); | 31 } |
33 } | |
34 | 32 |
35 // Then fail. | 33 Future dryRun(DryRunTransform transform) { |
34 return newFuture(() { | |
35 var id = new AssetId.parse(output); | |
36 transform.addOutputId(id); | |
36 throw ERROR; | 37 throw ERROR; |
37 }); | 38 }); |
38 } | 39 } |
39 } | 40 } |
OLD | NEW |