mono: generate refcounting helper functions for Boxed layout

This commit is contained in:
Brian Carroll 2022-07-03 23:31:49 +01:00
parent 7c7e450756
commit 6b1e9c75c8
No known key found for this signature in database
GPG key ID: 9CF4E3BF9C4722C7
3 changed files with 111 additions and 3 deletions

View file

@ -431,3 +431,46 @@ fn union_linked_list_long_dec() {
&[Deallocated; 1_000]
);
}
#[test]
#[cfg(any(feature = "gen-wasm"))]
fn boxed_str_inc() {
assert_refcounts!(
indoc!(
r#"
s = Str.concat "A long enough string " "to be heap-allocated"
b = Box.box s
Tuple b b
"#
),
(Pointer, Pointer),
&[
Live(2), // s
Live(2), // b
]
);
}
#[test]
#[cfg(any(feature = "gen-wasm"))]
fn boxed_str_dec() {
assert_refcounts!(
indoc!(
r#"
s = Str.concat "A long enough string " "to be heap-allocated"
b = Box.box s
if False then
ReturnTheBox b
else
DeallocateEverything
"#
),
(i32, i32),
&[
Deallocated, // s
Deallocated, // b
]
);
}