Skip to content

Commit 82be994

Browse files
add timeout stress test
1 parent bb3829b commit 82be994

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/timeout.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
use std::time::Duration;
2+
3+
use async_std::future::timeout;
4+
use async_std::task;
5+
6+
#[test]
7+
fn timeout_future_many() {
8+
task::block_on(async {
9+
let futures = (0..100)
10+
.map(|i| {
11+
timeout(Duration::from_millis(i * 10), async move {
12+
task::sleep(Duration::from_millis(i)).await;
13+
Ok::<(), async_std::future::TimeoutError>(())
14+
})
15+
})
16+
.collect::<Vec<_>>();
17+
18+
for future in futures {
19+
future.await.unwrap().unwrap();
20+
}
21+
});
22+
}

0 commit comments

Comments
 (0)