Skip to content

Commit

Permalink
Add some 'conformance tests' over zero rings
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Oct 10, 2024
1 parent 69ba0a5 commit c78425d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 15 deletions.
6 changes: 5 additions & 1 deletion test/Rings-conformance-tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@
#
# The "recursive" variants perform additional tests on algebraic
# structures derived from the original ring, by calling these helpers:
# - test_EuclideanRing_interface(R)
# - test_Poly_interface(R)
# - test_MatSpace_interface(R)
# - test_MatAlgebra_interface(R)
#
# The following helper needs can be invoked manually if appropriate
# (it is only automatically called by the "recursive" variants when
# testing an univariate polynomial ring over a field)
# - test_EuclideanRing_interface(R)

#
# add methods for test_elem on ring elements here
Expand Down
7 changes: 5 additions & 2 deletions test/generic/LaurentMPoly-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ end

@testset "Generic.LaurentMPoly.conformance" begin
L, (x, y) = laurent_polynomial_ring(ZZ, ["x", "y"])
test_Ring_interface(L)
test_Ring_interface_recursive(L)

L, (x, y) = laurent_polynomial_ring(residue_ring(ZZ, ZZ(6))[1], ["x", "y"])
test_Ring_interface(L)
test_Ring_interface_recursive(L)

# special case: over zero ring
L, (x, y) = laurent_polynomial_ring(residue_ring(ZZ, ZZ(1))[1], ["x", "y"])
test_Ring_interface(L) # TODO: fails because `isone(one(L)) == false`
end

@testset "Generic.LaurentMPoly.constructors" begin
Expand Down
25 changes: 14 additions & 11 deletions test/generic/LaurentPoly-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,27 @@ using AbstractAlgebra.Generic: Integers, LaurentPolyWrapRing, LaurentPolyWrap,

function test_elem(R::LaurentPolyWrapRing)
n = rand(0:10)
if n == 0
if n == 0 || characteristic(R) == 1
return zero(R)
else
m = rand(0:5)
rand(R, -m:n-m, -99:99)
end
end

@testset "Generic.LaurentPoly.conformance" begin
L, y = laurent_polynomial_ring(QQ, "y")
test_Ring_interface_recursive(L)
test_EuclideanRing_interface(L)

L, y = laurent_polynomial_ring(residue_ring(ZZ, ZZ(6))[1], "y")
test_Ring_interface_recursive(L)

# special case: over zero ring
L, y = laurent_polynomial_ring(residue_ring(ZZ, ZZ(1))[1], "y")
test_Ring_interface(L) # TODO: fails because `isone(one(L)) == false`
end

@testset "Generic.LaurentPoly" begin
@testset "constructors" begin
L0, y0 = laurent_polynomial_ring(zz, "y0")
Expand Down Expand Up @@ -491,14 +504,4 @@ end
@test sprint(show, "text/plain", -y*z + (-y*z^2)) == "-y*z^2 - y*z"
@test sprint(show, "text/plain", -y^0*z) == "-z"
end

@testset "conformance" begin
L, y = laurent_polynomial_ring(QQ, "y")
test_Ring_interface(L)
test_EuclideanRing_interface(L)
test_Ring_interface_recursive(L)

L, y = laurent_polynomial_ring(residue_ring(ZZ, ZZ(6))[1], "y")
test_Ring_interface(L)
end
end
5 changes: 4 additions & 1 deletion test/generic/Residue-test.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
@testset "EuclideanRingResidueRingElem.conformance_tests" begin
test_Ring_interface(residue_ring(ZZ, 1)[1]) # is_gen fails on polys
# special case: over zero ring
test_Ring_interface_recursive(residue_ring(ZZ, 1)[1]) # polynomial ring fail isone(one(R)) and more

#
test_Ring_interface_recursive(residue_ring(ZZ, -4)[1])

#
Expand Down

0 comments on commit c78425d

Please sign in to comment.