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

Commit 2682865

Browse files
committed
Move musl reference tests into its own file
1 parent 7118b00 commit 2682865

File tree

3 files changed

+37
-38
lines changed

3 files changed

+37
-38
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@
44
/math/src
55
/math/target
66
/target
7-
/tests
87
Cargo.lock

tests/musl-reference-tests.rs

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#![cfg(all(test, feature = "musl-reference-tests"))]
2+
3+
use core::{f32, f64};
4+
use libm::*;
5+
6+
/// Approximate equality with 1 ULP of tolerance
7+
#[inline]
8+
fn _eqf(a: f32, b: f32) -> Result<(), u32> {
9+
if a.is_nan() && b.is_nan() {
10+
Ok(())
11+
} else {
12+
let err = (a.to_bits() as i32).wrapping_sub(b.to_bits() as i32).abs();
13+
14+
if err <= 1 {
15+
Ok(())
16+
} else {
17+
Err(err as u32)
18+
}
19+
}
20+
}
21+
22+
#[inline]
23+
fn _eq(a: f64, b: f64) -> Result<(), u64> {
24+
if a.is_nan() && b.is_nan() {
25+
Ok(())
26+
} else {
27+
let err = (a.to_bits() as i64).wrapping_sub(b.to_bits() as i64).abs();
28+
29+
if err <= 1 {
30+
Ok(())
31+
} else {
32+
Err(err as u64)
33+
}
34+
}
35+
}
36+
37+
include!(concat!(env!("OUT_DIR"), "/musl-tests.rs"));

tests/unit.rs

-37
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,5 @@
1-
#![cfg(test)]
2-
3-
use core::{f32, f64};
41
use libm::*;
52

6-
/// Approximate equality with 1 ULP of tolerance
7-
#[inline]
8-
fn _eqf(a: f32, b: f32) -> Result<(), u32> {
9-
if a.is_nan() && b.is_nan() {
10-
Ok(())
11-
} else {
12-
let err = (a.to_bits() as i32).wrapping_sub(b.to_bits() as i32).abs();
13-
14-
if err <= 1 {
15-
Ok(())
16-
} else {
17-
Err(err as u32)
18-
}
19-
}
20-
}
21-
22-
#[inline]
23-
fn _eq(a: f64, b: f64) -> Result<(), u64> {
24-
if a.is_nan() && b.is_nan() {
25-
Ok(())
26-
} else {
27-
let err = (a.to_bits() as i64).wrapping_sub(b.to_bits() as i64).abs();
28-
29-
if err <= 1 {
30-
Ok(())
31-
} else {
32-
Err(err as u64)
33-
}
34-
}
35-
}
36-
37-
#[cfg(all(test, feature = "musl-reference-tests"))]
38-
include!(concat!(env!("OUT_DIR"), "/musl-tests.rs"));
39-
403
#[test]
414
fn remquo_q_overflow() {
425
// 0xc000000000000001, 0x04c0000000000004

0 commit comments

Comments
 (0)