Skip to content

Commit

Permalink
Add tests to JuliaLang#23519
Browse files Browse the repository at this point in the history
  • Loading branch information
cdsousa committed Sep 29, 2017
1 parent 988e4d6 commit 4c4bbd0
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions test/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1347,22 +1347,10 @@ end
end
end) == Expr(:error, "local variable Int cannot be used in closure declaration")

# some issues with backquote
# preserve QuoteNode and LineNumberNode
@test eval(Expr(:quote, QuoteNode(Expr(:tuple, 1, Expr(:$, :(1+2)))))) == QuoteNode(Expr(:tuple, 1, 3))
@test eval(Expr(:quote, Expr(:line, Expr(:$, :(1+2))))) === LineNumberNode(3, nothing)
# splicing at the top level should be an error
xs23917 = [1,2,3]
@test_throws ErrorException eval(:(:($(xs23917...))))
let ex2 = eval(:(:(:($$(xs23917...)))))
@test ex2 isa Expr
@test_throws ErrorException eval(ex2)
@test eval(:($(xs23917...),)) == (1,2,3) # adding a comma gives a tuple
end
# multi-unquote of splice in nested quote
let xs = [:(1+2), :(3+4), :(5+6)]
ex = quote quote $$(xs...) end end
@test ex.args[2].args[1].args[2].args[2] == :(3 + 4)
ex2 = eval(ex)
@test ex2.args[2:end] == [3,7,11]
end
# issue #23519
@test parse("@foo[1]") == parse("@foo([1])")
@test parse("@foo[1 2; 3 4]") == parse("@foo([1 2; 3 4])")
@test parse("@foo[1] + [2]") == parse("@foo([1]) + [2]")
@test parse("@foo [1] + [2]") == parse("@foo([1] + [2])")
@test parse("@Mdl.foo[1] + [2]") == parse("@Mdl.foo([1]) + [2]")
@test parse("@Mdl.foo [1] + [2]") == parse("@Mdl.foo([1] + [2])")

0 comments on commit 4c4bbd0

Please sign in to comment.