Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bicycle1885 committed Feb 4, 2018
1 parent 1499957 commit a556386
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1415,9 +1415,9 @@ end

@deprecate which(s::Symbol) which(Main, s)

@deprecate IOBuffer(data::AbstractVector{UInt8}, read::Bool, write::Bool, maxsize::Integer=typemax(Int)) IOBuffer(data, read=read, write=write, maxsize=maxsize)
@deprecate IOBuffer(data::AbstractVector{UInt8}, read::Bool, write::Bool=false, maxsize::Integer=typemax(Int)) IOBuffer(data, read=read, write=write, maxsize=maxsize)
@deprecate IOBuffer(read::Bool, write::Bool) IOBuffer(read=read, write=write)
@deprecate IOBuffer(maxsize::Integer) IOBuffer(maxsize=maxsize)
@deprecate IOBuffer(maxsize::Integer) IOBuffer(read=true, write=true, maxsize=maxsize)


# END 0.7 deprecations
Expand Down
2 changes: 1 addition & 1 deletion base/iobuffer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function IOBuffer(;
append=flags.append,
truncate=flags.truncate,
maxsize=maxsize)
buf.data[:] = 0 # TODO: Is this really needed?
buf.data[:] = 0
if flags.truncate
buf.size = 0
end
Expand Down
2 changes: 1 addition & 1 deletion stdlib/Dates/src/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ end

function format(dt::TimeType, fmt::DateFormat, bufsize=12)
# preallocate to reduce resizing
io = IOBuffer(Vector{UInt8}(uninitialized, bufsize), true, true)
io = IOBuffer(Vector{UInt8}(uninitialized, bufsize), read=true, write=true)
format(io, dt, fmt)
String(io.data[1:io.ptr - 1])
end
Expand Down
4 changes: 2 additions & 2 deletions test/functional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ end
@test isequal(map(sqrt, 2:6), [sqrt(i) for i in 2:6])

# map on ranges should evaluate first value only once (#4453)
let io=IOBuffer(3)
let io=IOBuffer(maxsize=3)
map(x->print(io,x), 1:2)
@test String(take!(io))=="12"
end
Expand Down Expand Up @@ -176,4 +176,4 @@ end
@test res isa Vector{Union{Bool, T}}
res = map(f, y)
@test res isa Vector{Union{Bool, T}}
end
end
10 changes: 5 additions & 5 deletions test/iobuffer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ end

@testset "pr #11554" begin
io = IOBuffer(SubString("***αhelloworldω***", 4, 16))
io2 = IOBuffer(Vector{UInt8}(b"goodnightmoon"), true, true)
io2 = IOBuffer(Vector{UInt8}(b"goodnightmoon"), read=true, write=true)

@test read(io, Char) == 'α'
@test_throws ArgumentError write(io,"!")
Expand Down Expand Up @@ -227,7 +227,7 @@ end

# issue #11917
# (previous tests triggered this sometimes, but this should trigger nearly all the time)
let io = IOBuffer(0)
let io = IOBuffer(maxsize=0)
write(io, fill(0x01, 1048577))
end

Expand Down Expand Up @@ -289,11 +289,11 @@ end
end

@testset "Test constructor with a generic type argument." begin
io = IOBuffer(Int16(10))
io = IOBuffer(maxsize=Int16(10))
@test io isa IOBuffer
io = IOBuffer(Int32(10))
io = IOBuffer(maxsize=Int32(10))
@test io isa IOBuffer
io = IOBuffer(Int64(10))
io = IOBuffer(maxsize=Int64(10))
@test io isa IOBuffer
end

Expand Down
2 changes: 1 addition & 1 deletion test/read.jl
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ for (name, f) in l
@test read("$filename.to", String) == text

verbose && println("$name write(::IOBuffer, ...)")
to = IOBuffer(Vector{UInt8}(codeunits(text)), false, true)
to = IOBuffer(Vector{UInt8}(codeunits(text)), read=false, write=true)
write(to, io())
@test String(take!(to)) == text

Expand Down
2 changes: 1 addition & 1 deletion test/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ end

# PR 17117
# test print_array
let s = IOBuffer(Vector{UInt8}(), true, true)
let s = IOBuffer(Vector{UInt8}(), read=true, write=true)
Base.print_array(s, [1, 2, 3])
@test String(resize!(s.data, s.size)) == " 1\n 2\n 3"
end
Expand Down

0 comments on commit a556386

Please sign in to comment.