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

Unified Diff: pkg/barback/test/utils.dart

Issue 149243009: Add support for lazy transformers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 10 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 | « pkg/barback/test/transformer/lazy_rewrite.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/barback/test/utils.dart
diff --git a/pkg/barback/test/utils.dart b/pkg/barback/test/utils.dart
index 2f587531a14b1742dce9720234b94915738ca012..7da5977e9b7a80561ea521a74f841a8b21f23ad5 100644
--- a/pkg/barback/test/utils.dart
+++ b/pkg/barback/test/utils.dart
@@ -20,6 +20,9 @@ export 'transformer/bad.dart';
export 'transformer/check_content.dart';
export 'transformer/check_content_and_rename.dart';
export 'transformer/create_asset.dart';
+export 'transformer/lazy_bad.dart';
+export 'transformer/lazy_many_to_one.dart';
+export 'transformer/lazy_rewrite.dart';
export 'transformer/many_to_one.dart';
export 'transformer/mock.dart';
export 'transformer/one_to_many.dart';
@@ -283,22 +286,41 @@ void expectNoAsset(String name) {
/// Schedules an expectation that the graph will output all of the given
/// assets, and no others.
///
-/// [assets] is a list of strings that can be parsed to [AssetID]s.
-void expectAllAssets(Iterable<String> assets) {
- var expected = assets.map((asset) => new AssetId.parse(asset));
+/// [assets] may be an iterable of asset id strings, in which case this asserts
+/// that the graph outputs exactly the assets with those ids. It may also be a
+/// map from asset id strings to asset contents, in which case the contents must
+/// also match.
+void expectAllAssets(assets) {
+ var expected;
+ var expectedString;
+ if (assets is Map) {
+ expected = mapMapKeys(assets, (key, _) => new AssetId.parse(key));
+ expectedString = expected.toString();
+ } else {
+ expected = assets.map((asset) => new AssetId.parse(asset));
+ expectedString = expected.join(', ');
+ }
schedule(() {
return _barback.getAllAssets().then((actualAssets) {
var actualIds = actualAssets.map((asset) => asset.id).toSet();
- for (var id in expected) {
- expect(actualIds, contains(id));
- actualIds.remove(id);
+ if (expected is Map) {
+ expected.forEach((id, contents) {
+ expect(actualIds, contains(id));
+ actualIds.remove(id);
+ expect(actualAssets[id].readAsString(), completion(equals(contents)));
+ });
+ } else {
+ for (var id in expected) {
+ expect(actualIds, contains(id));
+ actualIds.remove(id);
+ }
}
expect(actualIds, isEmpty);
});
- }, "get all assets, expecting ${expected.join(', ')}");
+ }, "get all assets, expecting $expectedString");
}
/// Schedules an expectation that [Barback.getAllAssets] will return a [Future]
« no previous file with comments | « pkg/barback/test/transformer/lazy_rewrite.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698