]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/assign-assign.rs
rustdoc: Replace no-pretty-expanded with pretty-expanded
[rust.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 // pretty-expanded FIXME #23616
13
14 fn test_assign() {
15     let mut x: int;
16     let y: () = x = 10;
17     assert_eq!(x, 10);
18     assert_eq!(y, ());
19     let mut z = x = 11;
20     assert_eq!(x, 11);
21     assert_eq!(z, ());
22     z = x = 12;
23     assert_eq!(x, 12);
24     assert_eq!(z, ());
25 }
26
27 fn test_assign_op() {
28     let mut x: int = 0;
29     let y: () = x += 10;
30     assert_eq!(x, 10);
31     assert_eq!(y, ());
32     let mut z = x += 11;
33     assert_eq!(x, 21);
34     assert_eq!(z, ());
35     z = x += 12;
36     assert_eq!(x, 33);
37     assert_eq!(z, ());
38 }
39
40 pub fn main() { test_assign(); test_assign_op(); }