From 7069316e59b7de57ce61be14b1eb149d55278f52 Mon Sep 17 00:00:00 2001 From: ThomasBreuer Date: Wed, 30 Nov 2022 12:55:19 +0100 Subject: [PATCH 1/3] admit `gap_to_julia` conversion to `Vector{GAP.Obj}` This addresses issue #740, but I am sill not sure what would be a good solution. --- src/gap_to_julia.jl | 4 ++++ test/conversion.jl | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/gap_to_julia.jl b/src/gap_to_julia.jl index ddd3a905e..65996e9f6 100644 --- a/src/gap_to_julia.jl +++ b/src/gap_to_julia.jl @@ -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 diff --git a/test/conversion.jl b/test/conversion.jl index a9c39ccd1..09414ee0d 100644 --- a/test/conversion.jl +++ b/test/conversion.jl @@ -284,6 +284,9 @@ @test [(1,)] == yy @test typeof(yy) == Vector{Tuple{Int64}} + x = BigInt(2)^64 + L = GAP.evalstr("List([1..10], i -> Julia.Main.x + i)") + @test Vector{GAP.GapObj}(L) == [GAP.GapObj(x) for x in L] end @testset "conversion to GAP" begin From 5fd578ec9828e7b4cb28f17696f451a861ac1d04 Mon Sep 17 00:00:00 2001 From: ThomasBreuer Date: Wed, 30 Nov 2022 13:31:15 +0100 Subject: [PATCH 2/3] fixed a test (and the testfile syntax) Variables that get assigned inside `@testset` do not belong to Julia's `Main` module ... --- test/conversion.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/conversion.jl b/test/conversion.jl index 09414ee0d..028d33ad6 100644 --- a/test/conversion.jl +++ b/test/conversion.jl @@ -284,13 +284,13 @@ @test [(1,)] == yy @test typeof(yy) == Vector{Tuple{Int64}} - x = BigInt(2)^64 - L = GAP.evalstr("List([1..10], i -> Julia.Main.x + i)") + 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) From cfd5f3a420bcbeefad4131af8ecfe21dc295a5e1 Mon Sep 17 00:00:00 2001 From: ThomasBreuer Date: Wed, 30 Nov 2022 15:07:55 +0100 Subject: [PATCH 3/3] fixed a bug in recursive `julia_to_gap` for GAP records --- src/julia_to_gap.jl | 3 ++- test/conversion.jl | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/julia_to_gap.jl b/src/julia_to_gap.jl index 1de615d2c..ab6cc3bee 100644 --- a/src/julia_to_gap.jl +++ b/src/julia_to_gap.jl @@ -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 diff --git a/test/conversion.jl b/test/conversion.jl index 028d33ad6..56f7df299 100644 --- a/test/conversion.jl +++ b/test/conversion.jl @@ -470,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