mirror of
https://github.com/kalmarek/Groups.jl.git
synced 2025-01-12 22:22:32 +01:00
add tests for iteration for GWords
This commit is contained in:
parent
ea7813b5dc
commit
dfce36c099
@ -36,6 +36,8 @@ Base.@propagate_inbounds function Base.getindex(w::GWord, i::Integer)
|
|||||||
return first(syllables(w)[idx])
|
return first(syllables(w)[idx])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Base.@propagate_inbounds Base.getindex(w::GWord, itr) = [w[i] for i in itr]
|
||||||
|
|
||||||
# no setindex! for syllable based words
|
# no setindex! for syllable based words
|
||||||
|
|
||||||
Base.convert(::Type{GW}, s::GSymbol) where GW <: GWord = GW(s)
|
Base.convert(::Type{GW}, s::GSymbol) where GW <: GWord = GW(s)
|
||||||
|
@ -42,6 +42,7 @@ end
|
|||||||
@testset "FreeGroup" begin
|
@testset "FreeGroup" begin
|
||||||
@test isa(FreeGroup(["s", "t"]), AbstractAlgebra.Group)
|
@test isa(FreeGroup(["s", "t"]), AbstractAlgebra.Group)
|
||||||
G = FreeGroup(["s", "t"])
|
G = FreeGroup(["s", "t"])
|
||||||
|
s, t = gens(G)
|
||||||
|
|
||||||
@testset "elements constructors" begin
|
@testset "elements constructors" begin
|
||||||
@test isa(one(G), FreeGroupElem)
|
@test isa(one(G), FreeGroupElem)
|
||||||
@ -49,9 +50,21 @@ end
|
|||||||
@test length(G.gens) == 2
|
@test length(G.gens) == 2
|
||||||
@test eltype(gens(G)) == FreeGroupElem
|
@test eltype(gens(G)) == FreeGroupElem
|
||||||
@test length(gens(G)) == 2
|
@test length(gens(G)) == 2
|
||||||
end
|
|
||||||
|
|
||||||
s, t = gens(G)
|
@test collect(s*t) == Groups.syllables(s*t)
|
||||||
|
tt, ss = Groups.FreeSymbol(:t), Groups.FreeSymbol(:s)
|
||||||
|
@test collect(t^2) == [tt, tt]
|
||||||
|
ttinv = Groups.FreeSymbol(:t, -1)
|
||||||
|
w = t^-2*s^3*t^2
|
||||||
|
@test collect(w) == [inv(tt), inv(tt), ss, ss, ss, tt, tt]
|
||||||
|
@test w[1] == inv(tt)
|
||||||
|
@test w[2] == inv(tt)
|
||||||
|
@test w[3] == ss
|
||||||
|
@test w[3:5] == [ss, ss, ss]
|
||||||
|
@test w[end] == tt
|
||||||
|
|
||||||
|
@test collect(ttinv) == [ttinv]
|
||||||
|
end
|
||||||
|
|
||||||
@testset "internal arithmetic" begin
|
@testset "internal arithmetic" begin
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user