Parentheses for stronger checks

This commit is contained in:
Patrick Lühne 2020-03-27 20:54:04 +01:00
parent 5ea0a96ec4
commit 0fdec430af
Signed by: patrick
GPG Key ID: 05F3611E97A70ABF

View File

@ -506,17 +506,17 @@ mod tests
_ => panic!("expected predicate"),
};
assert_eq!(format_formula("true and false"), "true and false");
assert_eq!(formula_as_and("true and false").len(), 2);
assert_eq!(*formula_as_and("true and false").remove(0), Formula::true_());
assert_eq!(*formula_as_and("true and false").remove(1), Formula::false_());
assert_eq!(format_formula("(true and false)"), "true and false");
assert_eq!(formula_as_and("(true and false)").len(), 2);
assert_eq!(*formula_as_and("(true and false)").remove(0), Formula::true_());
assert_eq!(*formula_as_and("(true and false)").remove(1), Formula::false_());
// The order of elements is retained
assert_ne!(formula("true and false"), formula("false and true"));
assert_eq!(format_formula("p and q and r and s"), "p and q and r and s");
assert_ne!(formula("(true and false)"), formula("false and true"));
assert_eq!(format_formula("(p and q and r and s)"), "p and q and r and s");
assert_eq!(
as_predicate(*formula_as_and("p and q and r and s").remove(0)).declaration.name, "p");
as_predicate(*formula_as_and("(p and q and r and s)").remove(0)).declaration.name, "p");
assert_eq!(
as_predicate(*formula_as_and("p and q and r and s").remove(3)).declaration.name, "s");
as_predicate(*formula_as_and("(p and q and r and s)").remove(3)).declaration.name, "s");
let formula = |i| original::formula(i, &Declarations::new());
@ -546,17 +546,17 @@ mod tests
_ => panic!("expected predicate"),
};
assert_eq!(format_formula("true or false"), "true or false");
assert_eq!(formula_as_or("true or false").len(), 2);
assert_eq!(*formula_as_or("true or false").remove(0), Formula::true_());
assert_eq!(*formula_as_or("true or false").remove(1), Formula::false_());
assert_eq!(format_formula("(true or false)"), "true or false");
assert_eq!(formula_as_or("(true or false)").len(), 2);
assert_eq!(*formula_as_or("(true or false)").remove(0), Formula::true_());
assert_eq!(*formula_as_or("(true or false)").remove(1), Formula::false_());
// The order of elements is retained
assert_ne!(formula("true or false"), formula("false or true"));
assert_eq!(format_formula("p or q or r or s"), "p or q or r or s");
assert_ne!(formula("(true or false)"), formula("false or true)"));
assert_eq!(format_formula("(p or q or r or s)"), "p or q or r or s");
assert_eq!(
as_predicate(*formula_as_or("p or q or r or s").remove(0)).declaration.name, "p");
as_predicate(*formula_as_or("(p or q or r or s)").remove(0)).declaration.name, "p");
assert_eq!(
as_predicate(*formula_as_or("p or q or r or s").remove(3)).declaration.name, "s");
as_predicate(*formula_as_or("(p or q or r or s)").remove(3)).declaration.name, "s");
let formula = |i| original::formula(i, &Declarations::new());