Skip to content

Commit 4540a1f

Browse files
committed
Remove readline, eachline, and readuntil from #477, #541, and #575
1 parent 15fe42b commit 4540a1f

File tree

4 files changed

+41
-67
lines changed

4 files changed

+41
-67
lines changed

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,6 @@ Currently, the `@compat` macro supports the following syntaxes:
118118

119119
* `isnothing` for testing if a variable is equal to `nothing` ([#29674]).
120120

121-
* `Compat.readline` with `keep` keyword argument ([#25646])
122-
123-
* `Compat.eachline` with `keep` keyword argument ([#25646])
124-
125-
* `Compat.readuntil` with `keep` keyword argument ([#25646])
126-
127121
* `Compat.invokelatest` supports keywords ([#22646]).
128122

129123
* `Cmd` elements can be accessed as if the `Cmd` were an array of strings for 0.6 and below ([#21197]).

src/Compat.jl

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,6 @@ end # module TypeUtils
1313

1414
include("compatmacro.jl")
1515

16-
# https://github.com/JuliaLang/julia/pull/25646
17-
@static if VERSION < v"0.7.0-DEV.3510"
18-
# not exported
19-
# chomp parameter preserved for compatibility with earliear Compat versions
20-
readline(s::IO=STDIN; chomp::Bool=true, keep::Bool=!chomp) = Base.readline(s; chomp=!keep)
21-
eachline(s; keep::Bool=false) = Base.eachline(s; chomp=!keep)
22-
23-
stripdelim(s, d::Union{Char,UInt8}) = s[end] == Char(d) ? s[1:prevind(s,lastindex(s))] : s
24-
stripdelim(s, d::AbstractString) = endswith(s, d) ? s[1:prevind(s,lastindex(s),length(d))] : s
25-
function readuntil(f, d; keep::Bool = false)
26-
s = Base.readuntil(f, d)
27-
if keep || isempty(s)
28-
return s
29-
else
30-
return stripdelim(s, d)
31-
end
32-
end
33-
readuntil(f, d::Vector{T}; keep::Bool = false) where {T<:Union{UInt8,Char}} = convert(Vector{T}, readuntil(f, String(d), keep=keep))
34-
end
35-
3616
# https://github.com/JuliaLang/julia/pull/22646
3717
if VERSION < v"0.7.0-DEV.1139"
3818
function invokelatest(f, args...; kwargs...)

test/old.jl

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,44 @@ end
6868
@test !isabstracttype(StridedArray)
6969
# 0.7
7070
@test isconcretetype(Int)
71+
72+
# PR 20203
73+
@test Compat.readline(IOBuffer("Hello, World!\n")) == "Hello, World!"
74+
@test Compat.readline(IOBuffer("x\n"), keep=false) == "x"
75+
@test Compat.readline(IOBuffer("x\n"), keep=true) == "x\n"
76+
@test collect(Compat.eachline(IOBuffer("x\ny"))) == ["x", "y"]
77+
@test collect(Compat.eachline(IOBuffer("x\ny"), keep=false)) == ["x", "y"]
78+
@test collect(Compat.eachline(IOBuffer("x\ny"), keep=true)) == ["x\n", "y"]
79+
80+
# PR 25646
81+
for (t, s, m, kept) in [
82+
("a", "ab", "a", "a"),
83+
("b", "ab", "b", "b"),
84+
("α", "αγ", "α", "α"),
85+
("ab", "abc", "ab", "ab"),
86+
("bc", "abc", "bc", "bc"),
87+
("αβ", "αβγ", "αβ", "αβ"),
88+
("aaabc", "ab", "aa", "aaab"),
89+
("aaabc", "ac", "aaabc", "aaabc"),
90+
("aaabc", "aab", "a", "aaab"),
91+
("aaabc", "aac", "aaabc", "aaabc"),
92+
("αααβγ", "αβ", "αα", "αααβ"),
93+
("αααβγ", "ααβ", "α", "αααβ"),
94+
("αααβγ", "αγ", "αααβγ", "αααβγ"),
95+
("barbarbarians", "barbarian", "bar", "barbarbarian"),
96+
("abcaabcaabcxl", "abcaabcx", "abca", "abcaabcaabcx"),
97+
("abbaabbaabbabbaax", "abbaabbabbaax", "abba", "abbaabbaabbabbaax"),
98+
("abbaabbabbaabbaabbabbaax", "abbaabbabbaax", "abbaabbabba", "abbaabbabbaabbaabbabbaax"),
99+
]
100+
local t, s, m, kept
101+
@test Compat.readuntil(IOBuffer(t), s) == m
102+
@test Compat.readuntil(IOBuffer(t), s, keep=true) == kept
103+
@test Compat.readuntil(IOBuffer(t), SubString(s, firstindex(s))) == m
104+
@test Compat.readuntil(IOBuffer(t), SubString(s, firstindex(s)), keep=true) == kept
105+
@test Compat.readuntil(IOBuffer(t), GenericString(s)) == m
106+
@test Compat.readuntil(IOBuffer(t), GenericString(s), keep=true) == kept
107+
@test Compat.readuntil(IOBuffer(t), Vector{UInt8}(codeunits(s))) == Vector{UInt8}(codeunits(m))
108+
@test Compat.readuntil(IOBuffer(t), Vector{UInt8}(codeunits(s)), keep=true) == Vector{UInt8}(codeunits(kept))
109+
@test Compat.readuntil(IOBuffer(t), collect(s)::Vector{Char}) == Vector{Char}(m)
110+
@test Compat.readuntil(IOBuffer(t), collect(s)::Vector{Char}, keep=true) == Vector{Char}(kept)
111+
end

test/runtests.jl

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -67,47 +67,6 @@ for x in (3.1, -17, 3//4, big(111.1), Inf)
6767
@test minmax(x) == (x, x)
6868
end
6969

70-
# PR 20203
71-
@test Compat.readline(IOBuffer("Hello, World!\n")) == "Hello, World!"
72-
@test Compat.readline(IOBuffer("x\n"), keep=false) == "x"
73-
@test Compat.readline(IOBuffer("x\n"), keep=true) == "x\n"
74-
@test collect(Compat.eachline(IOBuffer("x\ny"))) == ["x", "y"]
75-
@test collect(Compat.eachline(IOBuffer("x\ny"), keep=false)) == ["x", "y"]
76-
@test collect(Compat.eachline(IOBuffer("x\ny"), keep=true)) == ["x\n", "y"]
77-
78-
# PR 25646
79-
for (t, s, m, kept) in [
80-
("a", "ab", "a", "a"),
81-
("b", "ab", "b", "b"),
82-
("α", "αγ", "α", "α"),
83-
("ab", "abc", "ab", "ab"),
84-
("bc", "abc", "bc", "bc"),
85-
("αβ", "αβγ", "αβ", "αβ"),
86-
("aaabc", "ab", "aa", "aaab"),
87-
("aaabc", "ac", "aaabc", "aaabc"),
88-
("aaabc", "aab", "a", "aaab"),
89-
("aaabc", "aac", "aaabc", "aaabc"),
90-
("αααβγ", "αβ", "αα", "αααβ"),
91-
("αααβγ", "ααβ", "α", "αααβ"),
92-
("αααβγ", "αγ", "αααβγ", "αααβγ"),
93-
("barbarbarians", "barbarian", "bar", "barbarbarian"),
94-
("abcaabcaabcxl", "abcaabcx", "abca", "abcaabcaabcx"),
95-
("abbaabbaabbabbaax", "abbaabbabbaax", "abba", "abbaabbaabbabbaax"),
96-
("abbaabbabbaabbaabbabbaax", "abbaabbabbaax", "abbaabbabba", "abbaabbabbaabbaabbabbaax"),
97-
]
98-
local t, s, m, kept
99-
@test Compat.readuntil(IOBuffer(t), s) == m
100-
@test Compat.readuntil(IOBuffer(t), s, keep=true) == kept
101-
@test Compat.readuntil(IOBuffer(t), SubString(s, firstindex(s))) == m
102-
@test Compat.readuntil(IOBuffer(t), SubString(s, firstindex(s)), keep=true) == kept
103-
@test Compat.readuntil(IOBuffer(t), GenericString(s)) == m
104-
@test Compat.readuntil(IOBuffer(t), GenericString(s), keep=true) == kept
105-
@test Compat.readuntil(IOBuffer(t), Vector{UInt8}(codeunits(s))) == Vector{UInt8}(codeunits(m))
106-
@test Compat.readuntil(IOBuffer(t), Vector{UInt8}(codeunits(s)), keep=true) == Vector{UInt8}(codeunits(kept))
107-
@test Compat.readuntil(IOBuffer(t), collect(s)::Vector{Char}) == Vector{Char}(m)
108-
@test Compat.readuntil(IOBuffer(t), collect(s)::Vector{Char}, keep=true) == Vector{Char}(kept)
109-
end
110-
11170
# invokelatest with keywords
11271
pr22646(x; y=0) = 1
11372
let foo() = begin

0 commit comments

Comments
 (0)