add tests

This commit is contained in:
Folkert 2020-03-16 23:15:36 +01:00
parent 5fca5fe631
commit 74ec3682a2

View file

@ -136,6 +136,7 @@ mod test_gen {
// TODO try deleting this line and seeing if everything still works. // TODO try deleting this line and seeing if everything still works.
builder.append_block_params_for_function_params(block); builder.append_block_params_for_function_params(block);
dbg!(&mono_expr);
let main_body = let main_body =
roc_gen::crane::build::build_expr(&env, &scope, &mut module, &mut builder, &mono_expr, &procs); roc_gen::crane::build::build_expr(&env, &scope, &mut module, &mut builder, &mono_expr, &procs);
@ -1114,16 +1115,16 @@ mod test_gen {
} }
#[test] #[test]
fn when_on_result() { fn applied_tag_nothing() {
assert_evals_to!( assert_evals_to!(
indoc!( indoc!(
r#" r#"
x : Result Int Int Maybe a : [ Just a, Nothing ]
x = Ok 42
when x is x : Maybe Int
Ok _ -> 0 x = Nothing
Err _ -> 4
0x1
"# "#
), ),
1, 1,
@ -1131,6 +1132,42 @@ mod test_gen {
); );
} }
#[test]
fn applied_tag_just() {
assert_evals_to!(
indoc!(
r#"
Maybe a : [ Just a, Nothing ]
y : Maybe Int
y = Just 0x4
0x1
"#
),
1,
i64
);
}
// #[test]
// fn when_on_result() {
// assert_evals_to!(
// indoc!(
// r#"
// x : Result Int Int
// x = Ok 42
//
// when x is
// Err _ -> 4
// Ok _ -> 0
// "#
// ),
// 0,
// i64
// );
// }
#[test] #[test]
fn basic_record() { fn basic_record() {
assert_evals_to!( assert_evals_to!(