rust/src/test/run-fail/if-check-fail.rs

17 lines
303 B
Rust
Raw Normal View History

// error-pattern:Number is odd
pure fn even(x: uint) -> bool {
2011-07-27 07:19:39 -05:00
if x < 2u {
ret false;
} else if x == 2u { ret true; } else { ret even(x - 2u); }
}
fn foo(x: uint) {
if check even(x) {
log(debug, x);
} else {
fail "Number is odd";
}
}
fn main() { foo(3u); }