PageRenderTime 30ms CodeModel.GetById 17ms app.highlight 8ms RepoModel.GetById 2ms app.codeStats 0ms

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

http://github.com/jruderman/rust
Rust | 22 lines | 19 code | 2 blank | 1 comment | 6 complexity | 04f8b12ad0d1f2355763f676c9032a42 MD5 | raw file
 1// Issue 483 - Assignment expressions result in nil
 2fn test_assign() {
 3    let mut x: int;
 4    let mut y: () = x = 10;
 5    assert (x == 10);
 6    let mut z = x = 11;
 7    assert (x == 11);
 8    z = x = 12;
 9    assert (x == 12);
10}
11
12fn test_assign_op() {
13    let mut x: int = 0;
14    let mut y: () = x += 10;
15    assert (x == 10);
16    let mut z = x += 11;
17    assert (x == 21);
18    z = x += 12;
19    assert (x == 33);
20}
21
22fn main() { test_assign(); test_assign_op(); }