Merge remote-tracking branch 'remote/main' into upgrade-llvm-zig

This commit is contained in:
Luke Boswell 2024-11-29 08:58:47 +11:00
commit 2feb5d3c2e
No known key found for this signature in database
GPG key ID: F6DB3C9DB47377B0
426 changed files with 8889 additions and 4190 deletions

View file

@ -371,10 +371,10 @@ fn list_map_try_err() {
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn list_split() {
fn list_split_at() {
assert_evals_to!(
r"
list = List.split [1, 2, 3] 0
list = List.splitAt [1, 2, 3] 0
list.before
",
RocList::<i64>::from_slice(&[]),
@ -382,7 +382,7 @@ fn list_split() {
);
assert_evals_to!(
r"
list = List.split [1, 2, 3] 0
list = List.splitAt [1, 2, 3] 0
list.others
",
RocList::from_slice(&[1, 2, 3]),
@ -390,13 +390,13 @@ fn list_split() {
);
assert_evals_to!(
r"
List.split [1, 2, 3] 1
List.splitAt [1, 2, 3] 1
",
(RocList::from_slice(&[1]), RocList::from_slice(&[2, 3])),
(RocList<i64>, RocList<i64>,)
);
assert_evals_to!(
"List.split [1, 2, 3] 3",
"List.splitAt [1, 2, 3] 3",
(
RocList::from_slice(&[1, 2, 3]),
RocList::<i64>::from_slice(&[]),
@ -404,7 +404,7 @@ fn list_split() {
(RocList<i64>, RocList<i64>,)
);
assert_evals_to!(
"List.split [1, 2, 3] 4",
"List.splitAt [1, 2, 3] 4",
(
RocList::from_slice(&[1, 2, 3]),
RocList::<i64>::from_slice(&[]),
@ -412,7 +412,7 @@ fn list_split() {
(RocList<i64>, RocList<i64>,)
);
assert_evals_to!(
"List.split [] 1",
"List.splitAt [] 1",
(
RocList::<i64>::from_slice(&[]),
RocList::<i64>::from_slice(&[]),
@ -421,6 +421,133 @@ fn list_split() {
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn list_split_on() {
assert_evals_to!(
r"
List.splitOn [] 1
",
RocList::<RocList<i64>>::from_slice(&[RocList::<i64>::from_slice(&[])]),
RocList<RocList<i64>>
);
assert_evals_to!(
r"
List.splitOn [1] 1
",
RocList::<RocList<i64>>::from_slice(&[
RocList::<i64>::from_slice(&[]),
RocList::<i64>::from_slice(&[]),
]),
RocList<RocList<i64>>
);
assert_evals_to!(
r"
List.splitOn [1, 2, 3] 47
",
RocList::<RocList<i64>>::from_slice(&[RocList::<i64>::from_slice(&[1, 2, 3])]),
RocList<RocList<i64>>
);
assert_evals_to!(
r"
List.splitOn [1, 2, 3, 4, 5] 3
",
RocList::<RocList<i64>>::from_slice(&[
RocList::<i64>::from_slice(&[1, 2]),
RocList::<i64>::from_slice(&[4, 5]),
]),
RocList<RocList<i64>>
);
assert_evals_to!(
r"
List.splitOn [1, 0, 1, 0, 1] 1
",
RocList::<RocList<i64>>::from_slice(&[
RocList::<i64>::from_slice(&[]),
RocList::<i64>::from_slice(&[0]),
RocList::<i64>::from_slice(&[0]),
RocList::<i64>::from_slice(&[]),
]),
RocList<RocList<i64>>
);
assert_evals_to!(
r"
List.splitOn [1, 0, 1, 0, 1] 0
",
RocList::<RocList<i64>>::from_slice(&[
RocList::<i64>::from_slice(&[1]),
RocList::<i64>::from_slice(&[1]),
RocList::<i64>::from_slice(&[1]),
]),
RocList<RocList<i64>>
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn list_split_on_list() {
assert_evals_to!(
r"
List.splitOnList [] []
",
RocList::<RocList<i64>>::from_slice(&[RocList::<i64>::from_slice(&[])]),
RocList<RocList<i64>>
);
assert_evals_to!(
r"
List.splitOnList [] [1, 2, 3]
",
RocList::<RocList<i64>>::from_slice(&[RocList::<i64>::from_slice(&[]),]),
RocList<RocList<i64>>
);
assert_evals_to!(
r"
List.splitOnList [1, 2, 3] []
",
RocList::<RocList<i64>>::from_slice(&[RocList::<i64>::from_slice(&[1, 2, 3]),]),
RocList<RocList<i64>>
);
assert_evals_to!(
r"
List.splitOnList [1] [1]
",
RocList::<RocList<i64>>::from_slice(&[
RocList::<i64>::from_slice(&[]),
RocList::<i64>::from_slice(&[]),
]),
RocList<RocList<i64>>
);
assert_evals_to!(
r"
List.splitOnList [1, 2, 3] [47]
",
RocList::<RocList<i64>>::from_slice(&[RocList::<i64>::from_slice(&[1, 2, 3])]),
RocList<RocList<i64>>
);
assert_evals_to!(
r"
List.splitOnList [1, 2, 3, 4, 5] [2, 3]
",
RocList::<RocList<i64>>::from_slice(&[
RocList::<i64>::from_slice(&[1]),
RocList::<i64>::from_slice(&[4, 5]),
]),
RocList<RocList<i64>>
);
assert_evals_to!(
r"
List.splitOnList [1, 0, 1, 0, 1] [1]
",
RocList::<RocList<i64>>::from_slice(&[
RocList::<i64>::from_slice(&[]),
RocList::<i64>::from_slice(&[0]),
RocList::<i64>::from_slice(&[0]),
RocList::<i64>::from_slice(&[]),
]),
RocList<RocList<i64>>
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn list_split_first() {
@ -3172,7 +3299,7 @@ fn list_join_map() {
assert_evals_to!(
indoc!(
r#"
List.joinMap ["guava,apple,pear", "bailey,cyrus"] (\s -> Str.split s ",")
List.joinMap ["guava,apple,pear", "bailey,cyrus"] (\s -> Str.splitOn s ",")
"#
),
RocList::from_slice(&[
@ -3192,7 +3319,7 @@ fn list_join_map_empty() {
assert_evals_to!(
indoc!(
r#"
List.joinMap [] (\s -> Str.split s ",")
List.joinMap [] (\s -> Str.splitOn s ",")
"#
),
RocList::from_slice(&[]),

View file

@ -790,6 +790,13 @@ fn gen_div_checked_by_zero_dec() {
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
#[should_panic(expected = r#"Roc failed with message: "Decimal division by 0!"#)]
fn gen_div_dec_zero_by_zero() {
assert_evals_to!("0dec / 0", RocDec::from_str("-1").unwrap(), RocDec);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
#[should_panic(expected = r#"Roc failed with message: "Decimal division by 0!"#)]
@ -1607,7 +1614,7 @@ fn tail_call_elimination() {
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn int_negate() {
fn num_negate() {
assert_evals_to!("Num.neg 123i8", -123, i8);
assert_evals_to!("Num.neg Num.maxI8", -i8::MAX, i8);
assert_evals_to!("Num.neg (Num.minI8 + 1)", i8::MAX, i8);
@ -1623,6 +1630,26 @@ fn int_negate() {
assert_evals_to!("Num.neg 123", -123, i64);
assert_evals_to!("Num.neg Num.maxI64", -i64::MAX, i64);
assert_evals_to!("Num.neg (Num.minI64 + 1)", i64::MAX, i64);
assert_evals_to!("Num.neg 12.3f32", -12.3, f32);
assert_evals_to!("Num.neg 0.0f32", -0.0, f32);
assert_evals_to!("Num.neg Num.maxF32", -f32::MAX, f32);
assert_evals_to!("Num.neg Num.minF32", -f32::MIN, f32);
assert_evals_to!("Num.neg Num.infinityF32", -f32::INFINITY, f32);
// can't test equality for nan
assert_evals_to!("Num.isNaN (Num.neg Num.nanF32)", true, bool);
assert_evals_to!("Num.neg 12.3f64", -12.3, f64);
assert_evals_to!("Num.neg 0.0f64", -0.0, f64);
assert_evals_to!("Num.neg Num.maxF64", -f64::MAX, f64);
assert_evals_to!("Num.neg Num.minF64", -f64::MIN, f64);
assert_evals_to!("Num.neg Num.infinityF64", -f64::INFINITY, f64);
// can't test equality for nan
assert_evals_to!("Num.isNaN (Num.neg Num.nanF64)", true, bool);
assert_evals_to!("Num.neg 123dec", RocDec::from(-123), RocDec);
// 0 is signless, unlike f32/f64
assert_evals_to!("Num.neg 0dec", RocDec::from(0), RocDec);
}
#[test]

View file

@ -220,13 +220,13 @@ fn list_str_take_first() {
#[test]
#[cfg(feature = "gen-wasm")]
fn list_str_split() {
fn list_str_split_on() {
assert_refcounts!(
indoc!(
r#"
s = Str.concat "A long enough string " "to be heap-allocated"
list = [s, s, s]
List.split list 1
List.splitAt list 1
"#
),
(RocList<RocStr>, RocList<RocStr>),
@ -239,13 +239,13 @@ fn list_str_split() {
#[test]
#[cfg(feature = "gen-wasm")]
fn list_str_split_zero() {
fn list_str_split_on_zero() {
assert_refcounts!(
indoc!(
r#"
s = Str.concat "A long enough string " "to be heap-allocated"
list = [s, s, s]
List.split list 0
List.splitAt list 0
"#
),
(RocList<RocStr>, RocList<RocStr>),

View file

@ -107,3 +107,159 @@ fn early_return_solo() {
true
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn early_return_solo_annotated() {
assert_evals_to!(
r#"
identity : Str -> Str
identity = \x ->
return x
identity "abc"
"#,
RocStr::from("abc"),
RocStr,
identity,
true
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn early_return_annotated_function() {
assert_evals_to!(
indoc!(
r#"
app "test" provides [main] to "./platform"
failIfLessThanFive : U64 -> Result {} [LessThanFive]
failIfLessThanFive = \n ->
if n < 5 then
Err LessThanFive
else
Ok {}
validateInput : Str -> Result U64 [InvalidNumStr, LessThanFive]
validateInput = \str ->
num = try Str.toU64 str
when failIfLessThanFive num is
Err err ->
return Err err
Ok {} ->
Ok num
main : List Str
main =
["abc", "3", "7"]
|> List.map validateInput
|> List.map Inspect.toStr
"#
),
RocList::from_slice(&[
RocStr::from("(Err InvalidNumStr)"),
RocStr::from("(Err LessThanFive)"),
RocStr::from("(Ok 7)")
]),
RocList<RocStr>
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn early_return_nested_annotated_function() {
assert_evals_to!(
indoc!(
r#"
app "test" provides [main] to "./platform"
validateInput : Str -> Result U64 [InvalidNumStr, LessThanFive]
validateInput = \str ->
failIfLessThanFive : U64 -> Result {} [LessThanFive]
failIfLessThanFive = \n ->
if n < 5 then
Err LessThanFive
else
Ok {}
num = try Str.toU64 str
when failIfLessThanFive num is
Err err ->
return Err err
Ok {} ->
Ok num
main : List Str
main =
["abc", "3", "7"]
|> List.map validateInput
|> List.map Inspect.toStr
"#
),
RocList::from_slice(&[
RocStr::from("(Err InvalidNumStr)"),
RocStr::from("(Err LessThanFive)"),
RocStr::from("(Ok 7)")
]),
RocList<RocStr>
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn early_return_annotated_recursive_function() {
assert_evals_to!(
indoc!(
r#"
app "test" provides [main] to "./platform"
mightCallSecond : U64 -> Result U64 _
mightCallSecond = \num ->
nextNum =
if num < 5 then
return Err LessThanFive
else
num - 1
mightCallFirst nextNum
mightCallFirst : U64 -> Result U64 _
mightCallFirst = \num ->
nextNum =
if num < 10 then
return Err LessThanTen
else
num * 2
if nextNum > 25 then
Ok nextNum
else
mightCallSecond nextNum
main : List Str
main =
[
mightCallSecond 3,
mightCallSecond 7,
mightCallSecond 20,
mightCallFirst 7,
mightCallFirst 15,
]
|> List.map Inspect.toStr
"#
),
RocList::from_slice(&[
RocStr::from("(Err LessThanFive)"),
RocStr::from("(Err LessThanTen)"),
RocStr::from("(Ok 38)"),
RocStr::from("(Err LessThanTen)"),
RocStr::from("(Ok 30)")
]),
RocList<RocStr>
);
}

View file

@ -51,11 +51,11 @@ fn string_neq() {
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
fn str_split_empty_delimiter() {
fn str_split_on_empty_delimiter() {
assert_evals_to!(
indoc!(
r#"
List.len (Str.split "hello" "")
List.len (Str.splitOn "hello" "")
"#
),
1,
@ -65,7 +65,7 @@ fn str_split_empty_delimiter() {
assert_evals_to!(
indoc!(
r#"
when List.first (Str.split "JJJ" "") is
when List.first (Str.splitOn "JJJ" "") is
Ok str ->
Str.countUtf8Bytes str
@ -81,11 +81,11 @@ fn str_split_empty_delimiter() {
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
fn str_split_bigger_delimiter_small_str() {
fn str_split_on_bigger_delimiter_small_str() {
assert_evals_to!(
indoc!(
r#"
List.len (Str.split "hello" "JJJJ there")
List.len (Str.splitOn "hello" "JJJJ there")
"#
),
1,
@ -95,7 +95,7 @@ fn str_split_bigger_delimiter_small_str() {
assert_evals_to!(
indoc!(
r#"
when List.first (Str.split "JJJ" "JJJJ there") is
when List.first (Str.splitOn "JJJ" "JJJJ there") is
Ok str ->
Str.countUtf8Bytes str
@ -111,11 +111,11 @@ fn str_split_bigger_delimiter_small_str() {
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
fn str_split_str_concat_repeated() {
fn str_split_on_str_concat_repeated() {
assert_evals_to!(
indoc!(
r#"
when List.first (Str.split "JJJJJ" "JJJJ there") is
when List.first (Str.splitOn "JJJJJ" "JJJJ there") is
Ok str ->
str
|> Str.concat str
@ -135,9 +135,9 @@ fn str_split_str_concat_repeated() {
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
fn str_split_small_str_bigger_delimiter() {
fn str_split_on_small_str_bigger_delimiter() {
assert_evals_to!(
indoc!(r#"Str.split "JJJ" "0123456789abcdefghi""#),
indoc!(r#"Str.splitOn "JJJ" "0123456789abcdefghi""#),
RocList::from_slice(&[RocStr::from("JJJ")]),
RocList<RocStr>
);
@ -145,11 +145,11 @@ fn str_split_small_str_bigger_delimiter() {
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
fn str_split_big_str_small_delimiter() {
fn str_split_on_big_str_small_delimiter() {
assert_evals_to!(
indoc!(
r#"
Str.split "01234567789abcdefghi?01234567789abcdefghi" "?"
Str.splitOn "01234567789abcdefghi?01234567789abcdefghi" "?"
"#
),
RocList::from_slice(&[
@ -162,7 +162,7 @@ fn str_split_big_str_small_delimiter() {
assert_evals_to!(
indoc!(
r#"
Str.split "01234567789abcdefghi 3ch 01234567789abcdefghi" "3ch"
Str.splitOn "01234567789abcdefghi 3ch 01234567789abcdefghi" "3ch"
"#
),
RocList::from_slice(&[
@ -175,11 +175,11 @@ fn str_split_big_str_small_delimiter() {
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
fn str_split_small_str_small_delimiter() {
fn str_split_on_small_str_small_delimiter() {
assert_evals_to!(
indoc!(
r#"
Str.split "J!J!J" "!"
Str.splitOn "J!J!J" "!"
"#
),
RocList::from_slice(&[RocStr::from("J"), RocStr::from("J"), RocStr::from("J")]),
@ -189,11 +189,11 @@ fn str_split_small_str_small_delimiter() {
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
fn str_split_bigger_delimiter_big_strs() {
fn str_split_on_bigger_delimiter_big_strs() {
assert_evals_to!(
indoc!(
r#"
Str.split
Str.splitOn
"string to split is shorter"
"than the delimiter which happens to be very very long"
"#
@ -205,11 +205,11 @@ fn str_split_bigger_delimiter_big_strs() {
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
fn str_split_empty_strs() {
fn str_split_on_empty_strs() {
assert_evals_to!(
indoc!(
r#"
Str.split "" ""
Str.splitOn "" ""
"#
),
RocList::from_slice(&[RocStr::from("")]),
@ -219,11 +219,11 @@ fn str_split_empty_strs() {
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
fn str_split_minimal_example() {
fn str_split_on_minimal_example() {
assert_evals_to!(
indoc!(
r#"
Str.split "a," ","
Str.splitOn "a," ","
"#
),
RocList::from_slice(&[RocStr::from("a"), RocStr::from("")]),
@ -233,11 +233,11 @@ fn str_split_minimal_example() {
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
fn str_split_small_str_big_delimiter() {
fn str_split_on_small_str_big_delimiter() {
assert_evals_to!(
indoc!(
r#"
Str.split
Str.splitOn
"1---- ---- ---- ---- ----2---- ---- ---- ---- ----"
"---- ---- ---- ---- ----"
|> List.len
@ -250,7 +250,7 @@ fn str_split_small_str_big_delimiter() {
assert_evals_to!(
indoc!(
r#"
Str.split
Str.splitOn
"1---- ---- ---- ---- ----2---- ---- ---- ---- ----"
"---- ---- ---- ---- ----"
"#
@ -262,11 +262,11 @@ fn str_split_small_str_big_delimiter() {
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
fn str_split_small_str_20_char_delimiter() {
fn str_split_on_small_str_20_char_delimiter() {
assert_evals_to!(
indoc!(
r#"
Str.split
Str.splitOn
"3|-- -- -- -- -- -- |4|-- -- -- -- -- -- |"
"|-- -- -- -- -- -- |"
"#
@ -1548,7 +1548,7 @@ fn issue_2811() {
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
fn str_split_first_one_char() {
fn str_split_on_first_one_char() {
assert_evals_to!(
indoc!(
r#"
@ -1564,7 +1564,7 @@ fn str_split_first_one_char() {
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
fn str_split_first_multiple_chars() {
fn str_split_on_first_multiple_chars() {
assert_evals_to!(
indoc!(
r#"
@ -1578,7 +1578,7 @@ fn str_split_first_multiple_chars() {
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
fn str_split_first_entire_input() {
fn str_split_on_first_entire_input() {
assert_evals_to!(
indoc!(
r#"
@ -1592,7 +1592,7 @@ fn str_split_first_entire_input() {
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
fn str_split_first_not_found() {
fn str_split_on_first_not_found() {
assert_evals_to!(
indoc!(
r#"
@ -1606,7 +1606,7 @@ fn str_split_first_not_found() {
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
fn str_split_last_one_char() {
fn str_split_on_last_one_char() {
assert_evals_to!(
indoc!(
r#"
@ -1620,7 +1620,7 @@ fn str_split_last_one_char() {
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
fn str_split_last_multiple_chars() {
fn str_split_on_last_multiple_chars() {
assert_evals_to!(
indoc!(
r#"
@ -1634,7 +1634,7 @@ fn str_split_last_multiple_chars() {
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
fn str_split_last_entire_input() {
fn str_split_on_last_entire_input() {
assert_evals_to!(
indoc!(
r#"
@ -1648,7 +1648,7 @@ fn str_split_last_entire_input() {
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
fn str_split_last_not_found() {
fn str_split_on_last_not_found() {
assert_evals_to!(
indoc!(
r#"
@ -1662,9 +1662,9 @@ fn str_split_last_not_found() {
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
fn str_split_overlapping_substring_1() {
fn str_split_on_overlapping_substring_1() {
assert_evals_to!(
r#"Str.split "aaa" "aa""#,
r#"Str.splitOn "aaa" "aa""#,
RocList::from_slice(&[RocStr::from(""), RocStr::from("a")]),
RocList<RocStr>
);
@ -1672,9 +1672,9 @@ fn str_split_overlapping_substring_1() {
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
fn str_split_overlapping_substring_2() {
fn str_split_on_overlapping_substring_2() {
assert_evals_to!(
r#"Str.split "aaaa" "aa""#,
r#"Str.splitOn "aaaa" "aa""#,
RocList::from_slice(&[RocStr::from(""), RocStr::from(""), RocStr::from("")]),
RocList<RocStr>
);

View file

@ -554,6 +554,7 @@ pub fn try_run_lib_function<T>(
#[allow(dead_code)]
// only used in tests
#[allow(dead_code)]
pub(crate) fn llvm_evals_to<T, U, F>(
src: &str,
expected: U,

View file

@ -15,11 +15,11 @@ use indoc::indoc;
use roc_std::{RocList, RocStr, I128, U128};
#[test]
fn str_split_empty_delimiter() {
fn str_split_on_empty_delimiter() {
assert_evals_to!(
indoc!(
r#"
List.len (Str.split "hello" "")
List.len (Str.splitOn "hello" "")
"#
),
1,
@ -28,11 +28,11 @@ fn str_split_empty_delimiter() {
}
#[test]
fn str_split_bigger_delimiter_small_str() {
fn str_split_on_bigger_delimiter_small_str() {
assert_evals_to!(
indoc!(
r#"
List.len (Str.split "hello" "JJJJ there")
List.len (Str.splitOn "hello" "JJJJ there")
"#
),
1,
@ -41,11 +41,11 @@ fn str_split_bigger_delimiter_small_str() {
}
#[test]
fn str_split_str_concat_repeated() {
fn str_split_on_str_concat_repeated() {
assert_evals_to!(
indoc!(
r#"
when List.first (Str.split "JJJJJ" "JJJJ there") is
when List.first (Str.splitOn "JJJJJ" "JJJJ there") is
Ok str ->
str
|> Str.concat str
@ -64,13 +64,13 @@ fn str_split_str_concat_repeated() {
}
#[test]
fn str_split_small_str_bigger_delimiter() {
fn str_split_on_small_str_bigger_delimiter() {
assert_evals_to!(
indoc!(
r#"
when
List.first
(Str.split "JJJ" "0123456789abcdefghi")
(Str.splitOn "JJJ" "0123456789abcdefghi")
is
Ok str -> str
_ -> ""
@ -82,11 +82,11 @@ fn str_split_small_str_bigger_delimiter() {
}
#[test]
fn str_split_big_str_small_delimiter() {
fn str_split_on_big_str_small_delimiter() {
assert_evals_to!(
indoc!(
r#"
Str.split "01234567789abcdefghi?01234567789abcdefghi" "?"
Str.splitOn "01234567789abcdefghi?01234567789abcdefghi" "?"
"#
),
RocList::from_slice(&[
@ -99,7 +99,7 @@ fn str_split_big_str_small_delimiter() {
assert_evals_to!(
indoc!(
r#"
Str.split "01234567789abcdefghi 3ch 01234567789abcdefghi" "3ch"
Str.splitOn "01234567789abcdefghi 3ch 01234567789abcdefghi" "3ch"
"#
),
RocList::from_slice(&[
@ -111,11 +111,11 @@ fn str_split_big_str_small_delimiter() {
}
#[test]
fn str_split_small_str_small_delimiter() {
fn str_split_on_small_str_small_delimiter() {
assert_evals_to!(
indoc!(
r#"
Str.split "J!J!J" "!"
Str.splitOn "J!J!J" "!"
"#
),
RocList::from_slice(&[RocStr::from("J"), RocStr::from("J"), RocStr::from("J")]),
@ -124,11 +124,11 @@ fn str_split_small_str_small_delimiter() {
}
#[test]
fn str_split_bigger_delimiter_big_strs() {
fn str_split_on_bigger_delimiter_big_strs() {
assert_evals_to!(
indoc!(
r#"
Str.split
Str.splitOn
"string to split is shorter"
"than the delimiter which happens to be very very long"
"#
@ -139,11 +139,11 @@ fn str_split_bigger_delimiter_big_strs() {
}
#[test]
fn str_split_empty_strs() {
fn str_split_on_empty_strs() {
assert_evals_to!(
indoc!(
r#"
Str.split "" ""
Str.splitOn "" ""
"#
),
RocList::from_slice(&[RocStr::from("")]),
@ -152,11 +152,11 @@ fn str_split_empty_strs() {
}
#[test]
fn str_split_minimal_example() {
fn str_split_on_minimal_example() {
assert_evals_to!(
indoc!(
r#"
Str.split "a," ","
Str.splitOn "a," ","
"#
),
RocList::from_slice(&[RocStr::from("a"), RocStr::from("")]),
@ -165,11 +165,11 @@ fn str_split_minimal_example() {
}
#[test]
fn str_split_small_str_big_delimiter() {
fn str_split_on_small_str_big_delimiter() {
assert_evals_to!(
indoc!(
r#"
Str.split
Str.splitOn
"1---- ---- ---- ---- ----2---- ---- ---- ---- ----"
"---- ---- ---- ---- ----"
|> List.len
@ -182,7 +182,7 @@ fn str_split_small_str_big_delimiter() {
assert_evals_to!(
indoc!(
r#"
Str.split
Str.splitOn
"1---- ---- ---- ---- ----2---- ---- ---- ---- ----"
"---- ---- ---- ---- ----"
"#
@ -193,11 +193,11 @@ fn str_split_small_str_big_delimiter() {
}
#[test]
fn str_split_small_str_20_char_delimiter() {
fn str_split_on_small_str_20_char_delimiter() {
assert_evals_to!(
indoc!(
r#"
Str.split
Str.splitOn
"3|-- -- -- -- -- -- |4|-- -- -- -- -- -- |"
"|-- -- -- -- -- -- |"
"#