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

Unified Diff: tests/corelib/stream_controller_test.dart

Issue 11308154: Stream isolates. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Fixes and test. Created 8 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 side-by-side diff with in-line comments
Download patch
Index: tests/corelib/stream_controller_test.dart
diff --git a/tests/corelib/stream_controller_test.dart b/tests/corelib/stream_controller_test.dart
index 7e7333f8137532d882dab3b639aa4eecd00619e5..ad3cc670058374564ed25babb7c87dc0a2cfeaa4 100644
--- a/tests/corelib/stream_controller_test.dart
+++ b/tests/corelib/stream_controller_test.dart
@@ -255,4 +255,29 @@ main() {
Expect.listEquals(expectedEvents.events, actualEvents.events);
});
signal.complete();
+
+ // Test subscription changes while firing.
+ c = new StreamController();
+ var sink = c.sink;
+ var stream = c.stream;
+ var counter = 0;
+ var subscription = stream.subscribe();
+ subscription.onData((data) {
+ counter += data;
+ subscription.unsubscribe();
+ stream.subscribe(onData: (data) {
+ counter += 10 * data;
+ });
+ var subscription2 = stream.subscribe();
+ subscription2.onData((data) {
+ counter += 100 * data;
+ if (data == 4) subscription2.unsubscribe();
+ });
+ });
+ sink.write(1); // seen by stream 1
+ sink.write(2); // seen by stream 10 and 100
+ sink.write(3); // -"-
+ sink.write(4); // -"-
+ sink.write(5); // seen by stream 10
+ Expect.equals(1 + 20 + 200 + 30 + 300 + 40 + 400 + 50, counter);
}

Powered by Google App Engine
This is Rietveld 408576698