summaryrefslogtreecommitdiffstats
path: root/tokio-executor/tests/executor.rs
blob: c424df50ff4e23af3447ab1163cb7844e4bb193b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#![deny(warnings, rust_2018_idioms)]

use futures::{self, future::lazy, Future};
use tokio_executor::{self, DefaultExecutor};

mod out_of_executor_context {
    use super::*;
    use tokio_executor::Executor;

    fn test<F, E>(spawn: F)
    where
        F: Fn(Box<dyn 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));
    }
}