future test
This commit is contained in:
parent
43f20710a4
commit
655e33768f
@ -136,3 +136,35 @@ impl<'a> SharedFunctor<'a> for FutureInstance {
|
||||
Box::pin(sa)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod future_tests {
|
||||
use super::{test_suite, tests, FutureInstance};
|
||||
|
||||
type T = FutureInstance;
|
||||
|
||||
impl<'a> tests::Eqr<'a> for T {
|
||||
fn eqr<A: 'a + Send + PartialEq + std::fmt::Debug>(
|
||||
name: &'a str,
|
||||
left: Self::F<A>,
|
||||
right: Self::F<A>,
|
||||
) -> tests::R {
|
||||
tests::eqr(
|
||||
name,
|
||||
futures::executor::block_on(left),
|
||||
futures::executor::block_on(right),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> test_suite::FunctorTestSuite<'a> for T {
|
||||
fn sample<A: 'a + Send, F: FnMut(&'a (dyn Send + Sync + Fn(A) -> Self::F<A>))>(mut f: F) {
|
||||
f(&|a| Box::pin(futures::future::ready(a)));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn monad_follows_laws() {
|
||||
test_suite::monad_follows_laws::<T>().unwrap();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user