2011-06-16 13:56:34 -05:00
|
|
|
// error-pattern:Number is odd
|
2011-08-23 20:25:50 -05:00
|
|
|
pure fn even(x: uint) -> bool {
|
2011-07-27 07:19:39 -05:00
|
|
|
if x < 2u {
|
|
|
|
ret false;
|
2011-08-19 17:16:48 -05:00
|
|
|
} else if x == 2u { ret true; } else { ret even(x - 2u); }
|
2011-06-16 13:56:34 -05:00
|
|
|
}
|
|
|
|
|
2011-12-22 16:42:52 -06:00
|
|
|
fn foo(x: uint) {
|
|
|
|
if check even(x) {
|
|
|
|
log_full(core::debug, x);
|
|
|
|
} else {
|
|
|
|
fail "Number is odd";
|
|
|
|
}
|
|
|
|
}
|
2011-06-16 13:56:34 -05:00
|
|
|
|
2011-08-19 17:16:48 -05:00
|
|
|
fn main() { foo(3u); }
|