mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 16:21:11 +00:00
Add mono tests to validate refcounts with early return
This commit is contained in:
parent
7518a2c5ab
commit
01369dc6d8
3 changed files with 152 additions and 0 deletions
|
@ -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
|
||||
"#
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue