2011-11-15 17:01:06 -08:00
|
|
|
// -*- rust -*-
|
2010-06-23 21:03:09 -07:00
|
|
|
|
2011-11-15 17:01:06 -08:00
|
|
|
#[cfg(target_arch = "x86")]
|
|
|
|
fn target() {
|
|
|
|
assert (-1000 >> 3 == 536870787);
|
|
|
|
}
|
2010-06-23 21:03:09 -07:00
|
|
|
|
2011-11-15 17:01:06 -08:00
|
|
|
#[cfg(target_arch = "x86_64")]
|
|
|
|
fn target() {
|
2012-02-05 16:50:54 -08:00
|
|
|
assert (-1000 >> 3 == 2305843009213693827);
|
2011-11-15 17:01:06 -08:00
|
|
|
}
|
2010-06-23 21:03:09 -07:00
|
|
|
|
2011-11-15 17:01:06 -08:00
|
|
|
fn general() {
|
2011-07-27 14:19:39 +02:00
|
|
|
let a: int = 1;
|
|
|
|
let b: int = 2;
|
2011-06-15 11:19:50 -07:00
|
|
|
a ^= b;
|
|
|
|
b ^= a;
|
|
|
|
a = a ^ b;
|
2011-12-22 17:53:53 -08:00
|
|
|
log(debug, a);
|
|
|
|
log(debug, b);
|
2011-06-15 11:19:50 -07:00
|
|
|
assert (b == 1);
|
|
|
|
assert (a == 2);
|
|
|
|
assert (!0xf0 & 0xff == 0xf);
|
|
|
|
assert (0xf0 | 0xf == 0xff);
|
|
|
|
assert (0xf << 4 == 0xf0);
|
|
|
|
assert (0xf0 >> 4 == 0xf);
|
|
|
|
assert (-16 >>> 2 == -4);
|
|
|
|
assert (0b1010_1010 | 0b0101_0101 == 0xff);
|
2011-11-15 17:01:06 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
general();
|
|
|
|
target();
|
2011-08-19 15:16:48 -07:00
|
|
|
}
|