summaryrefslogtreecommitdiffstats
path: root/tokio-test
diff options
context:
space:
mode:
authorCarl Lerche <me@carllerche.com>2019-05-03 20:43:40 -0700
committerGitHub <noreply@github.com>2019-05-03 20:43:40 -0700
commit951f2fd910fddc632d78a3be3715e25fcaaa3081 (patch)
tree9b1d845a6908c6b5d4650bd43b2a29fbad4801fe /tokio-test
parent4ef736b9d5ac41b2548eaf7c59a00a63b2633ba4 (diff)
test: re-export macro dependencies (#1077)
Callers may not always have `futures` available at the root of the crate. Re-exporting dependencies makes them available to the macro at a deterministic location.
Diffstat (limited to 'tokio-test')
-rw-r--r--tokio-test/src/lib.rs7
-rw-r--r--tokio-test/src/macros.rs22
2 files changed, 21 insertions, 8 deletions
diff --git a/tokio-test/src/lib.rs b/tokio-test/src/lib.rs
index 262dca5c..1256e3c2 100644
--- a/tokio-test/src/lib.rs
+++ b/tokio-test/src/lib.rs
@@ -21,3 +21,10 @@ extern crate tokio_timer;
pub mod clock;
mod macros;
pub mod task;
+
+#[doc(hidden)]
+pub mod codegen {
+ pub mod futures {
+ pub use futures::*;
+ }
+}
diff --git a/tokio-test/src/macros.rs b/tokio-test/src/macros.rs
index f584971e..4dbabd29 100644
--- a/tokio-test/src/macros.rs
+++ b/tokio-test/src/macros.rs
@@ -4,15 +4,17 @@
#[macro_export]
macro_rules! assert_ready {
($e:expr) => {{
+ use $crate::codegen::futures::Async::Ready;
match $e {
- Ok(::futures::Async::Ready(v)) => v,
+ Ok(Ready(v)) => v,
Ok(_) => panic!("not ready"),
Err(e) => panic!("error = {:?}", e),
}
}};
($e:expr, $($msg:tt),+) => {{
+ use $crate::codegen::futures::Async::Ready;
match $e {
- Ok(::futures::Async::Ready(v)) => v,
+ Ok(Ready(v)) => v,
Ok(_) => {
let msg = format_args!($($msg),+);
panic!("not ready; {}", msg)
@@ -29,16 +31,18 @@ macro_rules! assert_ready {
#[macro_export]
macro_rules! assert_not_ready {
($e:expr) => {{
+ use $crate::codegen::futures::Async::{Ready, NotReady};
match $e {
- Ok(::futures::Async::NotReady) => {}
- Ok(::futures::Async::Ready(v)) => panic!("ready; value = {:?}", v),
+ Ok(NotReady) => {}
+ Ok(Ready(v)) => panic!("ready; value = {:?}", v),
Err(e) => panic!("error = {:?}", e),
}
}};
($e:expr, $($msg:tt),+) => {{
+ use $crate::codegen::futures::Async::{Ready, NotReady};
match $e {
- Ok(::futures::Async::NotReady) => {}
- Ok(::futures::Async::Ready(v)) => {
+ Ok(NotReady) => {}
+ Ok(Ready(v)) => {
let msg = format_args!($($msg),+);
panic!("ready; value = {:?}; {}", v, msg)
}
@@ -54,15 +58,17 @@ macro_rules! assert_not_ready {
#[macro_export]
macro_rules! assert_ready_eq {
($e:expr, $expect:expr) => {
+ use $crate::codegen::futures::Async::Ready;
match $e {
- Ok(e) => assert_eq!(e, ::futures::Async::Ready($expect)),
+ Ok(e) => assert_eq!(e, Ready($expect)),
Err(e) => panic!("error = {:?}", e),
}
};
($e:expr, $expect:expr, $($msg:tt),+) => {
+ use $crate::codegen::futures::Async::Ready;
match $e {
- Ok(e) => assert_eq!(e, ::futures::Async::Ready($expect), $($msg)+),
+ Ok(e) => assert_eq!(e, Ready($expect), $($msg)+),
Err(e) => {
let msg = format_args!($($msg),+);
panic!("error = {:?}; {}", e, msg)