Skip to content

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

Open
github-actions[bot] wants to merge 2 commits intomasterfrom
repo-assist/test-ral-lazylist-untested-functions-f66ace626adeb78b
Open

[Repo Assist] test: add coverage for untested RandomAccessList and LazyList functions; fix zip empty-list bug#251
github-actions[bot] wants to merge 2 commits intomasterfrom
repo-assist/test-ral-lazylist-untested-functions-f66ace626adeb78b

Conversation

@github-actions
Copy link
Contributor

🤖 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
- `zip` equal-length lists, both-empty (was the bug), different lengths (expect `ArgumentException`)  
- `reduce` sum of elements, single element, empty list (expect `ArgumentException`)
- `map2` element-wise combination, output length

### New tests — `LazyList`

Functions with no existing tests: `rev`, `concat`, `split`.

- `rev` empty list, singleton, multi-element
- `concat` empty outer list, non-empty inner 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`)

## Test Status

```
Passed!  - Failed: 0, Passed: 724, Skipped: 6, Total: 730

Previously 710 tests. 14 new tests added, 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

… 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
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

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.

1 participant