diff --git a/futures-test/src/lib.rs b/futures-test/src/lib.rs index 00cd980903..1117bb36cf 100644 --- a/futures-test/src/lib.rs +++ b/futures-test/src/lib.rs @@ -61,5 +61,17 @@ mod track_closed; /// assert!(fut.await); /// } /// ``` +/// +/// This is equivalent to the following code: +/// +/// ``` +/// #[test] +/// fn my_test() { +/// futures::executor::block_on(async move { +/// let fut = async { true }; +/// assert!(fut.await); +/// }) +/// } +/// ``` #[cfg(feature = "std")] pub use futures_macro::test_internal as test; diff --git a/futures/tests/test_macro.rs b/futures/tests/test_macro.rs index 4b3b44634e..2f391997ea 100644 --- a/futures/tests/test_macro.rs +++ b/futures/tests/test_macro.rs @@ -1,18 +1,15 @@ -#[cfg(test)] -mod tests { - #[futures_test::test] - async fn it_works() { - let fut = async { true }; - assert!(fut.await); +#[futures_test::test] +async fn it_works() { + let fut = async { true }; + assert!(fut.await); - let fut = async { false }; - assert!(!fut.await); - } + let fut = async { false }; + assert!(!fut.await); +} - #[futures_test::test] - #[should_panic] - async fn it_is_being_run() { - let fut = async { false }; - assert!(fut.await); - } +#[should_panic] +#[futures_test::test] +async fn it_is_being_run() { + let fut = async { false }; + assert!(fut.await); }