91
91
@test mapreduce (abs2, * , Float64[]) === 1.0
92
92
@test mapreduce (abs2, max, Float64[]) === 0.0
93
93
@test mapreduce (abs, max, Float64[]) === 0.0
94
+ @test mapreduce (abs2, min, Float64[]) === Inf
95
+ @test mapreduce (abs, min, Float64[]) === Inf
96
+ @test_throws ArgumentError mapreduce (abs2, & , Float64[])
97
+ @test_throws ArgumentError mapreduce (abs2, | , Float64[])
94
98
@test_throws " reducing over an empty collection is not allowed" mapreduce (abs2, & , Float64[])
95
99
@test_throws str -> ! occursin (" Closest candidates are" , str) mapreduce (abs2, & , Float64[])
96
100
@test_throws " reducing over an empty collection is not allowed" mapreduce (abs2, | , Float64[])
@@ -246,8 +250,8 @@ prod2(itr) = invoke(prod, Tuple{Any}, itr)
246
250
247
251
# maximum & minimum & extrema
248
252
249
- @test_throws " reducing over an empty " maximum (Int[])
250
- @test_throws " reducing over an empty " minimum (Int[])
253
+ @test maximum (Int[]) === typemin (Int )
254
+ @test minimum (Int[]) === typemax (Int )
251
255
@test_throws " reducing over an empty" extrema (Int[])
252
256
253
257
@test maximum (Int[]; init= - 1 ) == - 1
@@ -258,6 +262,21 @@ prod2(itr) = invoke(prod, Tuple{Any}, itr)
258
262
@test minimum (sin, []; init= 1 ) == 1
259
263
@test extrema (sin, []; init= (1 , - 1 )) == (1 , - 1 )
260
264
265
+ @test maximum (Float64[]) === - Inf
266
+ @test minimum (Float64[]) === + Inf
267
+
268
+ @test maximum (Float32[]) === - Inf32
269
+ @test minimum (Float32[]) === + Inf32
270
+
271
+ @test maximum (abs, Int[]) === 0
272
+ @test minimum (abs, Int[]) === typemax (Int)
273
+
274
+ @test maximum (abs, Float64[]) === 0.0
275
+ @test minimum (abs, Float64[]) === + Inf
276
+
277
+ @test maximum (abs, Float32[]) === 0.0f0
278
+ @test minimum (abs, Float32[]) === + Inf32
279
+
261
280
@test maximum (5 ) == 5
262
281
@test minimum (5 ) == 5
263
282
@test extrema (5 ) == (5 , 5 )
0 commit comments