]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/arith-1.rs
auto merge of #5340 : brson/rust/column, r=brson
[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     fail_unless!((i32_a == 10));
16     fail_unless!((i32_a - 10 == 0));
17     fail_unless!((i32_a / 10 == 1));
18     fail_unless!((i32_a - 20 == -10));
19     fail_unless!((i32_a << 10 == 10240));
20     fail_unless!((i32_a << 16 == 655360));
21     fail_unless!((i32_a * 16 == 160));
22     fail_unless!((i32_a * i32_a * i32_a == 1000));
23     fail_unless!((i32_a * i32_a * i32_a * i32_a == 10000));
24     fail_unless!((i32_a * i32_a / i32_a * i32_a == 100));
25     fail_unless!((i32_a * (i32_a - 1) << 2 + i32_a == 368640));
26     let i32_b: int = 0x10101010;
27     fail_unless!((i32_b + 1 - 1 == i32_b));
28     fail_unless!((i32_b << 1 == i32_b << 1));
29     fail_unless!((i32_b >> 1 == i32_b >> 1));
30     fail_unless!((i32_b & i32_b << 1 == 0));
31     debug!(i32_b | i32_b << 1);
32     fail_unless!((i32_b | i32_b << 1 == 0x30303030));
33 }