[Repo Assist] test: add SideEffects module to TaskSeq.OfXXX.Tests.fs#407
Draft
github-actions[bot] wants to merge 2 commits intomainfrom
Draft
[Repo Assist] test: add SideEffects module to TaskSeq.OfXXX.Tests.fs#407github-actions[bot] wants to merge 2 commits intomainfrom
github-actions[bot] wants to merge 2 commits intomainfrom
Conversation
Documents re-iteration semantics for the ofXxx conversion functions: - ofSeq: re-evaluates the underlying IEnumerable on each re-enumeration - ofTaskSeq with lazy seq: creates fresh Task objects on each re-enumeration - ofTaskArray: tasks run once upfront; re-enumeration awaits cached results Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
14 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.OfXXX.Tests.fshadEmptySeqandImmutablemodules but noSideEffectsmodule, unlike most other test files in the suite.This PR adds a
SideEffectsmodule with 3 new tests that document an important and subtle aspect of theofXxxconversion functions: re-iteration semantics.New tests
ofSeq re-evaluates the underlying source seq on each re-enumeration: Verifies thatTaskSeq.ofSeqis lazy — each call toGetAsyncEnumeratorcreates a freshIEnumeratorfrom the underlyingseq, so side effects in the seq body are re-triggered on every enumeration. After two enumerations of a 3-element side-effecting seq, the counter reaches 6.ofTaskSeq with lazy seq of tasks re-creates tasks on each re-enumeration: Verifies the same lazy re-evaluation applies toTaskSeq.ofTaskSeqwhen the input is a lazyseq. On each enumeration, theseqis re-iterated and freshTaskobjects are created and run — count goes from 3 to 6 across two enumerations.ofTaskArray does not re-run tasks on re-enumeration; task results are cached: Provides the complementary case. WhenTaskSeq.ofTaskArraywraps a fixed array, theTask<'T>objects are created upfront (and run synchronously to completion at array-construction time). Re-enumerating theTaskSeqmerely re-awaits the already-completed tasks — their results are cached in theTaskobject and no computation is re-run (count stays at 3 after both enumerations).These three tests together serve as executable documentation for the distinction between lazy-seq and fixed-collection variants of the conversion functions.
Test growth
Test Status
dotnet build src/FSharp.Control.TaskSeq.Test -c Release— succeeded (0 warnings, 0 errors)dotnet test --filter "FullyQualifiedName~TaskSeq.Tests.Conversion-From" -c Release— 24 passed, 0 faileddotnet fantomas src/.../TaskSeq.OfXXX.Tests.fs --check— clean