diff --git a/compiler/gen/tests/gen_records.rs b/compiler/gen/tests/gen_records.rs index d9e5dcf9cd..5a7bc5ca38 100644 --- a/compiler/gen/tests/gen_records.rs +++ b/compiler/gen/tests/gen_records.rs @@ -402,6 +402,34 @@ mod gen_records { #[test] fn optional_field_when_use_default() { + assert_evals_to!( + indoc!( + r#" + app Test provides [ main ] imports [] + + f = \r -> + when r is + { x: Blue, y ? 3 } -> y + { x: Red, y ? 5 } -> y + + + main = + a = f { x: Blue, y: 7 } + b = f { x: Blue } + c = f { x: Red, y: 11 } + d = f { x: Red } + + a * b * c * d + "# + ), + 3 * 5 * 7 * 11, + i64 + ); + } + + #[test] + #[ignore] + fn optional_field_when_use_default_nested() { assert_evals_to!( indoc!( r#" @@ -425,6 +453,27 @@ mod gen_records { #[test] fn optional_field_when_no_use_default() { + assert_evals_to!( + indoc!( + r#" + app Test provides [ main ] imports [] + + f = \r -> + { x ? 10, y } = r + x + y + + main = + f { x: 4, y: 9 } + "# + ), + 13, + i64 + ); + } + + #[test] + #[ignore] + fn optional_field_when_no_use_default_nested() { assert_evals_to!( indoc!( r#" @@ -445,11 +494,14 @@ mod gen_records { assert_evals_to!( indoc!( r#" + app Test provides [ main ] imports [] + f = \r -> { x ? 10, y } = r x + y - f { y: 9 } + main = + f { y: 9 } "# ), 19, @@ -459,6 +511,27 @@ mod gen_records { #[test] fn optional_field_let_no_use_default() { + assert_evals_to!( + indoc!( + r#" + app Test provides [ main ] imports [] + + f = \r -> + { x ? 10, y } = r + x + y + + main = + f { x: 4, y: 9 } + "# + ), + 13, + i64 + ); + } + + #[test] + #[ignore] + fn optional_field_let_no_use_default_nested() { assert_evals_to!( indoc!( r#" @@ -492,6 +565,25 @@ mod gen_records { #[test] fn optional_field_function_no_use_default() { + assert_evals_to!( + indoc!( + r#" + app Test provides [ main ] imports [] + + f = \{ x ? 10, y } -> x + y + + main = + f { x: 4, y: 9 } + "# + ), + 13, + i64 + ); + } + + #[test] + #[ignore] + fn optional_field_function_no_use_default_nested() { assert_evals_to!( indoc!( r#" diff --git a/compiler/gen/tests/gen_tags.rs b/compiler/gen/tests/gen_tags.rs index a95d7ec5df..d7119aea1a 100644 --- a/compiler/gen/tests/gen_tags.rs +++ b/compiler/gen/tests/gen_tags.rs @@ -413,6 +413,31 @@ mod gen_tags { #[test] fn maybe_is_just() { + assert_evals_to!( + indoc!( + r#" + app Test provides [ main ] imports [] + + Maybe a : [ Just a, Nothing ] + + isJust : Maybe a -> Bool + isJust = \list -> + when list is + Nothing -> False + Just _ -> True + + main = + isJust (Just 42) + "# + ), + true, + bool + ); + } + + #[test] + #[ignore] + fn maybe_is_just_nested() { assert_evals_to!( indoc!( r#"