Skip to content

Commit

Permalink
Add ident function to the rest of the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyres committed Sep 3, 2018
1 parent e54c5a9 commit beadf75
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 22 deletions.
24 changes: 14 additions & 10 deletions src/test/run-pass/const-int-overflowing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,23 @@ const SHL_B: (u32, bool) = 0x1u32.overflowing_shl(132);
const SHR_A: (u32, bool) = 0x10u32.overflowing_shr(4);
const SHR_B: (u32, bool) = 0x10u32.overflowing_shr(132);

fn ident<T>(ident: T) -> T {
ident
}

fn main() {
assert_eq!(ADD_A, (7, false));
assert_eq!(ADD_B, (0, true));
assert_eq!(ADD_A, ident((7, false)));
assert_eq!(ADD_B, ident((0, true)));

assert_eq!(SUB_A, (3, false));
assert_eq!(SUB_B, (u32::max_value(), true));
assert_eq!(SUB_A, ident((3, false)));
assert_eq!(SUB_B, ident((u32::max_value(), true)));

assert_eq!(MUL_A, (10, false));
assert_eq!(MUL_B, (1410065408, true));
assert_eq!(MUL_A, ident((10, false)));
assert_eq!(MUL_B, ident((1410065408, true)));

assert_eq!(SHL_A, (0x10, false));
assert_eq!(SHL_B, (0x10, true));
assert_eq!(SHL_A, ident((0x10, false)));
assert_eq!(SHL_B, ident((0x10, true)));

assert_eq!(SHR_A, (0x1, false));
assert_eq!(SHR_B, (0x1, true));
assert_eq!(SHR_A, ident((0x1, false)));
assert_eq!(SHR_B, ident((0x1, true)));
}
8 changes: 6 additions & 2 deletions src/test/run-pass/const-int-rotate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
const LEFT: u32 = 0x10000b3u32.rotate_left(8);
const RIGHT: u32 = 0xb301u32.rotate_right(8);

fn ident<T>(ident: T) -> T {
ident
}

fn main() {
assert_eq!(LEFT, 0xb301);
assert_eq!(RIGHT, 0x10000b3);
assert_eq!(LEFT, ident(0xb301));
assert_eq!(RIGHT, ident(0x10000b3));
}
24 changes: 14 additions & 10 deletions src/test/run-pass/const-int-wrapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,23 @@ const SHL_B: u32 = 1u32.wrapping_shl(128);
const SHR_A: u32 = 128u32.wrapping_shr(7);
const SHR_B: u32 = 128u32.wrapping_shr(128);

fn ident<T>(ident: T) -> T {
ident
}

fn main() {
assert_eq!(ADD_A, 255);
assert_eq!(ADD_B, 199);
assert_eq!(ADD_A, ident(255));
assert_eq!(ADD_B, ident(199));

assert_eq!(SUB_A, 0);
assert_eq!(SUB_B, 101);
assert_eq!(SUB_A, ident(0));
assert_eq!(SUB_B, ident(101));

assert_eq!(MUL_A, 120);
assert_eq!(MUL_B, 44);
assert_eq!(MUL_A, ident(120));
assert_eq!(MUL_B, ident(44));

assert_eq!(SHL_A, 128);
assert_eq!(SHL_B, 1);
assert_eq!(SHL_A, ident(128));
assert_eq!(SHL_B, ident(1));

assert_eq!(SHR_A, 1);
assert_eq!(SHR_B, 128);
assert_eq!(SHR_A, ident(1);
assert_eq!(SHR_B, ident(128));
}

0 comments on commit beadf75

Please sign in to comment.