blob: efaaf510f079359823c284b25942f7fed6e03dc7 [file] [log] [blame]
Jeff Vander Stoepbf372732021-02-18 09:39:46 +01001#![warn(rust_2018_idioms)]
2
3use tokio::time::{sleep_until, Duration, Instant};
4use tokio_test::block_on;
5
6#[test]
7fn async_block() {
8 assert_eq!(4, block_on(async { 4 }));
9}
10
11async fn five() -> u8 {
12 5
13}
14
15#[test]
16fn async_fn() {
17 assert_eq!(5, block_on(five()));
18}
19
20#[test]
21fn test_sleep() {
22 let deadline = Instant::now() + Duration::from_millis(100);
23
24 block_on(async {
25 sleep_until(deadline).await;
26 });
27}