Skip to content

Commit

Permalink
Drop compat code for split and rsplit from #572
Browse files Browse the repository at this point in the history
  • Loading branch information
martinholters committed Oct 8, 2019
1 parent 6db2c27 commit 18d693a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 40 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ Currently, the `@compat` macro supports the following syntaxes:

* `findin(a, b)` is now `findall(in(b), a)` ([#24673]).

* `Compat.split` and `Compat.rsplit` accept `keepempty` keyword argument
if `splitter` is given as second argument ([#26634])

* `realmin` and `realmax` are now `floatmin` and `floatmax` ([#28302])

* `squeeze` is now `dropdims` ([#28303], [#26660]).
Expand Down
8 changes: 0 additions & 8 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,6 @@ end
end
end

# https://github.com/JuliaLang/julia/pull/26647
@static if VERSION < v"0.7.0-DEV.4724"
rsplit(s::AbstractString, splitter; limit::Integer=0, keepempty::Bool=false) =
Base.rsplit(s, splitter; limit=limit, keep=keepempty)
split(s::AbstractString, splitter; limit::Integer=0, keepempty::Bool=false) =
Base.split(s, splitter; limit=limit, keep=keepempty)
end

# https://github.com/JuliaLang/julia/pull/27828
if VERSION < v"0.7.0-beta.73"
Base.mapslices(f, A::AbstractArray; dims=error("required keyword argument `dims` missing")) =
Expand Down
29 changes: 29 additions & 0 deletions test/old.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1217,3 +1217,32 @@ end
@test atan(1.0, 2.0) == atan(0.5)
@test atan(-1.0, -2.0) atan(0.5) - π
@test atan(big"-1.0", big"-2.0") atan(big"0.5") - π

# 0.7.0-DEV.4724
let
@test Compat.split("", ',' ; keepempty=false) == []
@test Compat.split(",", ',' ; keepempty=false) == []
@test Compat.split(",,", ','; keepempty=false) == []
@test Compat.rsplit("", ',' ; keepempty=false) == []
@test Compat.rsplit(",", ',' ; keepempty=false) == []
@test Compat.rsplit(",,", ','; keepempty=false) == []

str = "a.:.ba..:..cba.:.:.dcba.:."
@test Compat.split(str, ".:."; keepempty=false) == ["a","ba.",".cba",":.dcba"]
@test Compat.split(str, ".:."; keepempty=true) == ["a","ba.",".cba",":.dcba",""]
@test Compat.split(str, ".:."; limit=3, keepempty=false) == ["a","ba.",".cba.:.:.dcba.:."]
@test Compat.split(str, ".:."; limit=3, keepempty=true) == ["a","ba.",".cba.:.:.dcba.:."]
@test Compat.rsplit(str, ".:."; keepempty=false) == ["a","ba.",".cba.:","dcba"]
@test Compat.rsplit(str, ".:."; keepempty=true) == ["a","ba.",".cba.:","dcba",""]
@test Compat.rsplit(str, ".:."; limit=3, keepempty=false) == ["a.:.ba.",".cba.:","dcba"]
@test Compat.rsplit(str, ".:."; limit=3, keepempty=true) == ["a.:.ba..:..cba.:","dcba",""]

@test Compat.split(str, r"\.(:\.)+"; keepempty=false) == ["a","ba.",".cba","dcba"]
@test Compat.split(str, r"\.(:\.)+"; keepempty=true) == ["a","ba.",".cba","dcba",""]
@test Compat.split(str, r"\.(:\.)+"; limit=3, keepempty=false) == ["a","ba.",".cba.:.:.dcba.:."]
@test Compat.split(str, r"\.(:\.)+"; limit=3, keepempty=true) == ["a","ba.",".cba.:.:.dcba.:."]
@test Compat.split(str, r"\.+:\.+"; keepempty=false) == ["a","ba","cba",":.dcba"]
@test Compat.split(str, r"\.+:\.+"; keepempty=true) == ["a","ba","cba",":.dcba",""]
@test Compat.split(str, r"\.+:\.+"; limit=3, keepempty=false) == ["a","ba","cba.:.:.dcba.:."]
@test Compat.split(str, r"\.+:\.+"; limit=3, keepempty=true) == ["a","ba","cba.:.:.dcba.:."]
end
29 changes: 0 additions & 29 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,35 +92,6 @@ end
@test length(Compat.CartesianIndices((1:2,))) == 2
@test length(Compat.CartesianIndices((1:2, -1:1))) == 6

# 0.7.0-DEV.4724
let
@test Compat.split("", ',' ; keepempty=false) == []
@test Compat.split(",", ',' ; keepempty=false) == []
@test Compat.split(",,", ','; keepempty=false) == []
@test Compat.rsplit("", ',' ; keepempty=false) == []
@test Compat.rsplit(",", ',' ; keepempty=false) == []
@test Compat.rsplit(",,", ','; keepempty=false) == []

str = "a.:.ba..:..cba.:.:.dcba.:."
@test Compat.split(str, ".:."; keepempty=false) == ["a","ba.",".cba",":.dcba"]
@test Compat.split(str, ".:."; keepempty=true) == ["a","ba.",".cba",":.dcba",""]
@test Compat.split(str, ".:."; limit=3, keepempty=false) == ["a","ba.",".cba.:.:.dcba.:."]
@test Compat.split(str, ".:."; limit=3, keepempty=true) == ["a","ba.",".cba.:.:.dcba.:."]
@test Compat.rsplit(str, ".:."; keepempty=false) == ["a","ba.",".cba.:","dcba"]
@test Compat.rsplit(str, ".:."; keepempty=true) == ["a","ba.",".cba.:","dcba",""]
@test Compat.rsplit(str, ".:."; limit=3, keepempty=false) == ["a.:.ba.",".cba.:","dcba"]
@test Compat.rsplit(str, ".:."; limit=3, keepempty=true) == ["a.:.ba..:..cba.:","dcba",""]

@test Compat.split(str, r"\.(:\.)+"; keepempty=false) == ["a","ba.",".cba","dcba"]
@test Compat.split(str, r"\.(:\.)+"; keepempty=true) == ["a","ba.",".cba","dcba",""]
@test Compat.split(str, r"\.(:\.)+"; limit=3, keepempty=false) == ["a","ba.",".cba.:.:.dcba.:."]
@test Compat.split(str, r"\.(:\.)+"; limit=3, keepempty=true) == ["a","ba.",".cba.:.:.dcba.:."]
@test Compat.split(str, r"\.+:\.+"; keepempty=false) == ["a","ba","cba",":.dcba"]
@test Compat.split(str, r"\.+:\.+"; keepempty=true) == ["a","ba","cba",":.dcba",""]
@test Compat.split(str, r"\.+:\.+"; limit=3, keepempty=false) == ["a","ba","cba.:.:.dcba.:."]
@test Compat.split(str, r"\.+:\.+"; limit=3, keepempty=true) == ["a","ba","cba.:.:.dcba.:."]
end

let
# test required keyword arguments
@compat func1() = 1
Expand Down

0 comments on commit 18d693a

Please sign in to comment.