PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://github.com/jruderman/rust
Rust | 16 lines | 13 code | 2 blank | 1 comment | 7 complexity | d384e527e890d68141120ce6bd87b1d5 MD5 | raw file
 1// error-pattern:Number is odd
 2pure fn even(x: uint) -> bool {
 3    if x < 2u {
 4        return false;
 5    } else if x == 2u { return true; } else { return even(x - 2u); }
 6}
 7
 8fn foo(x: uint) {
 9    if even(x) {
10        log(debug, x);
11    } else {
12        fail ~"Number is odd";
13    }
14}
15
16fn main() { foo(3u); }