mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-11 05:34:11 +03:00
enable even more dev-backend num tests
This commit is contained in:
parent
b7a41bcb3e
commit
7a365eb88f
@ -1322,16 +1322,14 @@ impl<
|
||||
|
||||
fn build_num_add(&mut self, dst: &Symbol, src1: &Symbol, src2: &Symbol, layout: &InLayout<'a>) {
|
||||
match self.layout_interner.get_repr(*layout) {
|
||||
LayoutRepr::Builtin(Builtin::Int(quadword_and_smaller!())) => {
|
||||
let dst_reg = self.storage_manager.claim_general_reg(&mut self.buf, dst);
|
||||
let src1_reg = self
|
||||
.storage_manager
|
||||
.load_to_general_reg(&mut self.buf, src1);
|
||||
let src2_reg = self
|
||||
.storage_manager
|
||||
.load_to_general_reg(&mut self.buf, src2);
|
||||
ASM::add_reg64_reg64_reg64(&mut self.buf, dst_reg, src1_reg, src2_reg);
|
||||
}
|
||||
LayoutRepr::Builtin(Builtin::Int(int_width)) => self.build_fn_call(
|
||||
dst,
|
||||
bitcode::NUM_ADD_OR_PANIC_INT[int_width].to_string(),
|
||||
&[*src1, *src2],
|
||||
&[*layout, *layout],
|
||||
layout,
|
||||
),
|
||||
|
||||
LayoutRepr::Builtin(Builtin::Float(FloatWidth::F64)) => {
|
||||
let dst_reg = self.storage_manager.claim_float_reg(&mut self.buf, dst);
|
||||
let src1_reg = self.storage_manager.load_to_float_reg(&mut self.buf, src1);
|
||||
@ -1344,16 +1342,60 @@ impl<
|
||||
let src2_reg = self.storage_manager.load_to_float_reg(&mut self.buf, src2);
|
||||
ASM::add_freg32_freg32_freg32(&mut self.buf, dst_reg, src1_reg, src2_reg);
|
||||
}
|
||||
LayoutRepr::Builtin(Builtin::Decimal) => {
|
||||
self.build_fn_call(
|
||||
dst,
|
||||
bitcode::DEC_ADD_OR_PANIC.to_string(),
|
||||
&[*src1, *src2],
|
||||
&[Layout::DEC, Layout::DEC],
|
||||
&Layout::DEC,
|
||||
);
|
||||
|
||||
LayoutRepr::DEC => self.build_fn_call(
|
||||
dst,
|
||||
bitcode::DEC_ADD_OR_PANIC.to_string(),
|
||||
&[*src1, *src2],
|
||||
&[Layout::DEC, Layout::DEC],
|
||||
&Layout::DEC,
|
||||
),
|
||||
|
||||
other => unreachable!("NumAdd for layout {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
fn build_num_add_wrap(
|
||||
&mut self,
|
||||
dst: &Symbol,
|
||||
src1: &Symbol,
|
||||
src2: &Symbol,
|
||||
layout: &InLayout<'a>,
|
||||
) {
|
||||
match self.layout_interner.get_repr(*layout) {
|
||||
LayoutRepr::Builtin(Builtin::Int(quadword_and_smaller!())) => {
|
||||
let dst_reg = self.storage_manager.claim_general_reg(&mut self.buf, dst);
|
||||
let src1_reg = self
|
||||
.storage_manager
|
||||
.load_to_general_reg(&mut self.buf, src1);
|
||||
let src2_reg = self
|
||||
.storage_manager
|
||||
.load_to_general_reg(&mut self.buf, src2);
|
||||
ASM::add_reg64_reg64_reg64(&mut self.buf, dst_reg, src1_reg, src2_reg);
|
||||
}
|
||||
x => todo!("NumAdd: layout, {:?}", x),
|
||||
|
||||
LayoutRepr::Builtin(Builtin::Float(FloatWidth::F64)) => {
|
||||
let dst_reg = self.storage_manager.claim_float_reg(&mut self.buf, dst);
|
||||
let src1_reg = self.storage_manager.load_to_float_reg(&mut self.buf, src1);
|
||||
let src2_reg = self.storage_manager.load_to_float_reg(&mut self.buf, src2);
|
||||
ASM::add_freg64_freg64_freg64(&mut self.buf, dst_reg, src1_reg, src2_reg);
|
||||
}
|
||||
LayoutRepr::Builtin(Builtin::Float(FloatWidth::F32)) => {
|
||||
let dst_reg = self.storage_manager.claim_float_reg(&mut self.buf, dst);
|
||||
let src1_reg = self.storage_manager.load_to_float_reg(&mut self.buf, src1);
|
||||
let src2_reg = self.storage_manager.load_to_float_reg(&mut self.buf, src2);
|
||||
ASM::add_freg32_freg32_freg32(&mut self.buf, dst_reg, src1_reg, src2_reg);
|
||||
}
|
||||
|
||||
LayoutRepr::DEC => self.build_fn_call(
|
||||
dst,
|
||||
bitcode::DEC_ADD_SATURATED.to_string(),
|
||||
&[*src1, *src2],
|
||||
&[Layout::DEC, Layout::DEC],
|
||||
&Layout::DEC,
|
||||
),
|
||||
|
||||
other => unreachable!("NumAddWrap for layout {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1010,7 +1010,7 @@ trait Backend<'a> {
|
||||
arg_layouts[0], *ret_layout,
|
||||
"NumAdd: expected to have the same argument and return layout"
|
||||
);
|
||||
self.build_num_add(sym, &args[0], &args[1], ret_layout)
|
||||
self.build_num_add_wrap(sym, &args[0], &args[1], ret_layout)
|
||||
}
|
||||
LowLevel::NumAddChecked => {
|
||||
self.build_num_add_checked(sym, &args[0], &args[1], &arg_layouts[0], ret_layout)
|
||||
@ -2198,6 +2198,14 @@ trait Backend<'a> {
|
||||
return_layout: &InLayout<'a>,
|
||||
);
|
||||
|
||||
fn build_num_add_wrap(
|
||||
&mut self,
|
||||
dst: &Symbol,
|
||||
src1: &Symbol,
|
||||
src2: &Symbol,
|
||||
layout: &InLayout<'a>,
|
||||
);
|
||||
|
||||
/// build_num_sub_checked stores the sum of src1 and src2 into dst.
|
||||
fn build_num_sub_checked(
|
||||
&mut self,
|
||||
|
@ -650,34 +650,18 @@ fn gen_add_dec() {
|
||||
);
|
||||
}
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn gen_add_f32() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r"
|
||||
1.1f32 + 2.4f32 + 3
|
||||
"
|
||||
),
|
||||
6.5,
|
||||
f32
|
||||
);
|
||||
assert_evals_to!("1.1f32 + 2.4f32 + 3", 6.5, f32);
|
||||
}
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn gen_add_f64() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r"
|
||||
1.1f64 + 2.4 + 3
|
||||
"
|
||||
),
|
||||
6.5,
|
||||
f64
|
||||
);
|
||||
assert_evals_to!("1.1f64 + 2.4 + 3", 6.5, f64);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn gen_wrap_add_nums() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
@ -737,7 +721,7 @@ fn gen_div_checked_by_zero_f64() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn gen_div_dec() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
@ -757,7 +741,7 @@ fn gen_div_dec() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn gen_div_checked_dec() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
@ -778,7 +762,7 @@ fn gen_div_checked_dec() {
|
||||
);
|
||||
}
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn gen_div_checked_by_zero_dec() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
@ -1080,49 +1064,49 @@ fn gen_sub_f32() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn gen_sub_i8() {
|
||||
assert_evals_to!("1i8 - 2i8 - 3i8", -4, i8);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn gen_sub_u8() {
|
||||
assert_evals_to!("8u8 - 2u8 - 3u8", 3, u8);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn gen_sub_i16() {
|
||||
assert_evals_to!("1i16 - 2i16 - 3i16", -4, i16);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn gen_sub_u16() {
|
||||
assert_evals_to!("8u16 - 2u16 - 3u16", 3, u16);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn gen_sub_i32() {
|
||||
assert_evals_to!("1i32 - 2i32 - 3i32", -4, i32);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn gen_sub_u32() {
|
||||
assert_evals_to!("8u32 - 2u32 - 3u32", 3, u32);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn gen_sub_i64() {
|
||||
assert_evals_to!("1 - 2 - 3", -4, i64);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn gen_signed_mul_quadword_and_lower() {
|
||||
assert_evals_to!("2i64 * 4 * 6", 48, i64);
|
||||
assert_evals_to!("2i32 * 4 * 6", 48, i32);
|
||||
@ -1131,7 +1115,7 @@ fn gen_signed_mul_quadword_and_lower() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn gen_unsigned_mul_quadword_and_lower() {
|
||||
assert_evals_to!("2u64 * 4 * 6", 48, u64);
|
||||
assert_evals_to!("2u32 * 4 * 6", 48, u32);
|
||||
@ -1140,13 +1124,13 @@ fn gen_unsigned_mul_quadword_and_lower() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn gen_mul_f64() {
|
||||
assert_evals_to!("2f64 * 4 * 6", 48.0, f64);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn gen_mul_f32() {
|
||||
assert_evals_to!("2f32 * 4 * 6", 48.0, f32);
|
||||
}
|
||||
@ -1829,24 +1813,16 @@ fn pow_int() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn atan() {
|
||||
assert_evals_to!("Num.atan 10f64", 1.4711276743037347, f64);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
#[should_panic(expected = r#"Roc failed with message: "Integer addition overflowed!"#)]
|
||||
fn int_add_overflow() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r"
|
||||
9_223_372_036_854_775_807 + 1
|
||||
"
|
||||
),
|
||||
0,
|
||||
i64
|
||||
);
|
||||
assert_evals_to!("9_223_372_036_854_775_807 + 1", 0, i64);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1900,7 +1876,7 @@ fn float_add_checked_fail() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn float_add_overflow() {
|
||||
assert_evals_to!(
|
||||
"1.7976931348623157e308f64 + 1.7976931348623157e308",
|
||||
@ -1917,7 +1893,7 @@ fn int_sub_overflow() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn int_sub_wrap() {
|
||||
assert_evals_to!(
|
||||
"Num.subWrap -9_223_372_036_854_775_808 1",
|
||||
@ -1929,7 +1905,7 @@ fn int_sub_wrap() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn float_sub_overflow() {
|
||||
assert_evals_to!(
|
||||
"-1.7976931348623157e308f64 - 1.7976931348623157e308",
|
||||
@ -1939,30 +1915,18 @@ fn float_sub_overflow() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn int_sub_checked() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r"
|
||||
when Num.subChecked 5 2 is
|
||||
Ok v -> v
|
||||
_ -> -1
|
||||
"
|
||||
),
|
||||
3,
|
||||
i64
|
||||
"Num.subChecked 5 2",
|
||||
RocResult::ok(3),
|
||||
RocResult<i64, ()>
|
||||
);
|
||||
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r"
|
||||
when Num.subChecked Num.minI64 1 is
|
||||
Err Overflow -> -1
|
||||
Ok v -> v
|
||||
"
|
||||
),
|
||||
-1,
|
||||
i64
|
||||
"Num.subChecked Num.minI64 1 ",
|
||||
RocResult::err(()),
|
||||
RocResult<i64, ()>
|
||||
);
|
||||
}
|
||||
|
||||
@ -1970,86 +1934,42 @@ fn int_sub_checked() {
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn float_sub_checked() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r"
|
||||
when Num.subChecked 1.0 0.0f64 is
|
||||
Ok v -> v
|
||||
Err Overflow -> -1.0
|
||||
"
|
||||
),
|
||||
1.0,
|
||||
f64
|
||||
"Num.subChecked 1.0 0.0f64",
|
||||
RocResult::ok(1.0),
|
||||
RocResult<f64, ()>
|
||||
);
|
||||
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r"
|
||||
when Num.subChecked -1.7976931348623157e308f64 1.7976931348623157e308 is
|
||||
Err Overflow -> -1
|
||||
Ok v -> v
|
||||
"
|
||||
),
|
||||
-1.0,
|
||||
f64
|
||||
"Num.subChecked -1.7976931348623157e308f64 1.7976931348623157e308",
|
||||
RocResult::err(()),
|
||||
RocResult<f64, ()>
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
#[should_panic(expected = r#"Roc failed with message: "Integer multiplication overflowed!"#)]
|
||||
fn int_positive_mul_overflow() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r"
|
||||
9_223_372_036_854_775_807 * 2
|
||||
"
|
||||
),
|
||||
0,
|
||||
i64
|
||||
);
|
||||
assert_evals_to!("9_223_372_036_854_775_807 * 2", 0, i64);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
#[should_panic(expected = r#"Roc failed with message: "Integer multiplication overflowed!"#)]
|
||||
fn int_negative_mul_overflow() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r"
|
||||
(-9_223_372_036_854_775_808) * 2
|
||||
"
|
||||
),
|
||||
0,
|
||||
i64
|
||||
);
|
||||
assert_evals_to!("(-9_223_372_036_854_775_808) * 2", 0, i64);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn float_positive_mul_overflow() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r"
|
||||
1.7976931348623157e308f64 * 2
|
||||
"
|
||||
),
|
||||
f64::INFINITY,
|
||||
f64
|
||||
);
|
||||
assert_evals_to!("1.7976931348623157e308f64 * 2", f64::INFINITY, f64);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn float_negative_mul_overflow() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r"
|
||||
-1.7976931348623157e308f64 * 2
|
||||
"
|
||||
),
|
||||
-f64::INFINITY,
|
||||
f64
|
||||
);
|
||||
assert_evals_to!("-1.7976931348623157e308f64 * 2", -f64::INFINITY, f64);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -2068,27 +1988,15 @@ fn int_mul_wrap_i128() {
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn int_mul_checked() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r"
|
||||
when Num.mulChecked 20 2 is
|
||||
Ok v -> v
|
||||
_ -> -1
|
||||
"
|
||||
),
|
||||
40,
|
||||
i64
|
||||
"Num.mulChecked 20 2",
|
||||
RocResult::ok(40),
|
||||
RocResult::<i64, ()>
|
||||
);
|
||||
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r"
|
||||
when Num.mulChecked Num.maxI64 2 is
|
||||
Err Overflow -> -1
|
||||
Ok v -> v
|
||||
"
|
||||
),
|
||||
-1,
|
||||
i64
|
||||
"Num.mulChecked Num.maxI64 2",
|
||||
RocResult::err(()),
|
||||
RocResult::<i64, ()>
|
||||
);
|
||||
}
|
||||
|
||||
@ -2096,27 +2004,15 @@ fn int_mul_checked() {
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn float_mul_checked() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r"
|
||||
when Num.mulChecked 20.0 2.0f64 is
|
||||
Ok v -> v
|
||||
Err Overflow -> -1.0
|
||||
"
|
||||
),
|
||||
40.0,
|
||||
f64
|
||||
"Num.mulChecked 20.0 2.0f64",
|
||||
RocResult::ok(40.0),
|
||||
RocResult::<f64, ()>
|
||||
);
|
||||
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r"
|
||||
when Num.mulChecked 1.7976931348623157e308f64 2 is
|
||||
Err Overflow -> -1
|
||||
Ok v -> v
|
||||
"
|
||||
),
|
||||
-1.0,
|
||||
f64
|
||||
"Num.mulChecked 1.7976931348623157e308f64 2",
|
||||
RocResult::err(()),
|
||||
RocResult::<f64, ()>
|
||||
);
|
||||
}
|
||||
|
||||
@ -2226,121 +2122,121 @@ fn max_i128() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn min_i64() {
|
||||
assert_evals_to!("Num.minI64", i64::MIN, i64);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn max_i64() {
|
||||
assert_evals_to!("Num.maxI64", i64::MAX, i64);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn min_u64() {
|
||||
assert_evals_to!("Num.minU64", u64::MIN, u64);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn max_u64() {
|
||||
assert_evals_to!("Num.maxU64", u64::MAX, u64);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn min_i32() {
|
||||
assert_evals_to!("Num.minI32", i32::MIN, i32);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn max_i32() {
|
||||
assert_evals_to!("Num.maxI32", i32::MAX, i32);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn min_u32() {
|
||||
assert_evals_to!("Num.minU32", u32::MIN, u32);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn max_u32() {
|
||||
assert_evals_to!("Num.maxU32", u32::MAX, u32);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn min_i16() {
|
||||
assert_evals_to!("Num.minI16", i16::MIN, i16);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn max_i16() {
|
||||
assert_evals_to!("Num.maxI16", i16::MAX, i16);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn min_u16() {
|
||||
assert_evals_to!("Num.minU16", u16::MIN, u16);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn max_u16() {
|
||||
assert_evals_to!("Num.maxU16", u16::MAX, u16);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn min_i8() {
|
||||
assert_evals_to!("Num.minI8", i8::MIN, i8);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn max_i8() {
|
||||
assert_evals_to!("Num.maxI8", i8::MAX, i8);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn min_u8() {
|
||||
assert_evals_to!("Num.minU8", u8::MIN, u8);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn max_u8() {
|
||||
assert_evals_to!("Num.maxU8", u8::MAX, u8);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn max_f64() {
|
||||
assert_evals_to!("Num.maxF64", f64::MAX, f64);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn min_f64() {
|
||||
assert_evals_to!("Num.minF64", f64::MIN, f64);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn max_f32() {
|
||||
assert_evals_to!("Num.maxF32", f32::MAX, f32);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn min_f32() {
|
||||
assert_evals_to!("Num.minF32", f32::MIN, f32);
|
||||
}
|
||||
@ -2624,7 +2520,7 @@ fn is_multiple_of_signed() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn is_multiple_of_unsigned() {
|
||||
// true
|
||||
assert_evals_to!("Num.isMultipleOf 5u8 1", true, bool);
|
||||
@ -2970,7 +2866,7 @@ fn bytes_to_u128_random_u8s() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn when_on_i32() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
@ -2993,7 +2889,7 @@ fn when_on_i32() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn when_on_i16() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
@ -3032,7 +2928,7 @@ fn num_to_str() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn num_to_str_u8() {
|
||||
use roc_std::RocStr;
|
||||
|
||||
@ -3045,7 +2941,7 @@ fn num_to_str_u8() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn num_to_str_u16() {
|
||||
use roc_std::RocStr;
|
||||
|
||||
@ -3058,7 +2954,7 @@ fn num_to_str_u16() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn num_to_str_u32() {
|
||||
use roc_std::RocStr;
|
||||
|
||||
@ -3071,7 +2967,7 @@ fn num_to_str_u32() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn num_to_str_u64() {
|
||||
use roc_std::RocStr;
|
||||
|
||||
@ -3084,7 +2980,7 @@ fn num_to_str_u64() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn num_to_str_i8() {
|
||||
use roc_std::RocStr;
|
||||
|
||||
@ -3102,7 +2998,7 @@ fn num_to_str_i8() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn num_to_str_i16() {
|
||||
use roc_std::RocStr;
|
||||
|
||||
@ -3120,7 +3016,7 @@ fn num_to_str_i16() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn num_to_str_i32() {
|
||||
use roc_std::RocStr;
|
||||
|
||||
@ -3138,7 +3034,7 @@ fn num_to_str_i32() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn num_to_str_i64() {
|
||||
use roc_std::RocStr;
|
||||
|
||||
@ -3156,7 +3052,7 @@ fn num_to_str_i64() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn num_to_str_f32() {
|
||||
use roc_std::RocStr;
|
||||
|
||||
@ -3180,7 +3076,7 @@ fn num_to_str_f32() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn num_to_str_f64() {
|
||||
use roc_std::RocStr;
|
||||
|
||||
@ -3204,7 +3100,7 @@ fn num_to_str_f64() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn num_to_str_dec() {
|
||||
use roc_std::RocStr;
|
||||
|
||||
@ -3228,7 +3124,7 @@ fn num_to_str_dec() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn u8_addition_greater_than_i8() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
@ -3246,7 +3142,7 @@ fn u8_addition_greater_than_i8() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn u8_sub_greater_than_i8() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
@ -3264,7 +3160,7 @@ fn u8_sub_greater_than_i8() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn u8_mul_greater_than_i8() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
@ -3282,7 +3178,7 @@ fn u8_mul_greater_than_i8() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn add_saturated() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
@ -3328,7 +3224,7 @@ fn add_saturated() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn sub_saturated() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
@ -3442,7 +3338,7 @@ fn mul_saturated() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn monomorphized_ints() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
@ -3461,7 +3357,7 @@ fn monomorphized_ints() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn monomorphized_floats() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
@ -3480,7 +3376,7 @@ fn monomorphized_floats() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn monomorphized_ints_names_dont_conflict() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
@ -3504,7 +3400,7 @@ fn monomorphized_ints_names_dont_conflict() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn monomorphized_ints_aliased() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
@ -3601,7 +3497,7 @@ fn upcast_of_int_checked_is_zext() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn modulo_of_unsigned() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
@ -3615,7 +3511,7 @@ fn modulo_of_unsigned() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn div_of_unsigned() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
@ -3629,7 +3525,7 @@ fn div_of_unsigned() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn dec_float_suffix() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
@ -3643,7 +3539,7 @@ fn dec_float_suffix() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn dec_no_decimal() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
@ -3657,7 +3553,7 @@ fn dec_no_decimal() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn ceiling_to_u32() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
@ -3673,7 +3569,7 @@ fn ceiling_to_u32() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn floor_to_u32() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
@ -3689,7 +3585,7 @@ fn floor_to_u32() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn round_to_u32() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
@ -3705,7 +3601,7 @@ fn round_to_u32() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn promote_u64_number_layout() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
@ -3719,7 +3615,7 @@ fn promote_u64_number_layout() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn promote_i128_number_layout() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
@ -3736,7 +3632,7 @@ fn promote_i128_number_layout() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn promote_u128_number_layout() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
@ -3750,7 +3646,7 @@ fn promote_u128_number_layout() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn when_on_decimals() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
@ -3799,7 +3695,7 @@ fn when_on_i128() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn when_on_u128() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
@ -3817,7 +3713,7 @@ fn when_on_u128() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn condition_polymorphic_num_becomes_float() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
@ -3859,7 +3755,7 @@ fn num_count_one_bits() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn num_abs_diff_int() {
|
||||
assert_evals_to!(r"Num.absDiff 0u8 0u8", 0, u8);
|
||||
assert_evals_to!(r"Num.absDiff 1u8 2u8", 1, u8);
|
||||
@ -3879,7 +3775,7 @@ fn num_abs_diff_large_bits() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn num_abs_diff_float() {
|
||||
assert_evals_to!(r"Num.absDiff 0.0f64 0.0", 0.0, f64);
|
||||
assert_evals_to!(r"Num.absDiff 1.0f64 2.0", 1.0, f64);
|
||||
@ -3889,14 +3785,14 @@ fn num_abs_diff_float() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
#[should_panic(expected = r#"Roc failed with message: "Integer subtraction overflowed!"#)]
|
||||
fn num_abs_max_overflow() {
|
||||
assert_evals_to!(r"Num.absDiff Num.maxI64 -1", 0, i64);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
#[should_panic(expected = r#"Roc failed with message: "Integer subtraction overflowed!"#)]
|
||||
fn num_abs_int_min_overflow() {
|
||||
assert_evals_to!(r"Num.absDiff Num.minI64 0", 0, i64);
|
||||
@ -3910,7 +3806,7 @@ fn num_abs_large_bits_min_overflow() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn num_abs_float_overflow() {
|
||||
assert_evals_to!("Num.absDiff Num.maxF64 Num.minF64", f64::INFINITY, f64);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user