mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 06:44:46 +00:00
Merge remote-tracking branch 'origin/trunk' into div-no-result
This commit is contained in:
commit
8206f345c7
46 changed files with 1685 additions and 291 deletions
|
@ -2248,7 +2248,7 @@ fn max_u8() {
|
|||
);
|
||||
}
|
||||
|
||||
macro_rules! to_int_tests {
|
||||
macro_rules! num_conversion_tests {
|
||||
($($fn:expr, $typ:ty, ($($test_name:ident, $input:expr, $output:expr $(, [ $($support_gen:literal),* ])? )*))*) => {$($(
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", $($(feature = $support_gen)*)?))]
|
||||
|
@ -2259,7 +2259,7 @@ macro_rules! to_int_tests {
|
|||
)*)*}
|
||||
}
|
||||
|
||||
to_int_tests! {
|
||||
num_conversion_tests! {
|
||||
"Num.toI8", i8, (
|
||||
to_i8_same_width, "15u8", 15, ["gen-wasm"]
|
||||
to_i8_truncate, "115i32", 115, ["gen-wasm"]
|
||||
|
@ -2320,6 +2320,36 @@ to_int_tests! {
|
|||
to_nat_truncate, "115i128", 115
|
||||
to_nat_truncate_wraps, "10_000_000_000_000_000_000_000i128", 1864712049423024128
|
||||
)
|
||||
"Num.toF32", f32, (
|
||||
to_f32_from_i8, "15i8", 15.0
|
||||
to_f32_from_i16, "15i16", 15.0
|
||||
to_f32_from_i32, "15i32", 15.0
|
||||
to_f32_from_i64, "15i64", 15.0
|
||||
to_f32_from_i128, "15i128", 15.0
|
||||
to_f32_from_u8, "15u8", 15.0
|
||||
to_f32_from_u16, "15u16", 15.0
|
||||
to_f32_from_u32, "15u32", 15.0
|
||||
to_f32_from_u64, "15u64", 15.0
|
||||
to_f32_from_u128, "15u128", 15.0
|
||||
to_f32_from_nat, "15nat", 15.0
|
||||
to_f32_from_f32, "1.5f32", 1.5
|
||||
to_f32_from_f64, "1.5f64", 1.5
|
||||
)
|
||||
"Num.toF64", f64, (
|
||||
to_f64_from_i8, "15i8", 15.0
|
||||
to_f64_from_i16, "15i16", 15.0
|
||||
to_f64_from_i32, "15i32", 15.0
|
||||
to_f64_from_i64, "15i64", 15.0
|
||||
to_f64_from_i128, "15i128", 15.0
|
||||
to_f64_from_u8, "15u8", 15.0
|
||||
to_f64_from_u16, "15u16", 15.0
|
||||
to_f64_from_u32, "15u32", 15.0
|
||||
to_f64_from_u64, "15u64", 15.0
|
||||
to_f64_from_u128, "15u128", 15.0
|
||||
to_f64_from_nat, "15nat", 15.0
|
||||
to_f64_from_f32, "1.5f32", 1.5
|
||||
to_f64_from_f64, "1.5f64", 1.5
|
||||
)
|
||||
}
|
||||
|
||||
macro_rules! to_int_checked_tests {
|
||||
|
|
|
@ -3275,3 +3275,47 @@ fn box_and_unbox_string() {
|
|||
RocStr
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn box_and_unbox_num() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
Box.unbox (Box.box (123u8))
|
||||
"#
|
||||
),
|
||||
123,
|
||||
u8
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn box_and_unbox_record() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
Box.unbox (Box.box { a: 15u8, b: 27u8 })
|
||||
"#
|
||||
),
|
||||
(15, 27),
|
||||
(u8, u8)
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn box_and_unbox_tag_union() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
v : [ A U8, B U8 ] # usually stack allocated
|
||||
v = B 27u8
|
||||
Box.unbox (Box.box v)
|
||||
"#
|
||||
),
|
||||
(27, 1),
|
||||
(u8, u8)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1587,3 +1587,19 @@ fn str_to_dec() {
|
|||
RocDec
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn issue_2811() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
x = Command { tool: "bash" }
|
||||
Command c = x
|
||||
c.tool
|
||||
"#
|
||||
),
|
||||
RocStr::from("bash"),
|
||||
RocStr
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue