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

Unified Diff: tests/lib/async/stream_from_iterable_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/lib/async/stream_controller_async_test.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_from_iterable_test.dart
diff --git a/tests/lib/async/stream_from_iterable_test.dart b/tests/lib/async/stream_from_iterable_test.dart
index ab7d543724aa7dc4ef760d599f5af415e51f4520..4cd03bc900d26dedda9a862e441ac761ea8d90f7 100644
--- a/tests/lib/async/stream_from_iterable_test.dart
+++ b/tests/lib/async/stream_from_iterable_test.dart
@@ -73,4 +73,72 @@ main() {
Expect.listEquals(expected.events, actual.events);
}));
});
+
+ test("regression-14332", () {
+ // Regression test for http://dartbug.com/14332.
+ // This should succeede.
+ var from = new Stream.fromIterable([1,2,3,4,5]);
+
+ var c = new StreamController();
+ var sink = c.sink;
+
+ var done = expectAsync0((){}, count: 2);
+
+ // if this goes first, test failed (hanged). Swapping addStream and toList
+ // made failure go away.
+ sink.addStream(from).then((_) {
+ c.close();
+ done();
+ });
+
+ c.stream.toList().then((x) {
+ Expect.listEquals([1,2,3,4,5], x);
+ done();
+ });
+ });
+
+ test("regression-14334-a", () {
+ var from = new Stream.fromIterable([1,2,3,4,5]);
+
+ // odd numbers as data events, even numbers as error events
+ from = from.map((x) => x.isOdd ? x : throw x);
+
+ var c = new StreamController();
+ var sink = c.sink;
+
+ var done = expectAsync0((){}, count: 2);
+
+ var data = [], errors = [];
+ c.stream.listen(data.add, onError: errors.add, onDone: () {
+ Expect.listEquals([1], data);
+ Expect.listEquals([2], errors);
+ done();
+ });
+ sink.addStream(from).then((_) {
+ c.close();
+ done();
+ });
+ });
+
+ test("regression-14334-b", () {
+ var from = new Stream.fromIterable([1,2,3,4,5]);
+
+ // odd numbers as data events, even numbers as error events
+ from = from.map((x) => x.isOdd ? x : throw x);
+
+ var c = new StreamController();
+
+ var done = expectAsync0((){}, count: 2);
+
+ var data = [], errors = [];
+ c.stream.listen(data.add, onError: errors.add, onDone: () {
+ Expect.listEquals([1, 3, 5], data);
+ Expect.listEquals([2, 4], errors);
+ done();
+ });
+ c.addStream(from, cancelOnError: false).then((_) {
+ c.close();
+ done();
+ });
+ });
}
« no previous file with comments | « tests/lib/async/stream_controller_async_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698