Skip to content

Commit

Permalink
Rollup merge of rust-lang#76366 - ayushmishra2005:arith_tests_in_libr…
Browse files Browse the repository at this point in the history
…ary, r=jyn514

Add Arith Tests in Library

Added Arith Tests library as a part of rust-lang#76268

r? @matklad
  • Loading branch information
Dylan-DPC committed Sep 16, 2020
2 parents bc42cd8 + dc37b55 commit 921c15c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 41 deletions.
29 changes: 29 additions & 0 deletions library/core/tests/num/i32.rs
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
int_module!(i32, i32);

#[test]
fn test_arith_operation() {
let a: isize = 10;
assert_eq!(a * (a - 1), 90);
let i32_a: isize = 10;
assert_eq!(i32_a, 10);
assert_eq!(i32_a - 10, 0);
assert_eq!(i32_a / 10, 1);
assert_eq!(i32_a - 20, -10);
assert_eq!(i32_a << 10, 10240);
assert_eq!(i32_a << 16, 655360);
assert_eq!(i32_a * 16, 160);
assert_eq!(i32_a * i32_a * i32_a, 1000);
assert_eq!(i32_a * i32_a * i32_a * i32_a, 10000);
assert_eq!(i32_a * i32_a / i32_a * i32_a, 100);
assert_eq!(i32_a * (i32_a - 1) << (2 + i32_a as usize), 368640);
let i32_b: isize = 0x10101010;
assert_eq!(i32_b + 1 - 1, i32_b);
assert_eq!(i32_b << 1, i32_b << 1);
assert_eq!(i32_b >> 1, i32_b >> 1);
assert_eq!(i32_b & i32_b << 1, 0);
assert_eq!(i32_b | i32_b << 1, 0x30303030);
let i32_c: isize = 0x10101010;
assert_eq!(
i32_c + i32_c * 2 / 3 * 2 + (i32_c - 7 % 3),
i32_c + i32_c * 2 / 3 * 2 + (i32_c - 7 % 3)
);
}
8 changes: 0 additions & 8 deletions src/test/ui/numbers-arithmetic/arith-0.rs

This file was deleted.

24 changes: 0 additions & 24 deletions src/test/ui/numbers-arithmetic/arith-1.rs

This file was deleted.

9 changes: 0 additions & 9 deletions src/test/ui/numbers-arithmetic/arith-2.rs

This file was deleted.

0 comments on commit 921c15c

Please sign in to comment.