blob: 6669fffaa5337cd321f9b446f60f239ba0101f84 [file] [log] [blame] [edit]
// Copyright (c) 2024, 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 void add(T event)
/// Send a data event to a stream.
///
/// @description Checks that this method sends a data event to a stream.
/// @author sgrekhov22@gmail.com
import "dart:async";
import "../../../Utils/expect.dart";
main() {
asyncStart(2);
var stream = Stream<int>.multi((controller) {
controller.add(1);
controller.add(2);
controller.add(3);
controller.close();
});
listen(stream);
listen(stream);
}
void listen(Stream<int> stream) {
int i = 1;
stream.listen((v) {
Expect.equals(i++, v);
}, onDone: () {
Expect.equals(4, i);
asyncEnd();
});
}