1 // TODO: note that paths like futures_core::task::Context actually get redirected to core::task::Context 2 // in the rendered docs. Is this desirable? If so, should we change the paths here? 3 // 4 // Also, there is cross crate links in here. They are not going to work anytime soon. Do we put https links 5 // in here? to here: https://rust-lang.github.io/futures-api-docs? The problem is these have a 6 // version hardcoded in the url: 0.3.0-alpha.16 We could link to docs.rs, but currently that says: 7 // docs.rs failed to build futures-0.3.0-alpha.16 -> ok the reason seems to be that they are on 8 // 2019-04-17 which does still have futures-api unstable feature, so that should get solved. 9 // 10 //! Task related testing utilities. 11 //! 12 //! This module provides utilities for creating test 13 //! [`Context`](futures_core::task::Context)s, 14 //! [`Waker`](futures_core::task::Waker)s and 15 //! [`Spawn`](futures_task::Spawn) implementations. 16 //! 17 //! Test contexts: 18 //! - [`noop_context`] creates a context that ignores calls to 19 //! [`cx.waker().wake_by_ref()`](futures_core::task::Waker). 20 //! - [`panic_context`] creates a context that panics when 21 //! [`cx.waker().wake_by_ref()`](futures_core::task::Waker) is called. 22 //! 23 //! Test wakers: 24 //! - [`noop_waker`] creates a waker that ignores calls to 25 //! [`wake`](futures_core::task::Waker). 26 //! - [`panic_waker`](panic_waker()) creates a waker that panics when 27 //! [`wake`](futures_core::task::Waker) is called. 28 //! - [`new_count_waker`] creates a waker that increments a counter whenever 29 //! [`wake`](futures_core::task::Waker) is called. 30 //! 31 //! Test spawners: 32 //! - [`NoopSpawner`] ignores calls to 33 //! [`spawn`](futures_util::task::SpawnExt::spawn) 34 //! - [`PanicSpawner`] panics if [`spawn`](futures_util::task::SpawnExt::spawn) is 35 //! called. 36 //! - [`RecordSpawner`] records the spawned futures. 37 //! 38 //! For convenience there additionally exist various functions that directly 39 //! return waker/spawner references: [`noop_waker_ref`], [`panic_waker_ref`], 40 //! [`noop_spawner_mut`] and [`panic_spawner_mut`]. 41 42 mod context; 43 pub use self::context::{noop_context, panic_context}; 44 45 mod noop_spawner; 46 pub use self::noop_spawner::{noop_spawner_mut, NoopSpawner}; 47 48 pub use futures_util::task::{noop_waker, noop_waker_ref}; 49 50 mod panic_spawner; 51 pub use self::panic_spawner::{panic_spawner_mut, PanicSpawner}; 52 53 mod panic_waker; 54 pub use self::panic_waker::{panic_waker, panic_waker_ref}; 55 56 mod record_spawner; 57 pub use self::record_spawner::RecordSpawner; 58 59 mod wake_counter; 60 pub use self::wake_counter::{new_count_waker, AwokenCount}; 61