Skip to content

[Repo Assist] test: add 67 tests for TaskSeq.lengthOrMax (previously untested)#337

Draft
github-actions[bot] wants to merge 2 commits intomainfrom
repo-assist/test-length-or-max-20260314-04e38a11ad4bb183
Draft

[Repo Assist] test: add 67 tests for TaskSeq.lengthOrMax (previously untested)#337
github-actions[bot] wants to merge 2 commits intomainfrom
repo-assist/test-length-or-max-20260314-04e38a11ad4bb183

Conversation

@github-actions
Copy link
Contributor

🤖 This is an automated PR from Repo Assist.

Summary

TaskSeq.lengthOrMax had zero tests despite being a public, documented API. This PR adds 67 tests covering all the standard patterns: null validation, empty sequences, immutable sequences, and side-effect sequences.

What is lengthOrMax?

TaskSeq.lengthOrMax max source returns the actual length of the sequence, or max if the sequence has max or more elements — whichever comes first. It is the safe alternative to TaskSeq.length for potentially-long or infinite sequences.

New tests added (to TaskSeq.Length.Tests.fs)

Module Tests
EmptySeq Null raises; empty returns 0 with any max; empty with max=0 returns 0
Immutable Shorter than max returns actual length; longer than max returns max; exactly max returns max; max=1; max=0 returns 0
SideEffects Returns correct length below max; returns max and stops early; stops evaluating at max (read-ahead behaviour documented)

Read-ahead behaviour

The tests document an important implementation characteristic: lengthOrMax calls MoveNextAsync once before the while loop, so for a source longer than max, exactly max + 1 elements are evaluated. The tests explicitly assert this and include explanatory comments.

Test Status

✅ Build succeeded (dotnet build src/FSharp.Control.TaskSeq.sln -c Release)
✅ All tests passed: 4701 passed, 2 skipped, 0 failed (dotnet test -c Release)
✅ Formatting verified with dotnet fantomas . --check

Generated by Repo Assist ·

To install this agentic workflow, run

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

- covers null validation, empty sequences, immutable sequences, and side effects
- documents the read-ahead characteristic: for max=N with a longer source,
  N+1 elements are evaluated (implementation calls MoveNextAsync once before
  the while loop, then once per iteration)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

0 participants