@@ -1140,7 +1140,6 @@ end
1140
1140
end
1141
1141
1142
1142
@testset " nth" begin
1143
-
1144
1143
Z = Array {Int,0} (undef)
1145
1144
Z[] = 17
1146
1145
it_result_pairs = Dict (
@@ -1170,7 +1169,6 @@ end
1170
1169
(Iterators. cycle (((),)), 1000 ) => ()
1171
1170
)
1172
1171
1173
-
1174
1172
@testset " iter: $IT " for (IT, n) in keys (it_result_pairs)
1175
1173
@test it_result_pairs[(IT, n)] == nth (IT, n)
1176
1174
@test_throws BoundsError nth (IT, - 42 )
@@ -1206,3 +1204,18 @@ end
1206
1204
@test Base. infer_return_type ((Vector{Any},)) do xs
1207
1205
[x for x in xs if x isa Int]
1208
1206
end == Vector{Int}
1207
+
1208
+ @testset " issue #58922" begin
1209
+ # `last` short circuits correctly
1210
+ @test last (zip (1 : 10 , 2 : 11 )) == (10 , 11 ) # same length
1211
+ @test last (zip (1 : 3 , 2 : 11 )) == (3 , 4 ) # different length
1212
+
1213
+ # Finite-guarded zip iterator: one iterator bounded and the other is not
1214
+ @test last (zip (1 : 3 , Iterators. countfrom (2 ))) == (3 , 4 )
1215
+ @test last (zip (1 : 3 , Iterators. cycle ((' x' , ' y' )))) == (3 , ' x' )
1216
+ @test last (zip (1 : 3 , Iterators. repeated (' x' ))) == (3 , ' x' )
1217
+
1218
+ # TODO : test for other array types
1219
+ # @test last(zip(OffsetArray(1:10, 2), OffsetArray(1:10, 3))) == (10, 10)
1220
+ # @test last(collect(zip(OffsetArray(1:10, 2), OffsetArray(1:10, 3)))) == (10, 10)
1221
+ end
0 commit comments