add more refcounting test cases

This commit is contained in:
Brendan Hansknecht 2024-07-12 15:49:54 -07:00
parent 675e0693a4
commit f4117c99d5
No known key found for this signature in database
GPG key ID: 0EA784685083E75B

View file

@ -135,7 +135,7 @@ fn list_map() {
List.map i1 Str.toUtf8
"#
),
RocList<(RocStr, i64)>,
RocList<RocStr>,
&[
(StandardRC, Live(3)), // s
(AfterSize, Deallocated), // i1
@ -144,6 +144,27 @@ fn list_map() {
);
}
#[test]
#[cfg(feature = "gen-wasm")]
fn list_map_dealloc() {
assert_refcounts!(
indoc!(
r#"
s = Str.concat "A long enough string " "to be heap-allocated"
i1 = [s, s, s]
List.map i1 Str.toUtf8
|> List.len
"#
),
i64,
&[
(StandardRC, Deallocated), // s
(AfterSize, Deallocated), // i1
(AfterSize, Deallocated), // Result
]
);
}
#[test]
#[cfg(feature = "gen-wasm")]
fn list_map2_dealloc_tail() {
@ -166,6 +187,27 @@ fn list_map2_dealloc_tail() {
);
}
#[test]
#[cfg(feature = "gen-wasm")]
fn list_map2_dealloc() {
assert_refcounts!(
indoc!(
r#"
s = Str.concat "A long enough string " "to be heap-allocated"
i1 = [s, s, s]
List.map2 i1 i1 \a, b -> (a, b)
|> List.len
"#
),
i64,
&[
(StandardRC, Deallocated), // s
(AfterSize, Deallocated), // i1
(AfterSize, Deallocated), // Result
]
);
}
#[test]
#[cfg(feature = "gen-wasm")]
fn list_str_dealloc() {