diff --git a/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs b/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs index f12c5279..4d657903 100644 --- a/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs +++ b/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs @@ -2113,6 +2113,64 @@ let ``Seq.ofAsyncSeq with exception should propagate``() = #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.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 + // ---------------------------------------------------------------------------- // Additional Coverage Tests targeting uncovered edge cases and branches