Files
tokio/tokio-test/tests/block_on.rs
T
Jakub Beránek 2d56312b89 timer: introduce delay function shortcut (#1440)
This commit adds a simple delay shortcut to avoid writing Delay::new
everywhere and removes usages of Delay::new.
2019-08-20 08:39:55 -07:00

27 lines
448 B
Rust

#![warn(rust_2018_idioms)]
#![feature(async_await)]
use std::time::{Duration, Instant};
use tokio_test::block_on;
use tokio_timer::delay;
#[test]
fn async_block() {
assert_eq!(4, block_on(async { 4 }));
}
async fn five() -> u8 {
5
}
#[test]
fn async_fn() {
assert_eq!(5, block_on(five()));
}
#[test]
fn test_delay() {
let deadline = Instant::now() + Duration::from_millis(100);
assert_eq!((), block_on(delay(deadline)));
}