rust/src/test/run-pass/if-check.rs
Tim Chevalier 7fc89f573d Restructure the "checking" pass in typestate
I noticed that typestate was being lazier than it should be,
because it was only checking typestate for statements and
top-level expression (that is, the expression in a stmt_expr, but
not any subexpressions). So I rewrote the checks in tstate/ck.rs
to use walk, which exposed a few bugs in typestate that I fixed.

Also added some more test cases for if-check.
2011-06-17 19:09:18 -07:00

26 lines
273 B
Rust

// xfail-stage0
pred even(uint x) -> bool {
if (x < 2u) {
ret false;
}
else if (x == 2u) {
ret true;
}
else {
ret even(x - 2u);
}
}
fn foo(uint x) -> () {
if check(even(x)) {
log x;
}
else {
fail;
}
}
fn main() {
foo(2u);
}