Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Unified Diff: sdk/lib/_internal/pub/test/transformer/supports_a_transformer_that_doesnt_return_futures_test.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. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/barback/dart2js_transformer.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/test/transformer/supports_a_transformer_that_doesnt_return_futures_test.dart
diff --git a/sdk/lib/_internal/pub/test/transformer/can_use_consume_primary_test.dart b/sdk/lib/_internal/pub/test/transformer/supports_a_transformer_that_doesnt_return_futures_test.dart
similarity index 62%
copy from sdk/lib/_internal/pub/test/transformer/can_use_consume_primary_test.dart
copy to sdk/lib/_internal/pub/test/transformer/supports_a_transformer_that_doesnt_return_futures_test.dart
index 9b41b2bbc5905412e31e2c3d02224973d5b1ff64..e4ac4ef7e5fb32a25f00338dac7180fbe2c41902 100644
--- a/sdk/lib/_internal/pub/test/transformer/can_use_consume_primary_test.dart
+++ b/sdk/lib/_internal/pub/test/transformer/supports_a_transformer_that_doesnt_return_futures_test.dart
@@ -13,25 +13,25 @@ import 'dart:async';
import 'package:barback/barback.dart';
-class RewriteTransformer extends Transformer {
+class RewriteTransformer extends Transformer implements DeclaringTransformer {
RewriteTransformer.asPlugin();
- String get allowedExtensions => '.txt';
+ bool isPrimary(AssetId id) => id.extension == '.txt';
- Future apply(Transform transform) {
- transform.consumePrimary();
- return transform.primaryInput.readAsString().then((contents) {
- var id = transform.primaryInput.id.changeExtension(".out");
- var asset = new Asset.fromString(id, "\$contents.out");
- transform.addOutput(asset);
- });
+ void apply(Transform transform) {
+ transform.addOutput(new Asset.fromString(
+ transform.primaryInput.id, "new contents"));
+ }
+
+ void declareOutputs(DeclaringTransform transform) {
+ transform.declareOutput(transform.primaryId);
}
}
""";
main() {
initConfig();
- integration("a transform can use consumePrimary", () {
+ integration("supports a transformer that doesn't return futures", () {
d.dir(appPath, [
d.pubspec({
"name": "myapp",
@@ -48,8 +48,7 @@ main() {
createLockFile('myapp', pkg: ['barback']);
pubServe();
- requestShouldSucceed("foo.out", "foo.out");
- requestShould404("foo.txt");
+ requestShouldSucceed("foo.txt", "new contents");
endPubServe();
});
}
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/barback/dart2js_transformer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698