diff options
Diffstat (limited to 'third_party/rust/tokio-0.1.22/tests/enumerate.rs')
-rw-r--r-- | third_party/rust/tokio-0.1.22/tests/enumerate.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/third_party/rust/tokio-0.1.22/tests/enumerate.rs b/third_party/rust/tokio-0.1.22/tests/enumerate.rs new file mode 100644 index 0000000000..c71b7a24c9 --- /dev/null +++ b/third_party/rust/tokio-0.1.22/tests/enumerate.rs @@ -0,0 +1,26 @@ +extern crate futures; +extern crate tokio; +extern crate tokio_executor; +extern crate tokio_timer; + +use futures::sync::mpsc; +use tokio::util::StreamExt; + +#[test] +fn enumerate() { + use futures::*; + + let (mut tx, rx) = mpsc::channel(1); + + std::thread::spawn(|| { + for i in 0..5 { + tx = tx.send(i * 2).wait().unwrap(); + } + }); + + let result = rx.enumerate().collect(); + assert_eq!( + result.wait(), + Ok(vec![(0, 0), (1, 2), (2, 4), (3, 6), (4, 8)]) + ); +} |