Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 05fd5f2

Browse files
committed
fmod: add regression tests for subnormal issue
From discussion at [1] our loop count calculation is incorrect, causing an issue with subnormal numbers. Add test cases for known failures. [1]: #469 (comment)
1 parent 3020d64 commit 05fd5f2

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

crates/libm-test/src/gen/case_list.rs

+24-2
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,33 @@ fn fminimum_numf128_cases() -> Vec<TestCase<op::fminimum_numf128::Routine>> {
403403
}
404404

405405
fn fmod_cases() -> Vec<TestCase<op::fmod::Routine>> {
406-
vec![]
406+
let mut v = vec![];
407+
TestCase::append_pairs(
408+
&mut v,
409+
&[
410+
// Previous failure with incorrect loop iteration
411+
// <https://github.com/rust-lang/libm/pull/469#discussion_r2022337272>
412+
((2.1, 3.123e-320), Some(2.0696e-320)),
413+
((2.1, 2.253547e-318), Some(1.772535e-318)),
414+
],
415+
);
416+
v
407417
}
408418

409419
fn fmodf_cases() -> Vec<TestCase<op::fmodf::Routine>> {
410-
vec![]
420+
let mut v = vec![];
421+
TestCase::append_pairs(
422+
&mut v,
423+
&[
424+
// Previous failure with incorrect loop iteration
425+
// <https://github.com/rust-lang/libm/pull/469#discussion_r2022337272>
426+
((2.1, 8.858e-42), Some(8.085e-42)),
427+
((2.1, 6.39164e-40), Some(6.1636e-40)),
428+
((5.5, 6.39164e-40), Some(4.77036e-40)),
429+
((-151.189, 6.39164e-40), Some(-5.64734e-40)),
430+
],
431+
);
432+
v
411433
}
412434

413435
#[cfg(f128_enabled)]

0 commit comments

Comments
 (0)