From d32e072a0503f34acf66c9aad02fb58b6c491d16 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Mon, 22 Jul 2024 19:28:28 -0400 Subject: [PATCH] Move simplify and tests --- crates/rue-typing/src/check/simplify_and.rs | 67 ++++++++++++++++++ crates/rue-typing/src/check/simplify_check.rs | 69 ------------------- 2 files changed, 67 insertions(+), 69 deletions(-) diff --git a/crates/rue-typing/src/check/simplify_and.rs b/crates/rue-typing/src/check/simplify_and.rs index e4d70fe..4d0eb32 100644 --- a/crates/rue-typing/src/check/simplify_and.rs +++ b/crates/rue-typing/src/check/simplify_and.rs @@ -56,3 +56,70 @@ fn construct_and(mut items: Vec) -> Check { Check::And(items) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn simplify_and_none() { + assert_eq!(simplify_and_shallow(vec![Check::None]), Check::None); + } + + #[test] + fn simplify_none_and_none() { + assert_eq!( + simplify_and_shallow(vec![Check::None, Check::None]), + Check::None + ); + } + + #[test] + fn simplify_check_and_none() { + assert_eq!( + simplify_and_shallow(vec![Check::None, Check::IsAtom]), + Check::IsAtom + ); + assert_eq!( + simplify_and_shallow(vec![Check::IsAtom, Check::None]), + Check::IsAtom + ); + } + + #[test] + fn simplify_and_one_check() { + assert_eq!(simplify_and_shallow(vec![Check::IsAtom]), Check::IsAtom); + } + + #[test] + fn simplify_atom_and_atom() { + assert_eq!( + simplify_and_shallow(vec![Check::IsAtom, Check::IsAtom]), + Check::IsAtom + ); + } + + #[test] + fn simplify_atom_and_pair() { + assert_eq!( + simplify_and_shallow(vec![Check::IsAtom, Check::IsPair]), + Check::And(vec![Check::IsAtom, Check::IsPair]) + ); + } + + #[test] + fn simplify_pair_and_pair() { + assert_eq!( + simplify_and_shallow(vec![Check::IsPair, Check::IsPair]), + Check::IsPair + ); + } + + #[test] + fn simplify_pair_and_atom() { + assert_eq!( + simplify_and_shallow(vec![Check::IsPair, Check::IsAtom]), + Check::And(vec![Check::IsPair, Check::IsAtom]) + ); + } +} diff --git a/crates/rue-typing/src/check/simplify_check.rs b/crates/rue-typing/src/check/simplify_check.rs index c6c5a61..4f9e314 100644 --- a/crates/rue-typing/src/check/simplify_check.rs +++ b/crates/rue-typing/src/check/simplify_check.rs @@ -34,72 +34,3 @@ pub(crate) fn simplify_check(check: Check) -> Check { } } } - -#[cfg(test)] -mod tests { - use crate::simplify_and_shallow; - - use super::*; - - #[test] - fn simplify_and_none() { - assert_eq!(simplify_and_shallow(vec![Check::None]), Check::None); - } - - #[test] - fn simplify_none_and_none() { - assert_eq!( - simplify_and_shallow(vec![Check::None, Check::None]), - Check::None - ); - } - - #[test] - fn simplify_check_and_none() { - assert_eq!( - simplify_and_shallow(vec![Check::None, Check::IsAtom]), - Check::IsAtom - ); - assert_eq!( - simplify_and_shallow(vec![Check::IsAtom, Check::None]), - Check::IsAtom - ); - } - - #[test] - fn simplify_and_one_check() { - assert_eq!(simplify_and_shallow(vec![Check::IsAtom]), Check::IsAtom); - } - - #[test] - fn simplify_atom_and_atom() { - assert_eq!( - simplify_and_shallow(vec![Check::IsAtom, Check::IsAtom]), - Check::IsAtom - ); - } - - #[test] - fn simplify_atom_and_pair() { - assert_eq!( - simplify_and_shallow(vec![Check::IsAtom, Check::IsPair]), - Check::And(vec![Check::IsAtom, Check::IsPair]) - ); - } - - #[test] - fn simplify_pair_and_pair() { - assert_eq!( - simplify_and_shallow(vec![Check::IsPair, Check::IsPair]), - Check::IsPair - ); - } - - #[test] - fn simplify_pair_and_atom() { - assert_eq!( - simplify_and_shallow(vec![Check::IsPair, Check::IsAtom]), - Check::And(vec![Check::IsPair, Check::IsAtom]) - ); - } -}