diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 65c1d5e..ebe3e3d 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -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.distinctUntilChanged` (default-equality variant), `AsyncSeq.takeWhile`, and `AsyncSeq.skipWhile` (sync-predicate variants), which previously had no direct tests. 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 diff --git a/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs b/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs index c3738f3..8b79a3b 100644 --- a/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs +++ b/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs @@ -2876,6 +2876,39 @@ let ``AsyncSeq.distinctUntilChangedWith with all same elements should return sin let result = AsyncSeq.distinctUntilChangedWith (=) source |> AsyncSeq.toListSynchronously Assert.AreEqual([1], result) +[] +let ``AsyncSeq.distinctUntilChanged collapses consecutive duplicates using default equality`` () = + let source = asyncSeq { yield 1; yield 1; yield 2; yield 2; yield 2; yield 1; yield 3 } + let result = AsyncSeq.distinctUntilChanged source |> AsyncSeq.toListSynchronously + Assert.AreEqual([1; 2; 1; 3], result) + +[] +let ``AsyncSeq.distinctUntilChanged on empty sequence returns empty`` () = + let result = AsyncSeq.distinctUntilChanged AsyncSeq.empty |> AsyncSeq.toListSynchronously + Assert.AreEqual([], result) + +[] +let ``AsyncSeq.distinctUntilChanged on all-unique sequence returns all elements`` () = + let source = asyncSeq { yield 1; yield 2; yield 3 } + let result = AsyncSeq.distinctUntilChanged source |> AsyncSeq.toListSynchronously + Assert.AreEqual([1; 2; 3], result) + +[] +let ``AsyncSeq.takeWhile takes elements while predicate holds`` () = + for ls in [ []; [1]; [1;2;3;4;5] ] do + let p i = i < 4 + let actual = ls |> AsyncSeq.ofSeq |> AsyncSeq.takeWhile p + let expected = ls |> Seq.takeWhile p |> AsyncSeq.ofSeq + Assert.True(EQ expected actual) + +[] +let ``AsyncSeq.skipWhile skips elements while predicate holds`` () = + for ls in [ []; [1]; [3]; [1;2;3;4;5] ] do + let p i = i <= 2 + let actual = ls |> AsyncSeq.ofSeq |> AsyncSeq.skipWhile p + let expected = ls |> Seq.skipWhile p |> AsyncSeq.ofSeq + Assert.True(EQ expected actual) + [] let ``AsyncSeq.append with both sequences having exceptions should propagate first`` () = async {