builtin(list): add List.chunksOf

This commit is contained in:
Elias Mulhall 2023-10-07 11:54:34 -04:00
parent f966afc23e
commit b7923ac542
3 changed files with 54 additions and 0 deletions

View file

@ -487,6 +487,38 @@ fn list_split_last() {
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn list_chunks_of() {
assert_evals_to!(
"List.chunksOf [1, 2, 3, 4, 5, 6, 7, 8] 3",
RocList::from_slice(&[
RocList::from_slice(&[1, 2, 3]),
RocList::from_slice(&[4, 5, 6]),
RocList::from_slice(&[7, 8]),
]),
RocList<RocList<i64>>
);
assert_evals_to!(
"List.chunksOf [1, 2, 3, 4] 5",
RocList::from_slice(&[RocList::from_slice(&[1, 2, 3, 4]),]),
RocList<RocList<i64>>
);
assert_evals_to!(
"List.chunksOf [1, 2, 3] 0",
RocList::from_slice(&[]),
RocList<RocList<i64>>
);
assert_evals_to!(
"List.chunksOf [] 5",
RocList::from_slice(&[]),
RocList<RocList<i64>>
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn list_drop() {