diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:58 +0000 |
commit | a4b7ed7a42c716ab9f05e351f003d589124fd55d (patch) | |
tree | b620cd3f223850b28716e474e80c58059dca5dd4 /tests/ui/bitwise.rs | |
parent | Adding upstream version 1.67.1+dfsg1. (diff) | |
download | rustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.tar.xz rustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.zip |
Adding upstream version 1.68.2+dfsg1.upstream/1.68.2+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/bitwise.rs')
-rw-r--r-- | tests/ui/bitwise.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/ui/bitwise.rs b/tests/ui/bitwise.rs new file mode 100644 index 000000000..f79ff3c6e --- /dev/null +++ b/tests/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(); +} |