File tree Expand file tree Collapse file tree
src/FSharp.Control.AsyncSeq
tests/FSharp.Control.AsyncSeq.Tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -412,6 +412,7 @@ module AsyncSeq =
412412 while not fin.Value do
413413 match buf.Get() with
414414 | None ->
415+ fin := true
415416 match iteratorTask.Result with
416417 | Choice1Of2() -> ()
417418 | Choice2Of2 exn -> raise exn
Original file line number Diff line number Diff line change @@ -288,6 +288,42 @@ let ``AsyncSeq.skipUntil should skip everything with never signal``() =
288288 Assert.True( EQ AsyncSeq.empty actual)
289289
290290
291+ [<Test>]
292+ let ``AsyncSeq.toBlockingSeq should work length 1`` () =
293+ let s = asyncSeq { yield 1 } |> AsyncSeq.toBlockingSeq |> Seq.toList
294+ Assert.True(( s = [ 1 ]))
295+
296+ [<Test>]
297+ let ``AsyncSeq.toBlockingSeq should work length 0`` () =
298+ let s = asyncSeq { () } |> AsyncSeq.toBlockingSeq |> Seq.toList
299+ Assert.True(( s = []))
300+
301+ [<Test>]
302+ let ``AsyncSeq.toBlockingSeq should work length 2 with sleep`` () =
303+ let s = asyncSeq { yield 1
304+ do ! Async.Sleep 10
305+ yield 2 } |> AsyncSeq.toBlockingSeq |> Seq.toList
306+ Assert.True(( s = [ 1 ; 2 ]))
307+
308+ [<Test>]
309+ let ``AsyncSeq.toBlockingSeq should work length 1 with fail`` () =
310+ let s =
311+ asyncSeq { yield 1
312+ failwith " fail" }
313+ |> AsyncSeq.toBlockingSeq
314+ |> Seq.truncate 1
315+ |> Seq.toList
316+ Assert.True(( s = [ 1 ]))
317+
318+ [<Test>]
319+ let ``AsyncSeq.toBlockingSeq should work length 0 with fail`` () =
320+ let s =
321+ asyncSeq { failwith " fail" }
322+ |> AsyncSeq.toBlockingSeq
323+ |> Seq.truncate 0
324+ |> Seq.toList
325+ Assert.True(( s = []))
326+
291327[<Test>]
292328let ``AsyncSeq.toBlockingSeq should be cancellable`` () =
293329 let cancelCount = ref 0
You can’t perform that action at this time.
0 commit comments