From 9ff0d68650062305d57cad6edd4131b77d0f8e6f Mon Sep 17 00:00:00 2001 From: kalmarek Date: Fri, 7 Jun 2019 18:49:51 +0200 Subject: [PATCH] AA promote_rule is not symmetric by design --- test/AARing_interface_conformance.jl | 19 +++++++++++++++---- test/runtests.jl | 9 ++++----- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/test/AARing_interface_conformance.jl b/test/AARing_interface_conformance.jl index 3d6da2e..e6ce23b 100644 --- a/test/AARing_interface_conformance.jl +++ b/test/AARing_interface_conformance.jl @@ -3,6 +3,10 @@ using AbstractAlgebra has_base_ring(R::AbstractAlgebra.NCRing) = base_ring(R) != Union{} +function AbstractAlgebra.promote_rule(::Type{S}, ::Type{T}) where {S <: Real, T <: Real} + return Base.promote_rule(S, T) +end + function test_data_type(f,g) @testset "Data type" begin f,g = deepcopy(f), deepcopy(g) @@ -229,16 +233,23 @@ function test_promote_rules(f,g) f,g = deepcopy(f), deepcopy(g) @testset "promote_rules" begin - @test_broken AbstractAlgebra.promote_rule(typeof(f), Int16) == typeof(f) - @test_broken promote_rule(typeof(f), BigInt) == typeof(f) + function test_promotes(F::Type, I::Type) + @testset "Promote_type with $I" begin + @test AbstractAlgebra.promote_rule(F, I) isa Type + @test AbstractAlgebra.promote_rule(F, I) != Union{} + end + end + test_promotes(typeof(f), Int16) + test_promotes(typeof(f), Int) + + test_promotes(typeof(f), typeof(g)) @test AbstractAlgebra.promote_rule(typeof(f), typeof(g)) == typeof(f) - @test AbstractAlgebra.promote_rule(typeof(g), typeof(f)) == typeof(f) if has_base_ring(parent(f)) S = base_ring(parent(f)) + test_promotes(typeof(f), elem_type(S)) @test AbstractAlgebra.promote_rule(typeof(f), elem_type(S)) == typeof(f) - @test AbstractAlgebra.promote_rule(elem_type(S), typeof(f)) == typeof(f) end end end diff --git a/test/runtests.jl b/test/runtests.jl index 9588402..7caa56a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -4,13 +4,14 @@ using AbstractAlgebra using GroupRings using SparseArrays -@testset "Group Rings tests" begin +include("AARing_interface_conformance.jl") +@testset "Group Rings tests" begin include("unittests.jl") include("usetests.jl") let - include("AARing_interface_conformance.jl") + R = AbstractAlgebra.zz G = PermGroup(4) @@ -19,8 +20,6 @@ using SparseArrays X = rand(RG, 0.2, -3:3) Y = rand(RG, 0.4, -1:1) - # test_ringinterface(X, Y) - test_promote_rules(X, Y) + test_ringinterface(X, Y) end - end