diff --git a/README.md b/README.md index 9de7aca7a..5f7cbccdc 100644 --- a/README.md +++ b/README.md @@ -70,8 +70,6 @@ Currently, the `@compat` macro supports the following syntaxes: * Three-argument methods `prevind(s,i,n)`, `nextind(s,i,n)` ([#23805]), and `length(s,i,j)` ([#24999]); the latter two replace `chr2ind` and `ind2chr` in Julia 0.7, respectively. -* `Compat.IOBuffer` supporting keyword arguments ([#25873]). - * `Compat.range` supporting positional and keyword arguments flavors ([#25896]), ([#28708]). * `Compat.mv` and `Compat.cp` with `force` keyword argument ([#26069]). diff --git a/src/Compat.jl b/src/Compat.jl index 6a60d1e79..a01c7617d 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -76,57 +76,6 @@ end end end -# https://github.com/JuliaLang/julia/pull/25872 -if VERSION < v"0.7.0-DEV.3734" - if isdefined(Base, :open_flags) - import Base.open_flags - else - # copied from Base: - function open_flags(; read=nothing, write=nothing, create=nothing, truncate=nothing, append=nothing) - if write === true && read !== true && append !== true - create === nothing && (create = true) - truncate === nothing && (truncate = true) - end - if truncate === true || append === true - write === nothing && (write = true) - create === nothing && (create = true) - end - write === nothing && (write = false) - read === nothing && (read = !write) - create === nothing && (create = false) - truncate === nothing && (truncate = false) - append === nothing && (append = false) - return (read, write, create, truncate, append) - end - end - function IOBuffer( - data::Union{AbstractVector{UInt8},Nothing}=nothing; - read::Union{Bool,Nothing}=data === nothing ? true : nothing, - write::Union{Bool,Nothing}=data === nothing ? true : nothing, - truncate::Union{Bool,Nothing}=data === nothing ? true : nothing, - maxsize::Integer=typemax(Int), - sizehint::Union{Integer,Nothing}=nothing) - flags = open_flags(read=read, write=write, append=nothing, truncate=truncate) - if maxsize < 0 - throw(ArgumentError("negative maxsize: $(maxsize)")) - end - if data !== nothing - if sizehint !== nothing - sizehint!(data, sizehint) - end - buf = Base.IOBuffer(data, flags[1], flags[2], Int(maxsize)) - else - size = sizehint !== nothing ? Int(sizehint) : maxsize != typemax(Int) ? Int(maxsize) : 32 - buf = Base.IOBuffer(Base.StringVector(size), flags[1], flags[2], Int(maxsize)) - buf.data[:] = 0 - end - if flags[4] # flags.truncate - buf.size = 0 - end - return buf - end -end - @static if VERSION < v"0.7.0-DEV.3986" const LinRange = Base.LinSpace export LinRange diff --git a/test/old.jl b/test/old.jl index 77aa6770d..9025dee09 100644 --- a/test/old.jl +++ b/test/old.jl @@ -819,3 +819,18 @@ end @test Compat.ceil(pi, digits = 3, base = 2) == 3.25 @test Compat.round(pi, digits = 3, base = 2) == 3.125 @test Compat.round(pi, sigdigits = 5, base = 2) == 3.125 + +# 0.7.0-DEV.3734 +let buf = Compat.IOBuffer(read=true, write=false, maxsize=25) + @test buf.readable + @test !buf.writable + @test buf.maxsize == 25 +end +let buf = Compat.IOBuffer(zeros(UInt8, 4), write=true) # issue #502 + write(buf, 'a') + @test take!(buf) == [0x61] +end +let buf = Compat.IOBuffer(sizehint=20) + println(buf, "Hello world.") + @test String(take!(buf)) == "Hello world.\n" +end diff --git a/test/runtests.jl b/test/runtests.jl index 6302abe65..13a4f345e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -82,21 +82,6 @@ end @test codeunit("foo") == codeunit(SubString("fooαβγ",1,3)) == UInt8 -# 0.7.0-DEV.3734 -let buf = Compat.IOBuffer(read=true, write=false, maxsize=25) - @test buf.readable - @test !buf.writable - @test buf.maxsize == 25 -end -let buf = Compat.IOBuffer(zeros(UInt8, 4), write=true) # issue #502 - write(buf, 'a') - @test take!(buf) == [0x61] -end -let buf = Compat.IOBuffer(sizehint=20) - println(buf, "Hello world.") - @test String(take!(buf)) == "Hello world.\n" -end - # 0.7.0-DEV.3986 @test_throws ArgumentError Compat.range(1) @test_throws ArgumentError Compat.range(nothing)