Skip to content

Commit

Permalink
Meta: fix definition of dump macro
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed Jun 13, 2018
1 parent 919c0cd commit 08df29f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions base/meta.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ function show_sexpr(io::IO, ex::Expr, indent::Int)
print(io, ex.head === :block ? ",\n"*" "^inner : ", ")
show_sexpr(io, arg, inner)
end
if isempty(ex.args); print(io, ",)")
else print(io, (ex.head === :block ? "\n"*" "^indent : ""), ')')
if isempty(ex.args)
print(io, ",)")
else
print(io, (ex.head === :block ? "\n"*" "^indent : ""), ')')
end
end

Expand All @@ -53,7 +55,7 @@ Show every part of the representation of the given expression. Equivalent to
[`dump(:(expr))`](@ref dump).
"""
macro dump(expr)
dump(expr)
return :(dump($(QuoteNode(expr))))
end

"""
Expand Down
3 changes: 2 additions & 1 deletion test/meta.jl
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,13 @@ end


let oldout = stdout
ex = Meta.@lower @dump x + y
local rdout, wrout, out
try
rdout, wrout = redirect_stdout()
out = @async read(rdout, String)

@test eval(:(@dump x + y)) === nothing
@test eval(ex) === nothing

redirect_stdout(oldout)
close(wrout)
Expand Down

0 comments on commit 08df29f

Please sign in to comment.