isApproxEq function

This commit is contained in:
Brian Teague 2024-01-23 21:06:35 -05:00
parent 9a3340950e
commit 4499f8c6f4
No known key found for this signature in database
GPG key ID: A2006B3A49F673E3
86 changed files with 583 additions and 542 deletions

View file

@ -1491,6 +1491,29 @@ fn gte_f64() {
assert_evals_to!("0.0f64 >= 0.0", true, bool);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn gen_is_approx_eq() {
assert_evals_to!("Num.isApproxEq 1e10f64 1.00001e10f64 {}", true, bool);
assert_evals_to!("Num.isApproxEq 1e-7f64 1e-8f64 {}", false, bool);
assert_evals_to!("Num.isApproxEq 1e-8f32 1e-9f32 {}", true, bool);
assert_evals_to!("Num.isApproxEq 1e10f64 1.0001e10f64 {}", false, bool);
assert_evals_to!("Num.isApproxEq 1.0f32 1.0 {}", true, bool);
assert_evals_to!("Num.isApproxEq (1f64 / 0.0) (1f64 / 0.0) {}", true, bool);
assert_evals_to!("Num.isApproxEq (0f64 / 0.0) (0f64 / 0.0) {}", false, bool);
assert_evals_to!("Num.isApproxEq 1e-8f64 0f64 {}", true, bool);
assert_evals_to!("Num.isApproxEq 1e-7f64 0f64 {}", false, bool);
assert_evals_to!("Num.isApproxEq 1e-100f64 0f64 { atol: 0f64 }", false, bool);
assert_evals_to!("Num.isApproxEq 1e-7f64 0f64 { atol: 0f64 }", false, bool);
assert_evals_to!("Num.isApproxEq 1e-10f64 1e-20f64 {}", true, bool);
assert_evals_to!("Num.isApproxEq 1e-10f64 0f64 {}", true, bool);
assert_evals_to!(
"Num.isApproxEq 1e-10f64 0.999999e-10f64 { atol: 0f64 }",
true,
bool
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn gen_order_of_arithmetic_ops() {