rust/src/test/run-pass/move-3.rs

22 lines
416 B
Rust
Raw Normal View History

2011-05-31 18:11:30 -05:00
use std;
import std::uint;
fn test(bool x, @rec(int x, int y, int z) foo) -> int {
2011-05-31 18:11:30 -05:00
auto bar = foo;
let @rec(int x, int y, int z) y;
2011-05-31 18:11:30 -05:00
if (x) {
y <- bar;
} else {
y = @rec(x=4, y=5, z=6);
2011-05-31 18:11:30 -05:00
}
ret y.y;
2011-05-31 18:11:30 -05:00
}
fn main() {
auto x = @rec(x=1, y=2, z=3);
2011-05-31 18:11:30 -05:00
for each (uint i in uint::range(0u, 10000u)) {
assert (test(true, x) == 2);
}
assert (test(false, x) == 5);
}