Work in progress

This commit is contained in:
2020-03-30 05:10:59 +02:00
parent 5c51018ab1
commit f82a20e5f1
3 changed files with 108 additions and 21 deletions

View File

@@ -254,3 +254,31 @@ impl std::fmt::Display for crate::Formula
write!(format, "{}", display_formula(&self, None))
}
}
#[cfg(test)]
mod tests
{
use crate::*;
fn format(formula: &ast::Formula) -> String
{
format!("{}", formula)
}
#[test]
fn compare()
{
let ad = std::rc::Rc::new(FunctionDeclaration::new("a".to_string(), 0));
let bd = std::rc::Rc::new(FunctionDeclaration::new("b".to_string(), 0));
let a = || Box::new(Term::function(std::rc::Rc::clone(&ad), vec![]));
let b = || Box::new(Term::function(std::rc::Rc::clone(&bd), vec![]));
assert_eq!(format(&Formula::greater(a(), b())), "a > b");
assert_eq!(format(&Formula::less(a(), b())), "a < b");
assert_eq!(format(&Formula::less_or_equal(a(), b())), "a <= b");
assert_eq!(format(&Formula::greater_or_equal(a(), b())), "a >= b");
assert_eq!(format(&Formula::equal(a(), b())), "a = b");
assert_eq!(format(&Formula::not_equal(a(), b())), "a != b");
}
}