Add a refcount test for recursive unions

This commit is contained in:
Brian Carroll 2022-01-02 23:41:04 +00:00
parent e0d0e1884d
commit 94dea1df9f

View file

@ -153,7 +153,7 @@ fn struct_dealloc() {
#[test]
#[cfg(any(feature = "gen-wasm"))]
fn union_nonrec_inc() {
fn union_nonrecursive_inc() {
assert_refcounts!(
indoc!(
r#"
@ -177,7 +177,7 @@ fn union_nonrec_inc() {
#[test]
#[cfg(any(feature = "gen-wasm"))]
fn union_nonrec_dec() {
fn union_nonrecursive_dec() {
assert_refcounts!(
indoc!(
r#"
@ -197,3 +197,30 @@ fn union_nonrec_dec() {
&[1] // s
);
}
#[test]
#[cfg(any(feature = "gen-wasm"))]
fn union_recursive_inc() {
assert_refcounts!(
indoc!(
r#"
Expr : [ Sym Str, Add Expr Expr ]
s = Str.concat "heap_allocated_" "symbol_name"
e : Expr
e = Add (Sym s) (Sym s)
[e, e]
"#
),
RocStr,
&[
4, // s
1, // Sym
1, // Sym
2, // Add
1 // list
]
);
}