Work in progress
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user