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

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

Issue 48733002: Fix bugs in StreamController.addStream. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments. Added test. Fixed typos. Created 7 years, 2 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 | « tests/co19/co19-co19.status ('k') | tests/lib/async/stream_from_iterable_test.dart » ('j') | 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 d66a6f164702fff2b4164b360fddfa7deb951e6d..837872833127d9cae8707cbf7015d2f5f61eca80 100644
--- a/tests/lib/async/stream_controller_async_test.dart
+++ b/tests/lib/async/stream_controller_async_test.dart
@@ -675,6 +675,81 @@ void testSink({bool sync, bool broadcast, bool asBroadcast}) {
}
});
});
+
+ test("$type-controller-addstream-error-stop", () {
+ // Check that addStream defaults to ending after the first error.
+ var done = expectAsync0((){});
+ var c = broadcast ? new StreamController.broadcast(sync: sync)
+ : new StreamController(sync: sync);
+ var stream = asBroadcast ? c.stream.asBroadcastStream() : c.stream;
+ var actual = new Events.capture(stream);
+
+ var source = new Events();
+ source..add(1)..add(2)..error("BAD")..add(3)..error("FAIL")..close();
+
+ var expected = new Events()..add(1)..add(2)..error("BAD")..close();
+ StreamController sourceController = new StreamController();
+ c.addStream(sourceController.stream).then((_) {
+ c.close().then((_) {
+ Expect.listEquals(expected.events, actual.events);
+ done();
+ });
+ });
+
+ source.replay(sourceController);
+ });
+
+ test("$type-controller-addstream-error-forward", () {
+ // Check that addStream with cancelOnError:false passes all data and errors
+ // to the controller.
+ var done = expectAsync0((){});
+ var c = broadcast ? new StreamController.broadcast(sync: sync)
+ : new StreamController(sync: sync);
+ var stream = asBroadcast ? c.stream.asBroadcastStream() : c.stream;
+ var actual = new Events.capture(stream);
+
+ var source = new Events();
+ source..add(1)..add(2)..addError("BAD")..add(3)..addError("FAIL")..close();
+
+ StreamController sourceController = new StreamController();
+ c.addStream(sourceController.stream, cancelOnError: false).then((_) {
+ c.close().then((_) {
+ Expect.listEquals(source.events, actual.events);
+ done();
+ });
+ });
+
+ source.replay(sourceController);
+ });
+
+ test("$type-controller-addstream-twice", () {
+ // Using addStream twice on the same stream
+ var done = expectAsync0((){});
+ var c = broadcast ? new StreamController.broadcast(sync: sync)
+ : new StreamController(sync: sync);
+ var stream = asBroadcast ? c.stream.asBroadcastStream() : c.stream;
+ var actual = new Events.capture(stream);
+
+ // Streams of five events, throws on 3.
+ Stream s1 = new Stream.fromIterable([1,2,3,4,5])
+ .map((x) => (x == 3 ? throw x : x));
+ Stream s2 = new Stream.fromIterable([1,2,3,4,5])
+ .map((x) => (x == 3 ? throw x : x));
+
+ Events expected = new Events();
+ expected..add(1)..add(2)..error(3);
+ expected..add(1)..add(2)..error(3)..add(4)..add(5);
+ expected..close();
+
+ c.addStream(s1).then((_) {
+ c.addStream(s2, cancelOnError: false).then((_) {
+ c.close().then((_) {
+ Expect.listEquals(expected.events, actual.events);
+ done();
+ });
+ });
+ });
+ });
}
main() {
« no previous file with comments | « tests/co19/co19-co19.status ('k') | tests/lib/async/stream_from_iterable_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698