Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 26 additions & 18 deletions ext/TestExt/Rings-conformance-tests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# very generic testing: just define ConformanceTests.generate_element(R) to produce elements of R,
# then invoke one of these functions, as appropriate:
# - test_NCRing_interface(R)
# - test_NCRing_interface_recursive(R)
# - test_Ring_interface(R)
# - test_Ring_interface_recursive(R)
# - test_Field_interface(R)
Expand Down Expand Up @@ -768,7 +769,7 @@ function test_MatSpace_interface(S::MatSpace; reps = 10)
# TODO: ! variants (such as `swap_cols!` etc.) of all of the above
end

if nrows(S) == ncols(S)
if nrows(S) == ncols(S) && R isa Ring
@testset "Determinant" begin
@test isone(det(one(S))) # should always hold, even for 0x0
@test nrows(S) == 0 || iszero(det(zero(S)))
Expand Down Expand Up @@ -848,31 +849,29 @@ function test_MatRing_interface(S::MatRing; reps = 15)
end
end

@testset "Determinant" begin
@test isone(det(one(S))) # should always hold, even for 0x0
@test degree(S) == 0 || iszero(det(zero(S)))
if R isa Ring
@testset "Determinant" begin
@test isone(det(one(S))) # should always hold, even for 0x0
@test degree(S) == 0 || iszero(det(zero(S)))

for k in 1:reps
a = generate_element(S)::ST
b = generate_element(S)::ST
A = deepcopy(a)
B = deepcopy(b)
@test det(a*b) == det(a)*det(b)
@test a == A
@test b == B
for k in 1:reps
a = generate_element(S)::ST
b = generate_element(S)::ST
A = deepcopy(a)
B = deepcopy(b)
@test det(a*b) == det(a)*det(b)
@test a == A
@test b == B
end
end
end
end

return nothing
end

function test_Ring_interface_recursive(R::AbstractAlgebra.Ring; reps = 15)
test_Ring_interface(R; reps = reps)
Rx, _ = polynomial_ring(R, :x)
test_Poly_interface(Rx, reps = 2 + fld(reps, 2))
Rxy, _ = polynomial_ring(R, [:x, :y])
test_MPoly_interface(Rxy, reps = 2 + fld(reps, 2))
function test_NCRing_interface_recursive(R::AbstractAlgebra.NCRing; reps = 15)
test_NCRing_interface(R; reps = reps)
for d in 0:3
S = matrix_ring(R, d)
test_MatRing_interface(S, reps = 2 + fld(reps, 8))
Expand All @@ -883,6 +882,15 @@ function test_Ring_interface_recursive(R::AbstractAlgebra.Ring; reps = 15)
end
end

function test_Ring_interface_recursive(R::AbstractAlgebra.Ring; reps = 15)
test_Ring_interface(R; reps = reps)
test_NCRing_interface_recursive(R; reps = reps)
Rx, _ = polynomial_ring(R, :x)
test_Poly_interface(Rx, reps = 2 + fld(reps, 2))
Rxy, _ = polynomial_ring(R, [:x, :y])
test_MPoly_interface(Rxy, reps = 2 + fld(reps, 2))
end

function test_Field_interface_recursive(R::AbstractAlgebra.Field; reps = 15)
test_Ring_interface_recursive(R, reps = reps)
test_Field_interface(R, reps = reps)
Expand Down
1 change: 1 addition & 0 deletions ext/TestExt/TestExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import .ConformanceTests: test_Poly_interface
import .ConformanceTests: test_MPoly_interface
import .ConformanceTests: test_MatSpace_interface
import .ConformanceTests: test_MatRing_interface
import .ConformanceTests: test_NCRing_interface_recursive
import .ConformanceTests: test_Ring_interface_recursive
import .ConformanceTests: test_Field_interface_recursive

Expand Down
1 change: 1 addition & 0 deletions src/ConformanceTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function test_Poly_interface end
function test_MPoly_interface end
function test_MatSpace_interface end
function test_MatRing_interface end
function test_NCRing_interface_recursive end
function test_Ring_interface_recursive end
function test_Field_interface_recursive end

Expand Down
4 changes: 2 additions & 2 deletions test/generic/FreeAssociativeAlgebra-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,10 @@ end

@testset "Generic.FreeAssociativeAlgebra.NCRing_interface" begin
S, = free_associative_algebra(ZZ, 3)
ConformanceTests.test_NCRing_interface(S)
ConformanceTests.test_NCRing_interface_recursive(S)

R, = QQ[:x, :y]
S, = free_associative_algebra(R, :z => 1:3)
ConformanceTests.test_NCRing_interface(S)
ConformanceTests.test_NCRing_interface_recursive(S)
end

Loading