Skip to content

[Repo Assist] test: add SideEffects module to TaskSeq.FirstLastDefault.Tests.fs - #403

Merged
dsyme merged 2 commits into
mainfrom
repo-assist/test-firstlastdefault-sideeffects-20260422-ae6f0ce0cffc314f
May 1, 2026
Merged

[Repo Assist] test: add SideEffects module to TaskSeq.FirstLastDefault.Tests.fs#403
dsyme merged 2 commits into
mainfrom
repo-assist/test-firstlastdefault-sideeffects-20260422-ae6f0ce0cffc314f

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

🤖 This is an automated pull request from Repo Assist, an AI assistant.

Summary

TaskSeq.FirstLastDefault.Tests.fs had EmptySeq and Immutable modules but was missing a SideEffects module, unlike most other test files in the suite.

This PR adds a SideEffects module with 5 new test scenarios (19 new test runs when expanded with Theory data):

New tests

  1. firstOrDefault __special-case__ prove it does not read beyond first yield: Verifies that firstOrDefault stops consuming the sequence immediately after yielding the first element — code after the first yield is never executed (matches head/tryHead semantics, since firstOrDefault delegates to tryHead).

  2. firstOrDefault __special-case__ prove early side effect is executed: Verifies that side effects before the first yield do execute, but side effects after the first yield do not.

  3. lastOrDefault __special-case__ prove it reads the entire sequence: Verifies that lastOrDefault fully drains the sequence — all side effects (including those between yields) are executed before returning the last value.

  4. firstOrDefault returns first item in a side-effect sequence (TestSideEffectTaskSeq variants): Across all 8 side-effect sequence variants, firstOrDefault returns 1 on the first enumeration and a different value on the second (because mutable state has advanced).

  5. lastOrDefault returns last item and exhausts the sequence (TestSideEffectTaskSeq variants): Across all 8 variants, lastOrDefault returns 10 on the first full enumeration and 20 on the second — confirming the sequence is fully consumed each time.

Test growth

BeforeAfter
39 test runs58 test runs

Test Status

  • Build: ✅ dotnet build src/FSharp.Control.TaskSeq.Test -c Release — succeeded (0 warnings, 0 errors)
  • Tests: ✅ dotnet test --filter FirstLastDefault -c Release58 passed, 0 failed
  • Format: ✅ dotnet fantomas src/.../TaskSeq.FirstLastDefault.Tests.fs — unchanged

Generated by 🤖 Repo Assist, see workflow run.

Generated by 🌈 Repo Assist, see workflow run. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@96b9d4c39aa22359c0b38265927eadb31dcf4e2a

Add SideEffects tests for firstOrDefault and lastOrDefault, covering:
- firstOrDefault stops consuming after the first element (matches head behaviour)
- firstOrDefault executes side effects that occur before the first yield
- lastOrDefault fully drains the sequence (matches last/tryLast behaviour)
- TestSideEffectTaskSeq theory variants for both functions
58 tests now pass for the FirstLastDefault suite (19 new).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dsyme
dsyme marked this pull request as ready for review April 22, 2026 04:06
@github-actionsgithub-actionsBot mentioned this pull request May 1, 2026
6 tasks
@dsyme
dsyme merged commit defa712 into mainMay 1, 2026
5 checks passed
@dsyme
dsyme deleted the repo-assist/test-firstlastdefault-sideeffects-20260422-ae6f0ce0cffc314f branch May 1, 2026 16:54
Sign up for freeto 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

@dsyme