@@ -118,6 +118,61 @@ module Performance =
118118 combined |> Array.last |> should equal ( length, length)
119119 }
120120
121+ module UnequalLength =
122+ [<Fact>]
123+ let ``TaskSeq - zip stops at shorter first sequence`` () = task {
124+ // documented: "when one sequence is exhausted any remaining elements in the other sequence are ignored"
125+ let short = taskSeq { yield ! [ 1 .. 5 ] }
126+ let long = taskSeq { yield ! [ 1 .. 10 ] }
127+ let! combined = TaskSeq.zip short long |> TaskSeq.toArrayAsync
128+ combined |> should be ( haveLength 5 )
129+
130+ combined
131+ |> should equal ( Array.init 5 ( fun i -> i + 1 , i + 1 ))
132+ }
133+
134+ [<Fact>]
135+ let ``TaskSeq - zip stops at shorter second sequence`` () = task {
136+ // documented: "when one sequence is exhausted any remaining elements in the other sequence are ignored"
137+ let long = taskSeq { yield ! [ 1 .. 10 ] }
138+ let short = taskSeq { yield ! [ 1 .. 3 ] }
139+ let! combined = TaskSeq.zip long short |> TaskSeq.toArrayAsync
140+ combined |> should be ( haveLength 3 )
141+
142+ combined
143+ |> should equal ( Array.init 3 ( fun i -> i + 1 , i + 1 ))
144+ }
145+
146+ [<Fact>]
147+ let ``TaskSeq - zip with first sequence empty returns empty`` () =
148+ // documented: remaining elements in the longer sequence are ignored
149+ let empty = taskSeq { yield ! ([]: int list ) }
150+ let nonEmpty = taskSeq { yield ! [ 1 .. 10 ] }
151+ TaskSeq.zip empty nonEmpty |> verifyEmpty
152+
153+ [<Fact>]
154+ let ``TaskSeq - zip with second sequence empty returns empty`` () =
155+ // documented: remaining elements in the longer sequence are ignored
156+ let nonEmpty = taskSeq { yield ! [ 1 .. 10 ] }
157+ let empty = taskSeq { yield ! ([]: int list ) }
158+ TaskSeq.zip nonEmpty empty |> verifyEmpty
159+
160+ [<Fact>]
161+ let ``TaskSeq - zip with singleton first and longer second returns singleton`` () = task {
162+ let one = taskSeq { yield 42 }
163+ let many = taskSeq { yield ! [ 1 .. 10 ] }
164+ let! combined = TaskSeq.zip one many |> TaskSeq.toArrayAsync
165+ combined |> should equal [| ( 42 , 1 ) |]
166+ }
167+
168+ [<Fact>]
169+ let ``TaskSeq - zip with longer first and singleton second returns singleton`` () = task {
170+ let many = taskSeq { yield ! [ 1 .. 10 ] }
171+ let one = taskSeq { yield 99 }
172+ let! combined = TaskSeq.zip many one |> TaskSeq.toArrayAsync
173+ combined |> should equal [| ( 1 , 99 ) |]
174+ }
175+
121176module Other =
122177 [<Fact>]
123178 let ``TaskSeq - zip zips different types`` () = task {
0 commit comments