Chromium Code Reviews

Side by Side Diff: pkg/barback/test/transformer/declaring_bad.dart

Issue 243793005: Don't require Transformer methods to return Futures. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
OLDNEW
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.declaring_bad; 5 library barback.test.transformer.declaring_bad;
6 6
7 import 'dart:async';
8
9 import 'package:barback/barback.dart'; 7 import 'package:barback/barback.dart';
10 import 'package:barback/src/utils.dart';
11 8
12 import 'bad.dart'; 9 import 'bad.dart';
13 import 'mock.dart'; 10 import 'mock.dart';
14 11
15 /// A transformer that throws an exception when run, after generating the 12 /// A transformer that throws an exception when run, after generating the
16 /// given outputs. 13 /// given outputs.
17 class DeclaringBadTransformer extends MockTransformer 14 class DeclaringBadTransformer extends MockTransformer
18 implements DeclaringTransformer { 15 implements DeclaringTransformer {
19 /// Whether this should throw an error in [declareOutputs]. 16 /// Whether this should throw an error in [declareOutputs].
20 final bool declareError; 17 final bool declareError;
21 18
22 /// Whether this should throw an error in [apply]. 19 /// Whether this should throw an error in [apply].
23 final bool applyError; 20 final bool applyError;
24 21
25 /// The id of the output asset to emit. 22 /// The id of the output asset to emit.
26 final AssetId output; 23 final AssetId output;
27 24
28 DeclaringBadTransformer(String output, {bool declareError: true, 25 DeclaringBadTransformer(String output, {bool declareError: true,
29 bool applyError: false}) 26 bool applyError: false})
30 : this.output = new AssetId.parse(output), 27 : this.output = new AssetId.parse(output),
31 this.declareError = declareError, 28 this.declareError = declareError,
32 this.applyError = applyError; 29 this.applyError = applyError;
33 30
34 Future<bool> doIsPrimary(AssetId id) => new Future.value(true); 31 bool doIsPrimary(AssetId id) => true;
35 32
36 Future doApply(Transform transform) { 33 void doApply(Transform transform) {
37 return newFuture(() { 34 transform.addOutput(new Asset.fromString(output, "bad out"));
38 transform.addOutput(new Asset.fromString(output, "bad out")); 35 if (applyError) throw BadTransformer.ERROR;
39 if (applyError) throw BadTransformer.ERROR;
40 });
41 } 36 }
42 37
43 Future declareOutputs(DeclaringTransform transform) { 38 void declareOutputs(DeclaringTransform transform) {
44 return newFuture(() { 39 if (consumePrimary) transform.consumePrimary();
45 if (consumePrimary) transform.consumePrimary(); 40 transform.declareOutput(output);
46 transform.declareOutput(output); 41 if (declareError) throw BadTransformer.ERROR;
47 if (declareError) throw BadTransformer.ERROR;
48 });
49 } 42 }
50 } 43 }
OLDNEW
« no previous file with comments | « pkg/barback/test/transformer/declare_assets.dart ('k') | pkg/barback/test/transformer/declaring_rewrite.dart » ('j') | no next file with comments »

Powered by Google App Engine