Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### Unreleased

* Test coverage: Added tests for previously-untested public API functions `AsyncSeq.tryFirst`, `AsyncSeq.firstOrDefault`, `AsyncSeq.zipWithParallel`, `AsyncSeq.combineLatestWithAsync`, and `AsyncSeq.toObservable`. No functional changes.
* Test coverage: Added tests for `AsyncSeq.bufferByCount` (obsolete alias of `chunkBySize`) and `Seq.ofAsyncSeq`, which previously had no dedicated test coverage. No functional changes.
* Fixed Fable CI build: `Microsoft.Bcl.AsyncInterfaces` was pinned to a specific version (`10.0.7`) that was older than the version resolved transitively via `System.Threading.Channels`, causing a `NU1605` package downgrade error that made Fable's project cracker fail during `dotnet fable`. The reference now uses `Version="*"` (matching `System.Threading.Channels`) so both resolve consistently. (#334)

### 4.17.0
Expand Down
47 changes: 47 additions & 0 deletions tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#endif
module AsyncSeqTests

#nowarn "44" // suppress Obsolete warnings for intentional tests of obsolete API (e.g. AsyncSeq.bufferByCount)

open NUnit.Framework
open FSharp.Control
open System
Expand Down Expand Up @@ -5178,3 +5180,48 @@ let ``AsyncSeq.toObservable on empty sequence emits nothing`` () =
use _sub = (AsyncSeq.toObservable (AsyncSeq.empty<int>)).Subscribe(observer)
Assert.IsTrue(completedEvent.Wait(2000))
Assert.AreEqual([||], received.ToArray())

// ===== bufferByCount (obsolete alias for chunkBySize) =====

#if !FABLE_COMPILER
[<Test>]
let ``AsyncSeq.bufferByCount chunks elements into buffers of specified size`` () =
let result =
AsyncSeq.ofSeq [1;2;3;4;5]
|> AsyncSeq.bufferByCount 2
|> AsyncSeq.toListSynchronously
Assert.AreEqual([ [|1;2|]; [|3;4|]; [|5|] ], result)

[<Test>]
let ``AsyncSeq.bufferByCount on empty sequence returns empty`` () =
let result =
AsyncSeq.empty<int>
|> AsyncSeq.bufferByCount 3
|> AsyncSeq.toListSynchronously
Assert.AreEqual([], result)

[<Test>]
let ``AsyncSeq.bufferByCount matches chunkBySize behavior`` () =
let xs = AsyncSeq.ofSeq [1..7]
let viaBufferByCount = xs |> AsyncSeq.bufferByCount 3 |> AsyncSeq.toListSynchronously
let viaChunkBySize = xs |> AsyncSeq.chunkBySize 3 |> AsyncSeq.toListSynchronously
Assert.AreEqual(viaChunkBySize, viaBufferByCount)
#pragma warning restore 0044

// ===== Seq.ofAsyncSeq =====

[<Test>]
let ``Seq.ofAsyncSeq converts async sequence to blocking sequence`` () =
let result = AsyncSeq.ofSeq [1;2;3;4] |> Seq.ofAsyncSeq |> Seq.toList
Assert.AreEqual([1;2;3;4], result)

[<Test>]
let ``Seq.ofAsyncSeq on empty async sequence returns empty seq`` () =
let result = AsyncSeq.empty<int> |> Seq.ofAsyncSeq |> Seq.toList
Assert.AreEqual([], result)

[<Test>]
let ``Seq.ofAsyncSeq consumes elements lazily`` () =
let result = AsyncSeq.ofSeq [1;2;3] |> Seq.ofAsyncSeq |> Seq.take 2 |> Seq.toList
Assert.AreEqual([1;2], result)
#endif