blob: 4cd83d8a0d6876fd0e754f3a71233d8ddfbab5f1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::task;
use tokio_test::assert_ok;
use std::thread;
use std::time::Duration;
#[tokio::test]
async fn basic_blocking() {
// Run a few times
for _ in 0..100 {
let out = assert_ok!(
tokio::spawn(async {
assert_ok!(
task::spawn_blocking(|| {
thread::sleep(Duration::from_millis(5));
"hello"
})
.await
)
})
.await
);
assert_eq!(out, "hello");
}
}
|