diff options
Diffstat (limited to '')
-rw-r--r-- | third_party/rust/futures-0.1.31/tests/fuse.rs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/third_party/rust/futures-0.1.31/tests/fuse.rs b/third_party/rust/futures-0.1.31/tests/fuse.rs new file mode 100644 index 0000000000..177d914e19 --- /dev/null +++ b/third_party/rust/futures-0.1.31/tests/fuse.rs @@ -0,0 +1,39 @@ +extern crate futures; + +use futures::prelude::*; +use futures::future::ok; +use futures::executor; + +mod support; +use support::*; + +#[test] +fn fuse() { + let mut future = executor::spawn(ok::<i32, u32>(2).fuse()); + assert!(future.poll_future_notify(¬ify_panic(), 0).unwrap().is_ready()); + assert!(future.poll_future_notify(¬ify_panic(), 0).unwrap().is_not_ready()); +} + +#[test] +fn fuse_is_done() { + use futures::future::{Fuse, FutureResult}; + + struct Wrapped(Fuse<FutureResult<i32, u32>>); + + impl Future for Wrapped { + type Item = (); + type Error = (); + + fn poll(&mut self) -> Poll<(), ()> { + assert!(!self.0.is_done()); + assert_eq!(self.0.poll().unwrap(), Async::Ready(2)); + assert!(self.0.is_done()); + assert_eq!(self.0.poll().unwrap(), Async::NotReady); + assert!(self.0.is_done()); + + Ok(Async::Ready(())) + } + } + + assert!(Wrapped(ok::<i32, u32>(2).fuse()).wait().is_ok()); +}
\ No newline at end of file |