@@ -1941,3 +1941,73 @@ let ``AsyncSeq.toAsyncEnum can be cancelled``() : unit =
19411941 |> Async.RunSynchronously
19421942
19431943#endif
1944+
1945+ // Additional coverage improvement tests - parameter validation and edge cases
1946+ [<Test>]
1947+ let ``AsyncSeq.bufferByCount with zero size should throw ArgumentException`` () =
1948+ let s = asyncSeq { yield 1 ; yield 2 ; yield 3 }
1949+ Assert.Throws< System.ArgumentException>( fun () ->
1950+ s |> AsyncSeq.bufferByCount 0 |> AsyncSeq.toListSynchronously |> ignore
1951+ ) |> ignore
1952+
1953+ [<Test>]
1954+ let ``AsyncSeq.bufferByCount with negative size should throw ArgumentException`` () =
1955+ let s = asyncSeq { yield 1 ; yield 2 ; yield 3 }
1956+ Assert.Throws< System.ArgumentException>( fun () ->
1957+ s |> AsyncSeq.bufferByCount - 1 |> AsyncSeq.toListSynchronously |> ignore
1958+ ) |> ignore
1959+
1960+ [<Test>]
1961+ let ``AsyncSeq.replicate with negative count should throw ArgumentException`` () =
1962+ Assert.Throws< System.ArgumentException>( fun () ->
1963+ AsyncSeq.replicate - 1 42 |> AsyncSeq.toListSynchronously |> ignore
1964+ ) |> ignore
1965+
1966+ [<Test>]
1967+ let ``AsyncSeq.init with very large count should work`` () =
1968+ let result = AsyncSeq.init 3 L ( fun i -> int i * 2 ) |> AsyncSeq.toListSynchronously
1969+ Assert.AreEqual([ 0 ; 2 ; 4 ], result)
1970+
1971+ [<Test>]
1972+ let ``AsyncSeq.bufferByCountAndTime with zero count should throw ArgumentException`` () =
1973+ let s = asyncSeq { yield 1 ; yield 2 ; yield 3 }
1974+ Assert.Throws< System.ArgumentException>( fun () ->
1975+ s |> AsyncSeq.bufferByCountAndTime 0 100 |> AsyncSeq.toListSynchronously |> ignore
1976+ ) |> ignore
1977+
1978+ [<Test>]
1979+ let ``AsyncSeq.bufferByTime with negative time should throw ArgumentException`` () =
1980+ let s = asyncSeq { yield 1 ; yield 2 ; yield 3 }
1981+ Assert.Throws< System.ArgumentException>( fun () ->
1982+ s |> AsyncSeq.bufferByTime - 1 |> AsyncSeq.toListSynchronously |> ignore
1983+ ) |> ignore
1984+
1985+ [<Test>]
1986+ let ``AsyncSeq.pairwise with single element should return empty`` () =
1987+ let s = asyncSeq { yield 42 }
1988+ let s ' = s |> AsyncSeq.pairwise |> AsyncSeq.toListSynchronously
1989+ Assert.True(([] = s'))
1990+
1991+ [<Test>]
1992+ let ``AsyncSeq.pairwise with empty sequence should return empty`` () =
1993+ let s = AsyncSeq.empty< int>
1994+ let s ' = s |> AsyncSeq.pairwise |> AsyncSeq.toListSynchronously
1995+ Assert.True(([] = s'))
1996+
1997+ [<Test>]
1998+ let ``AsyncSeq.replicateInfiniteAsync with exception should propagate on enumeration`` () =
1999+ let exceptionSeq = AsyncSeq.replicateInfiniteAsync ( async { failwith " test exception" })
2000+ Assert.Throws< System.Exception>( fun () ->
2001+ exceptionSeq |> AsyncSeq.take 1 |> AsyncSeq.toListSynchronously |> ignore
2002+ ) |> ignore
2003+
2004+ [<Test>]
2005+ let ``AsyncSeq.mapAsyncParallel with exception should propagate`` () =
2006+ let s = asyncSeq { yield 1 ; yield 2 ; yield 3 }
2007+ let exceptionSeq = s |> AsyncSeq.mapAsyncParallel ( fun x -> async {
2008+ if x = 2 then return failwith " test exception"
2009+ else return x * 2
2010+ })
2011+ Assert.Throws< System.Exception>( fun () ->
2012+ exceptionSeq |> AsyncSeq.toListSynchronously |> ignore
2013+ ) |> ignore
0 commit comments