Skip to content

Commit

Permalink
Test for identical type promotion
Browse files Browse the repository at this point in the history
  • Loading branch information
jishnub committed Dec 8, 2024
1 parent 52e5024 commit 30d1239
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8390,10 +8390,18 @@ f_invalidate_me() = 2
@test_throws ErrorException invoke(f_invoke_me, f_invoke_me_ci)
@test_throws ErrorException f_call_me()

@testset "error with conflicting promote_rules" begin
@testset "promote_rule and promote_result overloads" begin
struct PromoteA end
struct PromoteB end
Base.promote_rule(::Type{PromoteA}, ::Type{PromoteB}) = PromoteA
Base.promote_rule(::Type{PromoteB}, ::Type{PromoteA}) = PromoteB
@test_throws ArgumentError promote_type(PromoteA, PromoteB)

@testset "error with conflicting promote_rules" begin
Base.promote_rule(::Type{PromoteA}, ::Type{PromoteB}) = PromoteA
Base.promote_rule(::Type{PromoteB}, ::Type{PromoteA}) = PromoteB
@test_throws ArgumentError promote_type(PromoteA, PromoteB)
end

@testset "promote_rule overload for identical types" begin
Base.promote_rule(::Type{PromoteA}, ::Type{PromoteA}) = PromoteB
@test promote_type(PromoteA, PromoteA) == PromoteB
end
end

0 comments on commit 30d1239

Please sign in to comment.