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

10 lines
265 B
Rust
Raw Normal View History

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