rust/src/test/run-pass/rec.rs
Tim Chevalier aa25f22f19 Use different syntax for checks that matter to typestate
This giant commit changes the syntax of Rust to use "assert" for
"check" expressions that didn't mean anything to the typestate
system, and continue using "check" for checks that are used as
part of typestate checking.

Most of the changes are just replacing "check" with "assert" in test
cases and rustc.
2011-05-02 12:16:29 -07:00

24 lines
455 B
Rust

// -*- rust -*-
type rect = rec(int x, int y, int w, int h);
fn f(rect r, int x, int y, int w, int h) {
assert (r.x == x);
assert (r.y == y);
assert (r.w == w);
assert (r.h == h);
}
fn main() {
let rect r = rec(x=10, y=20, w=100, h=200);
assert (r.x == 10);
assert (r.y == 20);
assert (r.w == 100);
assert (r.h == 200);
let rect r2 = r;
let int x = r2.x;
assert (x == 10);
f(r, 10, 20, 100, 200);
f(r2, 10, 20, 100, 200);
}