Skip to content

Commit 528ba72

Browse files
committed
Fix promotion tests on Julia 1.3
Behavior has changed and gives more reasonable results now.
1 parent 92ba3b3 commit 528ba72

File tree

1 file changed

+34
-18
lines changed

1 file changed

+34
-18
lines changed

test/05_convert.jl

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -109,30 +109,46 @@ end
109109
end
110110

111111
@testset "promote_type" begin
112-
# Tests that return Any are due to JuliaLang/julia#29348
113-
# It is not clear what would be the most appropriate promotion type for them,
114-
# but at least they should not throw an error
115112
@test promote_type(CategoricalValue{Int}, CategoricalValue{Float64}) ===
116113
CategoricalValue{Float64}
117114
@test promote_type(CategoricalValue{Int, UInt8}, CategoricalValue{Float64, UInt32}) ===
118115
CategoricalValue{Float64, UInt32}
119116
@test promote_type(CategoricalValue{Int, UInt8}, CategoricalValue{Float64}) ===
120117
CategoricalValue{Float64}
121-
@test promote_type(CategoricalValue{Int},
122-
Union{CategoricalValue{Float64}, Missing}) ===
123-
Any
124-
@test promote_type(CategoricalValue{Int, UInt8},
125-
Union{CategoricalValue{Float64, UInt32}, Missing}) ===
126-
Union{CategoricalValue{Float64, UInt32}, Missing}
127-
@test promote_type(Union{CategoricalValue{Int}, Missing},
128-
CategoricalValue{Float64}) ===
129-
Any
130-
@test promote_type(Union{CategoricalValue{Int, UInt8}, Missing},
131-
CategoricalValue{Float64, UInt32}) ===
132-
Union{CategoricalValue{Float64, UInt32}, Missing}
133-
@test promote_type(Union{CategoricalValue{Int}, Missing},
134-
Union{CategoricalValue{Float64}, Missing}) ===
135-
Any
118+
# Tests that return Any before Julia 1.3 are due to JuliaLang/julia#29348
119+
if VERSION >= v"1.3.0-DEV"
120+
@test promote_type(CategoricalValue{Int},
121+
Union{CategoricalValue{Float64}, Missing}) ===
122+
Union{Missing, Float64}
123+
@test promote_type(CategoricalValue{Int, UInt8},
124+
Union{CategoricalValue{Float64, UInt32}, Missing}) ===
125+
Union{CategoricalValue{Float64, UInt32}, Missing}
126+
@test promote_type(Union{CategoricalValue{Int}, Missing},
127+
CategoricalValue{Float64}) ===
128+
Union{Missing, Float64}
129+
@test promote_type(Union{CategoricalValue{Int, UInt8}, Missing},
130+
CategoricalValue{Float64, UInt32}) ===
131+
Union{CategoricalValue{Float64, UInt32}, Missing}
132+
@test promote_type(Union{CategoricalValue{Int}, Missing},
133+
Union{CategoricalValue{Float64}, Missing}) ===
134+
Union{Missing, Float64}
135+
else
136+
@test promote_type(CategoricalValue{Int},
137+
Union{CategoricalValue{Float64}, Missing}) ===
138+
Any
139+
@test promote_type(CategoricalValue{Int, UInt8},
140+
Union{CategoricalValue{Float64, UInt32}, Missing}) ===
141+
Union{CategoricalValue{Float64, UInt32}, Missing}
142+
@test promote_type(Union{CategoricalValue{Int}, Missing},
143+
CategoricalValue{Float64}) ===
144+
Any
145+
@test promote_type(Union{CategoricalValue{Int, UInt8}, Missing},
146+
CategoricalValue{Float64, UInt32}) ===
147+
Union{CategoricalValue{Float64, UInt32}, Missing}
148+
@test promote_type(Union{CategoricalValue{Int}, Missing},
149+
Union{CategoricalValue{Float64}, Missing}) ===
150+
Any
151+
end
136152
@test promote_type(Union{CategoricalValue{Int, UInt8}, Missing},
137153
Union{CategoricalValue{Float64, UInt32}, Missing}) ===
138154
Union{CategoricalValue{Float64, UInt32}, Missing}

0 commit comments

Comments
 (0)