From 90baecf5b8ca724d2173ffe51c66517ae05f3a84 Mon Sep 17 00:00:00 2001 From: Daily Test Coverage Improver Date: Fri, 29 Aug 2025 17:43:52 +0000 Subject: [PATCH 1/2] Add comprehensive parameter validation and edge case tests - Add 10 new tests covering parameter validation for buffer functions - Test negative and zero parameter handling with proper exception validation - Add edge case tests for pairwise operations - Test exception propagation in async parallel operations - Cover boundary conditions that were previously untested - All tests properly validate expected ArgumentException behavior --- .../AsyncSeqTests.fs | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs b/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs index 26098e47..2bb8d34a 100644 --- a/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs +++ b/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs @@ -1941,3 +1941,73 @@ let ``AsyncSeq.toAsyncEnum can be cancelled``() : unit = |> Async.RunSynchronously #endif + +// Additional coverage improvement tests - parameter validation and edge cases +[] +let ``AsyncSeq.bufferByCount with zero size should throw ArgumentException``() = + let s = asyncSeq { yield 1; yield 2; yield 3 } + Assert.Throws(fun () -> + s |> AsyncSeq.bufferByCount 0 |> AsyncSeq.toListSynchronously |> ignore + ) |> ignore + +[] +let ``AsyncSeq.bufferByCount with negative size should throw ArgumentException``() = + let s = asyncSeq { yield 1; yield 2; yield 3 } + Assert.Throws(fun () -> + s |> AsyncSeq.bufferByCount -1 |> AsyncSeq.toListSynchronously |> ignore + ) |> ignore + +[] +let ``AsyncSeq.replicate with negative count should throw ArgumentException``() = + Assert.Throws(fun () -> + AsyncSeq.replicate -1 42 |> AsyncSeq.toListSynchronously |> ignore + ) |> ignore + +[] +let ``AsyncSeq.init with very large count should work``() = + let result = AsyncSeq.init 3L (fun i -> int i * 2) |> AsyncSeq.toListSynchronously + Assert.AreEqual([0; 2; 4], result) + +[] +let ``AsyncSeq.bufferByCountAndTime with zero count should throw ArgumentException``() = + let s = asyncSeq { yield 1; yield 2; yield 3 } + Assert.Throws(fun () -> + s |> AsyncSeq.bufferByCountAndTime 0 100 |> AsyncSeq.toListSynchronously |> ignore + ) |> ignore + +[] +let ``AsyncSeq.bufferByTime with negative time should throw ArgumentException``() = + let s = asyncSeq { yield 1; yield 2; yield 3 } + Assert.Throws(fun () -> + s |> AsyncSeq.bufferByTime -1 |> AsyncSeq.toListSynchronously |> ignore + ) |> ignore + +[] +let ``AsyncSeq.pairwise with single element should return empty``() = + let s = asyncSeq { yield 42 } + let s' = s |> AsyncSeq.pairwise |> AsyncSeq.toListSynchronously + Assert.True(([] = s')) + +[] +let ``AsyncSeq.pairwise with empty sequence should return empty``() = + let s = AsyncSeq.empty + let s' = s |> AsyncSeq.pairwise |> AsyncSeq.toListSynchronously + Assert.True(([] = s')) + +[] +let ``AsyncSeq.replicateInfiniteAsync with exception should propagate on enumeration``() = + let exceptionSeq = AsyncSeq.replicateInfiniteAsync (async { failwith "test exception" }) + Assert.Throws(fun () -> + exceptionSeq |> AsyncSeq.take 1 |> AsyncSeq.toListSynchronously |> ignore + ) |> ignore + +[] +let ``AsyncSeq.mapAsyncParallel with exception should propagate``() = + let s = asyncSeq { yield 1; yield 2; yield 3 } + let exceptionSeq = s |> AsyncSeq.mapAsyncParallel (fun x -> async { + if x = 2 then return failwith "test exception" + else return x * 2 + }) + Assert.Throws(fun () -> + exceptionSeq |> AsyncSeq.toListSynchronously |> ignore + ) |> ignore From fffeff3921ab4e0869cdb6a270265f65de06d553 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Fri, 29 Aug 2025 19:02:37 +0100 Subject: [PATCH 2/2] Update AsyncSeqTests.fs --- tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs b/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs index e4c504cf..4d657903 100644 --- a/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs +++ b/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs @@ -2153,18 +2153,6 @@ let ``AsyncSeq.bufferByTime with negative time should throw ArgumentException``( s |> AsyncSeq.bufferByTime -1 |> AsyncSeq.toListSynchronously |> ignore ) |> ignore -[] -let ``AsyncSeq.pairwise with single element should return empty``() = - let s = asyncSeq { yield 42 } - let s' = s |> AsyncSeq.pairwise |> AsyncSeq.toListSynchronously - Assert.True(([] = s')) - -[] -let ``AsyncSeq.pairwise with empty sequence should return empty``() = - let s = AsyncSeq.empty - let s' = s |> AsyncSeq.pairwise |> AsyncSeq.toListSynchronously - Assert.True(([] = s')) - [] let ``AsyncSeq.replicateInfiniteAsync with exception should propagate on enumeration``() = let exceptionSeq = AsyncSeq.replicateInfiniteAsync (async { failwith "test exception" })