From 73aac31b5ef1ee1637e5e74461685b9c2a0ff97a Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 29 Aug 2025 16:23:28 +0000 Subject: [PATCH] Daily Test Coverage Improver: Add tests for AsyncSeqExtensions and Seq modules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add 6 new tests covering AsyncSeqExtensions and Seq module functions - AsyncSeqExtensions coverage: 0% → 100% - Seq module coverage: 0% → 100% - Overall test count: 128 → 134 tests - Line coverage improvement: 86.0% → 86.1% (1,045 → 1,047 lines) - Method coverage improvement: 87.7% → 88.0% (535 → 537 methods) Tests added: - async.For with AsyncSeq (basic functionality) - async.For with empty AsyncSeq (edge case) - async.For with exception in AsyncSeq (error handling) - Seq.ofAsyncSeq basic functionality - Seq.ofAsyncSeq with empty AsyncSeq - Seq.ofAsyncSeq with exception handling 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../AsyncSeqTests.fs | 63 +++++++++++++++++++ .../FSharp.Control.AsyncSeq.Tests.fsproj | 1 + 2 files changed, 64 insertions(+) diff --git a/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs b/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs index 9c209e48..26098e47 100644 --- a/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs +++ b/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs @@ -1762,6 +1762,69 @@ let ``AsyncSeq.sortByDescending should work``() = let actual = input |> AsyncSeq.sortByDescending fn Assert.AreEqual(expected, actual) +// ---------------------------------------------------------------------------- +// Tests for previously uncovered modules to improve coverage + +[] +let ``AsyncSeqExtensions - async.For with AsyncSeq`` () = + let mutable result = [] + let computation = async { + for item in asyncSeq { yield 1; yield 2; yield 3 } do + result <- item :: result + } + computation |> Async.RunSynchronously + Assert.AreEqual([3; 2; 1], result) + +[] +let ``AsyncSeqExtensions - async.For with empty AsyncSeq`` () = + let mutable result = [] + let computation = async { + for item in AsyncSeq.empty do + result <- item :: result + } + computation |> Async.RunSynchronously + Assert.AreEqual([], result) + +[] +let ``AsyncSeqExtensions - async.For with exception in AsyncSeq`` () = + let mutable exceptionCaught = false + let computation = async { + try + for item in asyncSeq { yield 1; failwith "test error"; yield 2 } do + () + with + | ex when ex.Message = "test error" -> + exceptionCaught <- true + } + computation |> Async.RunSynchronously + Assert.IsTrue(exceptionCaught) + +[] +let ``Seq.ofAsyncSeq should work`` () = + let asyncSeqData = asyncSeq { + yield 1 + yield 2 + yield 3 + } + let seqResult = Seq.ofAsyncSeq asyncSeqData |> Seq.toList + Assert.AreEqual([1; 2; 3], seqResult) + +[] +let ``Seq.ofAsyncSeq with empty AsyncSeq`` () = + let seqResult = Seq.ofAsyncSeq AsyncSeq.empty |> Seq.toList + Assert.AreEqual([], seqResult) + +[] +let ``Seq.ofAsyncSeq with exception`` () = + let asyncSeqWithError = asyncSeq { + yield 1 + failwith "test error" + yield 2 + } + Assert.Throws(fun () -> + Seq.ofAsyncSeq asyncSeqWithError |> Seq.toList |> ignore + ) |> ignore + #if (NETSTANDARD2_1 || NETCOREAPP3_0) [] let ``AsyncSeq.ofAsyncEnum should roundtrip successfully``() = diff --git a/tests/FSharp.Control.AsyncSeq.Tests/FSharp.Control.AsyncSeq.Tests.fsproj b/tests/FSharp.Control.AsyncSeq.Tests/FSharp.Control.AsyncSeq.Tests.fsproj index 26eb01b0..d3a260f0 100644 --- a/tests/FSharp.Control.AsyncSeq.Tests/FSharp.Control.AsyncSeq.Tests.fsproj +++ b/tests/FSharp.Control.AsyncSeq.Tests/FSharp.Control.AsyncSeq.Tests.fsproj @@ -9,6 +9,7 @@ +