From 8747c922cd3b690de6c20c5bfd8132de11089fc7 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Wed, 2 Feb 2022 22:44:22 +0100 Subject: [PATCH] conformance: types can't imply finiteness 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. --- test/conformance_test.jl | 44 ++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/test/conformance_test.jl b/test/conformance_test.jl index 071e613..d49ea5d 100644 --- a/test/conformance_test.jl +++ b/test/conformance_test.jl @@ -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