Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

admit gap_to_julia conversion to Vector{GAP.Obj} #849

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/gap_to_julia.jl
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,11 @@ function gap_to_julia(
end
if recursive && !isbitstype(typeof(current_obj))
new_array[i] = get!(recursion_dict, current_obj) do
if T == GapObj || T == Obj
julia_to_gap(current_obj, recursion_dict; recursive = true)
else
gap_to_julia(T, current_obj, recursion_dict; recursive = true)
end
end
else
new_array[i] = current_obj
Expand Down
3 changes: 2 additions & 1 deletion src/julia_to_gap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ function julia_to_gap(
ret_val = NewPrecord(0)
recursion_dict[obj] = ret_val
for x in Vector{String}(Wrappers.RecNames(obj))
Wrappers.ASS_REC(ret_val, x, julia_to_gap(Wrappers.ELM_REC(obj, x), recursion_dict; recursive = true))
xx = RNamObj(x)
Wrappers.ASS_REC(ret_val, xx, julia_to_gap(Wrappers.ELM_REC(obj, xx), recursion_dict; recursive = true))
end
else
ret_val = obj
Expand Down
8 changes: 7 additions & 1 deletion test/conversion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,13 @@
@test [(1,)] == yy
@test typeof(yy) == Vector{Tuple{Int64}}

str = "JuliaEvalString(\"BigInt(2)^64\")"
L = GAP.evalstr("List([1..10], i -> $str + i)")
@test Vector{GAP.GapObj}(L) == [GAP.GapObj(x) for x in L]
end
end

@testset "conversion to GAP" begin
end

@testset "Defaults" begin
@test GAP.julia_to_gap(true)
Expand Down Expand Up @@ -467,6 +470,9 @@ end
rec = GAP.julia_to_gap(val, recursive = true)
@test rec[1] == GAP.julia_to_gap([1, 2])
@test GAP.julia_to_gap(1, recursive = false) == 1

r = GAP.evalstr("rec(a:= 1, b:= 2)")
@test GAP.julia_to_gap(r, recursive = true) == r
end

@testset "Test function conversion" begin
Expand Down