add List.splitOn

This commit is contained in:
Isaac Van Doren 2024-11-10 18:20:31 -06:00
parent 45b50bd131
commit 0a7e98ab65
No known key found for this signature in database
GPG key ID: CFA524CD470E5B94
3 changed files with 75 additions and 0 deletions

View file

@ -421,6 +421,68 @@ fn list_split_at() {
);
}
#[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_first() {