Skip to content

[Repo Assist] test: add comprehensive coverage for RandomAccessList and LazyList functions; fix zip empty-list bug#251

Merged
gdziadkiewicz merged 4 commits intomasterfrom
repo-assist/test-ral-lazylist-untested-functions-f66ace626adeb78b
Mar 28, 2026
Merged

[Repo Assist] test: add comprehensive coverage for RandomAccessList and LazyList functions; fix zip empty-list bug#251
gdziadkiewicz merged 4 commits intomasterfrom
repo-assist/test-ral-lazylist-untested-functions-f66ace626adeb78b

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Mar 14, 2026

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

Bug fix — RandomAccessList.zip throws on empty inputs

zip had an incorrect guard condition:

// Before
if randomAccessList1.Length = randomAccessList2.Length || randomAccessList1.IsEmpty then
    let arr = Array.create randomAccessList1.Length (randomAccessList1.[0], randomAccessList2.[0])

When both lists are empty, randomAccessList1.Length = 0 satisfies the first clause, but Array.create 0 (randomAccessList1.[0], ...) still eagerly evaluates randomAccessList1.[0], which throws. The fix handles the both-empty case explicitly before attempting array access:

// After
if randomAccessList1.IsEmpty && randomAccessList2.IsEmpty then empty
elif randomAccessList1.Length = randomAccessList2.Length then
    let arr = Array.create randomAccessList1.Length (randomAccessList1.[0], randomAccessList2.[0])

The old || randomAccessList1.IsEmpty clause is also removed: if only one list is empty, the lengths differ and the invalidArg path is correct.

New tests — RandomAccessList

Functions with no existing tests: singleton, zip, reduce, map2.

  • singleton — basic length/head check, not-empty assertion, tail-is-empty invariant
  • zip — equal-length lists, both-empty (was the bug), different lengths (expect ArgumentException), output length matches input length
  • reduce — sum of elements, single element, empty list (expect ArgumentException), left-fold semantics verified with non-commutative operator
  • map2 — element-wise combination, output length, different lengths (expect ArgumentException)

New tests — LazyList

Functions 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 empties
  • split — documents the intended contract: split ll i returns the first i elements reversed plus the elements after index i, making it a deletion helper used in RealTimeDeque and BankersDeque (append (List.rev left) right removes element i)
  • drop — zero drop returns same list, drop n returns tail elements, drop past end returns empty (unlike skip, does not throw), drop from empty returns empty, negative n throws
  • unfold — generates finite sequence, returns empty when initial state immediately rejected

Test Status

Passed!  - Failed: 0, Passed: 822, Skipped: 5, Total: 827

Previously 711 tests on master. 111 new tests added across this branch, all passing. Build has 0 errors.

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@346204513ecfa08b81566450d7d599556807389f

💬 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.

… 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>
@dsyme dsyme marked this pull request as ready for review March 16, 2026 13:44
@dsyme
Copy link
Copy Markdown
Contributor

dsyme commented Mar 17, 2026

/repo-assist add comprehensive testing for this, and if you spot any missing unit tests for other things add those too

@gdziadkiewicz
Copy link
Copy Markdown
Collaborator

@copilot Resolve the merge conflicts

Copilot AI and others added 2 commits March 28, 2026 15:18
…st formatting

Co-authored-by: gdziadkiewicz <8547855+gdziadkiewicz@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 28, 2026

@copilot Resolve the merge conflicts

Merge conflicts resolved in commit a5d3f73. The conflict in LazyListTests.fs was resolved by taking master's improved test formatting (multi-line style, <| operator) for the rev/concat/split tests.

/repo-assist add comprehensive testing for this, and if you spot any missing unit tests for other things add those too

Added more comprehensive tests in commit 9d3229b:

RandomAccessList (new tests):

  • map2 on different lengths throws — verifies map2 propagates zip's length guard
  • singleton tail is empty — verifies singleton structural invariant
  • zip result length matches input length — verifies output cardinality
  • reduce with non-commutative op folds left — verifies left-fold semantics: ((1−2)−3)−4 = −8

LazyList (new tests for drop, which had no coverage at all):

  • drop 0 returns same list
  • drop n returns tail elements
  • drop more than length returns empty (unlike skip, drop doesn't throw when n > length)
  • drop from empty list returns empty
  • drop negative throws

LazyList.unfold (explicit test cases beyond the nats fixture):

  • unfold generates sequence
  • unfold empty when initial state rejected

Total: 822 tests passing (up from 711 on master).

Copilot AI changed the title [Repo Assist] test: add coverage for untested RandomAccessList and LazyList functions; fix zip empty-list bug [Repo Assist] test: add comprehensive coverage for RandomAccessList and LazyList functions; fix zip empty-list bug Mar 28, 2026
Copilot AI requested a review from gdziadkiewicz March 28, 2026 15:30
@gdziadkiewicz gdziadkiewicz merged commit 3a8f9b8 into master Mar 28, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants