extern crate rust2fun_laws; use std::marker::PhantomData; use rust2fun_laws::apply_laws::*; use rust2fun_laws::contravariant_laws::*; use rust2fun_laws::flatmap_laws::*; use rust2fun_laws::functor_laws::*; use rust2fun_laws::invariant_laws::*; use rust2fun_laws::semigroup_laws::*; use rust2fun_laws::semigroupal_laws::*; use crate::common::{parse, print}; mod common; #[test] fn test_invariant() { assert!(invariant_identity(PhantomData::).holds()); assert!(invariant_composition(PhantomData::, print, parse, parse::, print).holds()); } #[test] fn test_functor() { assert!(covariant_identity(PhantomData::).holds()); assert!(covariant_composition(PhantomData::, print, parse::).holds()); assert!(lift_identity(PhantomData::).holds()); assert!(lift_composition(PhantomData::, print, parse::).holds()); } #[test] fn test_contravariant() { assert!(contravariant_identity(PhantomData::).holds()); assert!(contravariant_composition(PhantomData::, parse::, print::).holds()); assert!(lift_contravariant_identity(PhantomData::).holds()); assert!(lift_contravariant_composition(PhantomData::, parse::, print::).holds()); } #[test] fn test_semigroup() { assert!(repeat_0(PhantomData::).holds()); assert!(repeat_1(PhantomData::).holds()); assert!( semigroup_associativity(PhantomData::, PhantomData::, PhantomData::).holds() ); } #[test] fn test_semigroupal() { assert!( semigroupal_associativity(PhantomData::, PhantomData::, PhantomData::) .holds() ); } #[test] fn test_apply() { assert!(map2_product_consistency(PhantomData, PhantomData, |x: &str, l| x.len() == l).holds()); assert!(product_r_consistency(PhantomData::, PhantomData::).holds()); assert!(product_l_consistency(PhantomData::, PhantomData::).holds()); } #[test] fn test_flatmap() { assert!(flat_map_associativity( PhantomData::, |_| PhantomData::, |_| PhantomData:: ) .holds()); assert!(flat_map_consistent_apply(PhantomData, PhantomData:: u32>).holds()); assert!(m_product_consistency(PhantomData, |_: bool| PhantomData::).holds()); }