mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 19:58:18 +00:00
Merge remote-tracking branch 'origin/trunk' into i2453
This commit is contained in:
commit
5b10ebeeb7
13 changed files with 579 additions and 125 deletions
|
@ -3812,3 +3812,18 @@ fn when_on_u128() {
|
|||
i64
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn condition_polymorphic_num_becomes_float() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
x = if True then 2 else 3
|
||||
x * 5f32
|
||||
"#
|
||||
),
|
||||
10.,
|
||||
f32
|
||||
);
|
||||
}
|
||||
|
|
|
@ -3705,3 +3705,136 @@ fn runtime_error_when_degenerate_pattern_reached() {
|
|||
true // allow errors
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn recursive_lambda_set_issue_3444() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
combine = \f, g -> \x -> g (f x)
|
||||
const = \x -> (\_y -> x)
|
||||
|
||||
list = [const "a", const "b", const "c"]
|
||||
|
||||
res : Str -> Str
|
||||
res = List.walk list (const "z") (\c1, c2 -> combine c1 c2)
|
||||
res "hello"
|
||||
"#
|
||||
),
|
||||
RocStr::from("c"),
|
||||
RocStr
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn recursive_lambda_set_toplevel_issue_3444() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [main] to "./platform"
|
||||
|
||||
combine = \f, g -> \x -> g (f x)
|
||||
const = \x -> (\_y -> x)
|
||||
|
||||
list = [const "a", const "b", const "c"]
|
||||
|
||||
res : Str -> Str
|
||||
res = List.walk list (const "z") (\c1, c2 -> combine c1 c2)
|
||||
|
||||
main = res "hello"
|
||||
"#
|
||||
),
|
||||
RocStr::from("c"),
|
||||
RocStr
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn recursive_lambda_set_issue_3444_inferred() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
combine = \f, g -> \x -> g (f x)
|
||||
const = \x -> (\_y -> x)
|
||||
|
||||
list = [const "a", const "b", const "c"]
|
||||
|
||||
res = List.walk list (const "z") (\c1, c2 -> combine c1 c2)
|
||||
res "hello"
|
||||
"#
|
||||
),
|
||||
RocStr::from("c"),
|
||||
RocStr
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn compose_recursive_lambda_set_productive_toplevel() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [main] to "./platform"
|
||||
|
||||
compose = \f, g -> \x -> g (f x)
|
||||
|
||||
identity = \x -> x
|
||||
exclaim = \s -> "\(s)!"
|
||||
whisper = \s -> "(\(s))"
|
||||
|
||||
main =
|
||||
res: Str -> Str
|
||||
res = List.walk [ exclaim, whisper ] identity compose
|
||||
res "hello"
|
||||
"#
|
||||
),
|
||||
RocStr::from("(hello!)"),
|
||||
RocStr
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn compose_recursive_lambda_set_productive_nested() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
compose = \f, g -> \x -> g (f x)
|
||||
|
||||
identity = \x -> x
|
||||
exclaim = \s -> "\(s)!"
|
||||
whisper = \s -> "(\(s))"
|
||||
|
||||
res: Str -> Str
|
||||
res = List.walk [ exclaim, whisper ] identity compose
|
||||
res "hello"
|
||||
"#
|
||||
),
|
||||
RocStr::from("(hello!)"),
|
||||
RocStr
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn compose_recursive_lambda_set_productive_inferred() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
compose = \f, g -> \x -> g (f x)
|
||||
|
||||
identity = \x -> x
|
||||
exclaim = \s -> "\(s)!"
|
||||
whisper = \s -> "(\(s))"
|
||||
|
||||
res = List.walk [ exclaim, whisper ] identity compose
|
||||
res "hello"
|
||||
"#
|
||||
),
|
||||
RocStr::from("(hello!)"),
|
||||
RocStr
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1913,3 +1913,23 @@ fn issue_3653_recursion_pointer_in_naked_opaque_localized() {
|
|||
RocStr
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn issue_2165_recursive_tag_destructure() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
SomeTag : [ Ctor { rec : List SomeTag } ]
|
||||
|
||||
x : SomeTag
|
||||
x = Ctor { rec: [] }
|
||||
|
||||
when x is
|
||||
Ctor { rec } -> Num.toStr (List.len rec)
|
||||
"#
|
||||
),
|
||||
RocStr::from("0"),
|
||||
RocStr
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue