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

Fix dump(io) and xdump(io), add tests #12072

Merged
merged 1 commit into from
Jul 9, 2015
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
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be in let block and I don't think the try block or even the @test is necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand about the let block, but shouldn't it have the @test to make sure that it returns as expected?

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