Skip to content

Commit ba5537f

Browse files
committed
add _extrema_rf test
1 parent c930ef0 commit ba5537f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/numbers.jl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,30 @@ end
134134
@test minmax(-Inf,NaN) (min(-Inf,NaN), max(-Inf,NaN))
135135
end
136136
end
137+
@testset "Base._extrema_rf for float" begin
138+
for T in (Float16, Float32, Float64, BigFloat)
139+
ordered = T[-Inf, -5, -0.0, 0.0, 3, Inf]
140+
unorded = T[NaN, -NaN]
141+
for i1 in 1:6, i2 in 1:6, j1 in 1:6, j2 in 1:6
142+
x = ordered[i1], ordered[i2]
143+
y = ordered[j1], ordered[j2]
144+
z = ordered[min(i1,j1)], ordered[max(i2,j2)]
145+
@test Base._extrema_rf(x, y) === z
146+
end
147+
for i in 1:2, j1 in 1:6, j2 in 1:6 # unordered test (only 1 NaN)
148+
x = unorded[i] , unorded[i]
149+
y = ordered[j1], ordered[j2]
150+
@test Base._extrema_rf(x, y) === x
151+
@test Base._extrema_rf(y, x) === x
152+
end
153+
for i in 1:2, j in 1:2 # unordered test (2 NaNs)
154+
x = unorded[i], unorded[i]
155+
y = unorded[j], unorded[j]
156+
z = Base._extrema_rf(x, y)
157+
@test z === x || z === y
158+
end
159+
end
160+
end
137161
@testset "fma" begin
138162
let x = Int64(7)^7
139163
@test fma(x-1, x-2, x-3) == (x-1) * (x-2) + (x-3)

0 commit comments

Comments
 (0)