Skip to content

Commit

Permalink
conformance: types can't imply finiteness
Browse files Browse the repository at this point in the history
Finitely presented groups can be both finite and infinite, so it is not
practical to require that the type of a group must already imply whether
instances of the type are finite or infinite. Yet the conformance tests
were doing exactly that.
  • Loading branch information
fingolfin committed Feb 3, 2022
1 parent d52268f commit 8747c92
Showing 1 changed file with 29 additions and 15 deletions.
44 changes: 29 additions & 15 deletions test/conformance_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,36 @@ function test_Group_interface(G::Group)
@testset "Group interface" begin
@testset "Iteration protocol" begin
IS = Base.IteratorSize(typeof(G))
if IS isa Base.HasLength || IS isa Base.HasShape
@test isfinite(G) == true
@test length(G) isa Int
@test length(G) > 0

@test eltype(G) <: GroupElement
@test one(G) isa eltype(G)

if GroupsCore.hasgens(G)
@test first(iterate(G)) isa eltype(G)
_, s = iterate(G)
@test first(iterate(G, s)) isa eltype(G)
@test isone(first(G))
end
else
if IS isa Base.IsInfinite
@test isfinite(G) == false
else
isfiniteG = false
if IS isa Base.HasLength || IS isa Base.HasShape
@test isfinite(G) == true
isfiniteG = true
else
@test IS isa Base.SizeUnknown
try
isfiniteG = isfinite(G)
catch e
@test e isa GroupsCore.InfiniteOrder
end
end

if isfiniteG
@test length(G) isa Int
@test length(G) > 0

@test eltype(G) <: GroupElement
@test one(G) isa eltype(G)

if GroupsCore.hasgens(G)
@test first(iterate(G)) isa eltype(G)
_, s = iterate(G)
@test first(iterate(G, s)) isa eltype(G)
@test isone(first(G))
end
end
end
end

Expand Down

0 comments on commit 8747c92

Please sign in to comment.