Auto merge of #2002 - RalfJung:negative-shifts, r=RalfJung
add extra tests for shifts with negative offsets Cc https://github.com/rust-lang/rust/pull/94659
This commit is contained in:
commit
176f070d4c
@ -1,13 +1,24 @@
|
||||
// compile-flags: -Coverflow-checks=off
|
||||
#![allow(arithmetic_overflow)]
|
||||
|
||||
pub fn main() {
|
||||
// This tests that do (not) do sign extension properly when loading integers
|
||||
// This tests that we do (not) do sign extension properly when loading integers
|
||||
assert_eq!(u32::MAX as i64, 4294967295);
|
||||
assert_eq!(i32::MIN as i64, -2147483648);
|
||||
|
||||
assert_eq!(i8::MAX, 127);
|
||||
assert_eq!(i8::MIN, -128);
|
||||
|
||||
// Shifts with negative offsets are subtle.
|
||||
assert_eq!(13 << -2i8, 13 << 254);
|
||||
assert_eq!(13 << i8::MIN, 13);
|
||||
assert_eq!(13 << -1i16, 13 << u16::MAX);
|
||||
assert_eq!(13 << i16::MIN, 13);
|
||||
assert_eq!(13i128 << -2i8, 13i128 << 254);
|
||||
assert_eq!(13i128 << i8::MIN, 13);
|
||||
assert_eq!(13i128 << -1i16, 13i128 << u16::MAX);
|
||||
assert_eq!(13i128 << i16::MIN, 13);
|
||||
|
||||
assert_eq!(i32::from_str_radix("A", 16), Ok(10));
|
||||
|
||||
let n = -0b1000_0000i8;
|
||||
|
Loading…
Reference in New Issue
Block a user