]> git.proxmox.com Git - rustc.git/blob - src/test/run-pass/assign-assign.rs
0f5d27015fb747a7709a6b3b908eeccf5a11eecb
[rustc.git] / src / test / run-pass / assign-assign.rs
1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // Issue 483 - Assignment expressions result in nil
12 fn test_assign() {
13 let mut x: int;
14 let y: () = x = 10;
15 assert_eq!(x, 10);
16 assert_eq!(y, ());
17 let mut z = x = 11;
18 assert_eq!(x, 11);
19 assert_eq!(z, ());
20 z = x = 12;
21 assert_eq!(x, 12);
22 assert_eq!(z, ());
23 }
24
25 fn test_assign_op() {
26 let mut x: int = 0;
27 let y: () = x += 10;
28 assert_eq!(x, 10);
29 assert_eq!(y, ());
30 let mut z = x += 11;
31 assert_eq!(x, 21);
32 assert_eq!(z, ());
33 z = x += 12;
34 assert_eq!(x, 33);
35 assert_eq!(z, ());
36 }
37
38 pub fn main() { test_assign(); test_assign_op(); }