Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add regression test for issue 1834
  • Loading branch information
tmiasko committed Sep 26, 2019
commit 554a7aa5b1bb692e890b829f2d3deeb33866245a
26 changes: 26 additions & 0 deletions futures/tests/sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,32 @@ fn with_flat_map() {
assert_eq!(sink.get_ref(), &[1, 2, 2, 3, 3, 3]);
}

// Check that `with` propagates `poll_ready` to the inner sink.
// Regression test for the issue #1834.
#[test]
fn with_propagates_poll_ready() {
let (tx, mut rx) = mpsc::channel::<i32>(0);
let mut tx = tx.with(|item: i32| future::ok::<i32, mpsc::SendError>(item + 10));

block_on(future::lazy(|_| {
flag_cx(|flag, cx| {
let mut tx = Pin::new(&mut tx);

// Should be ready for the first item.
assert_eq!(tx.as_mut().poll_ready(cx), Poll::Ready(Ok(())));
assert_eq!(tx.as_mut().start_send(0), Ok(()));

// Should be ready for the second item only after the first one is received.
assert_eq!(tx.as_mut().poll_ready(cx), Poll::Pending);
assert!(!flag.get());
sassert_next(&mut rx, 10);
assert!(flag.get());
assert_eq!(tx.as_mut().poll_ready(cx), Poll::Ready(Ok(())));
assert_eq!(tx.as_mut().start_send(1), Ok(()));
})
}));
}

// Immediately accepts all requests to start pushing, but completion is managed
// by manually flushing
struct ManualFlush<T: Unpin> {
Expand Down