Skip to content

Commit 3bbf37d

Browse files
committed
Backport "Fix test for exponentially growing promote_type (JuliaMath#280)"
1 parent 7310e7b commit 3bbf37d

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

test/fixed.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,14 @@ end
459459
@test promote_type(Int,Float32,Q0f7) == Float32
460460
@test promote_type(Float32,Int,Q0f7) == Float32
461461
@test promote_type(Float32,Q0f7,Int) == Float32
462-
@test promote_type(Q0f7,Q1f6,Q2f5,Q3f4,Q4f3,Q5f2) == Fixed{Int128,7}
462+
463+
if promote_type(Int, Float32, Complex{Int}, typeof(pi)) === ComplexF64
464+
# right-to-left
465+
@test @inferred(promote_type(Q0f7, Q1f6, Q2f5, Q3f4, Q4f3, Q5f2)) == Fixed{Int128,7}
466+
else
467+
# left-to-right
468+
@test @inferred(promote_type(Q5f2, Q4f3, Q3f4, Q2f5, Q1f6, Q0f7)) == Fixed{Int128,7}
469+
end
463470
end
464471

465472
@testset "show" begin

test/normed.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,14 @@ end
446446
@test promote_type(Int,Float32,N0f8) == Float32
447447
@test promote_type(Float32,Int,N0f8) == Float32
448448
@test promote_type(Float32,N0f8,Int) == Float32
449-
@test promote_type(N0f8,N1f7,N2f6,N3f5,N4f4,N5f3) == Normed{UInt128,8}
449+
450+
if promote_type(Int, Float32, Complex{Int}, typeof(pi)) === ComplexF64
451+
# right-to-left
452+
@test @inferred(promote_type(N0f8, N1f7, N2f6, N3f5, N4f4, N5f3)) === Normed{UInt128,8}
453+
else
454+
# left-to-right
455+
@test @inferred(promote_type(N5f3, N4f4, N3f5, N2f6, N1f7, N0f8)) === Normed{UInt128,8}
456+
end
450457
end
451458

452459
@testset "show" begin

0 commit comments

Comments
 (0)