blob: e8513935ce9d82203b3290736d9eb1ebf7ca4d32 [file] [log] [blame]
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
/// @assertion StreamController.broadcast({void onListen(), void onCancel(),
/// bool sync: false})
/// A controller where stream can be listened to more than once.
/// The Stream returned by stream is a broadcast stream. It can be listened to
/// more than once.
/// The controller distributes any events to all currently subscribed listeners
/// at the time when add, addError or close is called.
/// @description Checks that the controller distributes all events to all
/// currently subscribed listeners.
/// @author kaigorodov
import "dart:async";
import "../../../Utils/expect.dart";
check(List events0) {
StreamController controller = new StreamController.broadcast();
Stream s =;
List events1 = new List.empty(growable: true);
StreamSubscription ss1 = s.listen((event) {events1.add(event);});
ss1.onDone(() {
Expect.listEquals(events0, events1);
List events2 = new List.empty(growable: true);
StreamSubscription ss2 = s.listen((event) {events2.add(event);});
ss2.onDone(() {
Expect.listEquals(events0, events2);
for (var event in events0) {
main() {
check([1, 2, null, []]);