rust/tests/run-pass/bools.rs

30 lines
444 B
Rust
Raw Normal View History

2016-03-12 21:32:24 -06:00
fn boolean() -> bool {
true
}
fn if_false() -> i64 {
2016-03-17 07:39:29 -05:00
let c = false;
if c { 1 } else { 0 }
2016-03-12 21:32:24 -06:00
}
fn if_true() -> i64 {
2016-03-17 07:39:29 -05:00
let c = true;
if c { 1 } else { 0 }
2016-03-12 21:32:24 -06:00
}
2016-03-13 05:50:16 -05:00
fn match_bool() -> i16 {
let b = true;
match b {
true => 1,
_ => 0,
}
}
2016-04-22 03:34:14 -05:00
2016-04-22 07:38:46 -05:00
fn main() {
assert!(boolean());
assert_eq!(if_false(), 0);
assert_eq!(if_true(), 1);
assert_eq!(match_bool(), 1);
assert_eq!(true == true, true);
2016-04-22 07:38:46 -05:00
}