]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/bitwise.rs
Simplify some uses of cfg in test cases
[rust.git] / src / test / run-pass / bitwise.rs
1 // Copyright 2012-2015 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 #[cfg(any(target_pointer_width = "32"))]
12 fn target() {
13     assert_eq!(-1000isize as usize >> 3_usize, 536870787_usize);
14 }
15
16 #[cfg(any(target_pointer_width = "64"))]
17 fn target() {
18     assert_eq!(-1000isize as usize >> 3_usize, 2305843009213693827_usize);
19 }
20
21 fn general() {
22     let mut a: isize = 1;
23     let mut b: isize = 2;
24     a ^= b;
25     b ^= a;
26     a = a ^ b;
27     println!("{}", a);
28     println!("{}", b);
29     assert_eq!(b, 1);
30     assert_eq!(a, 2);
31     assert_eq!(!0xf0_isize & 0xff, 0xf);
32     assert_eq!(0xf0_isize | 0xf, 0xff);
33     assert_eq!(0xf_isize << 4, 0xf0);
34     assert_eq!(0xf0_isize >> 4, 0xf);
35     assert_eq!(-16 >> 2, -4);
36     assert_eq!(0b1010_1010_isize | 0b0101_0101, 0xff);
37 }
38
39 pub fn main() {
40     general();
41     target();
42 }