1 | use tokio_stream as stream; |
---|---|
2 | use tokio_test::task; |
3 | |
4 | use std::iter; |
5 | |
6 | #[tokio::test] |
7 | async fn coop() { |
8 | let mut stream = task::spawn(stream::iter(iter::repeat(1))); |
9 | |
10 | for _ in 0..10_000 { |
11 | if stream.poll_next().is_pending() { |
12 | assert!(stream.is_woken()); |
13 | return; |
14 | } |
15 | } |
16 | |
17 | panic!("did not yield"); |
18 | } |
19 |