mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 03:42:17 +00:00
Implement builtins for Num.isNan, Num.isInfinite, and Num.isFinite
Closes #5310 and closes #5309
This commit is contained in:
parent
d84a9fa8ba
commit
b8aaaaabda
12 changed files with 202 additions and 1 deletions
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue