Skip to content

Commit 154a2c6

Browse files
committed
Add MIRI tests.
1 parent b3132c2 commit 154a2c6

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/tools/miri/tests/pass/float.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,46 @@ fn test_algebraic() {
11441144
fadd_algebraic, fdiv_algebraic, fmul_algebraic, frem_algebraic, fsub_algebraic,
11451145
};
11461146

1147+
#[inline(never)]
1148+
pub fn test_operations_f16(a: f16, b: f16) {
1149+
// make sure they all map to the correct operation
1150+
assert_eq!(a.algebraic_add(b), a + b);
1151+
assert_eq!(a.algebraic_sub(b), a - b);
1152+
assert_eq!(a.algebraic_mul(b), a * b);
1153+
assert_eq!(a.algebraic_div(b), a / b);
1154+
assert_eq!(a.algebraic_rem(b), a % b);
1155+
}
1156+
1157+
#[inline(never)]
1158+
pub fn test_operations_f32(a: f32, b: f32) {
1159+
// make sure they all map to the correct operation
1160+
assert_eq!(a.algebraic_add(b), a + b);
1161+
assert_eq!(a.algebraic_sub(b), a - b);
1162+
assert_eq!(a.algebraic_mul(b), a * b);
1163+
assert_eq!(a.algebraic_div(b), a / b);
1164+
assert_eq!(a.algebraic_rem(b), a % b);
1165+
}
1166+
1167+
#[inline(never)]
1168+
pub fn test_operations_f64(a: f64, b: f64) {
1169+
// make sure they all map to the correct operation
1170+
assert_eq!(a.algebraic_add(b), a + b);
1171+
assert_eq!(a.algebraic_sub(b), a - b);
1172+
assert_eq!(a.algebraic_mul(b), a * b);
1173+
assert_eq!(a.algebraic_div(b), a / b);
1174+
assert_eq!(a.algebraic_rem(b), a % b);
1175+
}
1176+
1177+
#[inline(never)]
1178+
pub fn test_operations_f128(a: f128, b: f128) {
1179+
// make sure they all map to the correct operation
1180+
assert_eq!(a.algebraic_add(b), a + b);
1181+
assert_eq!(a.algebraic_sub(b), a - b);
1182+
assert_eq!(a.algebraic_mul(b), a * b);
1183+
assert_eq!(a.algebraic_div(b), a / b);
1184+
assert_eq!(a.algebraic_rem(b), a % b);
1185+
}
1186+
11471187
#[inline(never)]
11481188
pub fn test_operations_f16(a: f16, b: f16) {
11491189
// make sure they all map to the correct operation

0 commit comments

Comments
 (0)