2019-08-13 21:10:26 -07:00
|
|
|
#![warn(rust_2018_idioms)]
|
|
|
|
|
|
|
|
|
|
use std::time::{Duration, Instant};
|
|
|
|
|
use tokio_test::block_on;
|
2019-08-20 17:39:55 +02:00
|
|
|
use tokio_timer::delay;
|
2019-08-13 21:10:26 -07:00
|
|
|
|
|
|
|
|
#[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]
|
2019-08-20 17:39:55 +02:00
|
|
|
fn test_delay() {
|
2019-08-13 21:10:26 -07:00
|
|
|
let deadline = Instant::now() + Duration::from_millis(100);
|
2019-08-20 17:39:55 +02:00
|
|
|
assert_eq!((), block_on(delay(deadline)));
|
2019-08-13 21:10:26 -07:00
|
|
|
}
|