Implement builtins for Num.isNan, Num.isInfinite, and Num.isFinite

Closes #5310 and closes #5309
This commit is contained in:
Basile Henry 2023-04-30 16:28:13 +01:00
parent d84a9fa8ba
commit b8aaaaabda
12 changed files with 202 additions and 1 deletions

View file

@ -1705,6 +1705,31 @@ fn float_to_float() {
assert_evals_to!("Num.toFrac 0.5", 0.5, f64);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn frac_is_nan() {
assert_evals_to!("Num.isNaN (0 / 0)", true, bool);
assert_evals_to!("Num.isNaN (1 / 0)", false, bool);
assert_evals_to!("Num.isNaN 42", false, bool);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn frac_is_infinite() {
assert_evals_to!("Num.isInfinite (1 / 0)", true, bool);
assert_evals_to!("Num.isInfinite (-1 / 0)", true, bool);
assert_evals_to!("Num.isInfinite (0 / 0)", false, bool);
assert_evals_to!("Num.isInfinite 42", false, bool);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn frac_is_finite() {
assert_evals_to!("Num.isFinite 42", true, bool);
assert_evals_to!("Num.isFinite (1 / 0)", false, bool);
assert_evals_to!("Num.isFinite (0 / 0)", false, bool);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn int_compare() {