tokio/tokio-sync/tests/fuzz_mpsc.rs
Carl Lerche 06c473e628
Update Tokio to use std::future. (#1120)
A first pass at updating Tokio to use `std::future`.

Implementations of `Future` from the futures crate are updated to implement
`Future` from std. Implementations of `Stream` are moved to a feature flag.

This commits disables a number of crates that have not yet been updated.
2019-06-24 12:34:30 -07:00

42 lines
780 B
Rust

#![deny(warnings, rust_2018_idioms)]
#[macro_use]
extern crate loom;
macro_rules! if_fuzz {
($($t:tt)*) => {
$($t)*
}
}
#[path = "../src/mpsc/mod.rs"]
#[allow(warnings)]
mod mpsc;
#[path = "../src/semaphore.rs"]
#[allow(warnings)]
mod semaphore;
// use futures::{future::poll_fn, Stream};
use async_util::future::poll_fn;
use loom::futures::block_on;
use loom::thread;
#[test]
fn closing_tx() {
loom::fuzz(|| {
let (mut tx, mut rx) = mpsc::channel(16);
thread::spawn(move || {
tx.try_send(()).unwrap();
drop(tx);
});
let v = block_on(poll_fn(|cx| rx.poll_next(cx)));
assert!(v.is_some());
let v = block_on(poll_fn(|cx| rx.poll_next(cx)));
assert!(v.is_none());
});
}