From 84c2fed8ebf56ea9e32c3cabe8f7579aefa06724 Mon Sep 17 00:00:00 2001 From: ibraheemdev Date: Fri, 7 May 2021 11:07:23 -0400 Subject: [PATCH] apply suggestions from code review --- futures-test/src/lib.rs | 12 ++++++++++++ futures/tests/test_macro.rs | 27 ++++++++++++--------------- 2 files changed, 24 insertions(+), 15 deletions(-) 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); }