mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
fix llvm gen tests
This commit is contained in:
parent
f7104bfe54
commit
c38f8bec75
2 changed files with 35 additions and 40 deletions
|
@ -144,14 +144,8 @@ fn build_eq<'a, 'ctx>(
|
||||||
lhs_val: BasicValueEnum<'ctx>,
|
lhs_val: BasicValueEnum<'ctx>,
|
||||||
rhs_val: BasicValueEnum<'ctx>,
|
rhs_val: BasicValueEnum<'ctx>,
|
||||||
lhs_layout: LayoutRepr<'a>,
|
lhs_layout: LayoutRepr<'a>,
|
||||||
rhs_layout: LayoutRepr<'a>,
|
_rhs_layout: LayoutRepr<'a>,
|
||||||
) -> BasicValueEnum<'ctx> {
|
) -> BasicValueEnum<'ctx> {
|
||||||
debug_assert_eq!(
|
|
||||||
lhs_layout, rhs_layout,
|
|
||||||
"Equality of different layouts; did you have a type mismatch?\n{:?} == {:?}",
|
|
||||||
lhs_layout, rhs_layout
|
|
||||||
);
|
|
||||||
|
|
||||||
match lhs_layout {
|
match lhs_layout {
|
||||||
LayoutRepr::Builtin(builtin) => build_eq_builtin(
|
LayoutRepr::Builtin(builtin) => build_eq_builtin(
|
||||||
env,
|
env,
|
||||||
|
|
|
@ -2211,45 +2211,46 @@ fn nullable_eval_cfold() {
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||||
fn nested_switch() {
|
fn nested_switch() {
|
||||||
// exposed bug with passing the right symbol/layout down into switch branch generation
|
crate::helpers::with_larger_debug_stack(||
|
||||||
// This is also the only test_gen test that exercises Reset/Reuse (as of Aug 2022)
|
// exposed bug with passing the right symbol/layout down into switch branch generation
|
||||||
assert_evals_to!(
|
// This is also the only test_gen test that exercises Reset/Reuse (as of Aug 2022)
|
||||||
indoc!(
|
assert_evals_to!(
|
||||||
r#"
|
indoc!(
|
||||||
app "test" provides [main] to "./platform"
|
r#"
|
||||||
|
app "test" provides [main] to "./platform"
|
||||||
|
|
||||||
Expr : [ZAdd Expr Expr, Val I64, Var I64]
|
Expr : [ZAdd Expr Expr, Val I64, Var I64]
|
||||||
|
|
||||||
eval : Expr -> I64
|
eval : Expr -> I64
|
||||||
eval = \e ->
|
eval = \e ->
|
||||||
when e is
|
when e is
|
||||||
Var _ -> 0
|
Var _ -> 0
|
||||||
Val v -> v
|
Val v -> v
|
||||||
ZAdd l r -> eval l + eval r
|
ZAdd l r -> eval l + eval r
|
||||||
|
|
||||||
constFolding : Expr -> Expr
|
constFolding : Expr -> Expr
|
||||||
constFolding = \e ->
|
constFolding = \e ->
|
||||||
when e is
|
when e is
|
||||||
ZAdd e1 e2 ->
|
ZAdd e1 e2 ->
|
||||||
when Pair e1 e2 is
|
when Pair e1 e2 is
|
||||||
Pair (Val a) (Val b) -> Val (a+b)
|
Pair (Val a) (Val b) -> Val (a+b)
|
||||||
Pair (Val a) (ZAdd x (Val b)) -> ZAdd (Val (a+b)) x
|
Pair (Val a) (ZAdd x (Val b)) -> ZAdd (Val (a+b)) x
|
||||||
Pair _ _ -> ZAdd e1 e2
|
Pair _ _ -> ZAdd e1 e2
|
||||||
|
|
||||||
|
|
||||||
_ -> e
|
_ -> e
|
||||||
|
|
||||||
|
|
||||||
expr : Expr
|
expr : Expr
|
||||||
expr = ZAdd (Val 3) (ZAdd (Val 4) (Val 5))
|
expr = ZAdd (Val 3) (ZAdd (Val 4) (Val 5))
|
||||||
|
|
||||||
main : I64
|
main : I64
|
||||||
main = eval (constFolding expr)
|
main = eval (constFolding expr)
|
||||||
"#
|
"#
|
||||||
),
|
),
|
||||||
12,
|
12,
|
||||||
i64
|
i64
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -4522,8 +4523,8 @@ fn linked_list_trmc() {
|
||||||
Nil -> 0
|
Nil -> 0
|
||||||
Cons _ rest -> 1 + length rest
|
Cons _ rest -> 1 + length rest
|
||||||
|
|
||||||
main : I64
|
main : I64
|
||||||
main =
|
main =
|
||||||
repeat "foo" 5
|
repeat "foo" 5
|
||||||
|> length
|
|> length
|
||||||
"#
|
"#
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue