2
0
Fork 1
mirror of https://github.com/async-rs/async-std.git synced 2025-03-04 17:19:41 +00:00

Adding tests

This commit is contained in:
Miguel Pérez García 2019-12-05 08:10:06 -06:00
parent c14c377974
commit 4670388a56

27
tests/timeout_future.rs Normal file
View file

@ -0,0 +1,27 @@
#![cfg(feature = "unstable")]
use std::time::Duration;
use async_std::prelude::*;
use async_std::future;
use async_std::task;
#[test]
fn should_timeout() {
task::block_on(async {
let fut = future::pending::<()>();
let dur = Duration::from_millis(100);
let res = fut.timeout(dur).await;
assert!(res.is_err());
});
}
#[test]
fn should_not_timeout() {
task::block_on(async {
let fut = future::ready(0);
let dur = Duration::from_millis(100);
let res = fut.timeout(dur).await;
assert!(res.is_ok());
});
}