[Repo Assist] test: add comprehensive coverage for RandomAccessList and LazyList functions; fix zip empty-list bug#251
Conversation
… LazyList.rev/concat/split; fix zip empty-list bug - RandomAccessList.zip threw when both arguments were empty due to eager evaluation of Array.create default value on index 0 of an empty list. Fix: handle the both-empty case first. - Add tests for singleton, zip (including empty), reduce, map2. - Add tests for LazyList.rev, concat, and split (documenting its intended contract as a deletion helper). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/repo-assist add comprehensive testing for this, and if you spot any missing unit tests for other things add those too |
|
@copilot Resolve the merge conflicts |
…st formatting Co-authored-by: gdziadkiewicz <8547855+gdziadkiewicz@users.noreply.github.com>
…ts conflict Agent-Logs-Url: https://github.com/fsprojects/FSharpx.Collections/sessions/b902d80b-1385-4a31-80f7-006c5bef703d Co-authored-by: gdziadkiewicz <8547855+gdziadkiewicz@users.noreply.github.com>
Merge conflicts resolved in commit a5d3f73. The conflict in
Added more comprehensive tests in commit 9d3229b: RandomAccessList (new tests):
LazyList (new tests for
LazyList.unfold (explicit test cases beyond the
Total: 822 tests passing (up from 711 on master). |
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Bug fix —
RandomAccessList.zipthrows on empty inputsziphad an incorrect guard condition:When both lists are empty,
randomAccessList1.Length = 0satisfies the first clause, butArray.create 0 (randomAccessList1.[0], ...)still eagerly evaluatesrandomAccessList1.[0], which throws. The fix handles the both-empty case explicitly before attempting array access:The old
|| randomAccessList1.IsEmptyclause is also removed: if only one list is empty, the lengths differ and theinvalidArgpath is correct.New tests —
RandomAccessListFunctions with no existing tests:
singleton,zip,reduce,map2.singleton— basic length/head check, not-empty assertion, tail-is-empty invariantzip— equal-length lists, both-empty (was the bug), different lengths (expectArgumentException), output length matches input lengthreduce— sum of elements, single element, empty list (expectArgumentException), left-fold semantics verified with non-commutative operatormap2— element-wise combination, output length, different lengths (expectArgumentException)New tests —
LazyListFunctions with no existing tests:
rev,concat,split,drop,unfold.rev— empty list, singleton, multi-element, involution (double-reverse identity)concat— empty outer list, all-empty inner lists, two lists, three lists, inner lists containing emptiessplit— documents the intended contract:split ll ireturns the firstielements reversed plus the elements after indexi, making it a deletion helper used inRealTimeDequeandBankersDeque(append (List.rev left) rightremoves elementi)drop— zero drop returns same list, drop n returns tail elements, drop past end returns empty (unlikeskip, does not throw), drop from empty returns empty, negative n throwsunfold— generates finite sequence, returns empty when initial state immediately rejectedTest Status
Previously 711 tests on master. 111 new tests added across this branch, all passing. Build has 0 errors.
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.