rust/src/test/run-pass/assign-assign.rs

23 lines
437 B
Rust
Raw Normal View History

// Issue 483 - Assignment expressions result in nil
fn test_assign() {
2011-07-27 07:19:39 -05:00
let x: int;
let y: () = x = 10;
assert (x == 10);
2011-07-27 07:19:39 -05:00
let z = x = 11;
assert (x == 11);
z = x = 12;
assert (x == 12);
}
fn test_assign_op() {
2011-07-27 07:19:39 -05:00
let x: int = 0;
let y: () = x += 10;
assert (x == 10);
2011-07-27 07:19:39 -05:00
let z = x += 11;
assert (x == 21);
z = x += 12;
assert (x == 33);
}
fn main() { test_assign(); test_assign_op(); }