Skip to content

Commit

Permalink
Check exhaustiveness behavior on pattern guards.
Browse files Browse the repository at this point in the history
  • Loading branch information
KtorZ committed Aug 2, 2023
1 parent 4f7f392 commit 675b737
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions crates/aiken-lang/src/tests/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,30 @@ fn exhaustiveness_nested_list_and_tuples() {
assert!(matches!(check(parse(source_code)), Ok(_)))
}

#[test]
fn exhaustiveness_guard() {
let source_code = r#"
fn foo() {
when [(True, 42)] is {
[(True, x), ..] if x == 42 -> Void
[(False, x), ..] -> Void
[] -> Void
}
}
"#;

assert!(matches!(
check(parse(source_code)),
Err((
_,
Error::NotExhaustivePatternMatch {
unmatched,
..
}
)) if unmatched[0] == "[(True, _), ..]"
));
}

#[test]
fn expect_sugar_correct_type() {
let source_code = r#"
Expand Down

0 comments on commit 675b737

Please sign in to comment.