Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add extra tests for shifts with negative offsets #2002

Merged
merged 1 commit into from
Mar 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion tests/run-pass/integer-ops.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down