-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathmacros.jl
61 lines (49 loc) · 2.06 KB
/
macros.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
@gapattribute dersub(G::GapObj) = GAP.Globals.DerivedSubgroup(G)
@testset "@gapattribute" begin
"""
isevenint_GAP(x)
Return `true` if the input integer is even.
"""
@gapattribute isevenint_GAP(x::Int) = GAP.Globals.IsEvenInt(x)::Bool
doc = string(@doc isevenint_GAP)
@test !occursin("No documentation found", string(doc))
@test occursin("if the input integer is even", string(doc))
doc = string(@doc has_isevenint_GAP)
@test !occursin("No documentation found", string(doc))
@test occursin("has already been computed", string(doc))
doc = string(@doc set_isevenint_GAP)
@test !occursin("No documentation found", string(doc))
@test occursin("Set the value", string(doc))
# Do tester and setter refer to the right objects?
# (Choose a group `G` whose center is different from the center
# of its derived subgroup.)
@gapattribute cendersub(G::GapObj) = GAP.Globals.Centre(dersub(G))
G = GAP.Globals.SymmetricGroup(3)
@test GAP.Globals.Size(GAP.Globals.Centre(G)) == 1
G = GAP.Globals.SymmetricGroup(3) # create the group anew
@test ! GAP.Globals.HasCentre(G)
@test ! has_dersub(G)
@test ! has_cendersub(G)
@test has_dersub(G) # the previous call has set the value
ggens = GAP.Globals.GeneratorsOfGroup(G)
set_cendersub(G, GAP.Globals.Subgroup(G, GAP.GapObj([ggens[1]])))
@test has_cendersub(G)
@test GAP.Globals.HasCentre(GAP.Globals.DerivedSubgroup(G))
@test GAP.Globals.Size(GAP.Globals.Centre(G)) == 1
end
@testset "compat" begin
x = @gap (1, 2, 3)
@test x == GAP.evalstr("(1,2,3)")
x = @gap((1, 2, 3))
@test x == GAP.evalstr("(1,2,3)")
x = @gap [1, 2, 3]
@test x == GAP.evalstr("[1,2,3]")
x = @gap(SymmetricGroup)(3)
@test GAP.Globals.Size(x) == 6
@test_throws ErrorException @gap (1,2)(3,4)
x = GAP.g"foo"
@test x == GAP.julia_to_gap("foo")
x = GAP.g"1:\n, 2:\", 3:\\, 4:\b, 5:\r, 6:\c, 7:\001"
@test x == GAP.julia_to_gap("1:\n, 2:\", 3:\\, 4:\b, 5:\r, 6:\003, 7:\001")
@test_throws ErrorException g"\\"
end