mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 19:58:18 +00:00
add Str.releaseExcessCapacity
This commit is contained in:
parent
a80b25d044
commit
48f17a8e2c
11 changed files with 115 additions and 0 deletions
|
@ -2035,3 +2035,51 @@ fn destructure_pattern_assigned_from_thunk_tag() {
|
|||
RocStr
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn release_excess_capacity() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
Str.reserve "" 50
|
||||
|> Str.releaseExcessCapacity
|
||||
"#
|
||||
),
|
||||
(RocStr::empty().capacity(), RocStr::empty()),
|
||||
RocStr,
|
||||
|value: RocStr| (value.capacity(), value)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn release_excess_capacity_with_len() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
"123456789012345678901234567890"
|
||||
|> Str.reserve 50
|
||||
|> Str.releaseExcessCapacity
|
||||
"#
|
||||
),
|
||||
(30, "123456789012345678901234567890".into()),
|
||||
RocStr,
|
||||
|value: RocStr| (value.capacity(), value)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn release_excess_capacity_empty() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
Str.releaseExcessCapacity ""
|
||||
"#
|
||||
),
|
||||
(RocStr::empty().capacity(), RocStr::empty()),
|
||||
RocStr,
|
||||
|value: RocStr| (value.capacity(), value)
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue