summaryrefslogtreecommitdiffstats
path: root/src/test/ui/bitwise.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/test/ui/bitwise.rs
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/bitwise.rs')
-rw-r--r--src/test/ui/bitwise.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/test/ui/bitwise.rs b/src/test/ui/bitwise.rs
new file mode 100644
index 000000000..f79ff3c6e
--- /dev/null
+++ b/src/test/ui/bitwise.rs
@@ -0,0 +1,34 @@
+// run-pass
+
+#[cfg(any(target_pointer_width = "32"))]
+fn target() {
+ assert_eq!(-1000isize as usize >> 3_usize, 536870787_usize);
+}
+
+#[cfg(any(target_pointer_width = "64"))]
+fn target() {
+ assert_eq!(-1000isize as usize >> 3_usize, 2305843009213693827_usize);
+}
+
+fn general() {
+ let mut a: isize = 1;
+ let mut b: isize = 2;
+ a ^= b;
+ b ^= a;
+ a = a ^ b;
+ println!("{}", a);
+ println!("{}", b);
+ assert_eq!(b, 1);
+ assert_eq!(a, 2);
+ assert_eq!(!0xf0_isize & 0xff, 0xf);
+ assert_eq!(0xf0_isize | 0xf, 0xff);
+ assert_eq!(0xf_isize << 4, 0xf0);
+ assert_eq!(0xf0_isize >> 4, 0xf);
+ assert_eq!(-16 >> 2, -4);
+ assert_eq!(0b1010_1010_isize | 0b0101_0101, 0xff);
+}
+
+pub fn main() {
+ general();
+ target();
+}