add more refcounting test cases

This commit is contained in:
Brendan Hansknecht 2024-07-12 16:31:32 -07:00
parent f4117c99d5
commit 5d613cd5f5
No known key found for this signature in database
GPG key ID: 0EA784685083E75B

View file

@ -47,6 +47,43 @@ fn str_dealloc() {
);
}
#[test]
#[cfg(feature = "gen-wasm")]
fn str_to_utf8() {
assert_refcounts!(
indoc!(
r#"
s = Str.concat "A long enough string " "to be heap-allocated"
Str.toUtf8 s
"#
),
RocStr,
&[
(StandardRC, Live(1)), // s
]
);
}
#[test]
#[cfg(feature = "gen-wasm")]
fn str_to_utf8_dealloc() {
assert_refcounts!(
indoc!(
r#"
s = Str.concat "A long enough string " "to be heap-allocated"
Str.toUtf8 s
|> List.len
"#
),
i64,
&[
(StandardRC, Deallocated), // s
]
);
}
#[test]
#[cfg(feature = "gen-wasm")]
fn list_int_inc() {
@ -83,6 +120,24 @@ fn list_int_dealloc() {
);
}
#[test]
#[cfg(feature = "gen-wasm")]
fn list_str() {
assert_refcounts!(
indoc!(
r#"
s = Str.concat "A long enough string " "to be heap-allocated"
[s, s, s]
"#
),
RocList<RocStr>,
&[
(StandardRC, Live(3)), // s
(AfterSize, Live(1)), // Result
]
);
}
#[test]
#[cfg(feature = "gen-wasm")]
fn list_str_inc() {