mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 22:34:45 +00:00
add more refcounting test cases
This commit is contained in:
parent
f4117c99d5
commit
5d613cd5f5
1 changed files with 55 additions and 0 deletions
|
@ -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]
|
#[test]
|
||||||
#[cfg(feature = "gen-wasm")]
|
#[cfg(feature = "gen-wasm")]
|
||||||
fn list_int_inc() {
|
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]
|
#[test]
|
||||||
#[cfg(feature = "gen-wasm")]
|
#[cfg(feature = "gen-wasm")]
|
||||||
fn list_str_inc() {
|
fn list_str_inc() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue