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