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

Side by Side 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: Remove StreamControllerSink. The optional cancelOnError on addStream is only in controller. Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/lib/async/stream_controller_async_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // Test merging streams. 5 // Test merging streams.
6 library dart.test.stream_from_iterable; 6 library dart.test.stream_from_iterable;
7 7
8 import "package:expect/expect.dart"; 8 import "package:expect/expect.dart";
9 import "dart:async"; 9 import "dart:async";
10 import '../../../pkg/unittest/lib/unittest.dart'; 10 import '../../../pkg/unittest/lib/unittest.dart';
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 Duration duration = const Duration(milliseconds: 10); 66 Duration duration = const Duration(milliseconds: 10);
67 if (value == 20) { 67 if (value == 20) {
68 subscription.pause(new Future.delayed(duration, () {})); 68 subscription.pause(new Future.delayed(duration, () {}));
69 } 69 }
70 }, onDone: expectAsync0(() { 70 }, onDone: expectAsync0(() {
71 actual.close(); 71 actual.close();
72 Events expected = new Events.fromIterable(iter); 72 Events expected = new Events.fromIterable(iter);
73 Expect.listEquals(expected.events, actual.events); 73 Expect.listEquals(expected.events, actual.events);
74 })); 74 }));
75 }); 75 });
76
77 test("regression-14332", () {
78 // Regression test for http://dartbug.com/14332.
79 // This should succeede.
80 var from = new Stream.fromIterable([1,2,3,4,5]);
81
82 var c = new StreamController();
83 var sink = c.sink;
84
85 var done = expectAsync0((){}, count: 2);
86
87 // if this goes first, test failed (hanged). Swapping addStream and toList
88 // made failure go away.
89 sink.addStream(from).then((_) {
90 c.close();
91 done();
92 });
93
94 c.stream.toList().then((x) {
95 Expect.listEquals([1,2,3,4,5], x);
96 done();
97 });
98 });
99
100 test("regression-14334-a", () {
101 var from = new Stream.fromIterable([1,2,3,4,5]);
102
103 // odd numbers as data events, even numbers as error events
104 from = from.map((x) => x.isOdd ? x : throw x);
105
106 var c = new StreamController();
107 var sink = c.sink;
108
109 var done = expectAsync0((){}, count: 2);
110
111 var data = [], errors = [];
112 c.stream.listen(data.add, onError: errors.add, onDone: () {
113 Expect.listEquals([1], data);
114 Expect.listEquals([2], errors);
115 done();
116 });
117 sink.addStream(from).then((_) {
Anders Johnsen 2013/10/28 13:44:26 Add test with two 'addStream' on controller.
118 c.close();
119 done();
120 });
121 });
122
123 test("regression-14334-b", () {
124 var from = new Stream.fromIterable([1,2,3,4,5]);
125
126 // odd numbers as data events, even numbers as error events
127 from = from.map((x) => x.isOdd ? x : throw x);
128
129 var c = new StreamController();
130
131 var done = expectAsync0((){}, count: 2);
132
133 var data = [], errors = [];
134 c.stream.listen(data.add, onError: errors.add, onDone: () {
135 Expect.listEquals([1, 3, 5], data);
136 Expect.listEquals([2, 4], errors);
137 done();
138 });
139 c.addStream(from, cancelOnError: false).then((_) {
140 c.close();
141 done();
142 });
143 });
76 } 144 }
OLDNEW
« 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