summaryrefslogtreecommitdiffstats
path: root/tokio/tests/stream_iter.rs
diff options
context:
space:
mode:
authorCarl Lerche <me@carllerche.com>2020-03-25 14:56:24 -0700
committerGitHub <noreply@github.com>2020-03-25 14:56:24 -0700
commit186196b911bb7cbbd67e74b4ef051d3daf2d64c1 (patch)
tree5ac43c7a780e1ee0936d89607459e59f2ea90e80 /tokio/tests/stream_iter.rs
parent57ba37c97854d32e691ea68006c8d69d58c79b23 (diff)
stream: iter() should yield every so often. (#2343)
Diffstat (limited to 'tokio/tests/stream_iter.rs')
-rw-r--r--tokio/tests/stream_iter.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/tokio/tests/stream_iter.rs b/tokio/tests/stream_iter.rs
new file mode 100644
index 00000000..45148a7a
--- /dev/null
+++ b/tokio/tests/stream_iter.rs
@@ -0,0 +1,18 @@
+use tokio::stream;
+use tokio_test::task;
+
+use std::iter;
+
+#[tokio::test]
+async fn coop() {
+ let mut stream = task::spawn(stream::iter(iter::repeat(1)));
+
+ for _ in 0..10_000 {
+ if stream.poll_next().is_pending() {
+ assert!(stream.is_woken());
+ return;
+ }
+ }
+
+ panic!("did not yield");
+}