2011-06-13 19:25:36 -05:00
|
|
|
// 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;
|
2011-06-15 13:19:50 -05:00
|
|
|
assert (x == 10);
|
2011-07-27 07:19:39 -05:00
|
|
|
let z = x = 11;
|
2011-06-15 13:19:50 -05:00
|
|
|
assert (x == 11);
|
|
|
|
z = x = 12;
|
|
|
|
assert (x == 12);
|
2011-06-13 19:25:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn test_assign_op() {
|
2011-07-27 07:19:39 -05:00
|
|
|
let x: int = 0;
|
|
|
|
let y: () = x += 10;
|
2011-06-15 13:19:50 -05:00
|
|
|
assert (x == 10);
|
2011-07-27 07:19:39 -05:00
|
|
|
let z = x += 11;
|
2011-06-15 13:19:50 -05:00
|
|
|
assert (x == 21);
|
|
|
|
z = x += 12;
|
|
|
|
assert (x == 33);
|
2011-06-13 19:25:36 -05:00
|
|
|
}
|
|
|
|
|
2011-08-19 17:16:48 -05:00
|
|
|
fn main() { test_assign(); test_assign_op(); }
|