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

Unified Diff: tests/lib/async/stream_controller_async_test.dart

Issue 14312010: Add Stream.forEach (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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/async/stream.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/async/stream_controller_async_test.dart
diff --git a/tests/lib/async/stream_controller_async_test.dart b/tests/lib/async/stream_controller_async_test.dart
index 69499005361a74da738be914e689bc08b8cecd1c..9d88104f0a150cabf6fdb2fcbd7556c4cc2ac2e5 100644
--- a/tests/lib/async/stream_controller_async_test.dart
+++ b/tests/lib/async/stream_controller_async_test.dart
@@ -125,6 +125,44 @@ testSingleController() {
testExtraMethods() {
Events sentEvents = new Events()..add(7)..add(9)..add(13)..add(87)..close();
+ test("forEach", () {
+ StreamController c = new StreamController();
+ Events actualEvents = new Events();
+ Future f = c.stream.forEach(actualEvents.add);
+ f.then(expectAsync1((_) {
+ actualEvents.close();
+ Expect.listEquals(sentEvents.events, actualEvents.events);
+ }));
+ sentEvents.replay(c);
+ });
+
+ test("forEachError", () {
+ Events sentEvents = new Events()..add(7)..error("bad")..add(87)..close();
+ StreamController c = new StreamController();
+ Events actualEvents = new Events();
+ Future f = c.stream.forEach(actualEvents.add);
+ f.catchError(expectAsync1((error) {
+ Expect.equals("bad", error);
+ Expect.listEquals((new Events()..add(7)).events, actualEvents.events);
+ }));
+ sentEvents.replay(c);
+ });
+
+ test("forEachError2", () {
+ Events sentEvents = new Events()..add(7)..add(9)..add(87)..close();
+ StreamController c = new StreamController();
+ Events actualEvents = new Events();
+ Future f = c.stream.forEach((x) {
+ if (x == 9) throw "bad";
+ actualEvents.add(x);
+ });
+ f.catchError(expectAsync1((error) {
+ Expect.equals("bad", error);
+ Expect.listEquals((new Events()..add(7)).events, actualEvents.events);
+ }));
+ sentEvents.replay(c);
+ });
+
test("firstWhere", () {
StreamController c = new StreamController();
Future f = c.stream.firstWhere((x) => (x % 3) == 0);
@@ -373,7 +411,7 @@ class TestError { const TestError(); }
testRethrow() {
TestError error = const TestError();
-
+
testStream(name, streamValueTransform) {
test("rethrow-$name-value", () {
@@ -416,6 +454,7 @@ testRethrow() {
testStream("where", (s, act) => s.where(act));
testStreamError("handleError", (s, act) => s.handleError(act));
testStreamError("handleTest", (s, act) => s.handleError((v) {}, test: act));
+ testFuture("forEach", (s, act) => s.forEach(act));
testFuture("every", (s, act) => s.every(act));
testFuture("any", (s, act) => s.any(act));
testFuture("reduce", (s, act) => s.reduce((a,b) => act(b)));
« no previous file with comments | « sdk/lib/async/stream.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698