Merge branch 'main' of github.com:roc-lang/roc into wasm_interp_test_gen

This commit is contained in:
Brian Carroll 2022-12-16 14:50:09 +00:00
commit d389601035
No known key found for this signature in database
GPG key ID: 5C7B2EC4101703C0
61 changed files with 1506 additions and 537 deletions

View file

@ -4107,3 +4107,41 @@ fn issue_4349() {
RocStr
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn issue_4712() {
assert_evals_to!(
indoc!(
r#"
app "test" provides [main] to "./platform"
Parser a : {} -> a
v1 : {}
v1 = {}
v2 : Str
v2 = "cd"
apply : Parser (a -> Str), a -> Parser Str
apply = \fnParser, valParser ->
\{} ->
(fnParser {}) (valParser)
map : a, (a -> Str) -> Parser Str
map = \simpleParser, transform ->
apply (\{} -> transform) simpleParser
gen = \{} ->
[ map v1 (\{} -> "ab"), map v2 (\s -> s) ]
|> List.map (\f -> f {})
|> Str.joinWith ","
main = gen {}
"#
),
RocStr::from("ab,cd"),
RocStr
);
}

View file

@ -2083,3 +2083,53 @@ fn unify_types_with_fixed_fixpoints_outside_fixing_region() {
RocStr
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn lambda_set_with_imported_toplevels_issue_4733() {
assert_evals_to!(
indoc!(
r#"
app "test" provides [main] to "./platform"
fn = \s ->
instr = if s == "*" then (Op Num.mul) else (Op Num.add)
Op op = instr
\a -> op a a
main = ((fn "*") 3) * ((fn "+") 5)
"#
),
90,
i64
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn non_unary_union_with_lambda_set_with_imported_toplevels_issue_4733() {
assert_evals_to!(
indoc!(
r#"
app "test" provides [main] to "./platform"
fn = \s ->
instr =
if s == "*" then (Op Num.mul)
else if s == "+" then (Op Num.add)
else Noop
when instr is
Op op -> (\a -> op a a)
_ -> (\a -> a)
main = ((fn "*") 3) * ((fn "+") 5)
"#
),
90,
i64
);
}