[−][src]Trait futures_test::future::FutureTestExt
Additional combinators for testing futures.
Provided methods
pub fn assert_unmoved(self) -> AssertUnmoved<Self>ⓘNotable traits for AssertUnmoved<Fut>
impl<Fut: Future> Future for AssertUnmoved<Fut> type Output = Fut::Output;
where
Self: Sized,
[src]
Notable traits for AssertUnmoved<Fut>
impl<Fut: Future> Future for AssertUnmoved<Fut> type Output = Fut::Output;
Self: Sized,
Asserts that the given is not moved after being polled.
A check for movement is performed each time the future is polled
and when Drop
is called.
Aside from keeping track of the location at which the future was first polled and providing assertions, this future adds no runtime behavior and simply delegates to the child future.
pub fn pending_once(self) -> PendingOnce<Self>ⓘNotable traits for PendingOnce<Fut>
impl<Fut: Future> Future for PendingOnce<Fut> type Output = Fut::Output;
where
Self: Sized,
[src]
Notable traits for PendingOnce<Fut>
impl<Fut: Future> Future for PendingOnce<Fut> type Output = Fut::Output;
Self: Sized,
Introduces one Poll::Pending
before polling the given future.
Examples
use futures::task::Poll; use futures::future::FutureExt; use futures_test::task::noop_context; use futures_test::future::FutureTestExt; use futures::pin_mut; let future = (async { 5 }).pending_once(); pin_mut!(future); let mut cx = noop_context(); assert_eq!(future.poll_unpin(&mut cx), Poll::Pending); assert_eq!(future.poll_unpin(&mut cx), Poll::Ready(5));
pub fn run_in_background(self) where
Self: Sized + Send + 'static,
Self::Output: Send,
[src]
Self: Sized + Send + 'static,
Self::Output: Send,
Runs this future on a dedicated executor running in a background thread.
Examples
use futures::channel::oneshot; use futures_test::future::FutureTestExt; let (tx, rx) = oneshot::channel::<i32>(); (async { tx.send(5).unwrap() }).run_in_background(); assert_eq!(rx.await, Ok(5));
pub fn interleave_pending(self) -> InterleavePending<Self>ⓘNotable traits for InterleavePending<Fut>
impl<Fut: Future> Future for InterleavePending<Fut> type Output = Fut::Output;
where
Self: Sized,
[src]
Notable traits for InterleavePending<Fut>
impl<Fut: Future> Future for InterleavePending<Fut> type Output = Fut::Output;
Self: Sized,
Introduces an extra Poll::Pending
in between each call to poll.
Examples
use futures::task::Poll; use futures::future::{self, Future}; use futures_test::task::noop_context; use futures_test::future::FutureTestExt; use futures::pin_mut; let future = future::ready(1).interleave_pending(); pin_mut!(future); let mut cx = noop_context(); assert_eq!(future.as_mut().poll(&mut cx), Poll::Pending); assert_eq!(future.as_mut().poll(&mut cx), Poll::Ready(1));