Merge pull request #4237 from snprajwal/str-withcapacity

builtin(str): implement Str.withCapacity
This commit is contained in:
Ayaz 2022-10-08 14:31:30 -05:00 committed by GitHub
commit 9d05bcd9d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 59 additions and 2 deletions

View file

@ -1930,3 +1930,31 @@ fn when_on_strings() {
i64
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn with_capacity() {
assert_evals_to!(
indoc!(
r#"
Str.withCapacity 10
"#
),
RocStr::from(""),
RocStr
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn with_capacity_concat() {
assert_evals_to!(
indoc!(
r#"
Str.withCapacity 10 |> Str.concat "Forty-two"
"#
),
RocStr::from("Forty-two"),
RocStr
);
}