Skip to content

Commit 921c15c

Browse files
authored
Rollup merge of rust-lang#76366 - ayushmishra2005:arith_tests_in_library, r=jyn514
Add Arith Tests in Library Added Arith Tests library as a part of rust-lang#76268 r? @matklad
2 parents bc42cd8 + dc37b55 commit 921c15c

File tree

4 files changed

+29
-41
lines changed

4 files changed

+29
-41
lines changed

library/core/tests/num/i32.rs

+29
Original file line numberDiff line numberDiff line change
@@ -1 +1,30 @@
11
int_module!(i32, i32);
2+
3+
#[test]
4+
fn test_arith_operation() {
5+
let a: isize = 10;
6+
assert_eq!(a * (a - 1), 90);
7+
let i32_a: isize = 10;
8+
assert_eq!(i32_a, 10);
9+
assert_eq!(i32_a - 10, 0);
10+
assert_eq!(i32_a / 10, 1);
11+
assert_eq!(i32_a - 20, -10);
12+
assert_eq!(i32_a << 10, 10240);
13+
assert_eq!(i32_a << 16, 655360);
14+
assert_eq!(i32_a * 16, 160);
15+
assert_eq!(i32_a * i32_a * i32_a, 1000);
16+
assert_eq!(i32_a * i32_a * i32_a * i32_a, 10000);
17+
assert_eq!(i32_a * i32_a / i32_a * i32_a, 100);
18+
assert_eq!(i32_a * (i32_a - 1) << (2 + i32_a as usize), 368640);
19+
let i32_b: isize = 0x10101010;
20+
assert_eq!(i32_b + 1 - 1, i32_b);
21+
assert_eq!(i32_b << 1, i32_b << 1);
22+
assert_eq!(i32_b >> 1, i32_b >> 1);
23+
assert_eq!(i32_b & i32_b << 1, 0);
24+
assert_eq!(i32_b | i32_b << 1, 0x30303030);
25+
let i32_c: isize = 0x10101010;
26+
assert_eq!(
27+
i32_c + i32_c * 2 / 3 * 2 + (i32_c - 7 % 3),
28+
i32_c + i32_c * 2 / 3 * 2 + (i32_c - 7 % 3)
29+
);
30+
}

src/test/ui/numbers-arithmetic/arith-0.rs

-8
This file was deleted.

src/test/ui/numbers-arithmetic/arith-1.rs

-24
This file was deleted.

src/test/ui/numbers-arithmetic/arith-2.rs

-9
This file was deleted.

0 commit comments

Comments
 (0)