Skip to content

Commit

Permalink
Add a testcase for join where one stream remains pending forever
Browse files Browse the repository at this point in the history
This currently hangs (danieldg#12).
  • Loading branch information
zeenix committed Dec 27, 2022
1 parent 86e70c2 commit 1ac2385
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,11 @@ where

#[cfg(test)]
mod test {
extern crate alloc;

use alloc::boxed::Box;
use futures_util::stream::pending;

use crate::join;
use crate::FromStream;
use crate::OrderedStreamExt;
Expand Down Expand Up @@ -414,4 +419,18 @@ mod test {
}
});
}

#[test]
fn join_1_pending() {
futures_executor::block_on(async {
let stream1 = FromStream::with_ordering(pending::<Message>(), |m| m.serial);
let stream2 = FromStream::with_ordering(
futures_util::stream::once(Box::pin(async { Message { serial: 1 } })),
|m| m.serial,
);
let mut joined = join(stream1, stream2);
let msg = joined.next().await.unwrap();
assert_eq!(msg.serial, 1);
});
}
}

0 comments on commit 1ac2385

Please sign in to comment.