mirror of
https://github.com/roc-lang/roc.git
synced 2025-11-25 13:36:37 +00:00
mono: generate refcounting helper functions for Boxed layout
This commit is contained in:
parent
7c7e450756
commit
6b1e9c75c8
3 changed files with 111 additions and 3 deletions
|
|
@ -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
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue