OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 library barback.test.transformer.declaring_bad; | |
6 | |
7 import 'dart:async'; | |
8 | |
9 import 'package:barback/barback.dart'; | |
10 import 'package:barback/src/utils.dart'; | |
11 | |
12 import 'bad.dart'; | |
13 import 'mock.dart'; | |
14 | |
15 /// A transformer that throws an exception when run, after generating the | |
16 /// given outputs. | |
17 class DeclaringBadTransformer extends MockTransformer | |
18 implements DeclaringTransformer { | |
19 final bool declareError; | |
Bob Nystrom
2014/04/08 18:23:44
Document these.
nweiz
2014/04/08 23:42:33
Done.
| |
20 final bool applyError; | |
21 final String output; | |
Bob Nystrom
2014/04/08 18:23:44
How about making this an AssetId and parsing it in
nweiz
2014/04/08 23:42:33
Done.
| |
22 | |
23 DeclaringBadTransformer(this.output, {bool declareError: true, | |
24 bool applyError: false}) | |
25 : this.declareError = declareError, | |
26 this.applyError = applyError; | |
27 | |
28 Future<bool> doIsPrimary(AssetId id) => new Future.value(true); | |
29 | |
30 Future doApply(Transform transform) { | |
31 return newFuture(() { | |
32 var id = new AssetId.parse(output); | |
33 transform.addOutput(new Asset.fromString(id, "bad out")); | |
34 if (applyError) throw BadTransformer.ERROR; | |
35 }); | |
36 } | |
37 | |
38 Future declareOutputs(DeclaringTransform transform) { | |
39 return newFuture(() { | |
40 if (consumePrimary) transform.consumePrimary(); | |
41 transform.declareOutput(new AssetId.parse(output)); | |
42 if (declareError) throw BadTransformer.ERROR; | |
43 }); | |
44 } | |
45 } | |
OLD | NEW |