]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/arith-1.rs
cleanup: s/impl Copy/#[derive(Copy)]/g
[rust.git] / src / test / run-pass / arith-1.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
12
13 pub fn main() {
14     let i32_a: int = 10;
15     assert_eq!(i32_a, 10);
16     assert_eq!(i32_a - 10, 0);
17     assert_eq!(i32_a / 10, 1);
18     assert_eq!(i32_a - 20, -10);
19     assert_eq!(i32_a << 10, 10240);
20     assert_eq!(i32_a << 16, 655360);
21     assert_eq!(i32_a * 16, 160);
22     assert_eq!(i32_a * i32_a * i32_a, 1000);
23     assert_eq!(i32_a * i32_a * i32_a * i32_a, 10000);
24     assert_eq!(i32_a * i32_a / i32_a * i32_a, 100);
25     assert_eq!(i32_a * (i32_a - 1) << (2 + i32_a as uint), 368640);
26     let i32_b: int = 0x10101010;
27     assert_eq!(i32_b + 1 - 1, i32_b);
28     assert_eq!(i32_b << 1, i32_b << 1);
29     assert_eq!(i32_b >> 1, i32_b >> 1);
30     assert_eq!(i32_b & i32_b << 1, 0);
31     println!("{}", i32_b | i32_b << 1);
32     assert_eq!(i32_b | i32_b << 1, 0x30303030);
33 }