[Repo Assist] test: add SideEffects module to TaskSeq.FirstLastDefault.Tests.fs#403
Open
github-actions[bot] wants to merge 2 commits intomainfrom
Conversation
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>
10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This is an automated pull request from Repo Assist, an AI assistant.
Summary
TaskSeq.FirstLastDefault.Tests.fshadEmptySeqandImmutablemodules but was missing aSideEffectsmodule, unlike most other test files in the suite.This PR adds a
SideEffectsmodule with 5 new test scenarios (19 new test runs when expanded with Theory data):New tests
firstOrDefault __special-case__ prove it does not read beyond first yield: Verifies thatfirstOrDefaultstops consuming the sequence immediately after yielding the first element — code after the firstyieldis never executed (matcheshead/tryHeadsemantics, sincefirstOrDefaultdelegates totryHead).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.lastOrDefault __special-case__ prove it reads the entire sequence: Verifies thatlastOrDefaultfully drains the sequence — all side effects (including those between yields) are executed before returning the last value.firstOrDefault returns first item in a side-effect sequence(TestSideEffectTaskSeqvariants): Across all 8 side-effect sequence variants,firstOrDefaultreturns1on the first enumeration and a different value on the second (because mutable state has advanced).lastOrDefault returns last item and exhausts the sequence(TestSideEffectTaskSeqvariants): Across all 8 variants,lastOrDefaultreturns10on the first full enumeration and20on the second — confirming the sequence is fully consumed each time.Test growth
Test Status
dotnet build src/FSharp.Control.TaskSeq.Test -c Release— succeeded (0 warnings, 0 errors)dotnet test --filter FirstLastDefault -c Release— 58 passed, 0 faileddotnet fantomas src/.../TaskSeq.FirstLastDefault.Tests.fs— unchanged