Add mono tests to validate refcounts with early return

This commit is contained in:
Sam Mohr 2024-10-24 22:56:03 -07:00
parent 7518a2c5ab
commit 01369dc6d8
No known key found for this signature in database
GPG key ID: EA41D161A3C1BC99
3 changed files with 152 additions and 0 deletions

View file

@ -3672,3 +3672,53 @@ fn issue_6606_2() {
"
)
}
#[mono_test]
fn dec_refcount_for_usage_after_early_return_in_if() {
indoc!(
r#"
displayN = \n ->
first = Num.toStr n
second =
if n == 1 then
return "early 1"
else
third = Num.toStr (n + 1)
if n == 2 then
return "early 2"
else
third
"$(first), $(second)"
displayN 3
"#
)
}
#[mono_test]
fn dec_refcount_for_usage_after_early_return_in_when() {
indoc!(
r#"
displayN = \n ->
first = Num.toStr n
second =
when n is
1 ->
return "early 1"
_ ->
third = Num.toStr (n + 1)
when n is
2 ->
return "early 2"
_ ->
third
"$(first), $(second)"
displayN 3
"#
)
}