adding tests and changing trimLeft to pass long unique test

This commit is contained in:
Michael Downey 2021-11-09 18:16:32 -05:00
parent c1a48c0a9a
commit 151c92bb48
2 changed files with 89 additions and 5 deletions

View file

@ -1068,3 +1068,89 @@ fn str_trim_small_to_small_shared() {
(RocStr, RocStr)
);
}
#[test]
fn str_trim_left_small_blank_string() {
assert_evals_to!(indoc!(r#"Str.trimLeft " ""#), RocStr::from(""), RocStr);
}
#[test]
fn str_trim_left_small_to_small() {
assert_evals_to!(
indoc!(r#"Str.trimLeft " hello world ""#),
RocStr::from("hello world "),
RocStr
);
}
#[test]
fn str_trim_left_large_to_large_unique() {
assert_evals_to!(
indoc!(r#"Str.trimLeft (Str.concat " " "hello world from a large string ")"#),
RocStr::from("hello world from a large string "),
RocStr
);
}
#[test]
fn str_trim_left_large_to_small_unique() {
assert_evals_to!(
indoc!(r#"Str.trimLeft (Str.concat " " "hello world ")"#),
RocStr::from("hello world "),
RocStr
);
}
#[test]
fn str_trim_left_large_to_large_shared() {
assert_evals_to!(
indoc!(
r#"
original : Str
original = " hello world world "
{ trimmed: Str.trimLeft original, original: original }
"#
),
(
RocStr::from(" hello world world "),
RocStr::from("hello world world "),
),
(RocStr, RocStr)
);
}
#[test]
fn str_trim_left_large_to_small_shared() {
assert_evals_to!(
indoc!(
r#"
original : Str
original = " hello world "
{ trimmed: Str.trimLeft original, original: original }
"#
),
(
RocStr::from(" hello world "),
RocStr::from("hello world "),
),
(RocStr, RocStr)
);
}
#[test]
fn str_trim_left_small_to_small_shared() {
assert_evals_to!(
indoc!(
r#"
original : Str
original = " hello world "
{ trimmed: Str.trimLeft original, original: original }
"#
),
(RocStr::from(" hello world "), RocStr::from("hello world "),),
(RocStr, RocStr)
);
}