Skip to content

Commit c1872ec

Browse files
committed
Add a test for cornercase of multiple MoveNext after the end
1 parent d582041 commit c1872ec

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/FSharp.Control.TaskSeq.Test/TaskSeq.Singleton.Tests.fs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,19 @@ module Other =
7878
let defaultValue = enumerator.Current // should return the default value for int
7979
defaultValue |> should equal 0
8080
}
81+
82+
[<Fact>]
83+
let ``TaskSeq-singleton multiple MoveNext is fine`` () = task {
84+
let enumerator = (TaskSeq.singleton 42).GetAsyncEnumerator()
85+
let! isNext = enumerator.MoveNextAsync()
86+
isNext |> should be True
87+
let! _ = enumerator.MoveNextAsync()
88+
let! _ = enumerator.MoveNextAsync()
89+
let! _ = enumerator.MoveNextAsync()
90+
let! isNext = enumerator.MoveNextAsync()
91+
isNext |> should be False
92+
93+
// should return the default value for int after moving past the end
94+
let defaultValue = enumerator.Current
95+
defaultValue |> should equal 0
96+
}

0 commit comments

Comments
 (0)