mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-07 00:00:08 +02:00
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.
This commit is contained in:
@@ -21,3 +21,10 @@ extern crate tokio_timer;
|
|||||||
pub mod clock;
|
pub mod clock;
|
||||||
mod macros;
|
mod macros;
|
||||||
pub mod task;
|
pub mod task;
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub mod codegen {
|
||||||
|
pub mod futures {
|
||||||
|
pub use futures::*;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,15 +4,17 @@
|
|||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! assert_ready {
|
macro_rules! assert_ready {
|
||||||
($e:expr) => {{
|
($e:expr) => {{
|
||||||
|
use $crate::codegen::futures::Async::Ready;
|
||||||
match $e {
|
match $e {
|
||||||
Ok(::futures::Async::Ready(v)) => v,
|
Ok(Ready(v)) => v,
|
||||||
Ok(_) => panic!("not ready"),
|
Ok(_) => panic!("not ready"),
|
||||||
Err(e) => panic!("error = {:?}", e),
|
Err(e) => panic!("error = {:?}", e),
|
||||||
}
|
}
|
||||||
}};
|
}};
|
||||||
($e:expr, $($msg:tt),+) => {{
|
($e:expr, $($msg:tt),+) => {{
|
||||||
|
use $crate::codegen::futures::Async::Ready;
|
||||||
match $e {
|
match $e {
|
||||||
Ok(::futures::Async::Ready(v)) => v,
|
Ok(Ready(v)) => v,
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
let msg = format_args!($($msg),+);
|
let msg = format_args!($($msg),+);
|
||||||
panic!("not ready; {}", msg)
|
panic!("not ready; {}", msg)
|
||||||
@@ -29,16 +31,18 @@ macro_rules! assert_ready {
|
|||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! assert_not_ready {
|
macro_rules! assert_not_ready {
|
||||||
($e:expr) => {{
|
($e:expr) => {{
|
||||||
|
use $crate::codegen::futures::Async::{Ready, NotReady};
|
||||||
match $e {
|
match $e {
|
||||||
Ok(::futures::Async::NotReady) => {}
|
Ok(NotReady) => {}
|
||||||
Ok(::futures::Async::Ready(v)) => panic!("ready; value = {:?}", v),
|
Ok(Ready(v)) => panic!("ready; value = {:?}", v),
|
||||||
Err(e) => panic!("error = {:?}", e),
|
Err(e) => panic!("error = {:?}", e),
|
||||||
}
|
}
|
||||||
}};
|
}};
|
||||||
($e:expr, $($msg:tt),+) => {{
|
($e:expr, $($msg:tt),+) => {{
|
||||||
|
use $crate::codegen::futures::Async::{Ready, NotReady};
|
||||||
match $e {
|
match $e {
|
||||||
Ok(::futures::Async::NotReady) => {}
|
Ok(NotReady) => {}
|
||||||
Ok(::futures::Async::Ready(v)) => {
|
Ok(Ready(v)) => {
|
||||||
let msg = format_args!($($msg),+);
|
let msg = format_args!($($msg),+);
|
||||||
panic!("ready; value = {:?}; {}", v, msg)
|
panic!("ready; value = {:?}; {}", v, msg)
|
||||||
}
|
}
|
||||||
@@ -54,15 +58,17 @@ macro_rules! assert_not_ready {
|
|||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! assert_ready_eq {
|
macro_rules! assert_ready_eq {
|
||||||
($e:expr, $expect:expr) => {
|
($e:expr, $expect:expr) => {
|
||||||
|
use $crate::codegen::futures::Async::Ready;
|
||||||
match $e {
|
match $e {
|
||||||
Ok(e) => assert_eq!(e, ::futures::Async::Ready($expect)),
|
Ok(e) => assert_eq!(e, Ready($expect)),
|
||||||
Err(e) => panic!("error = {:?}", e),
|
Err(e) => panic!("error = {:?}", e),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
($e:expr, $expect:expr, $($msg:tt),+) => {
|
($e:expr, $expect:expr, $($msg:tt),+) => {
|
||||||
|
use $crate::codegen::futures::Async::Ready;
|
||||||
match $e {
|
match $e {
|
||||||
Ok(e) => assert_eq!(e, ::futures::Async::Ready($expect), $($msg)+),
|
Ok(e) => assert_eq!(e, Ready($expect), $($msg)+),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let msg = format_args!($($msg),+);
|
let msg = format_args!($($msg),+);
|
||||||
panic!("error = {:?}; {}", e, msg)
|
panic!("error = {:?}; {}", e, msg)
|
||||||
|
|||||||
Reference in New Issue
Block a user