1
0
Fork 0
firefox/third_party/rust/tokio/tests/io_sink.rs
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

44 lines
967 B
Rust

#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::io::AsyncWriteExt;
#[tokio::test]
async fn sink_poll_write_is_cooperative() {
tokio::select! {
biased;
_ = async {
loop {
let buf = vec![1, 2, 3];
tokio::io::sink().write_all(&buf).await.unwrap();
}
} => {},
_ = tokio::task::yield_now() => {}
}
}
#[tokio::test]
async fn sink_poll_flush_is_cooperative() {
tokio::select! {
biased;
_ = async {
loop {
tokio::io::sink().flush().await.unwrap();
}
} => {},
_ = tokio::task::yield_now() => {}
}
}
#[tokio::test]
async fn sink_poll_shutdown_is_cooperative() {
tokio::select! {
biased;
_ = async {
loop {
tokio::io::sink().shutdown().await.unwrap();
}
} => {},
_ = tokio::task::yield_now() => {}
}
}