Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2933. Add tests for Stream.multi constructor. #2935

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sgrekhov
Copy link
Contributor

No description provided.

stream.listen((v) {
Expect.equals(v, i++);
}, onDone: () {
asyncEnd();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe check here that i is 6. Ditto for j below.


stream.listen((v) {}, onDone: () {
stream.listen((v) {}, onDone: () {
Expect.notEquals(c1, c2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd use notIdentical.

They're probably not equal, but we don't actually specify what == does. (That usually means it's the same as identical, but ... sometimes it's not. Like StreamController.broadcast().stream which returns distinct but equal values each time.)


stream.listen((v) {}, onDone: () {
asyncEnd();
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Can be written as onDone: asyncEnd.)

/// all current listeners, it behaves like a broadcast stream.
///
/// @description Checks that reading of [MultiStreamController.stream] is not
/// supported.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Description not updated for this test?
(Same as for A03_t01.)

main() {
asyncStart();
var stream = Stream<int>.multi((MultiStreamController<int> controller) {
print(controller.hasListener);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test true or false? I think it's true. Also not paused, even though you can't send synchronous events before the call to listen has returned.

controller.close();
}, isBroadcast: true);
Expect.isTrue(stream.isBroadcast);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing below here is needed for the test.

@lrhn
Copy link
Member

lrhn commented Oct 15, 2024

Are there tests for the MultiStreamController API? Which is the normal StreamController API plus addSync, addErrorSync and closeSync, which allows adding events synchronously (after listen has returned, not paused, and if there are no prior events still enqueued).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants