2020-11-07 21:22:52 +00:00
|
|
|
// run-pass
|
|
|
|
|
|
|
|
fn main() {
|
2020-11-09 18:19:34 +00:00
|
|
|
assert!(f("", 0));
|
|
|
|
assert!(f("a", 1));
|
|
|
|
assert!(f("b", 1));
|
2020-11-07 21:22:52 +00:00
|
|
|
|
2020-11-09 18:19:34 +00:00
|
|
|
assert!(!f("", 1));
|
|
|
|
assert!(!f("a", 0));
|
|
|
|
assert!(!f("b", 0));
|
2020-11-07 21:22:52 +00:00
|
|
|
|
2020-11-14 13:20:25 +00:00
|
|
|
assert!(!f("asdf", 32));
|
2020-11-07 21:22:52 +00:00
|
|
|
|
|
|
|
////
|
|
|
|
|
2020-11-09 18:19:34 +00:00
|
|
|
assert!(!g(true, true, true));
|
|
|
|
assert!(!g(false, true, true));
|
|
|
|
assert!(!g(true, false, true));
|
|
|
|
assert!(!g(false, false, true));
|
|
|
|
assert!(!g(true, true, false));
|
2020-11-07 21:22:52 +00:00
|
|
|
|
2020-11-09 18:19:34 +00:00
|
|
|
assert!(g(false, true, false));
|
|
|
|
assert!(g(true, false, false));
|
|
|
|
assert!(g(false, false, false));
|
2020-11-07 21:22:52 +00:00
|
|
|
|
|
|
|
////
|
|
|
|
|
2020-11-09 18:19:34 +00:00
|
|
|
assert!(!h(true, true, true));
|
|
|
|
assert!(!h(false, true, true));
|
|
|
|
assert!(!h(true, false, true));
|
|
|
|
assert!(!h(false, false, true));
|
|
|
|
assert!(!h(true, true, false));
|
2020-11-07 21:22:52 +00:00
|
|
|
|
2020-11-09 18:19:34 +00:00
|
|
|
assert!(h(false, true, false));
|
|
|
|
assert!(h(true, false, false));
|
|
|
|
assert!(h(false, false, false));
|
2020-11-07 21:22:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn f(s: &str, num: usize) -> bool {
|
|
|
|
match (s, num) {
|
|
|
|
("", 0) | ("a" | "b", 1) => true,
|
|
|
|
|
|
|
|
_ => false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn g(x: bool, y: bool, z: bool) -> bool {
|
|
|
|
match (x, y, x, z) {
|
|
|
|
(true | false, false, true, false) => true,
|
|
|
|
(false, true | false, true | false, false) => true,
|
|
|
|
(true | false, true | false, true | false, true) => false,
|
|
|
|
(true, true | false, true | false, false) => false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn h(x: bool, y: bool, z: bool) -> bool {
|
|
|
|
match (x, (y, (x, (z,)))) {
|
|
|
|
(true | false, (false, (true, (false,)))) => true,
|
|
|
|
(false, (true | false, (true | false, (false,)))) => true,
|
|
|
|
(true | false, (true | false, (true | false, (true,)))) => false,
|
|
|
|
(true, (true | false, (true | false, (false,)))) => false,
|
|
|
|
}
|
|
|
|
}
|