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

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

Issue 15673006: Implement asBroadcast using a _MultiplexStreamController. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Don't keep pending events when calling onCancel. Created 7 years, 7 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_impl.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 1ed514372a13dead90d79a636c1dc2b00056bf5c..65e658f32b259b8cf2f236ae969566fe3061d698 100644
--- a/tests/lib/async/stream_controller_async_test.dart
+++ b/tests/lib/async/stream_controller_async_test.dart
@@ -482,6 +482,25 @@ void testBroadcastController() {
c.add(42);
c.close();
});
+
+ test("broadcast-controller-add-in-callback", () {
+ StreamController<int> c;
+ c = new StreamController(
+ onListen: expectAsync0(() {}),
+ onCancel: expectAsync0(() {
+ c.add(42);
+ })
+ );
+ var sub;
+ sub = c.stream.asBroadcastStream().listen(expectAsync1((v) {
+ Expect.equals(37, v);
+ c.add(21);
+ sub.cancel();
+ }));
+ c.add(37); // Triggers listener, which adds 21 and removes itself.
+ // Removing listener triggers onCancel which adds another 42.
+ // Both 21 and 42 are lost because there are no listeners.
+ });
}
main() {
« no previous file with comments | « sdk/lib/async/stream_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698