test + bugfix for chunkinto

This commit is contained in:
alex 2025-06-27 22:44:15 +01:00
parent 719c70a598
commit ff5b11f5ed
2 changed files with 40 additions and 19 deletions

View file

@ -1271,4 +1271,27 @@ describe('Pattern', () => {
);
});
});
describe('unjoin', () => {
it('destructures a pattern into subcycles', () => {
sameFirst(
fastcat('a', 'b', 'c', 'd').unjoin(fastcat(true, fastcat(true, true))).fmap(fast(2)).join(),
fastcat('a', 'b', 'a', 'b', 'c', 'c', 'd', 'd')
)
})
})
describe('into', () => {
it('applies a function to subcycles of a pattern', () => {
sameFirst(
fastcat('a', 'b', 'c', 'd').into(fastcat(fastcat('true', 'true'), 'true'), fast(2)),
fastcat('a', 'a', 'b', 'b', 'c', 'd', 'c', 'd')
)
})
}),
describe('chunkinto', () => {
it('chunks into subcycles', () => {
sameFirst(fastcat('a', 'b', 'c').chunkInto(3, fast(2)).fast(3),
fastcat(fastcat('a', 'a'), 'b', 'c', 'a', fastcat('b', 'b'), 'c', 'a', 'b', fastcat('c', 'c'))
)
})
})
});