Skip to content

Commit 686bd24

Browse files
committed
Merge pull request #12072 from ScottPJones/spj/dump
Fix dump(io) and xdump(io), add tests
2 parents 083dc41 + 7336f81 commit 686bd24

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

base/show.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,7 @@ xdump(fn::Function, io::IO, args...) = throw(ArgumentError("invalid arguments to
891891
xdump(fn::Function, args...) = xdump(fn, STDOUT::IO, args...)
892892
xdump(io::IO, args...) = xdump(xdump, io, args...)
893893
xdump(args...) = with_output_limit(()->xdump(xdump, STDOUT::IO, args...), true)
894+
xdump(arg::IO) = xdump(xdump, STDOUT::IO, arg)
894895

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

905907
function dump(io::IO, x::Dict, n::Int, indent)

test/show.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,3 +269,12 @@ end
269269
@test_repr "bitstype 100 B"
270270
@test repr(:(bitstype A B)) == ":(bitstype A B)"
271271
@test repr(:(bitstype 100 B)) == ":(bitstype 100 B)"
272+
273+
oldout = STDOUT
274+
try
275+
rd, wr = redirect_stdout()
276+
@test dump(STDERR) == nothing
277+
@test xdump(STDERR) == nothing
278+
finally
279+
redirect_stdout(oldout)
280+
end

0 commit comments

Comments
 (0)