Files
tokio/tokio-executor/tests/executor.rs
T

30 lines
664 B
Rust
Raw Normal View History

extern crate futures;
2019-02-21 11:56:15 -08:00
extern crate tokio_executor;
2019-02-21 11:56:15 -08:00
use futures::{future::lazy, Future};
2019-03-21 14:30:18 -07:00
use tokio_executor::DefaultExecutor;
mod out_of_executor_context {
use super::*;
2019-03-21 14:30:18 -07:00
use tokio_executor::Executor;
fn test<F, E>(spawn: F)
where
2019-02-21 11:56:15 -08:00
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));
}
}