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 import 'dart:async'; |
| 6 |
| 7 import 'package:barback/barback.dart'; |
| 8 import 'package:barback/src/utils.dart'; |
| 9 |
| 10 import 'mock.dart'; |
| 11 |
| 12 /// A transformer that throws an exception when run, after generating the |
| 13 /// given outputs. |
| 14 class BadTransformer extends MockTransformer { |
| 15 /// The error it throws. |
| 16 static const ERROR = "I am a bad transformer!"; |
| 17 |
| 18 /// The list of asset names that it should output. |
| 19 final List<String> outputs; |
| 20 |
| 21 BadTransformer(this.outputs); |
| 22 |
| 23 Future<bool> doIsPrimary(Asset asset) => new Future.value(true); |
| 24 |
| 25 Future doApply(Transform transform) { |
| 26 return newFuture(() { |
| 27 // Create the outputs first. |
| 28 for (var output in outputs) { |
| 29 var id = new AssetId.parse(output); |
| 30 transform.addOutput(new Asset.fromString(id, output)); |
| 31 } |
| 32 |
| 33 // Then fail. |
| 34 throw ERROR; |
| 35 }); |
| 36 } |
| 37 } |
OLD | NEW |