mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 12:18:19 +00:00
tests for boxing/unboxing floats
This commit is contained in:
parent
b968122bee
commit
816828040d
3 changed files with 38 additions and 30 deletions
|
@ -2512,7 +2512,7 @@ impl<
|
|||
let sym_reg = storage_manager.load_to_general_reg(buf, &value);
|
||||
ASM::mov_mem8_offset32_reg8(buf, ptr_reg, element_offset, sym_reg);
|
||||
}
|
||||
Layout::Builtin(Builtin::Float(FloatWidth::F64)) => {
|
||||
Layout::Builtin(Builtin::Float(FloatWidth::F64 | FloatWidth::F32)) => {
|
||||
let sym_reg = storage_manager.load_to_float_reg(buf, &value);
|
||||
ASM::movesd_mem64_offset32_freg64(buf, ptr_reg, element_offset, sym_reg);
|
||||
}
|
||||
|
|
|
@ -2700,24 +2700,22 @@ fn list_min() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when List.min [] is
|
||||
Ok val -> val
|
||||
Err _ -> -1
|
||||
"#
|
||||
List.min []
|
||||
|> Result.map (\_ -> {})
|
||||
"#
|
||||
),
|
||||
-1,
|
||||
i64
|
||||
RocResult::err(()),
|
||||
RocResult<(), ()>
|
||||
);
|
||||
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when List.min [3, 1, 2] is
|
||||
Ok val -> val
|
||||
Err _ -> -1
|
||||
"#
|
||||
List.min [3, 1, 2]
|
||||
"#
|
||||
),
|
||||
1,
|
||||
i64
|
||||
RocResult::ok(1),
|
||||
RocResult<i64, ()>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -2727,24 +2725,22 @@ fn list_max() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when List.max [] is
|
||||
Ok val -> val
|
||||
Err _ -> -1
|
||||
"#
|
||||
List.max []
|
||||
|> Result.map (\_ -> {})
|
||||
"#
|
||||
),
|
||||
-1,
|
||||
i64
|
||||
RocResult::err(()),
|
||||
RocResult<(), ()>
|
||||
);
|
||||
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when List.max [3, 1, 2] is
|
||||
Ok val -> val
|
||||
Err _ -> -1
|
||||
"#
|
||||
List.max [3, 1, 2]
|
||||
"#
|
||||
),
|
||||
3,
|
||||
i64
|
||||
RocResult::ok(3),
|
||||
RocResult<i64, ()>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -3307,34 +3307,46 @@ fn box_str() {
|
|||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn box_and_unbox_64bit_num() {
|
||||
fn box_and_unbox_u64() {
|
||||
assert_evals_to!("Box.unbox (Box.box (123u64))", 123, u64)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn box_and_unbox_32bit_num() {
|
||||
fn box_and_unbox_u32() {
|
||||
assert_evals_to!("Box.unbox (Box.box (123u32))", 123, u32)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn box_and_unbox_16bit_num() {
|
||||
fn box_and_unbox_u16() {
|
||||
assert_evals_to!("Box.unbox (Box.box (123u16))", 123, u16)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn box_and_unbox_8bit_num() {
|
||||
fn box_and_unbox_u8() {
|
||||
assert_evals_to!("Box.unbox (Box.box (123u8))", 123, u8)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn box_and_unbox_1bit_num() {
|
||||
fn box_and_unbox_bool() {
|
||||
assert_evals_to!("Box.unbox (Box.box (Bool.true))", true, bool)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn box_and_unbox_f64() {
|
||||
assert_evals_to!("Box.unbox (Box.box (123.0f64))", 123.0, f64)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn box_and_unbox_f32() {
|
||||
assert_evals_to!("Box.unbox (Box.box (123.0f32))", 123.0, f32)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn box_and_unbox_record() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue