From f7e65c7a27d43d5b0c1beb86cbff7068a70a8ca2 Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Tue, 2 Jan 2018 21:28:36 -0800 Subject: [PATCH 1/2] Add invpermute! --- README.md | 3 +++ src/Compat.jl | 6 ++++++ test/runtests.jl | 3 +++ 3 files changed, 12 insertions(+) diff --git a/README.md b/README.md index a6646614c..b29629ad7 100644 --- a/README.md +++ b/README.md @@ -264,6 +264,8 @@ Currently, the `@compat` macro supports the following syntaxes: * `Void` is now `Nothing` with an alias `Cvoid` for C interop ([#25162]). +* `ipermute!` is now `invpermute!` ([#25168]). + ## New macros * `@__DIR__` has been added ([#18380]) @@ -421,3 +423,4 @@ includes this fix. Find the minimum version from there. [#25057]: https://github.com/JuliaLang/julia/issues/25057 [#25102]: https://github.com/JuliaLang/julia/issues/25102 [#25162]: https://github.com/JuliaLang/julia/issues/25162 +[#25168]: https://github.com/JuliaLang/julia/issues/25168 diff --git a/src/Compat.jl b/src/Compat.jl index 7317bf70a..098b60d2e 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -1052,6 +1052,12 @@ else import Base: notnothing end +# 0.7.0-DEV.3173 +@static if !isdefined(Base, :invpermute!) + const invpermute! = ipermute! + export invpermute! +end + include("deprecated.jl") end # module Compat diff --git a/test/runtests.jl b/test/runtests.jl index e88d28e71..157415543 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1063,6 +1063,9 @@ end @test Compat.notnothing(1) == 1 @test_throws ArgumentError Compat.notnothing(nothing) +# 0.7.0-DEV.3173 +@test invpermute!(permute!([1, 2], 2:-1:1), 2:-1:1) == [1, 2] + if VERSION < v"0.6.0" include("deprecated.jl") end From e450796c0c3603feb7a991bc9e6b7fee2712006b Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Tue, 2 Jan 2018 21:41:52 -0800 Subject: [PATCH 2/2] Add pairs method for replace --- README.md | 4 ++++ src/Compat.jl | 5 +++++ test/runtests.jl | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/README.md b/README.md index b29629ad7..784b757a4 100644 --- a/README.md +++ b/README.md @@ -219,6 +219,9 @@ Currently, the `@compat` macro supports the following syntaxes: * `Some{T}` wraps `T` to signify that a result of `T<:Void` is expected ([#23642]). +* `replace` accepts a pair of pattern and replacement, with the number of replacements as + a keyword argument ([#25165]). + ## Renaming @@ -423,4 +426,5 @@ includes this fix. Find the minimum version from there. [#25057]: https://github.com/JuliaLang/julia/issues/25057 [#25102]: https://github.com/JuliaLang/julia/issues/25102 [#25162]: https://github.com/JuliaLang/julia/issues/25162 +[#25165]: https://github.com/JuliaLang/julia/issues/25165 [#25168]: https://github.com/JuliaLang/julia/issues/25168 diff --git a/src/Compat.jl b/src/Compat.jl index 098b60d2e..347e0d2d5 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -1058,6 +1058,11 @@ end export invpermute! end +@static if VERSION < v"0.7.0-DEV.3172" + Base.replace(s::AbstractString, pat_rep::Pair; count::Integer=typemax(Int)) = + replace(s, first(pat_rep), last(pat_rep), count) +end + include("deprecated.jl") end # module Compat diff --git a/test/runtests.jl b/test/runtests.jl index 157415543..f4df66e02 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1066,6 +1066,10 @@ end # 0.7.0-DEV.3173 @test invpermute!(permute!([1, 2], 2:-1:1), 2:-1:1) == [1, 2] +# 0.7.0-DEV.3172 +@test replace("abcb", "b"=>"c") == "accc" +@test replace("abcb", "b"=>"c", count=1) == "accb" + if VERSION < v"0.6.0" include("deprecated.jl") end