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_broadcast.rs:9 | fn unconsumed_messages_are_dropped() {
let (tx, rx) = broadcast::channel(16);
let msg = Arc::new(());
assert_ok!(tx.send(msg.clone()));
assert_eq!(2, Arc::strong_count(&msg));
drop(rx);
assert_eq!(1, Arc::strong_count(&msg));
}
fn is_closed(err: broadcast::RecvError) -> bool {
match er... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_broadcast.rs | MIT | 3bff5a3ffe68c7bbf94fc91a58633f5a91f4266c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3bff5a3ffe68c7bbf94fc91a58633f5a91f4266c/tokio/tests/sync_broadcast.rs | 321 | 340 |
tokio-rs/tokio:tokio/tests/sync_broadcast.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "sync")]
use tokio::sync::broadcast;
use tokio_test::task;
use tokio_test::{
assert_err, assert_ok, assert_pending, assert_ready, assert_ready_err, assert_ready_ok,
};
use std::sync::Arc;
macro_rules! assert_recv {
($e:expr) => {
match $e.try_recv() {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_broadcast.rs | MIT | 7c010ed030d0084d38451bbebf727c6695c2dbac | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7c010ed030d0084d38451bbebf727c6695c2dbac/tokio/tests/sync_broadcast.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/sync_broadcast.rs:2 | trait AssertSend: Send {}
impl AssertSend for broadcast::Sender<i32> {}
impl AssertSend for broadcast::Receiver<i32> {}
#[test]
fn send_try_recv_bounded() {
let (tx, mut rx) = broadcast::channel(16);
assert_empty!(rx);
let n = assert_ok!(tx.send("hello"));
assert_eq!(n, 1);
let val = assert_recv... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_broadcast.rs | MIT | 7c010ed030d0084d38451bbebf727c6695c2dbac | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7c010ed030d0084d38451bbebf727c6695c2dbac/tokio/tests/sync_broadcast.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/sync_broadcast.rs:3 | #[test]
fn send_recv_bounded() {
let (tx, mut rx) = broadcast::channel(16);
let mut recv = task::spawn(rx.recv());
assert_pending!(recv.poll());
assert_ok!(tx.send("hello"));
assert!(recv.is_woken());
let val = assert_ready_ok!(recv.poll());
assert_eq!(val, "hello");
}
#[test]
fn send_t... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_broadcast.rs | MIT | 7c010ed030d0084d38451bbebf727c6695c2dbac | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7c010ed030d0084d38451bbebf727c6695c2dbac/tokio/tests/sync_broadcast.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/sync_broadcast.rs:4 | let mut recv2 = task::spawn(rx2.recv());
assert_pending!(recv1.poll());
assert_ok!(tx.send("world"));
assert!(recv1.is_woken());
assert!(!recv2.is_woken());
let val1 = assert_ready_ok!(recv1.poll());
let val2 = assert_ready_ok!(recv2.poll());
assert_eq!(val1, "world");
assert_eq!(val... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_broadcast.rs | MIT | 7c010ed030d0084d38451bbebf727c6695c2dbac | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7c010ed030d0084d38451bbebf727c6695c2dbac/tokio/tests/sync_broadcast.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/sync_broadcast.rs:5 | let val = assert_ready_ok!(task::spawn(rx1.recv()).poll());
assert_eq!(val, "two");
let mut recv1 = task::spawn(rx1.recv());
assert_pending!(recv1.poll());
assert_ok!(tx.send("three"));
assert!(recv1.is_woken());
let val = assert_ready_ok!(recv1.poll());
asse... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_broadcast.rs | MIT | 7c010ed030d0084d38451bbebf727c6695c2dbac | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7c010ed030d0084d38451bbebf727c6695c2dbac/tokio/tests/sync_broadcast.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/sync_broadcast.rs:6 | #[test]
fn lagging_rx() {
let (tx, mut rx1) = broadcast::channel(2);
let mut rx2 = tx.subscribe();
assert_ok!(tx.send("one"));
assert_ok!(tx.send("two"));
assert_eq!("one", assert_recv!(rx1));
assert_ok!(tx.send("three"));
// Lagged too far
assert_lagged!(rx2.try_recv(), 1);
// ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_broadcast.rs | MIT | 7c010ed030d0084d38451bbebf727c6695c2dbac | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7c010ed030d0084d38451bbebf727c6695c2dbac/tokio/tests/sync_broadcast.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/sync_broadcast.rs:7 | let val = assert_recv!(rx);
assert_eq!("world", val);
}
#[test]
#[should_panic]
fn zero_capacity() {
broadcast::channel::<()>(0);
}
#[test]
#[should_panic]
fn capacity_too_big() {
use std::usize;
broadcast::channel::<()>(1 + (usize::MAX >> 1));
}
#[test]
fn panic_in_clone() {
use std::panic::{se... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_broadcast.rs | MIT | 7c010ed030d0084d38451bbebf727c6695c2dbac | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7c010ed030d0084d38451bbebf727c6695c2dbac/tokio/tests/sync_broadcast.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/sync_broadcast.rs:8 | }));
assert_err!(res);
let val = assert_recv!(rx);
assert_eq!(val, MyVal(1));
}
#[test]
fn dropping_tx_notifies_rx() {
let (tx, mut rx1) = broadcast::channel::<()>(16);
let mut rx2 = tx.subscribe();
let tx2 = tx.clone();
let mut recv1 = task::spawn(rx1.recv());
let mut recv2 = task:... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_broadcast.rs | MIT | 7c010ed030d0084d38451bbebf727c6695c2dbac | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7c010ed030d0084d38451bbebf727c6695c2dbac/tokio/tests/sync_broadcast.rs | 281 | 339 |
tokio-rs/tokio:tokio/tests/sync_broadcast.rs:9 | let (tx, rx) = broadcast::channel(16);
let msg = Arc::new(());
assert_ok!(tx.send(msg.clone()));
assert_eq!(2, Arc::strong_count(&msg));
drop(rx);
assert_eq!(1, Arc::strong_count(&msg));
}
fn is_closed(err: broadcast::RecvError) -> bool {
match err {
broadcast::RecvError::Closed =>... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_broadcast.rs | MIT | 7c010ed030d0084d38451bbebf727c6695c2dbac | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7c010ed030d0084d38451bbebf727c6695c2dbac/tokio/tests/sync_broadcast.rs | 321 | 339 |
tokio-rs/tokio:tokio/tests/sync_broadcast_weak.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;
use tokio::sync::broadcast::{self, channel};
#[tokio::test]
async fn weak_sender() {
let (tx, mut rx) = channel(11... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_broadcast_weak.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_broadcast_weak.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/sync_broadcast_weak.rs:2 | }
}
Err(_) => {
assert_eq!(i, 11);
break;
}
}
}
let tx_weak = tx_weak.unwrap();
let upgraded = tx_weak.upgrade();
assert!(upgraded.is_none());
}
// Tests that a `WeakSender` fails to upgrade when no other `Sender` exists.
#[te... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_broadcast_weak.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_broadcast_weak.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/sync_broadcast_weak.rs:3 | let tx_weak2 = tx.downgrade();
assert_eq!(tx.strong_count(), 1);
assert_eq!(tx.weak_count(), 2);
drop(tx);
assert!(tx_weak.upgrade().is_none());
assert!(tx_weak2.upgrade().is_none());
assert_eq!(tx_weak.strong_count(), 0);
assert_eq!(tx_weak.weak_count(), 2);
}
#[tokio::test]
async fn tes... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_broadcast_weak.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_broadcast_weak.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/sync_broadcast_weak.rs:4 | assert_eq!(tx.weak_count(), 1);
assert_eq!(weak.weak_count(), 1);
}
#[tokio::test]
async fn sender_strong_count_when_dropped() {
let (tx, rx) = broadcast::channel::<()>(1);
let tx2 = tx.clone();
drop(tx2);
assert_eq!(tx.strong_count(), 1);
assert_eq!(rx.sender_strong_count(), 1);
}
#[tokio:... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_broadcast_weak.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_broadcast_weak.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/sync_broadcast_weak.rs:5 | assert_eq!(weak.strong_count(), 2);
assert_eq!(weak2.strong_count(), 2);
assert_eq!(rx.sender_strong_count(), 2);
assert_eq!(tx.weak_count(), 2);
assert_eq!(tx2.weak_count(), 2);
assert_eq!(weak.weak_count(), 2);
assert_eq!(weak2.weak_count(), 2);
assert_eq!(rx.sender_weak_count(), 2);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_broadcast_weak.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_broadcast_weak.rs | 161 | 181 |
tokio-rs/tokio:tokio/tests/sync_cancellation_token.rs:1 | #![cfg(tokio_unstable)]
use tokio::pin;
use tokio::sync::CancellationToken;
use core::future::Future;
use core::task::{Context, Poll};
use futures_test::task::new_count_waker;
#[test]
fn cancel_token() {
let (waker, wake_counter) = new_count_waker();
let token = CancellationToken::new();
assert_eq!(false... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_cancellation_token.rs | MIT | 264ae3bdb22004609de45b67e2890081bb47e5b2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/264ae3bdb22004609de45b67e2890081bb47e5b2/tokio/tests/sync_cancellation_token.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/sync_cancellation_token.rs:5 | Poll::Ready(()),
child_fut.as_mut().poll(&mut Context::from_waker(&waker))
);
assert_eq!(
Poll::Ready(()),
parent_fut.as_mut().poll(&mut Context::from_waker(&waker))
);
assert_eq!(wake_counter, 0);
drop(child_fu... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_cancellation_token.rs | MIT | 264ae3bdb22004609de45b67e2890081bb47e5b2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/264ae3bdb22004609de45b67e2890081bb47e5b2/tokio/tests/sync_cancellation_token.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/sync_errors.rs:1 | #![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;
fn is_error<T: std::error::Error + Send + Sync>() {}
#[test]
fn mpsc_error_bound() {
use tokio::sync::mpsc::error;
is_error::<error::SendError<(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_errors.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_errors.rs | 1 | 30 |
tokio-rs/tokio:tokio/tests/sync_errors.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "sync")]
#[cfg(tokio_wasm_not_wasi)]
use wasm_bindgen_test::wasm_bindgen_test as test;
fn is_error<T: std::error::Error + Send + Sync>() {}
#[test]
fn mpsc_error_bound() {
use tokio::sync::mpsc::error;
is_error::<error::SendError<()>>();
is_error::<error::TryS... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_errors.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/sync_errors.rs | 1 | 30 |
tokio-rs/tokio:tokio/tests/sync_errors.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "sync")]
#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
use wasm_bindgen_test::wasm_bindgen_test as test;
fn is_error<T: std::error::Error + Send + Sync>() {}
#[test]
fn mpsc_error_bound() {
use tokio::sync::mpsc::error;
is_error::<error::SendError<(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_errors.rs | MIT | 6d3f92dddc510e9276191cfab1b0432ce8248589 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/tests/sync_errors.rs | 1 | 30 |
tokio-rs/tokio:tokio/tests/sync_errors.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "sync")]
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;
fn is_error<T: std::error::Error + Send + Sync>() {}
#[test]
fn mpsc_error_bound() {
use tokio::sync::mpsc::error;
is_error::<error::SendError<()>>();
is_error::<error::T... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_errors.rs | MIT | 2747043f6f7e0870cc5aa72c146dfae9543c5ba8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2747043f6f7e0870cc5aa72c146dfae9543c5ba8/tokio/tests/sync_errors.rs | 1 | 30 |
tokio-rs/tokio:tokio/tests/sync_errors.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
fn is_error<T: std::error::Error + Send + Sync>() {}
#[test]
fn mpsc_error_bound() {
use tokio::sync::mpsc::error;
is_error::<error::SendError<()>>();
is_error::<error::TrySendError<()>>();
}
#[test]
fn oneshot_error_bound() {
use tokio::sync::one... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_errors.rs | MIT | dcfa895b512e3ed522b81b18baf3e33fd78a600c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/dcfa895b512e3ed522b81b18baf3e33fd78a600c/tokio/tests/sync_errors.rs | 1 | 27 |
tokio-rs/tokio:tokio/tests/sync_errors.rs:1 | #![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
fn is_error<T: ::std::error::Error + Send + Sync>() {}
#[test]
fn mpsc_error_bound() {
use tokio::sync::mpsc::error;
is_error::<error::SendError<()>>();
is_error::<error::TrySendError<()>>();
}
#[test]
fn oneshot_error_bound() {
use tokio::sync::o... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_errors.rs | MIT | 7b4c999341809588a427a9a80d310ee4aa1c1a21 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7b4c999341809588a427a9a80d310ee4aa1c1a21/tokio/tests/sync_errors.rs | 1 | 27 |
tokio-rs/tokio:tokio/tests/sync_errors.rs:1 | #![warn(rust_2018_idioms)]
fn is_error<T: ::std::error::Error + Send + Sync>() {}
#[test]
fn mpsc_error_bound() {
use tokio::sync::mpsc::error;
is_error::<error::SendError<()>>();
is_error::<error::TrySendError<()>>();
}
#[test]
fn oneshot_error_bound() {
use tokio::sync::oneshot::error;
is_err... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_errors.rs | MIT | 8a7e57786a5dca139f5b4261685e22991ded0859 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/tests/sync_errors.rs | 1 | 26 |
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 | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:2 | impl<'a, T> AssertUnwindSafe for mpsc::PermitIterator<'a, T> {}
impl<T> AssertUnwindSafe for mpsc::Receiver<T> {}
impl<T> AssertUnwindSafe for mpsc::Sender<T> {}
impl<T> AssertUnwindSafe for mpsc::UnboundedReceiver<T> {}
impl<T> AssertUnwindSafe for mpsc::UnboundedSender<T> {}
impl<T> AssertUnwindSafe for mpsc::WeakSen... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 41 | 100 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:3 | // We should be able to `poll_ready` two handles without problem
let permit1 = assert_ok!(tx1.reserve().await);
let permit2 = assert_ok!(tx2.reserve().await);
// But a third should not be ready
let mut r3 = tokio_test::task::spawn(tx3.reserve());
assert_pending!(r3.poll());
let mut r4 = tokio_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 81 | 140 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:4 | assert_ok!(tx.send(2).await);
});
assert_eq!(Some(1), rx.next().await);
assert_eq!(Some(2), rx.next().await);
assert_eq!(None, rx.next().await);
}
#[tokio::test]
#[cfg(feature = "full")]
async fn async_send_recv_with_buffer() {
let (tx, mut rx) = mpsc::channel(16);
tokio::spawn(async move {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:5 | let mut recv_count = 0usize;
while recv_count < 4 {
recv_count += rx.recv_many(&mut buffer, limit).await;
assert_eq!(buffer.len(), recv_count);
}
assert_eq!(vec![1, 2, 7, 0], buffer);
assert_eq!(0, rx.recv_many(&mut buffer, limit).await);
handle.await.unwrap();
}
#[tokio::test]
#[c... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:6 | assert!(rx.recv().await.is_none());
}
#[test]
#[should_panic]
#[cfg(not(target_family = "wasm"))] // wasm currently doesn't support unwinding
fn buffer_gteq_one() {
mpsc::channel::<i32>(0);
}
#[maybe_tokio_test]
async fn send_recv_unbounded() {
let (tx, mut rx) = mpsc::unbounded_channel::<i32>();
// Usin... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:7 | assert_ok!(tx.send(1002));
rx.recv_many(&mut buffer, 0).await;
assert_eq!(0, buffer.len());
let mut count = 0;
while count < 4 {
count += rx.recv_many(&mut buffer, 1).await;
}
assert_eq!(count, 4);
assert_eq!(vec![7, 13, 100, 1002], buffer);
let final_capacity = buffer.capacity... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:8 | let limit = buffer.capacity();
let (tx, mut rx) = mpsc::channel(100);
let mut expected: Vec<String> = (0..limit)
.map(|x: usize| format!("{x}"))
.collect::<Vec<_>>();
for x in expected.clone() {
tx.send(x).await.unwrap()
}
tx.send("one more".to_string()).await.unwrap();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 281 | 340 |
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 | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:10 | #[maybe_tokio_test]
async fn recv_many_with_non_empty_buffer_bounded_rx_closed_and_idle() {
let (_tx, mut rx) = mpsc::channel::<i32>(1);
let mut buffer: Vec<i32> = vec![1];
rx.close();
assert_eq!(0, rx.recv_many(&mut buffer, 1).await);
assert_eq!(vec![1], buffer);
}
#[maybe_tokio_test]
async fn ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:11 | #[cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support threads
async fn send_recv_stream_unbounded() {
use tokio_stream::StreamExt;
let (tx, rx) = support::mpsc_stream::unbounded_channel_stream::<i32>();
let mut rx = Box::pin(rx);
tokio::spawn(async move {
assert_ok!(t... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:12 | // 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().send(NoImpls).is_ok());
assert!(rx.recv().await.is_some());
}
#[tokio::test]
#[cfg(feature = "full")]
async fn send... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:13 | #[maybe_tokio_test]
async fn recv_close_gets_none_idle() {
let (tx, mut rx) = mpsc::channel::<i32>(10);
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::ch... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 481 | 540 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:14 | #[maybe_tokio_test]
async fn tx_close_gets_none() {
let (_, mut rx) = mpsc::channel::<i32>(10);
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... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 521 | 580 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:15 | assert_eq!(rx.try_recv(), Ok("hello"));
assert_ok!(tx.try_send("goodbye"));
drop(tx);
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::... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 561 | 620 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:16 | async fn reserve_many_zero() {
let (tx, rx) = mpsc::channel::<()>(1);
// Succeeds when not closed.
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... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 601 | 660 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:17 | }
#[maybe_tokio_test]
async fn try_reserve_fails() {
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.rec... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 641 | 700 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:18 | for permit in assert_ok!(tx.try_reserve_many(i)) {
permit.send("foo");
assert_eq!(rx.recv().await, Some("foo"));
}
assert_eq!(rx.try_recv(), Err(TryRecvError::Empty));
}
}
#[maybe_tokio_test]
async fn reserve_many_on_closed_channel() {
let (tx, rx) = mpsc::channel::<()>(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 681 | 740 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:19 | };
for permit in permits.take(k) {
permit.send(0);
}
// 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 tha... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 721 | 780 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:20 | drop(permit);
assert!(reserve2.is_woken());
assert_ready_ok!(reserve2.poll());
}
#[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,... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 761 | 820 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:21 | assert!(recv.is_woken());
assert_ready!(recv.poll());
}
#[test]
fn dropping_last_owned_permit_wakes_closed_receiver() {
let (tx, mut rx) = mpsc::channel::<()>(100);
let permit = tx.try_reserve_owned().unwrap();
rx.close();
let mut recv = tokio_test::task::spawn(rx.recv());
assert_pending!(rec... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 801 | 860 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:22 | assert_pending!(recv.poll());
permit.send(());
assert!(recv.is_woken());
assert_ready!(recv.poll());
}
#[test]
fn sending_last_owned_permit_wakes_closed_receiver() {
let (tx, mut rx) = mpsc::channel::<()>(100);
let permit = tx.try_reserve_owned().unwrap();
rx.close();
let mut recv = tokio... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 841 | 900 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:23 | assert_ok!(tx.try_send(msg.clone()));
drop(rx);
assert_err!(tx.reserve().await);
assert_err!(tx.reserve_many(10).await);
assert_eq!(1, Arc::strong_count(&msg));
}
#[test]
fn dropping_rx_closes_channel_for_try() {
let (tx, rx) = mpsc::channel(100);
let msg = Arc::new(());
tx.try_send(msg.c... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 881 | 940 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:24 | drop((tx, rx));
assert_eq!(1, Arc::strong_count(&msg));
}
#[test]
#[cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support threads
fn blocking_recv() {
let (tx, mut rx) = mpsc::channel::<u8>(1);
let sync_code = std::thread::spawn(move || {
assert_eq!(Some(10), rx.blocking_re... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 921 | 980 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:25 | .unwrap()
.block_on(async move {
assert_eq!(Some(10), rx.recv().await);
});
sync_code.join().unwrap()
}
#[tokio::test]
#[should_panic]
#[cfg(not(target_family = "wasm"))] // wasm currently doesn't support unwinding
async fn blocking_send_async() {
let (tx, _rx) = mpsc::channel::<()>... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:26 | let permit1 = assert_ok!(tx1.reserve().await);
let mut permit2 = tokio_test::task::spawn(tx2.reserve());
assert_pending!(permit2.poll());
rx.close();
drop(permit1);
assert!(permit2.is_woken());
drop(permit2);
assert!(rx.recv().await.is_none());
}
#[test]
fn try_recv_bounded() {
let ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 1,001 | 1,060 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:27 | assert!(tx.try_send("hello").is_err());
assert_eq!(Ok("hello"), rx.try_recv());
assert_eq!(Ok("hello"), rx.try_recv());
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::Empty), rx.try_recv());
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 1,041 | 1,100 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:28 | assert_eq!(Err(TryRecvError::Empty), rx.try_recv());
rx.close();
assert_eq!(Err(TryRecvError::Disconnected), rx.try_recv());
}
#[test]
fn try_recv_after_receiver_close_with_permit() {
let (tx, mut rx) = mpsc::channel::<()>(5);
let permit = tx.try_reserve().unwrap();
assert_eq!(Err(TryRecvError::E... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 1,081 | 1,140 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:29 | use tokio::sync::mpsc::error::SendTimeoutError::{Closed, Timeout};
use tokio::time::Duration;
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... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 1,121 | 1,180 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:30 | let _permit = tx.reserve().await.unwrap();
// 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_capacit... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 1,161 | 1,220 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:31 | assert!(!rx.is_closed());
}
#[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.se... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/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_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!(t... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 1,241 | 1,300 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:33 | 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() {}
assert!(rx.is_empty())
}
#[tokio::test]
async fn test_rx_is_empty_all_senders_are_dropped_and_messages_cons... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 1,281 | 1,340 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:34 | #[tokio::test]
async fn test_rx_len_on_filled_channel() {
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);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 1,321 | 1,380 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:35 | let (tx, mut rx) = mpsc::channel(100);
tx.send(()).await.unwrap();
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... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 1,361 | 1,420 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:36 | let another_tx = tx.clone();
let task = tokio::spawn(async move {
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
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 1,401 | 1,460 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:37 | #[tokio::test]
async fn test_rx_unbounded_is_empty_when_no_messages_were_sent() {
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!(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 1,441 | 1,500 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:38 | for i in 0..10 {
assert!(tx.send(i).is_ok());
}
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()... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 1,481 | 1,540 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:39 | let (tx, rx) = mpsc::unbounded_channel();
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 {
asser... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 1,521 | 1,580 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:40 | drop(tx);
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/tok... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 1,561 | 1,620 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:41 | fn drop(&mut self) {
COUNTER.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
if self.0 {
panic!("panic!")
}
}
}
fn func(tx: UnboundedSender<A>, rx: UnboundedReceiver<A>) {
tx.send(A(true)).unwrap();
tx.send(A(false)).unwrap();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_mpsc.rs | 1,601 | 1,634 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:20 | drop(permit);
assert!(reserve2.is_woken());
assert_ready_ok!(reserve2.poll());
}
#[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,... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9fccf5339d41c1f2f863f97b9133bc8a5a10bc28 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9fccf5339d41c1f2f863f97b9133bc8a5a10bc28/tokio/tests/sync_mpsc.rs | 761 | 820 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:21 | assert_eq!(1, Arc::strong_count(&msg));
}
#[test]
fn dropping_rx_closes_channel_for_try() {
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(_))
));
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9fccf5339d41c1f2f863f97b9133bc8a5a10bc28 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9fccf5339d41c1f2f863f97b9133bc8a5a10bc28/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_recv() {
let (tx, mut rx) = mpsc::channel::<u8>(1);
let sync_code = std::thread::spawn(move || {
assert_eq!(Some(10), rx.blocking_recv());
});
tokio::runtime::Runtime::new()
.unwr... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9fccf5339d41c1f2f863f97b9133bc8a5a10bc28 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9fccf5339d41c1f2f863f97b9133bc8a5a10bc28/tokio/tests/sync_mpsc.rs | 841 | 900 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:23 | }
#[tokio::test]
#[should_panic]
#[cfg(not(target_family = "wasm"))] // wasm currently doesn't support unwinding
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,... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9fccf5339d41c1f2f863f97b9133bc8a5a10bc28 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9fccf5339d41c1f2f863f97b9133bc8a5a10bc28/tokio/tests/sync_mpsc.rs | 881 | 940 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:24 | rx.close();
drop(permit1);
assert!(permit2.is_woken());
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_se... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9fccf5339d41c1f2f863f97b9133bc8a5a10bc28 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9fccf5339d41c1f2f863f97b9133bc8a5a10bc28/tokio/tests/sync_mpsc.rs | 921 | 980 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:25 | 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();
drop(tx);
assert_eq!(Ok("hello"), rx.try_recv());
assert_eq!(Ok("hello"), rx.try_recv());
assert_eq!(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9fccf5339d41c1f2f863f97b9133bc8a5a10bc28 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9fccf5339d41c1f2f863f97b9133bc8a5a10bc28/tokio/tests/sync_mpsc.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:26 | #[test]
fn try_recv_after_receiver_close_with_permit() {
let (tx, mut rx) = mpsc::channel::<()>(5);
let permit = tx.try_reserve().unwrap();
assert_eq!(Err(TryRecvError::Empty), rx.try_recv());
rx.close();
assert_eq!(Err(TryRecvError::Empty), rx.try_recv());
drop(permit);
assert_eq!(Err(Try... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9fccf5339d41c1f2f863f97b9133bc8a5a10bc28 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9fccf5339d41c1f2f863f97b9133bc8a5a10bc28/tokio/tests/sync_mpsc.rs | 1,001 | 1,060 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:27 | 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)).await, Ok(()));
assert_eq!(tx.send_t... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9fccf5339d41c1f2f863f97b9133bc8a5a10bc28 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9fccf5339d41c1f2f863f97b9133bc8a5a10bc28/tokio/tests/sync_mpsc.rs | 1,041 | 1,100 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:28 | 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_closed_when_calling_close_with_sender() {
// is_closed should return true after calling close but still has a sender
let... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9fccf5339d41c1f2f863f97b9133bc8a5a10bc28 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9fccf5339d41c1f2f863f97b9133bc8a5a10bc28/tokio/tests/sync_mpsc.rs | 1,081 | 1,140 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:29 | // 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());
}
assert!(!rx.is_closed());
}
#[tokio::test]
async fn test_rx_is_closed_when_there_are_no_sen... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9fccf5339d41c1f2f863f97b9133bc8a5a10bc28 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9fccf5339d41c1f2f863f97b9133bc8a5a10bc28/tokio/tests/sync_mpsc.rs | 1,121 | 1,180 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:30 | 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());
assert!(!rx.is_empty())
}
#[tokio::test]
async fn test_rx_is_not_empty_wh... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9fccf5339d41c1f2f863f97b9133bc8a5a10bc28 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9fccf5339d41c1f2f863f97b9133bc8a5a10bc28/tokio/tests/sync_mpsc.rs | 1,161 | 1,220 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:31 | 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_ok());
}
drop(tx);
for _ in 0..10 {
assert!(rx.r... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9fccf5339d41c1f2f863f97b9133bc8a5a10bc28 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9fccf5339d41c1f2f863f97b9133bc8a5a10bc28/tokio/tests/sync_mpsc.rs | 1,201 | 1,260 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:32 | 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());
}
drop(tx);
assert_eq!(rx.len(), 100);
}
#[tokio::tes... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9fccf5339d41c1f2f863f97b9133bc8a5a10bc28 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9fccf5339d41c1f2f863f97b9133bc8a5a10bc28/tokio/tests/sync_mpsc.rs | 1,241 | 1,300 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:33 | }
#[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_called_after_dropping_sender() {
let (tx,... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9fccf5339d41c1f2f863f97b9133bc8a5a10bc28 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9fccf5339d41c1f2f863f97b9133bc8a5a10bc28/tokio/tests/sync_mpsc.rs | 1,281 | 1,340 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:34 | 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());
}
#[tokio::test]
async fn ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9fccf5339d41c1f2f863f97b9133bc8a5a10bc28 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9fccf5339d41c1f2f863f97b9133bc8a5a10bc28/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_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_unbounded_is_not_empty_when_all_but_one_messages_are_consumed() {
let (tx, m... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9fccf5339d41c1f2f863f97b9133bc8a5a10bc28 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9fccf5339d41c1f2f863f97b9133bc8a5a10bc28/tokio/tests/sync_mpsc.rs | 1,361 | 1,420 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:36 | 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_empty_channel_without... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9fccf5339d41c1f2f863f97b9133bc8a5a10bc28 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9fccf5339d41c1f2f863f97b9133bc8a5a10bc28/tokio/tests/sync_mpsc.rs | 1,401 | 1,460 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:37 | 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.len(), i + 1);
}
drop(tx);
for i in (0..100).rev() {... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9fccf5339d41c1f2f863f97b9133bc8a5a10bc28 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9fccf5339d41c1f2f863f97b9133bc8a5a10bc28/tokio/tests/sync_mpsc.rs | 1,441 | 1,500 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:38 | #[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/issues/6602
#[tokio::test]
asyn... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9fccf5339d41c1f2f863f97b9133bc8a5a10bc28 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9fccf5339d41c1f2f863f97b9133bc8a5a10bc28/tokio/tests/sync_mpsc.rs | 1,481 | 1,540 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:39 | }
}
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 panicked while dropping the first value,
// but will keep droppi... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | 9fccf5339d41c1f2f863f97b9133bc8a5a10bc28 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9fccf5339d41c1f2f863f97b9133bc8a5a10bc28/tokio/tests/sync_mpsc.rs | 1,521 | 1,549 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:25 | 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();
drop(tx);
assert_eq!(Ok("hello"), rx.try_recv());
assert_eq!(Ok("hello"), rx.try_recv());
assert_eq!(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | bf18ed452d6aae438e84ae008a01a74776abdc19 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bf18ed452d6aae438e84ae008a01a74776abdc19/tokio/tests/sync_mpsc.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:26 | #[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);
assert_eq!(Err(TryRecvError::Disconnected), rx.try_recv());
}
#[test]
fn try_recv_close_while_empty_unbounded() {
let (tx, mut rx) = mpsc::unb... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | bf18ed452d6aae438e84ae008a01a74776abdc19 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bf18ed452d6aae438e84ae008a01a74776abdc19/tokio/tests/sync_mpsc.rs | 1,001 | 1,060 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:27 | 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't support unwinding
fn recv_timeout_panic() {
use futures::future::FutureExt;
use tokio::time::Duration;
let ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | bf18ed452d6aae438e84ae008a01a74776abdc19 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bf18ed452d6aae438e84ae008a01a74776abdc19/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_closed_when_dropping_all_senders() {
// is_closed should return true after dropping all senders
let (tx, rx) = mpsc::channel::<()>(10);
let another_tx = tx.clone();
let task = tokio::spawn(async move {
drop(another_tx);
});
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | bf18ed452d6aae438e84ae008a01a74776abdc19 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bf18ed452d6aae438e84ae008a01a74776abdc19/tokio/tests/sync_mpsc.rs | 1,081 | 1,140 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:29 | assert!(tx.send(i).await.is_ok());
}
drop(tx);
assert!(rx.is_closed());
}
#[tokio::test]
async fn test_rx_is_closed_when_there_are_messages_and_close_is_called() {
// is_closed should return true when there are messages in the buffer, and close is called
let (tx, mut rx) = mpsc::channel(10);
fo... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | bf18ed452d6aae438e84ae008a01a74776abdc19 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bf18ed452d6aae438e84ae008a01a74776abdc19/tokio/tests/sync_mpsc.rs | 1,121 | 1,180 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:30 | 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_empty_when_all_but_one_messages_are_consumed() {
let (tx, mut rx) = mpsc::channel(10);
for i in 0..10 {
assert!(tx.send(i).await.i... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | bf18ed452d6aae438e84ae008a01a74776abdc19 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bf18ed452d6aae438e84ae008a01a74776abdc19/tokio/tests/sync_mpsc.rs | 1,161 | 1,220 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:31 | 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);
}
#[tokio::test]
async fn test_rx_len_on_empty_channel_without_senders() {
// when all senders are dropped, a ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | bf18ed452d6aae438e84ae008a01a74776abdc19 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bf18ed452d6aae438e84ae008a01a74776abdc19/tokio/tests/sync_mpsc.rs | 1,201 | 1,260 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:32 | 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).await.is_ok());
assert_eq!(rx.len(), i + 1);
}
drop(tx);
for i in (0..100).rev() {
assert!(rx.recv(... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | bf18ed452d6aae438e84ae008a01a74776abdc19 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bf18ed452d6aae438e84ae008a01a74776abdc19/tokio/tests/sync_mpsc.rs | 1,241 | 1,300 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:33 | 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_calling_close_with_sender() {
// is_closed should ret... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | bf18ed452d6aae438e84ae008a01a74776abdc19 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bf18ed452d6aae438e84ae008a01a74776abdc19/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_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::unbounded_channel();
for i in 0..10 {
assert!(tx.send(i).is_ok());
}
drop(tx);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | bf18ed452d6aae438e84ae008a01a74776abdc19 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bf18ed452d6aae438e84ae008a01a74776abdc19/tokio/tests/sync_mpsc.rs | 1,321 | 1,380 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:35 | }
for _ in 0..9 {
assert!(rx.recv().await.is_some());
}
assert!(!rx.is_empty())
}
#[tokio::test]
async fn test_rx_unbounded_is_empty_when_all_messages_are_consumed() {
let (tx, mut rx) = mpsc::unbounded_channel();
for i in 0..10 {
assert!(tx.send(i).is_ok());
}
while rx.tr... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | bf18ed452d6aae438e84ae008a01a74776abdc19 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bf18ed452d6aae438e84ae008a01a74776abdc19/tokio/tests/sync_mpsc.rs | 1,361 | 1,420 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:36 | #[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 linked list.
// here we test that the "closed" value does not change the len of the channel.
let (tx, rx) = mpsc::unbounded_channel::<()>();
dr... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | bf18ed452d6aae438e84ae008a01a74776abdc19 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bf18ed452d6aae438e84ae008a01a74776abdc19/tokio/tests/sync_mpsc.rs | 1,401 | 1,460 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:37 | 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) = mpsc::unbounded_channel();
tx.send(()).unwrap();
rx.close();
assert_eq!(rx.len(), 1);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | bf18ed452d6aae438e84ae008a01a74776abdc19 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bf18ed452d6aae438e84ae008a01a74776abdc19/tokio/tests/sync_mpsc.rs | 1,441 | 1,500 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:38 | let (sender, mut receiver) = mpsc::channel(33);
for value in 1..257 {
sender.send(value).await.unwrap();
receiver.recv().await.unwrap();
assert!(receiver.is_empty(), "{value}. len: {}", receiver.len());
}
}
#[test]
#[cfg(not(panic = "abort"))]
fn drop_all_elements_during_panic() {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | bf18ed452d6aae438e84ae008a01a74776abdc19 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bf18ed452d6aae438e84ae008a01a74776abdc19/tokio/tests/sync_mpsc.rs | 1,481 | 1,536 |
tokio-rs/tokio:tokio/tests/sync_mpsc.rs:39 | let (tx, rx) = mpsc::unbounded_channel();
let _ = panic::catch_unwind(panic::AssertUnwindSafe(|| {
func(tx.clone(), rx);
}));
// all A's destructor should be called at this point, even before `mpsc::Chan`'s
// drop gets called.
assert_eq!(COUNTER.load(Relaxed), 3);
drop(tx);
// `m... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/sync_mpsc.rs | MIT | bf18ed452d6aae438e84ae008a01a74776abdc19 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bf18ed452d6aae438e84ae008a01a74776abdc19/tokio/tests/sync_mpsc.rs | 1,521 | 1,536 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.