id stringlengths 22 133 | text stringlengths 40 40.2k | arch stringclasses 1
value | syntax stringclasses 1
value | kind stringclasses 4
values | repo stringclasses 27
values | path stringlengths 5 116 | license stringclasses 6
values | commit stringlengths 40 40 | source_host stringclasses 1
value | category stringclasses 16
values | source_url stringlengths 85 196 | line_start int64 1 4.28k | line_end int64 4 4.31k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:9 | async fn send_recv_many_unbounded_capacity() {
let mut buffer: Vec<String> = Vec::with_capacity(9); // capacity >= 9
let limit = buffer.capacity();
let (tx, mut rx) = mpsc::unbounded_channel();
let mut expected: Vec<String> = (0..limit)
.map(|x: usize| format!("{x}"))
.collect::<Vec<_>>... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/tests/sync_mpsc.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:10 | #[tokio::test]
#[cfg(feature = "full")]
async fn async_send_recv_unbounded() {
let (tx, mut rx) = mpsc::unbounded_channel();
tokio::spawn(async move {
assert_ok!(tx.send(1));
assert_ok!(tx.send(2));
});
assert_eq!(Some(1), rx.recv().await);
assert_eq!(Some(2), rx.recv().await);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/tests/sync_mpsc.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:11 | // sender should be Debug even though T isn't Debug
is_debug(&tx);
// same with Receiver
is_debug(&rx);
// and sender should be Clone even though T isn't Clone
assert!(tx.clone().try_send(NoImpls).is_ok());
assert!(rx.recv().await.is_some());
}
#[maybe_tokio_test]
async fn no_t_bounds_unbounde... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/tests/sync_mpsc.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:12 | // Take the value
assert!(rx.recv().await.is_some());
// Notified
assert!(p2.is_woken());
// Trying to send fails
assert_err!(tx.try_send(1337));
// Send second
let permit = assert_ready_ok!(p2.poll());
permit.send(2);
assert!(rx.recv().await.is_some());
}
#[maybe_tokio_test]
as... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/tests/sync_mpsc.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:13 | assert!(permit2.is_woken());
assert_ready_err!(permit2.poll());
{
let mut recv = tokio_test::task::spawn(rx.recv());
assert_pending!(recv.poll());
permit1.send(123);
assert!(recv.is_woken());
let v = assert_ready!(recv.poll());
assert_eq!(v, Some(123));
}
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/tests/sync_mpsc.rs | 481 | 540 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:14 | assert_eq!(rx.recv().await, Some("goodbye"));
assert!(rx.recv().await.is_none());
}
#[maybe_tokio_test]
async fn try_send_fail_with_try_recv() {
let (tx, mut rx) = mpsc::channel(1);
tx.try_send("hello").unwrap();
// This should fail
match assert_err!(tx.try_send("fail")) {
TrySendError::F... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/tests/sync_mpsc.rs | 521 | 580 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:15 | assert!(assert_ok!(tx.try_reserve_many(0)).next().is_none());
// Even when channel is full.
tx.try_send(()).unwrap();
assert!(assert_ok!(tx.try_reserve_many(0)).next().is_none());
drop(rx);
// Closed error when closed.
assert_eq!(
assert_err!(tx.try_reserve_many(0)),
TrySendEr... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/tests/sync_mpsc.rs | 561 | 620 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:16 | let permit = tx.try_reserve_many(MAX_PERMITS + 1);
match assert_err!(permit) {
TrySendError::Full(..) => {}
_ => panic!(),
}
let permit = tx.try_reserve_many(usize::MAX);
match assert_err!(permit) {
TrySendError::Full(..) => {}
_ => panic!(),
}
// Dropping the r... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/tests/sync_mpsc.rs | 601 | 660 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:17 | #[maybe_tokio_test]
async fn reserve_many_and_send() {
let (tx, mut rx) = mpsc::channel(100);
for i in 0..100 {
for permit in assert_ok!(tx.reserve_many(i).await) {
permit.send("foo");
assert_eq!(rx.recv().await, Some("foo"));
}
assert_eq!(rx.try_recv(), Err(TryRe... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/tests/sync_mpsc.rs | 641 | 700 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:18 | #[maybe_tokio_test]
#[cfg_attr(miri, ignore)] // Too slow on miri.
async fn try_reserve_many_full() {
// Reserve n capacity and send k messages
for n in 1..100 {
for k in 0..n {
let (tx, mut rx) = mpsc::channel::<usize>(n);
let permits = assert_ok!(tx.try_reserve_many(n));
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/tests/sync_mpsc.rs | 681 | 740 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:19 | }
}
#[tokio::test]
#[cfg(feature = "full")]
async fn drop_permit_releases_permit() {
// poll_ready reserves capacity, ensure that the capacity is released if tx
// is dropped w/o sending a value.
let (tx1, _rx) = mpsc::channel::<i32>(1);
let tx2 = tx1.clone();
let permit = assert_ok!(tx1.reserve()... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/tests/sync_mpsc.rs | 721 | 780 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:20 | drop(permits);
assert_eq!(tx1.capacity(), n);
}
}
#[maybe_tokio_test]
async fn dropping_rx_closes_channel() {
let (tx, rx) = mpsc::channel(100);
let msg = Arc::new(());
assert_ok!(tx.try_send(msg.clone()));
drop(rx);
assert_err!(tx.reserve().await);
assert_err!(tx.reserve_many(10... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/tests/sync_mpsc.rs | 761 | 820 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:21 | #[test]
fn unconsumed_messages_are_dropped() {
let msg = Arc::new(());
let (tx, rx) = mpsc::channel(100);
tx.try_send(msg.clone()).unwrap();
assert_eq!(2, Arc::strong_count(&msg));
drop((tx, rx));
assert_eq!(1, Arc::strong_count(&msg));
}
#[test]
#[cfg(all(feature = "full", not(target_os =... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/tests/sync_mpsc.rs | 801 | 860 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:22 | #[test]
#[cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support threads
fn blocking_send() {
let (tx, mut rx) = mpsc::channel::<u8>(1);
let sync_code = std::thread::spawn(move || {
tx.blocking_send(10).unwrap();
});
tokio::runtime::Runtime::new()
.unwrap()
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/tests/sync_mpsc.rs | 841 | 900 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:23 | assert!(recv.is_woken());
let val = assert_ready!(recv.poll());
assert!(val.is_none());
}
#[tokio::test]
#[cfg(feature = "full")]
async fn permit_available_not_acquired_close() {
let (tx1, mut rx) = mpsc::channel::<()>(1);
let tx2 = tx1.clone();
let permit1 = assert_ok!(tx1.reserve().await);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/tests/sync_mpsc.rs | 881 | 940 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:24 | assert_eq!(Ok("hello"), rx.try_recv());
assert_eq!(Ok("hello"), rx.try_recv());
assert_eq!(Err(TryRecvError::Empty), rx.try_recv());
tx.try_send("hello").unwrap();
tx.try_send("hello").unwrap();
tx.try_send("hello").unwrap();
tx.try_send("hello").unwrap();
assert_eq!(Ok("hello"), rx.try_rec... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/tests/sync_mpsc.rs | 921 | 980 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:25 | }
assert_eq!(rx.try_recv(), Err(TryRecvError::Empty));
drop(tx);
assert_eq!(rx.try_recv(), Err(TryRecvError::Disconnected));
}
}
#[test]
fn try_recv_after_receiver_close() {
let (_tx, mut rx) = mpsc::channel::<()>(5);
assert_eq!(Err(TryRecvError::Empty), rx.try_recv());
rx.clo... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/tests/sync_mpsc.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:26 | let (tx, rx) = mpsc::channel(5);
assert_eq!(tx.send_timeout(10, Duration::from_secs(1)).await, Ok(()));
assert_eq!(tx.send_timeout(20, Duration::from_secs(1)).await, Ok(()));
assert_eq!(tx.send_timeout(30, Duration::from_secs(1)).await, Ok(()));
assert_eq!(tx.send_timeout(40, Duration::from_secs(1)).aw... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/tests/sync_mpsc.rs | 1,001 | 1,060 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:27 | // after reserve, only capacity should drop by one
assert_eq!(tx.capacity(), 9);
assert_eq!(tx.max_capacity(), 10);
tx.send(()).await.unwrap();
// after send, capacity should drop by one again
assert_eq!(tx.capacity(), 8);
assert_eq!(tx.max_capacity(), 10);
}
#[tokio::test]
async fn test_rx_is... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/tests/sync_mpsc.rs | 1,041 | 1,100 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:28 | #[tokio::test]
async fn test_rx_is_not_closed_when_there_are_senders_and_buffer_filled() {
// is_closed should return false when there is a sender, even if enough messages have been sent to fill the channel
let (tx, rx) = mpsc::channel(10);
for i in 0..10 {
assert!(tx.send(i).await.is_ok());
}
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/tests/sync_mpsc.rs | 1,081 | 1,140 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:29 | #[tokio::test]
async fn test_rx_is_empty_when_no_messages_were_sent() {
let (_tx, rx) = mpsc::channel::<()>(10);
assert!(rx.is_empty())
}
#[tokio::test]
async fn test_rx_is_not_empty_when_there_are_messages_in_the_buffer() {
let (tx, rx) = mpsc::channel::<()>(10);
assert!(tx.send(()).await.is_ok());
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/tests/sync_mpsc.rs | 1,121 | 1,180 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:30 | for i in 0..10 {
assert!(tx.send(i).await.is_ok());
}
while rx.try_recv().is_ok() {}
assert!(rx.is_empty())
}
#[tokio::test]
async fn test_rx_is_empty_all_senders_are_dropped_and_messages_consumed() {
let (tx, mut rx) = mpsc::channel(10);
for i in 0..10 {
assert!(tx.send(i).await.is... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/tests/sync_mpsc.rs | 1,161 | 1,220 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:31 | let (tx, rx) = mpsc::channel(100);
for i in 0..100 {
assert!(tx.send(i).await.is_ok());
}
assert_eq!(rx.len(), 100);
}
#[tokio::test]
async fn test_rx_len_on_filled_channel_without_senders() {
let (tx, rx) = mpsc::channel(100);
for i in 0..100 {
assert!(tx.send(i).await.is_ok());
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/tests/sync_mpsc.rs | 1,201 | 1,260 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:32 | rx.close();
assert_eq!(rx.len(), 1);
}
#[tokio::test]
async fn test_rx_len_when_close_is_called_before_dropping_sender() {
let (tx, mut rx) = mpsc::channel(100);
tx.send(()).await.unwrap();
rx.close();
drop(tx);
assert_eq!(rx.len(), 1);
}
#[tokio::test]
async fn test_rx_len_when_close_is_cal... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/tests/sync_mpsc.rs | 1,241 | 1,300 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:33 | drop(another_tx);
});
drop(tx);
let _ = task.await;
assert!(rx.is_closed());
}
#[tokio::test]
async fn test_rx_unbounded_is_not_closed_when_there_are_senders() {
// is_closed should return false when there is a sender
let (_tx, rx) = mpsc::unbounded_channel::<()>();
assert!(!rx.is_closed(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/tests/sync_mpsc.rs | 1,281 | 1,340 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:34 | let (_tx, rx) = mpsc::unbounded_channel::<()>();
assert!(rx.is_empty())
}
#[tokio::test]
async fn test_rx_unbounded_is_not_empty_when_there_are_messages_in_the_buffer() {
let (tx, rx) = mpsc::unbounded_channel();
assert!(tx.send(()).is_ok());
assert!(!rx.is_empty())
}
#[tokio::test]
async fn test_rx_u... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/tests/sync_mpsc.rs | 1,321 | 1,380 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:35 | }
drop(tx);
for _ in 0..10 {
assert!(rx.recv().await.is_some());
}
assert!(rx.is_empty())
}
#[tokio::test]
async fn test_rx_unbounded_len_on_empty_channel() {
let (_tx, rx) = mpsc::unbounded_channel::<()>();
assert_eq!(rx.len(), 0);
}
#[tokio::test]
async fn test_rx_unbounded_len_on_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/tests/sync_mpsc.rs | 1,361 | 1,420 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:36 | for i in 0..100 {
assert!(tx.send(i).is_ok());
}
drop(tx);
assert_eq!(rx.len(), 100);
}
#[tokio::test]
async fn test_rx_unbounded_len_when_consuming_all_messages() {
let (tx, mut rx) = mpsc::unbounded_channel();
for i in 0..100 {
assert!(tx.send(i).is_ok());
assert_eq!(rx.l... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/tests/sync_mpsc.rs | 1,401 | 1,460 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:37 | assert_eq!(rx.len(), 1);
}
#[tokio::test]
async fn test_rx_unbounded_len_when_close_is_called_after_dropping_sender() {
let (tx, mut rx) = mpsc::unbounded_channel();
tx.send(()).unwrap();
drop(tx);
rx.close();
assert_eq!(rx.len(), 1);
}
// Regression test for https://github.com/tokio-rs/tokio/iss... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 484cb52d8d21cb8156decbeba9569651fcc09d0d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/484cb52d8d21cb8156decbeba9569651fcc09d0d/tokio/tests/sync_mpsc.rs | 1,441 | 1,466 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:37 | assert_eq!(rx.len(), 1);
}
#[tokio::test]
async fn test_rx_unbounded_len_when_close_is_called_after_dropping_sender() {
let (tx, mut rx) = mpsc::unbounded_channel();
tx.send(()).unwrap();
drop(tx);
rx.close();
assert_eq!(rx.len(), 1);
}
// Regression test for https://github.com/tokio-rs/tokio/iss... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | d060401f6c7dca4a20674e3ad63ad7f1b228aa31 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d060401f6c7dca4a20674e3ad63ad7f1b228aa31/tokio/tests/sync_mpsc.rs | 1,441 | 1,500 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:38 | if self.0 {
panic!("panic!")
}
}
}
fn func(tx: UnboundedSender<A>, rx: UnboundedReceiver<A>) {
tx.send(A(true)).unwrap();
tx.send(A(false)).unwrap();
tx.send(A(false)).unwrap();
drop(rx);
// `mpsc::Rx`'s drop is called and gets panic... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | d060401f6c7dca4a20674e3ad63ad7f1b228aa31 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d060401f6c7dca4a20674e3ad63ad7f1b228aa31/tokio/tests/sync_mpsc.rs | 1,481 | 1,512 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:24 | assert_eq!(Ok("hello"), rx.try_recv());
assert_eq!(Ok("hello"), rx.try_recv());
assert_eq!(Err(TryRecvError::Empty), rx.try_recv());
tx.try_send("hello").unwrap();
tx.try_send("hello").unwrap();
tx.try_send("hello").unwrap();
tx.try_send("hello").unwrap();
assert_eq!(Ok("hello"), rx.try_rec... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | a82bdeebe9560d22a0179ae7ff8ce3986202e24d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a82bdeebe9560d22a0179ae7ff8ce3986202e24d/tokio/tests/sync_mpsc.rs | 921 | 980 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:25 | }
assert_eq!(rx.try_recv(), Err(TryRecvError::Empty));
drop(tx);
assert_eq!(rx.try_recv(), Err(TryRecvError::Disconnected));
}
}
#[test]
fn try_recv_close_while_empty_bounded() {
let (tx, mut rx) = mpsc::channel::<()>(5);
assert_eq!(Err(TryRecvError::Empty), rx.try_recv());
dr... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | a82bdeebe9560d22a0179ae7ff8ce3986202e24d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a82bdeebe9560d22a0179ae7ff8ce3986202e24d/tokio/tests/sync_mpsc.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:26 | tx.send_timeout(60, Duration::from_secs(1)).await,
Err(Timeout(60))
);
drop(rx);
assert_eq!(
tx.send_timeout(70, Duration::from_secs(1)).await,
Err(Closed(70))
);
}
#[test]
#[should_panic = "there is no reactor running, must be called from the context of a Tokio 1.x runtime"]
#... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | a82bdeebe9560d22a0179ae7ff8ce3986202e24d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a82bdeebe9560d22a0179ae7ff8ce3986202e24d/tokio/tests/sync_mpsc.rs | 1,001 | 1,060 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:27 | #[tokio::test]
async fn test_rx_is_closed_when_calling_close_with_sender() {
// is_closed should return true after calling close but still has a sender
let (_tx, mut rx) = mpsc::channel::<()>(10);
rx.close();
assert!(rx.is_closed());
}
#[tokio::test]
async fn test_rx_is_closed_when_dropping_all_sender... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | a82bdeebe9560d22a0179ae7ff8ce3986202e24d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a82bdeebe9560d22a0179ae7ff8ce3986202e24d/tokio/tests/sync_mpsc.rs | 1,041 | 1,100 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:28 | }
#[tokio::test]
async fn test_rx_is_closed_when_there_are_no_senders_and_there_are_messages() {
// is_closed should return true when there are messages in the buffer, but no senders
let (tx, rx) = mpsc::channel(10);
for i in 0..10 {
assert!(tx.send(i).await.is_ok());
}
drop(tx);
assert... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | a82bdeebe9560d22a0179ae7ff8ce3986202e24d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a82bdeebe9560d22a0179ae7ff8ce3986202e24d/tokio/tests/sync_mpsc.rs | 1,081 | 1,140 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:29 | let (tx, rx) = mpsc::channel::<()>(10);
assert!(tx.send(()).await.is_ok());
assert!(!rx.is_empty())
}
#[tokio::test]
async fn test_rx_is_not_empty_when_the_buffer_is_full() {
let (tx, rx) = mpsc::channel(10);
for i in 0..10 {
assert!(tx.send(i).await.is_ok());
}
assert!(!rx.is_empty())
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | a82bdeebe9560d22a0179ae7ff8ce3986202e24d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a82bdeebe9560d22a0179ae7ff8ce3986202e24d/tokio/tests/sync_mpsc.rs | 1,121 | 1,180 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:30 | let (tx, mut rx) = mpsc::channel(10);
for i in 0..10 {
assert!(tx.send(i).await.is_ok());
}
drop(tx);
for _ in 0..10 {
assert!(rx.recv().await.is_some());
}
assert!(rx.is_empty())
}
#[tokio::test]
async fn test_rx_len_on_empty_channel() {
let (_tx, rx) = mpsc::channel::<()... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | a82bdeebe9560d22a0179ae7ff8ce3986202e24d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a82bdeebe9560d22a0179ae7ff8ce3986202e24d/tokio/tests/sync_mpsc.rs | 1,161 | 1,220 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:31 | async fn test_rx_len_on_filled_channel_without_senders() {
let (tx, rx) = mpsc::channel(100);
for i in 0..100 {
assert!(tx.send(i).await.is_ok());
}
drop(tx);
assert_eq!(rx.len(), 100);
}
#[tokio::test]
async fn test_rx_len_when_consuming_all_messages() {
let (tx, mut rx) = mpsc::chann... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | a82bdeebe9560d22a0179ae7ff8ce3986202e24d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a82bdeebe9560d22a0179ae7ff8ce3986202e24d/tokio/tests/sync_mpsc.rs | 1,201 | 1,260 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:32 | rx.close();
drop(tx);
assert_eq!(rx.len(), 1);
}
#[tokio::test]
async fn test_rx_len_when_close_is_called_after_dropping_sender() {
let (tx, mut rx) = mpsc::channel(100);
tx.send(()).await.unwrap();
drop(tx);
rx.close();
assert_eq!(rx.len(), 1);
}
#[tokio::test]
async fn test_rx_unbounde... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | a82bdeebe9560d22a0179ae7ff8ce3986202e24d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a82bdeebe9560d22a0179ae7ff8ce3986202e24d/tokio/tests/sync_mpsc.rs | 1,241 | 1,300 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:33 | #[tokio::test]
async fn test_rx_unbounded_is_not_closed_when_there_are_senders() {
// is_closed should return false when there is a sender
let (_tx, rx) = mpsc::unbounded_channel::<()>();
assert!(!rx.is_closed());
}
#[tokio::test]
async fn test_rx_unbounded_is_closed_when_there_are_no_senders_and_there_are... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | a82bdeebe9560d22a0179ae7ff8ce3986202e24d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a82bdeebe9560d22a0179ae7ff8ce3986202e24d/tokio/tests/sync_mpsc.rs | 1,281 | 1,340 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:34 | }
#[tokio::test]
async fn test_rx_unbounded_is_not_empty_when_all_but_one_messages_are_consumed() {
let (tx, mut rx) = mpsc::unbounded_channel();
for i in 0..10 {
assert!(tx.send(i).is_ok());
}
for _ in 0..9 {
assert!(rx.recv().await.is_some());
}
assert!(!rx.is_empty())
}
#[... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | a82bdeebe9560d22a0179ae7ff8ce3986202e24d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a82bdeebe9560d22a0179ae7ff8ce3986202e24d/tokio/tests/sync_mpsc.rs | 1,321 | 1,380 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:35 | #[tokio::test]
async fn test_rx_unbounded_len_on_empty_channel() {
let (_tx, rx) = mpsc::unbounded_channel::<()>();
assert_eq!(rx.len(), 0);
}
#[tokio::test]
async fn test_rx_unbounded_len_on_empty_channel_without_senders() {
// when all senders are dropped, a "closed" value is added to the end of the link... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | a82bdeebe9560d22a0179ae7ff8ce3986202e24d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a82bdeebe9560d22a0179ae7ff8ce3986202e24d/tokio/tests/sync_mpsc.rs | 1,361 | 1,420 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:36 | let (tx, mut rx) = mpsc::unbounded_channel();
for i in 0..100 {
assert!(tx.send(i).is_ok());
assert_eq!(rx.len(), i + 1);
}
drop(tx);
for i in (0..100).rev() {
assert!(rx.recv().await.is_some());
assert_eq!(rx.len(), i);
}
}
#[tokio::test]
async fn test_rx_unbound... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | a82bdeebe9560d22a0179ae7ff8ce3986202e24d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a82bdeebe9560d22a0179ae7ff8ce3986202e24d/tokio/tests/sync_mpsc.rs | 1,401 | 1,460 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:37 | assert_eq!(rx.len(), 1);
}
// Regression test for https://github.com/tokio-rs/tokio/issues/6602
#[tokio::test]
async fn test_is_empty_32_msgs() {
let (sender, mut receiver) = mpsc::channel(33);
for value in 1..257 {
sender.send(value).await.unwrap();
receiver.recv().await.unwrap();
ass... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | a82bdeebe9560d22a0179ae7ff8ce3986202e24d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a82bdeebe9560d22a0179ae7ff8ce3986202e24d/tokio/tests/sync_mpsc.rs | 1,441 | 1,500 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:38 | tx.send(A(false)).unwrap();
drop(rx);
// `mpsc::Rx`'s drop is called and gets panicked while dropping the first value,
// but will keep dropping following elements.
}
let (tx, rx) = mpsc::unbounded_channel();
let _ = panic::catch_unwind(panic::AssertUnwindSafe(|| {
func(t... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | a82bdeebe9560d22a0179ae7ff8ce3986202e24d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a82bdeebe9560d22a0179ae7ff8ce3986202e24d/tokio/tests/sync_mpsc.rs | 1,481 | 1,503 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:36 | let (tx, mut rx) = mpsc::unbounded_channel();
for i in 0..100 {
assert!(tx.send(i).is_ok());
assert_eq!(rx.len(), i + 1);
}
drop(tx);
for i in (0..100).rev() {
assert!(rx.recv().await.is_some());
assert_eq!(rx.len(), i);
}
}
#[tokio::test]
async fn test_rx_unbound... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/sync_mpsc.rs | 1,401 | 1,457 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:37 | assert_eq!(rx.len(), 1);
}
// Regression test for https://github.com/tokio-rs/tokio/issues/6602
#[tokio::test]
async fn test_is_empty_32_msgs() {
let (sender, mut receiver) = mpsc::channel(33);
for value in 1..257 {
sender.send(value).await.unwrap();
receiver.recv().await.unwrap();
ass... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 161b8c80d58a4a070c7f41db18d43ea258737db7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/sync_mpsc.rs | 1,441 | 1,457 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:17 | #[maybe_tokio_test]
async fn reserve_many_and_send() {
let (tx, mut rx) = mpsc::channel(100);
for i in 0..100 {
for permit in assert_ok!(tx.reserve_many(i).await) {
permit.send("foo");
assert_eq!(rx.recv().await, Some("foo"));
}
assert_eq!(rx.try_recv(), Err(TryRe... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9bd6702a3f52c71ab687170f6aeab6142d2282d0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9bd6702a3f52c71ab687170f6aeab6142d2282d0/tokio/tests/sync_mpsc.rs | 641 | 700 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:18 | #[maybe_tokio_test]
async fn try_reserve_many_full() {
// Reserve n capacity and send k messages
for n in 1..100 {
for k in 0..n {
let (tx, mut rx) = mpsc::channel::<usize>(n);
let permits = assert_ok!(tx.try_reserve_many(n));
assert_eq!(permits.len(), n);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9bd6702a3f52c71ab687170f6aeab6142d2282d0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9bd6702a3f52c71ab687170f6aeab6142d2282d0/tokio/tests/sync_mpsc.rs | 681 | 740 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:19 | }
#[tokio::test]
#[cfg(feature = "full")]
async fn drop_permit_releases_permit() {
// poll_ready reserves capacity, ensure that the capacity is released if tx
// is dropped w/o sending a value.
let (tx1, _rx) = mpsc::channel::<i32>(1);
let tx2 = tx1.clone();
let permit = assert_ok!(tx1.reserve().a... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9bd6702a3f52c71ab687170f6aeab6142d2282d0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9bd6702a3f52c71ab687170f6aeab6142d2282d0/tokio/tests/sync_mpsc.rs | 721 | 780 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:20 | assert_eq!(tx1.capacity(), n);
}
}
#[maybe_tokio_test]
async fn dropping_rx_closes_channel() {
let (tx, rx) = mpsc::channel(100);
let msg = Arc::new(());
assert_ok!(tx.try_send(msg.clone()));
drop(rx);
assert_err!(tx.reserve().await);
assert_err!(tx.reserve_many(10).await);
assert_eq!... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9bd6702a3f52c71ab687170f6aeab6142d2282d0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9bd6702a3f52c71ab687170f6aeab6142d2282d0/tokio/tests/sync_mpsc.rs | 761 | 820 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:21 | #[test]
fn unconsumed_messages_are_dropped() {
let msg = Arc::new(());
let (tx, rx) = mpsc::channel(100);
tx.try_send(msg.clone()).unwrap();
assert_eq!(2, Arc::strong_count(&msg));
drop((tx, rx));
assert_eq!(1, Arc::strong_count(&msg));
}
#[test]
#[cfg(all(feature = "full", not(target_os =... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9bd6702a3f52c71ab687170f6aeab6142d2282d0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9bd6702a3f52c71ab687170f6aeab6142d2282d0/tokio/tests/sync_mpsc.rs | 801 | 860 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:22 | #[test]
#[cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support threads
fn blocking_send() {
let (tx, mut rx) = mpsc::channel::<u8>(1);
let sync_code = std::thread::spawn(move || {
tx.blocking_send(10).unwrap();
});
tokio::runtime::Runtime::new()
.unwrap()
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9bd6702a3f52c71ab687170f6aeab6142d2282d0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9bd6702a3f52c71ab687170f6aeab6142d2282d0/tokio/tests/sync_mpsc.rs | 841 | 900 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:23 | assert!(recv.is_woken());
let val = assert_ready!(recv.poll());
assert!(val.is_none());
}
#[tokio::test]
#[cfg(feature = "full")]
async fn permit_available_not_acquired_close() {
let (tx1, mut rx) = mpsc::channel::<()>(1);
let tx2 = tx1.clone();
let permit1 = assert_ok!(tx1.reserve().await);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9bd6702a3f52c71ab687170f6aeab6142d2282d0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9bd6702a3f52c71ab687170f6aeab6142d2282d0/tokio/tests/sync_mpsc.rs | 881 | 940 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:24 | assert_eq!(Ok("hello"), rx.try_recv());
assert_eq!(Err(TryRecvError::Empty), rx.try_recv());
tx.try_send("hello").unwrap();
tx.try_send("hello").unwrap();
tx.try_send("hello").unwrap();
tx.try_send("hello").unwrap();
assert_eq!(Ok("hello"), rx.try_recv());
tx.try_send("hello").unwrap();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9bd6702a3f52c71ab687170f6aeab6142d2282d0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9bd6702a3f52c71ab687170f6aeab6142d2282d0/tokio/tests/sync_mpsc.rs | 921 | 980 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:25 | assert_eq!(rx.try_recv(), Err(TryRecvError::Empty));
drop(tx);
assert_eq!(rx.try_recv(), Err(TryRecvError::Disconnected));
}
}
#[test]
fn try_recv_close_while_empty_bounded() {
let (tx, mut rx) = mpsc::channel::<()>(5);
assert_eq!(Err(TryRecvError::Empty), rx.try_recv());
drop(tx);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9bd6702a3f52c71ab687170f6aeab6142d2282d0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9bd6702a3f52c71ab687170f6aeab6142d2282d0/tokio/tests/sync_mpsc.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:26 | Err(Timeout(60))
);
drop(rx);
assert_eq!(
tx.send_timeout(70, Duration::from_secs(1)).await,
Err(Closed(70))
);
}
#[test]
#[should_panic = "there is no reactor running, must be called from the context of a Tokio 1.x runtime"]
#[cfg(not(target_family = "wasm"))] // wasm currently doesn'... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9bd6702a3f52c71ab687170f6aeab6142d2282d0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9bd6702a3f52c71ab687170f6aeab6142d2282d0/tokio/tests/sync_mpsc.rs | 1,001 | 1,060 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:27 | #[tokio::test]
async fn test_rx_is_closed_when_calling_close_with_sender() {
// is_closed should return true after calling close but still has a sender
let (_tx, mut rx) = mpsc::channel::<()>(10);
rx.close();
assert!(rx.is_closed());
}
#[tokio::test]
async fn test_rx_is_closed_when_dropping_all_sender... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9bd6702a3f52c71ab687170f6aeab6142d2282d0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9bd6702a3f52c71ab687170f6aeab6142d2282d0/tokio/tests/sync_mpsc.rs | 1,041 | 1,100 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:28 | #[tokio::test]
async fn test_rx_is_closed_when_there_are_no_senders_and_there_are_messages() {
// is_closed should return true when there are messages in the buffer, but no senders
let (tx, rx) = mpsc::channel(10);
for i in 0..10 {
assert!(tx.send(i).await.is_ok());
}
drop(tx);
assert!(r... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9bd6702a3f52c71ab687170f6aeab6142d2282d0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9bd6702a3f52c71ab687170f6aeab6142d2282d0/tokio/tests/sync_mpsc.rs | 1,081 | 1,140 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:29 | assert!(tx.send(()).await.is_ok());
assert!(!rx.is_empty())
}
#[tokio::test]
async fn test_rx_is_not_empty_when_the_buffer_is_full() {
let (tx, rx) = mpsc::channel(10);
for i in 0..10 {
assert!(tx.send(i).await.is_ok());
}
assert!(!rx.is_empty())
}
#[tokio::test]
async fn test_rx_is_not_em... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9bd6702a3f52c71ab687170f6aeab6142d2282d0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9bd6702a3f52c71ab687170f6aeab6142d2282d0/tokio/tests/sync_mpsc.rs | 1,121 | 1,180 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:30 | for i in 0..10 {
assert!(tx.send(i).await.is_ok());
}
drop(tx);
for _ in 0..10 {
assert!(rx.recv().await.is_some());
}
assert!(rx.is_empty())
}
#[tokio::test]
async fn test_rx_len_on_empty_channel() {
let (_tx, rx) = mpsc::channel::<()>(100);
assert_eq!(rx.len(), 0);
}
#[... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9bd6702a3f52c71ab687170f6aeab6142d2282d0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9bd6702a3f52c71ab687170f6aeab6142d2282d0/tokio/tests/sync_mpsc.rs | 1,161 | 1,220 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:31 | let (tx, rx) = mpsc::channel(100);
for i in 0..100 {
assert!(tx.send(i).await.is_ok());
}
drop(tx);
assert_eq!(rx.len(), 100);
}
#[tokio::test]
async fn test_rx_len_when_consuming_all_messages() {
let (tx, mut rx) = mpsc::channel(100);
for i in 0..100 {
assert!(tx.send(i).awai... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9bd6702a3f52c71ab687170f6aeab6142d2282d0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9bd6702a3f52c71ab687170f6aeab6142d2282d0/tokio/tests/sync_mpsc.rs | 1,201 | 1,260 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:32 | drop(tx);
assert_eq!(rx.len(), 1);
}
#[tokio::test]
async fn test_rx_len_when_close_is_called_after_dropping_sender() {
let (tx, mut rx) = mpsc::channel(100);
tx.send(()).await.unwrap();
drop(tx);
rx.close();
assert_eq!(rx.len(), 1);
}
#[tokio::test]
async fn test_rx_unbounded_is_closed_when... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9bd6702a3f52c71ab687170f6aeab6142d2282d0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9bd6702a3f52c71ab687170f6aeab6142d2282d0/tokio/tests/sync_mpsc.rs | 1,241 | 1,300 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:33 | async fn test_rx_unbounded_is_not_closed_when_there_are_senders() {
// is_closed should return false when there is a sender
let (_tx, rx) = mpsc::unbounded_channel::<()>();
assert!(!rx.is_closed());
}
#[tokio::test]
async fn test_rx_unbounded_is_closed_when_there_are_no_senders_and_there_are_messages() {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9bd6702a3f52c71ab687170f6aeab6142d2282d0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9bd6702a3f52c71ab687170f6aeab6142d2282d0/tokio/tests/sync_mpsc.rs | 1,281 | 1,340 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:34 | #[tokio::test]
async fn test_rx_unbounded_is_not_empty_when_all_but_one_messages_are_consumed() {
let (tx, mut rx) = mpsc::unbounded_channel();
for i in 0..10 {
assert!(tx.send(i).is_ok());
}
for _ in 0..9 {
assert!(rx.recv().await.is_some());
}
assert!(!rx.is_empty())
}
#[tok... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9bd6702a3f52c71ab687170f6aeab6142d2282d0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9bd6702a3f52c71ab687170f6aeab6142d2282d0/tokio/tests/sync_mpsc.rs | 1,321 | 1,380 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:36 | for i in 0..100 {
assert!(tx.send(i).is_ok());
assert_eq!(rx.len(), i + 1);
}
drop(tx);
for i in (0..100).rev() {
assert!(rx.recv().await.is_some());
assert_eq!(rx.len(), i);
}
}
#[tokio::test]
async fn test_rx_unbounded_len_when_close_is_called() {
let (tx, mut rx... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9bd6702a3f52c71ab687170f6aeab6142d2282d0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9bd6702a3f52c71ab687170f6aeab6142d2282d0/tokio/tests/sync_mpsc.rs | 1,401 | 1,456 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:1 | #![allow(clippy::redundant_clone)]
#![warn(rust_2018_idioms)]
#![cfg(feature = "sync")]
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_tes... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:2 | drop(tx);
let val = rx.recv().await;
assert_eq!(val, Some(1));
let val = rx.recv().await;
assert_eq!(val, Some(2));
let val = rx.recv().await;
assert!(val.is_none());
}
#[tokio::test]
#[cfg(feature = "full")]
async fn reserve_disarm() {
let (tx, mut rx) = mpsc::channel::<i32>(2);
let... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:3 | assert!(!r4.is_woken());
// Dropping a permit should also open up a slot
drop(permit2);
assert!(r4.is_woken());
let mut r1 = tokio_test::task::spawn(tx1.reserve());
assert_pending!(r1.poll());
}
#[tokio::test]
#[cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support threads
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:4 | assert_eq!(None, rx.recv().await);
}
#[tokio::test]
#[cfg(feature = "full")]
async fn async_send_recv_many_with_buffer() {
let (tx, mut rx) = mpsc::channel(2);
let mut buffer = Vec::<i32>::with_capacity(3);
// With `limit=0` does not sleep, returns immediately
assert_eq!(0, rx.recv_many(&mut buffer, 0... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:5 | assert_ok!(tx1.try_send(()));
let mut r1 = Box::pin(tx1.reserve());
t1.enter(|cx, _| assert_pending!(r1.as_mut().poll(cx)));
{
let mut r2 = tokio_test::task::spawn(tx2.reserve());
assert_pending!(r2.poll());
drop(r1);
assert!(rx.recv().await.is_some());
assert!(r... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:6 | assert_eq!(rx.recv().await, Some(2));
drop(tx);
assert!(rx.recv().await.is_none());
}
#[maybe_tokio_test]
async fn send_recv_many_unbounded() {
let (tx, mut rx) = mpsc::unbounded_channel::<i32>();
let mut buffer: Vec<i32> = Vec::new();
// With `limit=0` does not sleep, returns immediately
r... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:7 | // Re-use existing capacity
count = rx.recv_many(&mut buffer, 32).await;
assert_eq!(final_capacity, buffer.capacity());
assert_eq!(count, 4);
assert_eq!(vec![5, 6, 7, 2], buffer);
drop(tx);
// recv_many will immediately return zero if the channel
// is closed and no more messages are wait... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:8 | assert!(buffer.capacity() > limit);
expected.push("one more".to_string());
assert_eq!(expected, buffer);
tokio::spawn(async move {
tx.send("final".to_string()).await.unwrap();
});
// 'tx' is dropped, but `recv_many` is guaranteed not
// to return 0 as the channel has outstanding permit... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:9 | // Receive up more values:
assert_eq!(1, rx.recv_many(&mut buffer, limit).await);
assert!(buffer.capacity() > limit);
expected.push("one more".to_string());
assert_eq!(expected, buffer);
tokio::spawn(async move {
tx.send("final".to_string()).unwrap();
});
// 'tx' is dropped, but `r... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:10 | let (tx, rx) = support::mpsc_stream::unbounded_channel_stream::<i32>();
let mut rx = Box::pin(rx);
tokio::spawn(async move {
assert_ok!(tx.send(1));
assert_ok!(tx.send(2));
});
assert_eq!(Some(1), rx.next().await);
assert_eq!(Some(2), rx.next().await);
assert_eq!(None, rx.next... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:11 | // and sender should be Clone even though T isn't Clone
assert!(tx.clone().send(NoImpls).is_ok());
assert!(rx.recv().await.is_some());
}
#[tokio::test]
#[cfg(feature = "full")]
async fn send_recv_buffer_limited() {
let (tx, mut rx) = mpsc::channel::<i32>(1);
// Reserve capacity
let p1 = assert_ok... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:12 | rx.close();
assert!(rx.recv().await.is_none());
assert_err!(tx.send(1).await);
}
#[tokio::test]
#[cfg(feature = "full")]
async fn recv_close_gets_none_reserved() {
let (tx1, mut rx) = mpsc::channel::<i32>(1);
let tx2 = tx1.clone();
let permit1 = assert_ok!(tx1.reserve().await);
let mut permi... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:13 | assert!(rx.recv().await.is_none());
}
#[maybe_tokio_test]
async fn try_send_fail() {
let (tx, mut rx) = mpsc::channel(1);
tx.try_send("hello").unwrap();
// This should fail
match assert_err!(tx.try_send("fail")) {
TrySendError::Full(..) => {}
_ => panic!(),
}
assert_eq!(rx.re... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 481 | 540 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:14 | assert_eq!(rx.try_recv(), Ok("goodbye"));
assert_eq!(rx.try_recv(), Err(TryRecvError::Disconnected));
}
#[maybe_tokio_test]
async fn reserve_many_above_cap() {
const MAX_PERMITS: usize = tokio::sync::Semaphore::MAX_PERMITS;
let (tx, _rx) = mpsc::channel::<()>(1);
assert_err!(tx.reserve_many(2).await);... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 521 | 580 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:15 | assert!(assert_ok!(tx.reserve_many(0).await).next().is_none());
// Even when channel is full.
tx.send(()).await.unwrap();
assert!(assert_ok!(tx.reserve_many(0).await).next().is_none());
drop(rx);
// Closed error when closed.
assert_err!(tx.reserve_many(0).await);
}
#[maybe_tokio_test]
async ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 561 | 620 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:16 | let (tx, mut rx) = mpsc::channel(1);
let permit = tx.try_reserve().unwrap();
// This should fail
match assert_err!(tx.try_reserve()) {
TrySendError::Full(()) => {}
_ => panic!(),
}
permit.send("foo");
assert_eq!(rx.recv().await, Some("foo"));
// Dropping permit releases ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 601 | 660 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:17 | assert_eq!(rx.try_recv(), Err(TryRecvError::Empty));
}
}
#[maybe_tokio_test]
async fn reserve_many_on_closed_channel() {
let (tx, rx) = mpsc::channel::<()>(100);
drop(rx);
assert_err!(tx.reserve_many(10).await);
}
#[maybe_tokio_test]
async fn try_reserve_many_on_closed_channel() {
let (tx, rx) = m... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 641 | 700 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:18 | // We only used k permits on the n reserved
assert_eq!(tx.capacity(), n - k);
// We can reserve more permits
assert_ok!(tx.try_reserve_many(1));
// But not more than the current capacity
match assert_err!(tx.try_reserve_many(n - k + 1)) {
Try... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 681 | 740 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:19 | #[maybe_tokio_test]
async fn drop_permit_iterator_releases_permits() {
// poll_ready reserves capacity, ensure that the capacity is released if tx
// is dropped w/o sending a value.
for n in 1..100 {
let (tx1, _rx) = mpsc::channel::<i32>(n);
let tx2 = tx1.clone();
let permits = asse... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 721 | 780 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:20 | let (tx, rx) = mpsc::channel(100);
let msg = Arc::new(());
tx.try_send(msg.clone()).unwrap();
drop(rx);
assert!(matches!(
tx.try_send(msg.clone()),
Err(TrySendError::Closed(_))
));
assert!(matches!(tx.try_reserve(), Err(TrySendError::Closed(_))));
assert!(matches!(
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 761 | 820 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:21 | let sync_code = std::thread::spawn(move || {
assert_eq!(Some(10), rx.blocking_recv());
});
tokio::runtime::Runtime::new()
.unwrap()
.block_on(async move {
let _ = tx.send(10).await;
});
sync_code.join().unwrap()
}
#[tokio::test]
#[should_panic]
#[cfg(not(target_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 801 | 860 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:22 | async fn blocking_send_async() {
let (tx, _rx) = mpsc::channel::<()>(1);
let _ = tx.blocking_send(());
}
#[tokio::test]
#[cfg(feature = "full")]
async fn ready_close_cancel_bounded() {
let (tx, mut rx) = mpsc::channel::<()>(100);
let _tx2 = tx.clone();
let permit = assert_ok!(tx.reserve().await);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 841 | 900 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:23 | drop(permit2);
assert!(rx.recv().await.is_none());
}
#[test]
fn try_recv_bounded() {
let (tx, mut rx) = mpsc::channel(5);
tx.try_send("hello").unwrap();
tx.try_send("hello").unwrap();
tx.try_send("hello").unwrap();
tx.try_send("hello").unwrap();
tx.try_send("hello").unwrap();
assert!(t... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 881 | 940 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:24 | tx.try_send("hello").unwrap();
drop(tx);
assert_eq!(Ok("hello"), rx.try_recv());
assert_eq!(Ok("hello"), rx.try_recv());
assert_eq!(Ok("hello"), rx.try_recv());
assert_eq!(Err(TryRecvError::Disconnected), rx.try_recv());
}
#[test]
fn try_recv_unbounded() {
for num in 0..100 {
let (tx, m... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 921 | 980 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:25 | assert_eq!(Err(TryRecvError::Empty), rx.try_recv());
drop(tx);
assert_eq!(Err(TryRecvError::Disconnected), rx.try_recv());
}
#[tokio::test(start_paused = true)]
#[cfg(feature = "full")]
async fn recv_timeout() {
use tokio::sync::mpsc::error::SendTimeoutError::{Closed, Timeout};
use tokio::time::Duratio... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:26 | // Tests that channel `capacity` changes and `max_capacity` stays the same
#[tokio::test]
async fn test_tx_capacity() {
let (tx, _rx) = mpsc::channel::<()>(10);
// both capacities are same before
assert_eq!(tx.capacity(), 10);
assert_eq!(tx.max_capacity(), 10);
let _permit = tx.reserve().await.unwr... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 1,001 | 1,060 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:27 | assert!(rx.is_closed());
}
#[tokio::test]
async fn test_rx_is_not_closed_when_there_are_senders() {
// is_closed should return false when there is a sender
let (_tx, rx) = mpsc::channel::<()>(10);
assert!(!rx.is_closed());
}
#[tokio::test]
async fn test_rx_is_not_closed_when_there_are_senders_and_buffer_f... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 1,041 | 1,100 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:28 | assert!(rx.is_closed());
}
#[tokio::test]
async fn test_rx_is_not_closed_when_there_are_permits_but_not_senders() {
// is_closed should return false when there is a permit (but no senders)
let (tx, rx) = mpsc::channel::<()>(10);
let _permit = tx.reserve_owned().await.expect("Failed to reserve permit");
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 1,081 | 1,140 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:29 | for _ in 0..9 {
assert!(rx.recv().await.is_some());
}
assert!(!rx.is_empty())
}
#[tokio::test]
async fn test_rx_is_empty_when_all_messages_are_consumed() {
let (tx, mut rx) = mpsc::channel(10);
for i in 0..10 {
assert!(tx.send(i).await.is_ok());
}
while rx.try_recv().is_ok() {}... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 1,121 | 1,180 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:30 | // when all senders are dropped, a "closed" value is added to the end of the linked list.
// here we test that the "closed" value does not change the len of the channel.
let (tx, rx) = mpsc::channel::<()>(100);
drop(tx);
assert_eq!(rx.len(), 0);
}
#[tokio::test]
async fn test_rx_len_on_filled_channel(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 1,161 | 1,220 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:31 | for i in (0..100).rev() {
assert!(rx.recv().await.is_some());
assert_eq!(rx.len(), i);
}
}
#[tokio::test]
async fn test_rx_len_when_close_is_called() {
let (tx, mut rx) = mpsc::channel(100);
tx.send(()).await.unwrap();
rx.close();
assert_eq!(rx.len(), 1);
}
#[tokio::test]
async fn... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 1,201 | 1,260 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:32 | assert!(rx.is_closed());
}
#[tokio::test]
async fn test_rx_unbounded_is_closed_when_dropping_all_senders() {
// is_closed should return true after dropping all senders
let (tx, rx) = mpsc::unbounded_channel::<()>();
let another_tx = tx.clone();
let task = tokio::spawn(async move {
drop(another_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 1,241 | 1,300 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:33 | let (tx, mut rx) = mpsc::unbounded_channel();
for i in 0..10 {
assert!(tx.send(i).is_ok());
}
rx.close();
assert!(rx.is_closed());
}
#[tokio::test]
async fn test_rx_unbounded_is_empty_when_no_messages_were_sent() {
let (_tx, rx) = mpsc::unbounded_channel::<()>();
assert!(rx.is_empty())
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | dbf93c71844a01574a10f9dee0d4d9655a569f0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dbf93c71844a01574a10f9dee0d4d9655a569f0a/tokio/tests/sync_mpsc.rs | 1,281 | 1,340 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.