summaryrefslogtreecommitdiffstats
path: root/tokio-executor/tests/executor.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tokio-executor/tests/executor.rs')
-rw-r--r--tokio-executor/tests/executor.rs27
1 files changed, 22 insertions, 5 deletions
diff --git a/tokio-executor/tests/executor.rs b/tokio-executor/tests/executor.rs
index 77436ec9..0c7269fd 100644
--- a/tokio-executor/tests/executor.rs
+++ b/tokio-executor/tests/executor.rs
@@ -2,10 +2,27 @@ extern crate tokio_executor;
extern crate futures;
use tokio_executor::*;
-use futures::future::lazy;
+use futures::{Future, future::lazy};
-#[test]
-fn spawn_out_of_executor_context() {
- let res = DefaultExecutor::current().spawn(Box::new(lazy(|| Ok(()))));
- assert!(res.is_err());
+mod out_of_executor_context {
+ use super::*;
+
+ fn test<F, E>(spawn: F)
+ where
+ F: Fn(Box<Future<Item=(), Error=()> + Send>) -> Result<(), E>,
+ {
+ let res = spawn(Box::new(lazy(|| Ok(()))));
+ assert!(res.is_err());
+ }
+
+ #[test]
+ fn spawn() {
+ test(|f| DefaultExecutor::current().spawn(f));
+ }
+
+ #[test]
+ fn execute() {
+ use futures::future::Executor as FuturesExecutor;
+ test(|f| DefaultExecutor::current().execute(f));
+ }
}