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

Quote @gap and g_str results #904

Merged
merged 1 commit into from
Jun 19, 2023
Merged
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
6 changes: 3 additions & 3 deletions src/macros.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ GAP: (1,2)(3,4)
```
"""
macro gap(str)
return evalstr(string(str))
return :(evalstr($(string(str))))
end

export @gap
Expand Down Expand Up @@ -101,7 +101,7 @@ not all strings representing valid GAP strings can be processed.

```jldoctest
julia> g"\\\\"
ERROR: LoadError: Error thrown by GAP: Syntax error: String must end with " before end of file in stream:1
ERROR: Error thrown by GAP: Syntax error: String must end with " before end of file in stream:1
[...]

```
Expand All @@ -116,7 +116,7 @@ GAP: "\\c"
```
"""
macro g_str(str)
return gap_string_macro_helper(str)
return :(gap_string_macro_helper($str))
end

export @g_str
Expand Down
8 changes: 2 additions & 6 deletions test/macros.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,12 @@ end
@test x == GAP.evalstr("[1,2,3]")
x = @gap(SymmetricGroup)(3)
@test GAP.Globals.Size(x) == 6
# Errors thrown by the GAP.@gap macro cannot be tested directly,
# the following test does not work as intended.
# @test_throws ErrorException @gap (1,2)(3,4)
@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")
# Errors thrown by the GAP.@g_str macro cannot be tested directly,
# and the string "\\" can be handed over in the macro.
@test_throws ErrorException GAP.gap_string_macro_helper("\\")
@test_throws ErrorException g"\\"

end