Skip to content

Commit

Permalink
Move simplify and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Rigidity committed Jul 22, 2024
1 parent 4e24d7f commit d32e072
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 69 deletions.
67 changes: 67 additions & 0 deletions crates/rue-typing/src/check/simplify_and.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,70 @@ fn construct_and(mut items: Vec<Check>) -> 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])
);
}
}
69 changes: 0 additions & 69 deletions crates/rue-typing/src/check/simplify_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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])
);
}
}

0 comments on commit d32e072

Please sign in to comment.