@@ -1819,6 +1819,69 @@ let ``async.For with exception in AsyncSeq should propagate``() =
18191819 }
18201820 |> Async.RunSynchronously
18211821
1822+ // ----------------------------------------------------------------------------
1823+ // Tests for previously uncovered modules to improve coverage
1824+
1825+ [<Test>]
1826+ let ``AsyncSeqExtensions - async.For with AsyncSeq`` () =
1827+ let mutable result = []
1828+ let computation = async {
1829+ for item in asyncSeq { yield 1 ; yield 2 ; yield 3 } do
1830+ result <- item :: result
1831+ }
1832+ computation |> Async.RunSynchronously
1833+ Assert.AreEqual([ 3 ; 2 ; 1 ], result)
1834+
1835+ [<Test>]
1836+ let ``AsyncSeqExtensions - async.For with empty AsyncSeq`` () =
1837+ let mutable result = []
1838+ let computation = async {
1839+ for item in AsyncSeq.empty do
1840+ result <- item :: result
1841+ }
1842+ computation |> Async.RunSynchronously
1843+ Assert.AreEqual([], result)
1844+
1845+ [<Test>]
1846+ let ``AsyncSeqExtensions - async.For with exception in AsyncSeq`` () =
1847+ let mutable exceptionCaught = false
1848+ let computation = async {
1849+ try
1850+ for item in asyncSeq { yield 1 ; failwith " test error" ; yield 2 } do
1851+ ()
1852+ with
1853+ | ex when ex.Message = " test error" ->
1854+ exceptionCaught <- true
1855+ }
1856+ computation |> Async.RunSynchronously
1857+ Assert.IsTrue( exceptionCaught)
1858+
1859+ [<Test>]
1860+ let ``Seq.ofAsyncSeq should work`` () =
1861+ let asyncSeqData = asyncSeq {
1862+ yield 1
1863+ yield 2
1864+ yield 3
1865+ }
1866+ let seqResult = Seq.ofAsyncSeq asyncSeqData |> Seq.toList
1867+ Assert.AreEqual([ 1 ; 2 ; 3 ], seqResult)
1868+
1869+ [<Test>]
1870+ let ``Seq.ofAsyncSeq with empty AsyncSeq`` () =
1871+ let seqResult = Seq.ofAsyncSeq AsyncSeq.empty |> Seq.toList
1872+ Assert.AreEqual([], seqResult)
1873+
1874+ [<Test>]
1875+ let ``Seq.ofAsyncSeq with exception`` () =
1876+ let asyncSeqWithError = asyncSeq {
1877+ yield 1
1878+ failwith " test error"
1879+ yield 2
1880+ }
1881+ Assert.Throws< System.Exception>( fun () ->
1882+ Seq.ofAsyncSeq asyncSeqWithError |> Seq.toList |> ignore
1883+ ) |> ignore
1884+
18221885#if ( NETSTANDARD2_ 1 || NETCOREAPP3_ 0)
18231886[<Test>]
18241887let ``AsyncSeq.ofAsyncEnum should roundtrip successfully`` () =
0 commit comments