Clean up tests
This commit is contained in:
parent
5512813cba
commit
9e74116a4d
@ -508,36 +508,30 @@ mod tests
|
||||
#[test]
|
||||
fn format_compare()
|
||||
{
|
||||
assert_eq!(format(greater(constant("a"), constant("b"))), "a > b");
|
||||
assert_eq!(format(less(constant("a"), constant("b"))), "a < b");
|
||||
assert_eq!(format(less_or_equal(constant("a"), constant("b"))), "a <= b");
|
||||
assert_eq!(format(greater_or_equal(constant("a"), constant("b"))), "a >= b");
|
||||
assert_eq!(format(equal(constant("a"), constant("b"))), "a = b");
|
||||
assert_eq!(format(not_equal(constant("a"), constant("b"))), "a != b");
|
||||
assert_eq!(format(greater(a(), b())), "a > b");
|
||||
assert_eq!(format(less(a(), b())), "a < b");
|
||||
assert_eq!(format(less_or_equal(a(), b())), "a <= b");
|
||||
assert_eq!(format(greater_or_equal(a(), b())), "a >= b");
|
||||
assert_eq!(format(equal(a(), b())), "a = b");
|
||||
assert_eq!(format(not_equal(a(), b())), "a != b");
|
||||
|
||||
assert_eq!(format(
|
||||
greater(multiply(add(constant("a"), constant("b")), constant("c")),
|
||||
absolute_value(subtract(constant("d"), constant("e"))))),
|
||||
greater(multiply(add(a(), b()), c()), absolute_value(subtract(d(), e())))),
|
||||
"(a + b) * c > |d - e|");
|
||||
assert_eq!(format(
|
||||
less(multiply(add(constant("a"), constant("b")), constant("c")),
|
||||
absolute_value(subtract(constant("d"), constant("e"))))),
|
||||
less(multiply(add(a(), b()), c()), absolute_value(subtract(d(), e())))),
|
||||
"(a + b) * c < |d - e|");
|
||||
assert_eq!(format(
|
||||
less_or_equal(multiply(add(constant("a"), constant("b")), constant("c")),
|
||||
absolute_value(subtract(constant("d"), constant("e"))))),
|
||||
less_or_equal(multiply(add(a(), b()), c()), absolute_value(subtract(d(), e())))),
|
||||
"(a + b) * c <= |d - e|");
|
||||
assert_eq!(format(
|
||||
greater_or_equal(multiply(add(constant("a"), constant("b")), constant("c")),
|
||||
absolute_value(subtract(constant("d"), constant("e"))))),
|
||||
greater_or_equal(multiply(add(a(), b()), c()), absolute_value(subtract(d(), e())))),
|
||||
"(a + b) * c >= |d - e|");
|
||||
assert_eq!(format(
|
||||
equal(multiply(add(constant("a"), constant("b")), constant("c")),
|
||||
absolute_value(subtract(constant("d"), constant("e"))))),
|
||||
equal(multiply(add(a(), b()), c()), absolute_value(subtract(d(), e())))),
|
||||
"(a + b) * c = |d - e|");
|
||||
assert_eq!(format(
|
||||
not_equal(multiply(add(constant("a"), constant("b")), constant("c")),
|
||||
absolute_value(subtract(constant("d"), constant("e"))))),
|
||||
not_equal(multiply(add(a(), b()), c()), absolute_value(subtract(d(), e())))),
|
||||
"(a + b) * c != |d - e|");
|
||||
}
|
||||
|
||||
@ -546,20 +540,16 @@ mod tests
|
||||
{
|
||||
assert_eq!(format(p()), "p");
|
||||
assert_eq!(format(predicate("predicate", vec![])), "predicate");
|
||||
assert_eq!(format(predicate("q", vec![constant("a")])), "q(a)");
|
||||
assert_eq!(format(
|
||||
predicate("q", vec![constant("a"), constant("b"), constant("c")])),
|
||||
"q(a, b, c)");
|
||||
assert_eq!(format(
|
||||
predicate("predicate", vec![constant("a"), constant("b"), constant("c")])),
|
||||
"predicate(a, b, c)");
|
||||
assert_eq!(format(predicate("q", vec![a()])), "q(a)");
|
||||
assert_eq!(format(predicate("q", abc())), "q(a, b, c)");
|
||||
assert_eq!(format(predicate("predicate", abc())), "predicate(a, b, c)");
|
||||
|
||||
assert_eq!(format(
|
||||
predicate("predicate", vec![
|
||||
exponentiate(absolute_value(multiply(constant("a"), integer(-20))), integer(2)),
|
||||
exponentiate(absolute_value(multiply(a(), integer(-20))), integer(2)),
|
||||
string("test"),
|
||||
function("f", vec![multiply(add(constant("b"), constant("c")),
|
||||
subtract(constant("b"), constant("c"))), infimum(), variable("X")])])),
|
||||
function("f", vec![multiply(add(b(), c()),
|
||||
subtract(b(), c())), infimum(), variable("X")])])),
|
||||
"predicate(|a * -20| ** 2, \"test\", f((b + c) * (b - c), #inf, X))");
|
||||
|
||||
// TODO: escape predicates that start with capital letters or that conflict with keywords
|
||||
@ -673,9 +663,9 @@ mod tests
|
||||
#[test]
|
||||
fn format_combination_compare_and_lower()
|
||||
{
|
||||
let term_1 = || multiply(add(constant("a"), constant("b")), constant("c"));
|
||||
let term_2 = || absolute_value(subtract(constant("d"), constant("e")));
|
||||
let term_3 = || exponentiate(constant("a"), exponentiate(constant("b"), constant("c")));
|
||||
let term_1 = || multiply(add(a(), b()), c());
|
||||
let term_2 = || absolute_value(subtract(d(), e()));
|
||||
let term_3 = || exponentiate(a(), exponentiate(b(), c()));
|
||||
let term_4 = || negative(function("f", vec![integer(5), add(variable("X"), integer(3))]));
|
||||
|
||||
// Compare + not
|
||||
|
@ -359,6 +359,36 @@ pub(crate) mod tests
|
||||
std::rc::Rc::new(VariableDeclaration::new(name.to_string()))
|
||||
}
|
||||
|
||||
pub(crate) fn a() -> Box<Term>
|
||||
{
|
||||
constant("a")
|
||||
}
|
||||
|
||||
pub(crate) fn b() -> Box<Term>
|
||||
{
|
||||
constant("b")
|
||||
}
|
||||
|
||||
pub(crate) fn c() -> Box<Term>
|
||||
{
|
||||
constant("c")
|
||||
}
|
||||
|
||||
pub(crate) fn d() -> Box<Term>
|
||||
{
|
||||
constant("d")
|
||||
}
|
||||
|
||||
pub(crate) fn e() -> Box<Term>
|
||||
{
|
||||
constant("e")
|
||||
}
|
||||
|
||||
pub(crate) fn abc() -> Terms
|
||||
{
|
||||
vec![a(), b(), c()]
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn format_binary_operation()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user