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

Unified Diff: pkg/scheduled_test/lib/src/utils.dart

Issue 12330062: Add a filesystem descriptor library to scheduled_test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 7 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/scheduled_test/lib/src/descriptor/utils.dart ('k') | pkg/scheduled_test/test/descriptor_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/scheduled_test/lib/src/utils.dart
diff --git a/pkg/scheduled_test/lib/src/utils.dart b/pkg/scheduled_test/lib/src/utils.dart
index b5e086e4c11b38c34d64e255f8fe590bf28d004a..e36863d19bba0f1de8c428e72be965986ebcc0b9 100644
--- a/pkg/scheduled_test/lib/src/utils.dart
+++ b/pkg/scheduled_test/lib/src/utils.dart
@@ -24,3 +24,39 @@ Future pumpEventQueue([int times=200]) {
if (times == 0) return new Future.immediate(null);
return new Future.immediate(null).then((_) => pumpEventQueue(times - 1));
}
+
+/// Returns whether [iterable1] has the same elements in the same order as
+/// [iterable2]. The elements are compared using `==`.
+bool orderedIterableEquals(Iterable iterable1, Iterable iterable2) {
+ var iter1 = iterable1.iterator;
+ var iter2 = iterable2.iterator;
+
+ while (true) {
+ var hasNext1 = iter1.moveNext();
+ var hasNext2 = iter2.moveNext();
+ if (hasNext1 != hasNext2) return false;
+ if (!hasNext1) return true;
+ if (iter1.current != iter2.current) return false;
+ }
+}
+
+// TODO(nweiz): remove this when issue 8731 is fixed.
+/// Returns a [Stream] that will immediately emit [error] and then close.
+Stream errorStream(error) => new Future.immediateError(error).asStream();
+
+/// Returns a buffered stream that will emit the same values as the stream
+/// returned by [future] once [future] completes. If [future] completes to an
+/// error, the return value will emit that error and then close.
+Stream futureStream(Future<Stream> future) {
+ var controller = new StreamController();
+ future.then((stream) {
+ stream.listen(
+ controller.add,
+ onError: (error) => controller.signalError(error),
+ onDone: controller.close);
+ }).catchError((e) {
+ controller.signalError(e);
+ controller.close();
+ });
+ return controller.stream;
+}
« no previous file with comments | « pkg/scheduled_test/lib/src/descriptor/utils.dart ('k') | pkg/scheduled_test/test/descriptor_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698