PageRenderTime 9ms CodeModel.GetById 2ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/src/test/run-pass/bitwise.rs

http://github.com/jruderman/rust
Rust | 34 lines | 29 code | 4 blank | 1 comment | 10 complexity | e4ce9d94afe07ea5158bb2863243bc0e MD5 | raw file
 1// -*- rust -*-
 2
 3#[cfg(target_arch = "x86")]
 4fn target() {
 5    assert (-1000 as uint >> 3u == 536870787u);
 6}
 7
 8#[cfg(target_arch = "x86_64")]
 9fn target() {
10    assert (-1000 as uint >> 3u == 2305843009213693827u);
11}
12
13fn general() {
14    let mut a: int = 1;
15    let mut b: int = 2;
16    a ^= b;
17    b ^= a;
18    a = a ^ b;
19    log(debug, a);
20    log(debug, b);
21    assert (b == 1);
22    assert (a == 2);
23    assert (!0xf0 & 0xff == 0xf);
24    assert (0xf0 | 0xf == 0xff);
25    assert (0xf << 4 == 0xf0);
26    assert (0xf0 >> 4 == 0xf);
27    assert (-16 >> 2 == -4);
28    assert (0b1010_1010 | 0b0101_0101 == 0xff);
29}
30
31fn main() {
32    general();
33    target();
34}