Skip to content

Commit

Permalink
Merge pull request #12072 from ScottPJones/spj/dump
Browse files Browse the repository at this point in the history
Fix dump(io) and xdump(io), add tests
  • Loading branch information
jakebolewski committed Jul 9, 2015
2 parents 083dc41 + 7336f81 commit 686bd24
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,7 @@ xdump(fn::Function, io::IO, args...) = throw(ArgumentError("invalid arguments to
xdump(fn::Function, args...) = xdump(fn, STDOUT::IO, args...)
xdump(io::IO, args...) = xdump(xdump, io, args...)
xdump(args...) = with_output_limit(()->xdump(xdump, STDOUT::IO, args...), true)
xdump(arg::IO) = xdump(xdump, STDOUT::IO, arg)

# Here are methods specifically for dump:
dump(io::IO, x, n::Int) = dump(io, x, n, "")
Expand All @@ -900,6 +901,7 @@ dump(io::IO, x::AbstractString, n::Int, indent) =
show(io, x); println(io))
dump(io::IO, x, n::Int, indent) = xdump(dump, io, x, n, indent)
dump(io::IO, args...) = throw(ArgumentError("invalid arguments to dump"))
dump(arg::IO) = xdump(dump, STDOUT::IO, arg)
dump(args...) = with_output_limit(()->dump(STDOUT::IO, args...), true)

function dump(io::IO, x::Dict, n::Int, indent)
Expand Down
9 changes: 9 additions & 0 deletions test/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,12 @@ end
@test_repr "bitstype 100 B"
@test repr(:(bitstype A B)) == ":(bitstype A B)"
@test repr(:(bitstype 100 B)) == ":(bitstype 100 B)"

oldout = STDOUT
try
rd, wr = redirect_stdout()
@test dump(STDERR) == nothing
@test xdump(STDERR) == nothing
finally
redirect_stdout(oldout)
end

0 comments on commit 686bd24

Please sign in to comment.