Skip to content

Commit

Permalink
some test simplifications
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed Nov 5, 2024
1 parent 7608241 commit 9ff14d0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 66 deletions.
75 changes: 12 additions & 63 deletions experimental/LieAlgebras/test/RootSystem-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
end

@testset "property tests" begin
Main.equality(a::RootSpaceElem, b::RootSpaceElem) = a == b
Main.equality(a::DualRootSpaceElem, b::DualRootSpaceElem) = a == b
Main.equality(a::WeightLatticeElem, b::WeightLatticeElem) = a == b

function root_system_property_tests(R::RootSystem, rk::Int, npositive_roots::Int)
W = weyl_group(R)

Expand Down Expand Up @@ -136,72 +140,17 @@
RootSpaceElem, DualRootSpaceElem, WeightLatticeElem
)
rk = rank(R)
for _ in 1:10
a = T(R, rand(-10:10, rk))
b = T(R, rand(-10:10, rk))
c = T(R, rand(-10:10, rk))

x1 = T(R, rand(-10:10, rk))
x2 = T(R, rand(-10:10, rk))
x3 = T(R, rand(-10:10, rk))
x1c = deepcopy(x1)
x2c = deepcopy(x2)
x3c = deepcopy(x3)

for (f, f!) in ((zero, zero!),)
x1 = f!(x1)
@test x1 == f(x1c)
x1 = deepcopy(x1c)
end

for (f, f!) in ((-, neg!),)
x1 = f!(x1, x2)
@test x1 == f(x2c)
@test x2 == x2c
x1 = deepcopy(x1c)
x2 = deepcopy(x2c)
test_mutating_op_like_zero(zero, zero!, a)

x1 = f!(x1)
@test x1 == f(x1c)
x1 = deepcopy(x1c)
end
test_mutating_op_like_neg(-, neg!, a)

for (f, f!) in ((+, add!), (-, sub!))
x1 = f!(x1, x2, x3)
@test x1 == f(x2c, x3c)
@test x2 == x2c
@test x3 == x3c
x1 = deepcopy(x1c)
x2 = deepcopy(x2c)
x3 = deepcopy(x3c)

x1 = f!(x1, x1, x2)
@test x1 == f(x1c, x2c)
@test x2 == x2c
x1 = deepcopy(x1c)
x2 = deepcopy(x2c)

x1 = f!(x1, x2, x1)
@test x1 == f(x2c, x1c)
@test x2 == x2c
x1 = deepcopy(x1c)
x2 = deepcopy(x2c)

x1 = f!(x1, x2, x2)
@test x1 == f(x2c, x2c)
@test x2 == x2c
x1 = deepcopy(x1c)
x2 = deepcopy(x2c)

x1 = f!(x1, x1, x1)
@test x1 == f(x1c, x1c)
x1 = deepcopy(x1c)

x1 = f!(x1, x2)
@test x1 == f(x1c, x2c)
@test x2 == x2c
x1 = deepcopy(x1c)
x2 = deepcopy(x2c)

x1 = f!(x1, x1)
@test x1 == f(x1c, x1c)
x1 = deepcopy(x1c)
test_mutating_op_like_add(+, add!, a, b)
test_mutating_op_like_add(-, sub!, a, b)
end
end

Expand Down
6 changes: 3 additions & 3 deletions experimental/LieAlgebras/test/WeylGroup-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,9 @@ include(
@test ngens(weyl_group(:F, 4)) == 4
@test ngens(weyl_group(:G, 2)) == 2

@test ngens(weyl_group((:A, 2), (:B, 4))) == 6
@test ngens(weyl_group((:C, 3), (:E, 7))) == 10
@test ngens(weyl_group((:F, 4), (:G, 2))) == 6
@test ngens(weyl_group((:A, 2), (:B, 4))) == 2 + 4
@test ngens(weyl_group((:C, 3), (:E, 7))) == 3 + 7
@test ngens(weyl_group((:F, 4), (:G, 2))) == 4 + 2
end

@testset "Base.:(*)(x::WeylGroupElem, y::WeylGroupElem)" begin
Expand Down
8 changes: 8 additions & 0 deletions experimental/LieAlgebras/test/setup_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ if !isdefined(Main, :GAPWrap)
import Oscar: GAPWrap
end

if !isdefined(Main, :test_mutating_op_like_zero)
include(
joinpath(
pathof(Oscar.Nemo.AbstractAlgebra), "..", "..", "test", "Rings-conformance-tests.jl"
),
)
end

if !isdefined(Main, :lie_algebra_conformance_test) || isinteractive()
function lie_algebra_conformance_test(
L::LieAlgebra{C}, parentT::DataType, elemT::DataType; num_random_tests::Int=10
Expand Down

0 comments on commit 9ff14d0

Please sign in to comment.