From c3c2ef968811c1f745b6ee78e54d1448be5c9d9a Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Sun, 29 Sep 2019 21:11:19 +0200 Subject: [PATCH 001/121] Drop support for Julia versions older than 1.0 --- .travis.yml | 3 +-- Project.toml | 2 +- REQUIRE | 1 - appveyor.yml | 3 +-- 4 files changed, 3 insertions(+), 6 deletions(-) delete mode 100644 REQUIRE diff --git a/.travis.yml b/.travis.yml index 98ceb19dd..194743664 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,11 +3,10 @@ os: - linux - osx julia: - - 0.6 - - 0.7 - 1.0 - 1.1 - 1.2 + - 1.3 - nightly notifications: email: false diff --git a/Project.toml b/Project.toml index e5fbfd0a0..58e59e065 100644 --- a/Project.toml +++ b/Project.toml @@ -27,4 +27,4 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" [compat] -julia = "0.6,0.7,1" +julia = "1" diff --git a/REQUIRE b/REQUIRE deleted file mode 100644 index 137767a42..000000000 --- a/REQUIRE +++ /dev/null @@ -1 +0,0 @@ -julia 0.6 diff --git a/appveyor.yml b/appveyor.yml index b1aee80f6..efde23f1b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,10 +1,9 @@ environment: matrix: - - julia_version: 0.6 - - julia_version: 0.7 - julia_version: 1.0 - julia_version: 1.1 - julia_version: 1.2 + - julia_version: 1.3 - julia_version: latest platform: From 73b1f18618f538dae16b118f1197b164b79c73f3 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Sun, 29 Sep 2019 21:11:26 +0200 Subject: [PATCH 002/121] Don't create our own `Compat.Sockets` (from #545, #594) Note that this still leaves `import Socket` so `using Compat.Sockets` will still work, although this should be deprecated in the future. --- README.md | 3 --- src/Compat.jl | 18 ++---------------- test/old.jl | 15 +++++++++++++++ test/runtests.jl | 16 ++-------------- 4 files changed, 19 insertions(+), 33 deletions(-) create mode 100644 test/old.jl diff --git a/README.md b/README.md index 316863687..df7258ad7 100644 --- a/README.md +++ b/README.md @@ -106,9 +106,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `using Compat.Markdown` is provided on versions older than 0.7, where this library is not yet part of the standard library ([#25738]). -* `using Compat.Sockets` is provided on versions older than 0.7, where this library is - not yet part of the standard library ([#25935]) - * `using Compat.Statistics` is provided on versions older than 0.7, where this library is not yet part of the standard library ([#27834]). diff --git a/src/Compat.jl b/src/Compat.jl index f0d99c7f9..b17076f85 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -2,22 +2,8 @@ VERSION < v"0.7.0-beta2.199" && __precompile__() module Compat -# https://github.com/JuliaLang/julia/pull/25935 -if VERSION < v"0.7.0-DEV.4442" - @eval module Sockets - import Base: - @ip_str, IPAddr, IPv4, IPv6, UDPSocket, TCPSocket, DNSError, - accept, connect, getaddrinfo, getipaddr, getsockname, listen, - listenany, recv, recvfrom, send, bind - - export - @ip_str, IPAddr, IPv4, IPv6, UDPSocket, TCPSocket, - accept, connect, getaddrinfo, getipaddr, getsockname, listen, - listenany, recv, recvfrom, send, bind - end -else - import Sockets -end +# to be deprecated +import Sockets include("compatmacro.jl") diff --git a/test/old.jl b/test/old.jl new file mode 100644 index 000000000..648991db0 --- /dev/null +++ b/test/old.jl @@ -0,0 +1,15 @@ +# tests of functionality to be deprecated + +# 0.7.0-DEV.3666 +module TestSockets + using Compat + using Compat.Sockets + using Compat.Test + + @test isdefined(@__MODULE__, :UDPSocket) + @test isdefined(@__MODULE__, :connect) + @test isdefined(@__MODULE__, :listen) + @test isdefined(@__MODULE__, :recv) + + @test ip"127.0.0.1".host == UInt32(2130706433) +end diff --git a/test/runtests.jl b/test/runtests.jl index 0765091e1..def808796 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -913,20 +913,6 @@ import Compat.Markdown @test stderr === STDERR end -# 0.7.0-DEV.3666 -module TestSockets - using Compat - using Compat.Sockets - using Compat.Test - - @test isdefined(@__MODULE__, :UDPSocket) - @test isdefined(@__MODULE__, :connect) - @test isdefined(@__MODULE__, :listen) - @test isdefined(@__MODULE__, :recv) - - @test ip"127.0.0.1".host == UInt32(2130706433) -end - # 0.7.0-DEV.3526 module TestNames export foo @@ -1554,4 +1540,6 @@ if VERSION >= v"0.7" end end +include("old.jl") + nothing From f16e3e5b3a24883cb8734778db6f7428d6c48d43 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Sun, 29 Sep 2019 21:11:30 +0200 Subject: [PATCH 003/121] Drop compat code for `devnull`, `stdin`, `stdout`, and `stderr` from #499 --- README.md | 3 --- src/Compat.jl | 25 ------------------------- test/old.jl | 10 ++++++++++ test/runtests.jl | 8 -------- 4 files changed, 10 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index df7258ad7..d8665a9e6 100644 --- a/README.md +++ b/README.md @@ -338,9 +338,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `object_id` is now `objectid` ([#25615]). -* `DevNull`, `STDIN`, `STDOUT` and `STDERR` are now `devnull`, `stdin`, `stdout` and - `stderr` respectively ([#25959]). - * `LinSpace` is now `LinRange` ([#25896]). * `isupper`, `islower`, `ucfirst` and `lcfirst` are now `isuppercase`, `islowercase`, diff --git a/src/Compat.jl b/src/Compat.jl index b17076f85..6a442a966 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -7,31 +7,6 @@ import Sockets include("compatmacro.jl") -@static if !isdefined(Base, :devnull) #25959 - export devnull, stdout, stdin, stderr - const devnull = DevNull - for f in (:stdout, :stdin, :stderr) - F = Symbol(uppercase(string(f))) - rf = Symbol(string("_redirect_", f)) - @eval begin - $f = $F - # overload internal _redirect_std* functions - # so that they change Compat.std* - function Base.$rf(stream::IO) - ret = invoke(Base.$rf, Tuple{Any}, stream) - global $f = $F - return ret - end - end - end - # in __init__ because these can't be saved during precompiling - function __init__() - global stdout = STDOUT - global stdin = STDIN - global stderr = STDERR - end -end - @static if !isdefined(Base, Symbol("@nospecialize")) # 0.7 macro nospecialize(arg) diff --git a/test/old.jl b/test/old.jl index 648991db0..3f1710336 100644 --- a/test/old.jl +++ b/test/old.jl @@ -13,3 +13,13 @@ module TestSockets @test ip"127.0.0.1".host == UInt32(2130706433) end + +# tests of removed functionality (i.e. justs tests Base) + +# 25959 +@test all(x -> isa(x, IO), (devnull, stdin, stdout, stderr)) +@static if !isdefined(Base, :devnull) + @test stdin === STDIN + @test stdout === STDOUT + @test stderr === STDERR +end diff --git a/test/runtests.jl b/test/runtests.jl index def808796..2fab9bc7a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -905,14 +905,6 @@ import Compat.Markdown @test repr("text/plain", "string") == "\"string\"" #25990 @test showable("text/plain", 3.14159) #26089 -# 25959 -@test all(x -> isa(x, IO), (devnull, stdin, stdout, stderr)) -@static if !isdefined(Base, :devnull) - @test stdin === STDIN - @test stdout === STDOUT - @test stderr === STDERR -end - # 0.7.0-DEV.3526 module TestNames export foo From 0ba707dee52d9df7f0cc1e5489c01c6a440e04f3 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Sun, 29 Sep 2019 21:11:34 +0200 Subject: [PATCH 004/121] Drop compat code for `at-nospecialize` (from #385 and #409) --- README.md | 2 -- src/Compat.jl | 26 -------------------------- test/old.jl | 17 +++++++++++++++++ test/runtests.jl | 17 ----------------- 4 files changed, 17 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index d8665a9e6..97022f420 100644 --- a/README.md +++ b/README.md @@ -368,8 +368,6 @@ Currently, the `@compat` macro supports the following syntaxes: ## New macros -* `@nospecialize` has been added ([#22666]). - * The logging macros `@error`, `@warn`, `@info` and `@debug` can be used as `Compat.@error`, `Compat.@warn`, `Compat.@info` and `Compat.@debug` on Julia 0.6 ([#24490]). Note that the behavior do not mirror the logging macros in Julia 0.7, instead on Julia 0.6: diff --git a/src/Compat.jl b/src/Compat.jl index 6a442a966..a88cdc029 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -7,32 +7,6 @@ import Sockets include("compatmacro.jl") -@static if !isdefined(Base, Symbol("@nospecialize")) - # 0.7 - macro nospecialize(arg) - if isa(arg, Symbol) - # @nospecialize(arg) - return :($(esc(arg))::ANY) - elseif isa(arg, Expr) && arg.head == :(::) - # @nospecialize(arg::typ) - # unsupported: needs ::ANY which would change dispatch as determined by ::typ - elseif isa(arg, Expr) && arg.head == :(=) - # @nospecialize(arg=val) - arg, val = arg.args - if isa(arg, Expr) && arg.head == :(::) - # @nospecialize(arg::typ=val) - # unsupported (see above), but generate a kw arg - arg, typ = arg.args - return Expr(:kw, :($(esc(arg))::$(esc(typ))), esc(val)) - else - return Expr(:kw, :($(esc(arg))::ANY), esc(val)) - end - end - return esc(arg) - end - export @nospecialize -end - # https://github.com/JuliaLang/julia/pull/22064 @static if !isdefined(Base, Symbol("@__MODULE__")) # 0.7 diff --git a/test/old.jl b/test/old.jl index 3f1710336..64c04ca25 100644 --- a/test/old.jl +++ b/test/old.jl @@ -23,3 +23,20 @@ end @test stdout === STDOUT @test stderr === STDERR end + +# @nospecialize +# 0.7 +no_specialize(@nospecialize(x)) = sin(1) +no_specialize(@nospecialize(x::Integer)) = sin(2) +@test no_specialize(1.0) == sin(1) +@test no_specialize(1) == sin(2) +no_specialize_kw1(@nospecialize(x=0)) = sin(1) +no_specialize_kw1(@nospecialize(x::Integer)) = sin(2) +@test no_specialize_kw1(1.0) == sin(1) +@test no_specialize_kw1(1) == sin(2) +@test no_specialize_kw1() == sin(2) +no_specialize_kw2(@nospecialize(x)) = sin(1) +no_specialize_kw2(@nospecialize(x::Integer=0)) = sin(2) +@test no_specialize_kw2(1.0) == sin(1) +@test no_specialize_kw2(1) == sin(2) +@test no_specialize_kw2() == sin(2) diff --git a/test/runtests.jl b/test/runtests.jl index 2fab9bc7a..2130296ed 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -265,23 +265,6 @@ end @test @inferred(ntuple(x->x, Val(0))) == () @test @inferred(ntuple(x->x, Val(5))) == (1,2,3,4,5) -# @nospecialize -# 0.7 -no_specialize(@nospecialize(x)) = sin(1) -no_specialize(@nospecialize(x::Integer)) = sin(2) -@test no_specialize(1.0) == sin(1) -@test no_specialize(1) == sin(2) -no_specialize_kw1(@nospecialize(x=0)) = sin(1) -no_specialize_kw1(@nospecialize(x::Integer)) = sin(2) -@test no_specialize_kw1(1.0) == sin(1) -@test no_specialize_kw1(1) == sin(2) -@test no_specialize_kw1() == sin(2) -no_specialize_kw2(@nospecialize(x)) = sin(1) -no_specialize_kw2(@nospecialize(x::Integer=0)) = sin(2) -@test no_specialize_kw2(1.0) == sin(1) -@test no_specialize_kw2(1) == sin(2) -@test no_specialize_kw2() == sin(2) - # 0.7 @test read(IOBuffer("aaaa"), String) == "aaaa" @test occursin("read(@__FILE__, String)", read(@__FILE__, String)) From 20b3ff852b3fe8d7f9dceca7b6ed76b74c4baa73 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Sun, 29 Sep 2019 21:09:10 +0200 Subject: [PATCH 005/121] Drop compat code for `at-__MODULE__` (from #363) --- README.md | 2 -- src/Compat.jl | 15 --------------- test/old.jl | 7 +++++++ test/runtests.jl | 7 ------- 4 files changed, 7 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 97022f420..0d64c29c7 100644 --- a/README.md +++ b/README.md @@ -130,8 +130,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `Compat.invokelatest` supports keywords ([#22646]). -* `@__MODULE__` is aliased to `current_module()` for Julia versions 0.6 and below. Versions of `Base.binding_module`, `expand`, `macroexpand`, and `include_string` were added that accept a module as the first argument. ([#22064]) - * `Cmd` elements can be accessed as if the `Cmd` were an array of strings for 0.6 and below ([#21197]). * `Val(x)` constructs `Val{x}()`. ([#22475]) diff --git a/src/Compat.jl b/src/Compat.jl index a88cdc029..451759110 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -7,21 +7,6 @@ import Sockets include("compatmacro.jl") -# https://github.com/JuliaLang/julia/pull/22064 -@static if !isdefined(Base, Symbol("@__MODULE__")) - # 0.7 - export @__MODULE__ - macro __MODULE__() - return current_module() - end - Base.expand(mod::Module, x::ANY) = eval(mod, :(expand($(QuoteNode(x))))) - Base.macroexpand(mod::Module, x::ANY) = eval(mod, :(macroexpand($(QuoteNode(x))))) - Base.include_string(mod::Module, code::String, fname::String) = - eval(mod, :(include_string($code, $fname))) - Base.include_string(mod::Module, code::AbstractString, fname::AbstractString="string") = - eval(mod, :(include_string($code, $fname))) -end - @static if !isdefined(Base, :isabstracttype) # VERSION < v"0.7.0-DEV.3475" const isabstracttype = Base.isabstract export isabstracttype diff --git a/test/old.jl b/test/old.jl index 64c04ca25..ca4a90136 100644 --- a/test/old.jl +++ b/test/old.jl @@ -40,3 +40,10 @@ no_specialize_kw2(@nospecialize(x::Integer=0)) = sin(2) @test no_specialize_kw2(1.0) == sin(1) @test no_specialize_kw2(1) == sin(2) @test no_specialize_kw2() == sin(2) + +# PR 22064 +module Test22064 +using Compat +using Compat.Test +@test (@__MODULE__) === Test22064 +end diff --git a/test/runtests.jl b/test/runtests.jl index 2130296ed..242f19ce6 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -132,13 +132,6 @@ for (t, s, m, kept) in [ @test Compat.readuntil(IOBuffer(t), collect(s)::Vector{Char}, keep=true) == Vector{Char}(kept) end -# PR 22064 -module Test22064 -using Compat -using Compat.Test -@test (@__MODULE__) === Test22064 -end - # invokelatest with keywords pr22646(x; y=0) = 1 let foo() = begin From e546efaf4871fdc0cbf0664cdf78049d9fa201db Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Sun, 29 Sep 2019 21:16:27 +0200 Subject: [PATCH 006/121] Drop compat code for `isabstracttype` and `isconcretetype` (from #477) --- README.md | 3 --- src/Compat.jl | 19 ------------------- test/old.jl | 8 ++++++++ test/runtests.jl | 8 -------- 4 files changed, 8 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 0d64c29c7..fb573cb9c 100644 --- a/README.md +++ b/README.md @@ -323,9 +323,6 @@ Currently, the `@compat` macro supports the following syntaxes: for entries with no match and gives the index of the first (rather than the last) match ([#25662], [#25998]). -* `isabstract` and `isleaftype` are now `isabstracttype` and `isconcretetype`, respectively - ([#23666], [#25496]). - * `gc` and `gc_enable` are now `GC.gc` and `GC.enable`, respectively ([#25616]). * `endof` is now `lastindex` ([#25458]). (Note that `lastindex(A, n)` is not supported.) diff --git a/src/Compat.jl b/src/Compat.jl index 451759110..e3cc67427 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -7,11 +7,6 @@ import Sockets include("compatmacro.jl") -@static if !isdefined(Base, :isabstracttype) # VERSION < v"0.7.0-DEV.3475" - const isabstracttype = Base.isabstract - export isabstracttype -end - module TypeUtils using Base: parameter_upper_bound, typename using Compat: isabstracttype @@ -285,20 +280,6 @@ if VERSION < v"0.7.0-DEV.1325" end end - -# 0.7.0-DEV.3475 -@static if !isdefined(Base, :isconcretetype) - # 0.7.0-DEV.1775 - @static if !isdefined(Base, :isconcrete) - const isconcretetype = isleaftype - const isconcrete = isleaftype # for compatibility with earlier Compat versions - export isconcrete - else - const isconcretetype = isconcrete - end - export isconcretetype -end - # 0.7.0-DEV.2005 if VERSION < v"0.7.0-DEV.2005" const Mmap = Base.Mmap diff --git a/test/old.jl b/test/old.jl index ca4a90136..a3b0e78b8 100644 --- a/test/old.jl +++ b/test/old.jl @@ -47,3 +47,11 @@ using Compat using Compat.Test @test (@__MODULE__) === Test22064 end + +@test isabstracttype(AbstractFoo20006) +@test !isabstracttype(ConcreteFoo20006) +@test !isabstracttype(ConcreteFoo20006N) +@test !isabstracttype(ConcreteFoo200061) +@test !isabstracttype(StridedArray) +# 0.7 +@test isconcretetype(Int) diff --git a/test/runtests.jl b/test/runtests.jl index 242f19ce6..d5736a757 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -85,11 +85,6 @@ eval(Expr( @test !Compat.TypeUtils.isabstract(StridedArray) @test Compat.TypeUtils.parameter_upper_bound(ConcreteFoo20006, 1) == Int @test isa(Compat.TypeUtils.typename(Array), Core.TypeName) -@test isabstracttype(AbstractFoo20006) -@test !isabstracttype(ConcreteFoo20006) -@test !isabstracttype(ConcreteFoo20006N) -@test !isabstracttype(ConcreteFoo200061) -@test !isabstracttype(StridedArray) # PR 20203 @test Compat.readline(IOBuffer("Hello, World!\n")) == "Hello, World!" @@ -320,9 +315,6 @@ if VERSION < v"0.7.0-DEV.5238" @test cov([1, 2], [0, 10], corrected=false) === 2.5 end -# 0.7 -@test isconcretetype(Int) - # 0.7 module Test23876 using Compat From 896856e36416d260ccba5a91deb5b3a58d2747b0 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Mon, 30 Sep 2019 16:50:07 +0200 Subject: [PATCH 007/121] Mark `TypeUtils` from #304 for future deprecation, remove it from README While at it, simplify the syntax of its test due to relaxed compatibility requirements. --- README.md | 2 -- src/Compat.jl | 5 ++--- test/old.jl | 13 +++++++++++++ test/runtests.jl | 19 ------------------- 4 files changed, 15 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index fb573cb9c..fdc967d0d 100644 --- a/README.md +++ b/README.md @@ -126,8 +126,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `Compat.readuntil` with `keep` keyword argument ([#25646]) -* The `isabstract`, `parameter_upper_bound`, `typename` reflection methods were added in Julia 0.6. This package re-exports these from the `Compat.TypeUtils` submodule. On earlier versions of julia, that module contains the same functions, but operating on the pre-0.6 type system representation. - * `Compat.invokelatest` supports keywords ([#22646]). * `Cmd` elements can be accessed as if the `Cmd` were an array of strings for 0.6 and below ([#21197]). diff --git a/src/Compat.jl b/src/Compat.jl index e3cc67427..b3937c240 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -4,9 +4,6 @@ module Compat # to be deprecated import Sockets - -include("compatmacro.jl") - module TypeUtils using Base: parameter_upper_bound, typename using Compat: isabstracttype @@ -14,6 +11,8 @@ module TypeUtils export isabstract, parameter_upper_bound, typename end # module TypeUtils +include("compatmacro.jl") + # https://github.com/JuliaLang/julia/pull/25646 @static if VERSION < v"0.7.0-DEV.3510" # not exported diff --git a/test/old.jl b/test/old.jl index a3b0e78b8..09d8e60aa 100644 --- a/test/old.jl +++ b/test/old.jl @@ -14,6 +14,19 @@ module TestSockets @test ip"127.0.0.1".host == UInt32(2130706433) end +# julia#20006 +abstract type AbstractFoo20006 end +struct ConcreteFoo20006{T<:Int} <: AbstractFoo20006 end +struct ConcreteFoo20006N{T<:Int,N} <: AbstractFoo20006 end +@compat ConcreteFoo200061{T<:Int} = ConcreteFoo20006N{T,1} +@test Compat.TypeUtils.isabstract(AbstractFoo20006) +@test !Compat.TypeUtils.isabstract(ConcreteFoo20006) +@test !Compat.TypeUtils.isabstract(ConcreteFoo20006N) +@test !Compat.TypeUtils.isabstract(ConcreteFoo200061) +@test !Compat.TypeUtils.isabstract(StridedArray) +@test Compat.TypeUtils.parameter_upper_bound(ConcreteFoo20006, 1) == Int +@test isa(Compat.TypeUtils.typename(Array), Core.TypeName) + # tests of removed functionality (i.e. justs tests Base) # 25959 diff --git a/test/runtests.jl b/test/runtests.jl index d5736a757..e8842d220 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -67,25 +67,6 @@ for x in (3.1, -17, 3//4, big(111.1), Inf) @test minmax(x) == (x, x) end -# julia#20006 -abstract type AbstractFoo20006 end -eval(Expr( - struct_sym, false, - Expr(:(<:), :(ConcreteFoo20006{T<:Int}), :AbstractFoo20006), - quote end)) -eval(Expr( - struct_sym, false, - Expr(:(<:), :(ConcreteFoo20006N{T<:Int,N}), :AbstractFoo20006), - quote end)) -@compat ConcreteFoo200061{T<:Int} = ConcreteFoo20006N{T,1} -@test Compat.TypeUtils.isabstract(AbstractFoo20006) -@test !Compat.TypeUtils.isabstract(ConcreteFoo20006) -@test !Compat.TypeUtils.isabstract(ConcreteFoo20006N) -@test !Compat.TypeUtils.isabstract(ConcreteFoo200061) -@test !Compat.TypeUtils.isabstract(StridedArray) -@test Compat.TypeUtils.parameter_upper_bound(ConcreteFoo20006, 1) == Int -@test isa(Compat.TypeUtils.typename(Array), Core.TypeName) - # PR 20203 @test Compat.readline(IOBuffer("Hello, World!\n")) == "Hello, World!" @test Compat.readline(IOBuffer("x\n"), keep=false) == "x" From 939ae7ef60ff9c1498b5c99e2d6e4e15b5e637c3 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Mon, 30 Sep 2019 16:59:13 +0200 Subject: [PATCH 008/121] Remove `readline`, `eachline`, and `readuntil` from #477, #541, and #575 --- README.md | 6 ------ src/Compat.jl | 20 -------------------- test/old.jl | 41 +++++++++++++++++++++++++++++++++++++++++ test/runtests.jl | 41 ----------------------------------------- 4 files changed, 41 insertions(+), 67 deletions(-) diff --git a/README.md b/README.md index fdc967d0d..fad54de45 100644 --- a/README.md +++ b/README.md @@ -120,12 +120,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `isnothing` for testing if a variable is equal to `nothing` ([#29674]). -* `Compat.readline` with `keep` keyword argument ([#25646]) - -* `Compat.eachline` with `keep` keyword argument ([#25646]) - -* `Compat.readuntil` with `keep` keyword argument ([#25646]) - * `Compat.invokelatest` supports keywords ([#22646]). * `Cmd` elements can be accessed as if the `Cmd` were an array of strings for 0.6 and below ([#21197]). diff --git a/src/Compat.jl b/src/Compat.jl index b3937c240..4afd0cbc1 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -13,26 +13,6 @@ end # module TypeUtils include("compatmacro.jl") -# https://github.com/JuliaLang/julia/pull/25646 -@static if VERSION < v"0.7.0-DEV.3510" - # not exported - # chomp parameter preserved for compatibility with earliear Compat versions - readline(s::IO=STDIN; chomp::Bool=true, keep::Bool=!chomp) = Base.readline(s; chomp=!keep) - eachline(s; keep::Bool=false) = Base.eachline(s; chomp=!keep) - - stripdelim(s, d::Union{Char,UInt8}) = s[end] == Char(d) ? s[1:prevind(s,lastindex(s))] : s - stripdelim(s, d::AbstractString) = endswith(s, d) ? s[1:prevind(s,lastindex(s),length(d))] : s - function readuntil(f, d; keep::Bool = false) - s = Base.readuntil(f, d) - if keep || isempty(s) - return s - else - return stripdelim(s, d) - end - end - readuntil(f, d::Vector{T}; keep::Bool = false) where {T<:Union{UInt8,Char}} = convert(Vector{T}, readuntil(f, String(d), keep=keep)) -end - # https://github.com/JuliaLang/julia/pull/22646 if VERSION < v"0.7.0-DEV.1139" function invokelatest(f, args...; kwargs...) diff --git a/test/old.jl b/test/old.jl index 09d8e60aa..f5ae0ca77 100644 --- a/test/old.jl +++ b/test/old.jl @@ -68,3 +68,44 @@ end @test !isabstracttype(StridedArray) # 0.7 @test isconcretetype(Int) + +# PR 20203 +@test Compat.readline(IOBuffer("Hello, World!\n")) == "Hello, World!" +@test Compat.readline(IOBuffer("x\n"), keep=false) == "x" +@test Compat.readline(IOBuffer("x\n"), keep=true) == "x\n" +@test collect(Compat.eachline(IOBuffer("x\ny"))) == ["x", "y"] +@test collect(Compat.eachline(IOBuffer("x\ny"), keep=false)) == ["x", "y"] +@test collect(Compat.eachline(IOBuffer("x\ny"), keep=true)) == ["x\n", "y"] + +# PR 25646 +for (t, s, m, kept) in [ + ("a", "ab", "a", "a"), + ("b", "ab", "b", "b"), + ("α", "αγ", "α", "α"), + ("ab", "abc", "ab", "ab"), + ("bc", "abc", "bc", "bc"), + ("αβ", "αβγ", "αβ", "αβ"), + ("aaabc", "ab", "aa", "aaab"), + ("aaabc", "ac", "aaabc", "aaabc"), + ("aaabc", "aab", "a", "aaab"), + ("aaabc", "aac", "aaabc", "aaabc"), + ("αααβγ", "αβ", "αα", "αααβ"), + ("αααβγ", "ααβ", "α", "αααβ"), + ("αααβγ", "αγ", "αααβγ", "αααβγ"), + ("barbarbarians", "barbarian", "bar", "barbarbarian"), + ("abcaabcaabcxl", "abcaabcx", "abca", "abcaabcaabcx"), + ("abbaabbaabbabbaax", "abbaabbabbaax", "abba", "abbaabbaabbabbaax"), + ("abbaabbabbaabbaabbabbaax", "abbaabbabbaax", "abbaabbabba", "abbaabbabbaabbaabbabbaax"), + ] + local t, s, m, kept + @test Compat.readuntil(IOBuffer(t), s) == m + @test Compat.readuntil(IOBuffer(t), s, keep=true) == kept + @test Compat.readuntil(IOBuffer(t), SubString(s, firstindex(s))) == m + @test Compat.readuntil(IOBuffer(t), SubString(s, firstindex(s)), keep=true) == kept + @test Compat.readuntil(IOBuffer(t), GenericString(s)) == m + @test Compat.readuntil(IOBuffer(t), GenericString(s), keep=true) == kept + @test Compat.readuntil(IOBuffer(t), Vector{UInt8}(codeunits(s))) == Vector{UInt8}(codeunits(m)) + @test Compat.readuntil(IOBuffer(t), Vector{UInt8}(codeunits(s)), keep=true) == Vector{UInt8}(codeunits(kept)) + @test Compat.readuntil(IOBuffer(t), collect(s)::Vector{Char}) == Vector{Char}(m) + @test Compat.readuntil(IOBuffer(t), collect(s)::Vector{Char}, keep=true) == Vector{Char}(kept) +end diff --git a/test/runtests.jl b/test/runtests.jl index e8842d220..289587ea8 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -67,47 +67,6 @@ for x in (3.1, -17, 3//4, big(111.1), Inf) @test minmax(x) == (x, x) end -# PR 20203 -@test Compat.readline(IOBuffer("Hello, World!\n")) == "Hello, World!" -@test Compat.readline(IOBuffer("x\n"), keep=false) == "x" -@test Compat.readline(IOBuffer("x\n"), keep=true) == "x\n" -@test collect(Compat.eachline(IOBuffer("x\ny"))) == ["x", "y"] -@test collect(Compat.eachline(IOBuffer("x\ny"), keep=false)) == ["x", "y"] -@test collect(Compat.eachline(IOBuffer("x\ny"), keep=true)) == ["x\n", "y"] - -# PR 25646 -for (t, s, m, kept) in [ - ("a", "ab", "a", "a"), - ("b", "ab", "b", "b"), - ("α", "αγ", "α", "α"), - ("ab", "abc", "ab", "ab"), - ("bc", "abc", "bc", "bc"), - ("αβ", "αβγ", "αβ", "αβ"), - ("aaabc", "ab", "aa", "aaab"), - ("aaabc", "ac", "aaabc", "aaabc"), - ("aaabc", "aab", "a", "aaab"), - ("aaabc", "aac", "aaabc", "aaabc"), - ("αααβγ", "αβ", "αα", "αααβ"), - ("αααβγ", "ααβ", "α", "αααβ"), - ("αααβγ", "αγ", "αααβγ", "αααβγ"), - ("barbarbarians", "barbarian", "bar", "barbarbarian"), - ("abcaabcaabcxl", "abcaabcx", "abca", "abcaabcaabcx"), - ("abbaabbaabbabbaax", "abbaabbabbaax", "abba", "abbaabbaabbabbaax"), - ("abbaabbabbaabbaabbabbaax", "abbaabbabbaax", "abbaabbabba", "abbaabbabbaabbaabbabbaax"), - ] - local t, s, m, kept - @test Compat.readuntil(IOBuffer(t), s) == m - @test Compat.readuntil(IOBuffer(t), s, keep=true) == kept - @test Compat.readuntil(IOBuffer(t), SubString(s, firstindex(s))) == m - @test Compat.readuntil(IOBuffer(t), SubString(s, firstindex(s)), keep=true) == kept - @test Compat.readuntil(IOBuffer(t), GenericString(s)) == m - @test Compat.readuntil(IOBuffer(t), GenericString(s), keep=true) == kept - @test Compat.readuntil(IOBuffer(t), Vector{UInt8}(codeunits(s))) == Vector{UInt8}(codeunits(m)) - @test Compat.readuntil(IOBuffer(t), Vector{UInt8}(codeunits(s)), keep=true) == Vector{UInt8}(codeunits(kept)) - @test Compat.readuntil(IOBuffer(t), collect(s)::Vector{Char}) == Vector{Char}(m) - @test Compat.readuntil(IOBuffer(t), collect(s)::Vector{Char}, keep=true) == Vector{Char}(kept) -end - # invokelatest with keywords pr22646(x; y=0) = 1 let foo() = begin From 6a8f49fa8521a1fd9abd18532a399443b27f0cbf Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Mon, 30 Sep 2019 17:03:09 +0200 Subject: [PATCH 009/121] Drop compat code for `invokelatest` from #424 --- README.md | 2 -- src/Compat.jl | 11 +---------- test/old.jl | 10 ++++++++++ test/runtests.jl | 9 --------- 4 files changed, 11 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index fad54de45..0b589d82b 100644 --- a/README.md +++ b/README.md @@ -120,8 +120,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `isnothing` for testing if a variable is equal to `nothing` ([#29674]). -* `Compat.invokelatest` supports keywords ([#22646]). - * `Cmd` elements can be accessed as if the `Cmd` were an array of strings for 0.6 and below ([#21197]). * `Val(x)` constructs `Val{x}()`. ([#22475]) diff --git a/src/Compat.jl b/src/Compat.jl index 4afd0cbc1..ee7341489 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -10,19 +10,10 @@ module TypeUtils const isabstract = isabstracttype export isabstract, parameter_upper_bound, typename end # module TypeUtils +import Base.invokelatest include("compatmacro.jl") -# https://github.com/JuliaLang/julia/pull/22646 -if VERSION < v"0.7.0-DEV.1139" - function invokelatest(f, args...; kwargs...) - inner() = f(args...; kwargs...) - Base.invokelatest(inner) - end -else - import Base.invokelatest -end - # https://github.com/JuliaLang/julia/pull/21197 if VERSION < v"0.7.0-DEV.257" # allow the elements of the Cmd to be accessed as an array or iterator diff --git a/test/old.jl b/test/old.jl index f5ae0ca77..a243f9039 100644 --- a/test/old.jl +++ b/test/old.jl @@ -27,6 +27,16 @@ struct ConcreteFoo20006N{T<:Int,N} <: AbstractFoo20006 end @test Compat.TypeUtils.parameter_upper_bound(ConcreteFoo20006, 1) == Int @test isa(Compat.TypeUtils.typename(Array), Core.TypeName) +# invokelatest with keywords +pr22646(x; y=0) = 1 +let foo() = begin + eval(:(pr22646(x::Int; y=0) = 2)) + return Compat.invokelatest(pr22646, 0, y=1) + end + @test foo() == 2 +end + + # tests of removed functionality (i.e. justs tests Base) # 25959 diff --git a/test/runtests.jl b/test/runtests.jl index 289587ea8..00ac5d983 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -67,15 +67,6 @@ for x in (3.1, -17, 3//4, big(111.1), Inf) @test minmax(x) == (x, x) end -# invokelatest with keywords -pr22646(x; y=0) = 1 -let foo() = begin - eval(:(pr22646(x::Int; y=0) = 2)) - return Compat.invokelatest(pr22646, 0, y=1) - end - @test foo() == 2 -end - # PR #21197 let c = `ls -l "foo bar"` @test collect(c) == ["ls", "-l", "foo bar"] From d8ece039c8982b46df0ce8e96510dc0dec28a124 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Mon, 30 Sep 2019 17:07:59 +0200 Subject: [PATCH 010/121] Drop compat code for array-like access to `Cmd` from #379 --- README.md | 2 -- src/Compat.jl | 11 ----------- test/old.jl | 11 +++++++++++ test/runtests.jl | 11 ----------- 4 files changed, 11 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 0b589d82b..4ef013841 100644 --- a/README.md +++ b/README.md @@ -120,8 +120,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `isnothing` for testing if a variable is equal to `nothing` ([#29674]). -* `Cmd` elements can be accessed as if the `Cmd` were an array of strings for 0.6 and below ([#21197]). - * `Val(x)` constructs `Val{x}()`. ([#22475]) * The `reshape` and `ntuple` APIs are extended to support `Val{x}()` arguments on 0.6 and below. diff --git a/src/Compat.jl b/src/Compat.jl index ee7341489..abe41b134 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -14,17 +14,6 @@ import Base.invokelatest include("compatmacro.jl") -# https://github.com/JuliaLang/julia/pull/21197 -if VERSION < v"0.7.0-DEV.257" - # allow the elements of the Cmd to be accessed as an array or iterator - for f in (:length, :endof, :start, :eachindex, :eltype, :first, :last) - @eval Base.$f(cmd::Cmd) = $f(cmd.exec) - end - for f in (:next, :done, :getindex) - @eval Base.$f(cmd::Cmd, i) = $f(cmd.exec, i) - end -end - # https://github.com/JuliaLang/julia/pull/22475 @static if VERSION < v"0.7.0-DEV.843" import Base: Val diff --git a/test/old.jl b/test/old.jl index a243f9039..b5c8e8d4a 100644 --- a/test/old.jl +++ b/test/old.jl @@ -119,3 +119,14 @@ for (t, s, m, kept) in [ @test Compat.readuntil(IOBuffer(t), collect(s)::Vector{Char}) == Vector{Char}(m) @test Compat.readuntil(IOBuffer(t), collect(s)::Vector{Char}, keep=true) == Vector{Char}(kept) end + +# PR #21197 +let c = `ls -l "foo bar"` + @test collect(c) == ["ls", "-l", "foo bar"] + @test first(c) == "ls" == c[1] + @test last(c) == "foo bar" == c[3] == c[end] + @test c[1:2] == ["ls", "-l"] + @test eltype(c) == String + @test length(c) == 3 + @test eachindex(c) == 1:3 +end diff --git a/test/runtests.jl b/test/runtests.jl index 00ac5d983..56b0a48d1 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -67,17 +67,6 @@ for x in (3.1, -17, 3//4, big(111.1), Inf) @test minmax(x) == (x, x) end -# PR #21197 -let c = `ls -l "foo bar"` - @test collect(c) == ["ls", "-l", "foo bar"] - @test first(c) == "ls" == c[1] - @test last(c) == "foo bar" == c[3] == c[end] - @test c[1:2] == ["ls", "-l"] - @test eltype(c) == String - @test length(c) == 3 - @test eachindex(c) == 1:3 -end - # PR 22629 @test logdet(0.5) == log(det(0.5)) From 6d3229e1bdb576e0603edad37ffd413694ee179e Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Mon, 30 Sep 2019 17:13:28 +0200 Subject: [PATCH 011/121] Drop compat code for `Val(n)` and `ntuple`/`reshape` with `Val` from #381 and #399 --- README.md | 4 ---- src/Compat.jl | 11 ----------- test/old.jl | 35 +++++++++++++++++++++++++++++++++++ test/runtests.jl | 35 ----------------------------------- 4 files changed, 35 insertions(+), 50 deletions(-) diff --git a/README.md b/README.md index 4ef013841..a5e860987 100644 --- a/README.md +++ b/README.md @@ -120,10 +120,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `isnothing` for testing if a variable is equal to `nothing` ([#29674]). -* `Val(x)` constructs `Val{x}()`. ([#22475]) - -* The `reshape` and `ntuple` APIs are extended to support `Val{x}()` arguments on 0.6 and below. - * `logdet` for `Number`s ([#22629]). * `fieldcount` is equivalent to `nfields` for Julia versions 0.6 and below and is used to diff --git a/src/Compat.jl b/src/Compat.jl index abe41b134..930572f6e 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -14,17 +14,6 @@ import Base.invokelatest include("compatmacro.jl") -# https://github.com/JuliaLang/julia/pull/22475 -@static if VERSION < v"0.7.0-DEV.843" - import Base: Val - (::Type{Val})(x) = (Base.@_pure_meta; Val{x}()) - # Also add methods for Val(x) that were previously Val{x} - import Base: reshape - reshape{N}(parent::AbstractArray, ndims::Val{N}) = reshape(parent, Val{N}) - import Base: ntuple - ntuple{F,N}(f::F, ::Val{N}) = ntuple(f, Val{N}) -end - # https://github.com/JuliaLang/julia/pull/22629 if VERSION < v"0.7.0-DEV.848" import Base: logdet diff --git a/test/old.jl b/test/old.jl index b5c8e8d4a..48741ca3b 100644 --- a/test/old.jl +++ b/test/old.jl @@ -130,3 +130,38 @@ let c = `ls -l "foo bar"` @test length(c) == 3 @test eachindex(c) == 1:3 end + +# Val(x) +# 0.7 +begin + local firstlast + firstlast(::Val{true}) = "First" + firstlast(::Val{false}) = "Last" + + @test firstlast(Val(true)) == "First" + @test firstlast(Val(false)) == "Last" +end + +# Reshape to a given number of dimensions using Val(N) +# 0.7 +let + for A in (rand(Float64, ()), rand(2), rand(2,3), rand(2,3,5), rand(2,3,5,7)), N in (1,2,3,4,5,6) + B = @inferred reshape(A, Val(N)) + @test ndims(B) == N + if N < ndims(A) + new_sz = (size(A)[1:N-1]..., prod(size(A)[N:end])) + elseif N == ndims(A) + new_sz = size(A) + else + new_sz = (size(A)..., ntuple(x->1, N-ndims(A))...) + end + @test size(B) == new_sz + @test B == reshape(A, new_sz) + end +end + +# ntuple with Val(N) +# 0.7 +@test @inferred(ntuple(x->1, Val(3))) == (1,1,1) +@test @inferred(ntuple(x->x, Val(0))) == () +@test @inferred(ntuple(x->x, Val(5))) == (1,2,3,4,5) diff --git a/test/runtests.jl b/test/runtests.jl index 56b0a48d1..53db7c7dd 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -138,41 +138,6 @@ let @test vec([b for (a,b) in pairs(IndexCartesian(), A14)]) == [11,12,13,14] end -# Val(x) -# 0.7 -begin - local firstlast - firstlast(::Val{true}) = "First" - firstlast(::Val{false}) = "Last" - - @test firstlast(Val(true)) == "First" - @test firstlast(Val(false)) == "Last" -end - -# Reshape to a given number of dimensions using Val(N) -# 0.7 -let - for A in (rand(Float64, ()), rand(2), rand(2,3), rand(2,3,5), rand(2,3,5,7)), N in (1,2,3,4,5,6) - B = @inferred reshape(A, Val(N)) - @test ndims(B) == N - if N < ndims(A) - new_sz = (size(A)[1:N-1]..., prod(size(A)[N:end])) - elseif N == ndims(A) - new_sz = size(A) - else - new_sz = (size(A)..., ntuple(x->1, N-ndims(A))...) - end - @test size(B) == new_sz - @test B == reshape(A, new_sz) - end -end - -# ntuple with Val(N) -# 0.7 -@test @inferred(ntuple(x->1, Val(3))) == (1,1,1) -@test @inferred(ntuple(x->x, Val(0))) == () -@test @inferred(ntuple(x->x, Val(5))) == (1,2,3,4,5) - # 0.7 @test read(IOBuffer("aaaa"), String) == "aaaa" @test occursin("read(@__FILE__, String)", read(@__FILE__, String)) From e62df26ac6527a4fe948330f0213181662193282 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Mon, 30 Sep 2019 17:16:29 +0200 Subject: [PATCH 012/121] Drop compat code for `logdet(::Any)` fallback from #382 --- README.md | 2 -- src/Compat.jl | 6 ------ test/old.jl | 3 +++ test/runtests.jl | 3 --- 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index a5e860987..cb36351d7 100644 --- a/README.md +++ b/README.md @@ -120,8 +120,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `isnothing` for testing if a variable is equal to `nothing` ([#29674]). -* `logdet` for `Number`s ([#22629]). - * `fieldcount` is equivalent to `nfields` for Julia versions 0.6 and below and is used to determine the number of fields in a data type ([#22350]). diff --git a/src/Compat.jl b/src/Compat.jl index 930572f6e..f27f5b01f 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -14,12 +14,6 @@ import Base.invokelatest include("compatmacro.jl") -# https://github.com/JuliaLang/julia/pull/22629 -if VERSION < v"0.7.0-DEV.848" - import Base: logdet - logdet(A) = log(det(A)) -end - # https://github.com/JuliaLang/julia/pull/22633 if VERSION < v"0.7.0-DEV.1041" # these have been deprecated in Julia 0.7.0-DEV.5272; we keep them here to avoid diff --git a/test/old.jl b/test/old.jl index 48741ca3b..fbf3771a4 100644 --- a/test/old.jl +++ b/test/old.jl @@ -165,3 +165,6 @@ end @test @inferred(ntuple(x->1, Val(3))) == (1,1,1) @test @inferred(ntuple(x->x, Val(0))) == () @test @inferred(ntuple(x->x, Val(5))) == (1,2,3,4,5) + +# PR 22629 +@test logdet(0.5) == log(det(0.5)) diff --git a/test/runtests.jl b/test/runtests.jl index 53db7c7dd..54d153828 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -67,9 +67,6 @@ for x in (3.1, -17, 3//4, big(111.1), Inf) @test minmax(x) == (x, x) end -# PR 22629 -@test logdet(0.5) == log(det(0.5)) - # PR 22633 if VERSION < v"0.7.0-DEV.5272" # chol(A::UniformScaling) has been deprecated in Julia, we still test it to avoid From d1a7419aab8e0c535b96eecc3811c1519df1001a Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Mon, 30 Sep 2019 17:18:54 +0200 Subject: [PATCH 013/121] Drop compat code for `chol(::UniformScaling)` from #382 --- src/Compat.jl | 9 --------- test/runtests.jl | 11 ----------- 2 files changed, 20 deletions(-) diff --git a/src/Compat.jl b/src/Compat.jl index f27f5b01f..eb60054c1 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -14,15 +14,6 @@ import Base.invokelatest include("compatmacro.jl") -# https://github.com/JuliaLang/julia/pull/22633 -if VERSION < v"0.7.0-DEV.1041" - # these have been deprecated in Julia 0.7.0-DEV.5272; we keep them here to avoid - # breakage in packages already using them on Julia 0.6 - import Base.LinAlg: chol, chol! - chol!(J::UniformScaling, uplo) = UniformScaling(chol!(J.λ, uplo)) - chol(J::UniformScaling, args...) = UniformScaling(chol(J.λ, args...)) -end - # https://github.com/JuliaLang/julia/pull/21746 const macros_have_sourceloc = VERSION >= v"0.7-" && length(:(@test).args) == 2 diff --git a/test/runtests.jl b/test/runtests.jl index 54d153828..2b0d35dbd 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -67,17 +67,6 @@ for x in (3.1, -17, 3//4, big(111.1), Inf) @test minmax(x) == (x, x) end -# PR 22633 -if VERSION < v"0.7.0-DEV.5272" - # chol(A::UniformScaling) has been deprecated in Julia, we still test it to avoid - # accidental breakage in packages using the Compat vesion of it on Julia 0.6 - for T in (Float64, ComplexF32, BigFloat, Int) - λ = T(4) - @test chol(λ*I).λ ≈ √λ - @test_throws Union{ArgumentError,Compat.LinearAlgebra.PosDefException} chol(-λ*I) - end -end - let @compat cr(::CartesianIndices{2}) = 2 @test cr(CartesianIndices((5, 3))) == 2 From c23d53589e39bfb031972dc7c77f11ebd145fa3f Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Mon, 30 Sep 2019 17:25:18 +0200 Subject: [PATCH 014/121] Mark `macros_have_sourceloc` from #355 for future deprecation --- README.md | 2 -- src/Compat.jl | 4 +--- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/README.md b/README.md index cb36351d7..143d4114d 100644 --- a/README.md +++ b/README.md @@ -360,8 +360,6 @@ Currently, the `@compat` macro supports the following syntaxes: * On versions of Julia that do not contain a Base.Threads module, Compat defines a Threads module containing a no-op `@threads` macro. -* The `Expr(:macrocall)` has an extra initial argument `__source__`, which can be tested for with `Compat.macros_have_sourceloc`. - ## New types * `Compat.AbstractDateTime` is an alias for `Compat.Dates.AbstractDateTime` as of ([#25227]) and `Compat.Dates.TimeType` prior to that. diff --git a/src/Compat.jl b/src/Compat.jl index eb60054c1..6b4beef9f 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -11,12 +11,10 @@ module TypeUtils export isabstract, parameter_upper_bound, typename end # module TypeUtils import Base.invokelatest +const macros_have_sourceloc = true include("compatmacro.jl") -# https://github.com/JuliaLang/julia/pull/21746 -const macros_have_sourceloc = VERSION >= v"0.7-" && length(:(@test).args) == 2 - # 0.7.0-DEV.3155 @static if !isdefined(Base, :pushfirst!) const pushfirst! = unshift! From 3e85b871e1ed73f78ce03b7e94d19a815d8993bd Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Mon, 30 Sep 2019 17:30:28 +0200 Subject: [PATCH 015/121] Drop compat code for `pushfirst!`, `popfirst!` from #444 --- README.md | 2 -- src/Compat.jl | 7 ------- test/old.jl | 6 ++++++ test/runtests.jl | 6 ------ 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 143d4114d..c9e2ba832 100644 --- a/README.md +++ b/README.md @@ -267,8 +267,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `Void` is now `Nothing` with an alias `Cvoid` for C interop ([#25162]). -* `unshift!` and `shift!` are now `pushfirst!` and `popfirst!` ([#25100]). - * `Base.IteratorSize` and `Base.IteratorEltype` are available as `Compat.IteratorSize` and `Compat.IteratorEltype` ([#25402]). diff --git a/src/Compat.jl b/src/Compat.jl index 6b4beef9f..fddaa2c52 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -15,13 +15,6 @@ const macros_have_sourceloc = true include("compatmacro.jl") -# 0.7.0-DEV.3155 -@static if !isdefined(Base, :pushfirst!) - const pushfirst! = unshift! - const popfirst! = shift! - export pushfirst!, popfirst! -end - # https://github.com/JuliaLang/julia/pull/22182 module Sys const KERNEL = Base.Sys.KERNEL diff --git a/test/old.jl b/test/old.jl index fbf3771a4..fc4776be3 100644 --- a/test/old.jl +++ b/test/old.jl @@ -168,3 +168,9 @@ end # PR 22629 @test logdet(0.5) == log(det(0.5)) + +# 0.7.0-DEV.3155 +let coolvec = [1,2,3] + @test pushfirst!(coolvec, 0) == [0,1,2,3] + @test popfirst!(coolvec) == 0 +end diff --git a/test/runtests.jl b/test/runtests.jl index 2b0d35dbd..23ffbf2ff 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -373,12 +373,6 @@ end @test Compat.notnothing(1) == 1 @test_throws ArgumentError Compat.notnothing(nothing) -# 0.7.0-DEV.3155 -let coolvec = [1,2,3] - @test pushfirst!(coolvec, 0) == [0,1,2,3] - @test popfirst!(coolvec) == 0 -end - # 0.7.0-DEV.3309 let v = [1, 2, 3] @test Compat.IteratorSize(v) isa Base.HasShape From 3702883507685fc9c7d568c414c103f731781bb2 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Mon, 30 Sep 2019 19:34:21 +0200 Subject: [PATCH 016/121] Remove compat code for `Sys` from #380, #433, #552 And mark it for future deprecation --- README.md | 8 ------ src/Compat.jl | 74 ++++-------------------------------------------- test/old.jl | 22 ++++++++++++++ test/runtests.jl | 26 ----------------- 4 files changed, 27 insertions(+), 103 deletions(-) diff --git a/README.md b/README.md index c9e2ba832..78f7d5314 100644 --- a/README.md +++ b/README.md @@ -206,8 +206,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `Compat.qr` takes `pivot` as a `Val` _instance_ ([#22475]). -* `Compat.Sys.which` and `Compat.Sys.isexecutable` ([#26559], [#27298]). - * `Compat.rmul!` provides a subset of the functionality of `LinearAlgebra.rmul!` for use with Julia 0.6 ([#25701], [#25812]). @@ -229,10 +227,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `reprmime(mime, x)` is now `repr(mime, x)` ([#25990]) and `mimewritable` is now `showable` ([#26089]). -* `is_apple`, `is_bsd`, `is_linux`, `is_unix`, and `is_windows` are now `Sys.isapple`, `Sys.isbsd`, - `Sys.islinux`, `Sys.isunix`, and `Sys.iswindows`, respectively. These are available in the `Compat.Sys` - submodule. ([#22182]) - * `readstring` is replaced by methods of `read`. ([#22864]) `read(::IO, ::Type{String})`, `read(::AbstractString, ::Type{String})`, @@ -258,8 +252,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `trace` is now `tr`, available as `Compat.tr` ([#26365]). -* `JULIA_HOME` is now `Sys.BINDIR`, available in the `Compat.Sys` submodule. ([#25102]) - * `Associative` is now `AbstractDict` ([#25012]). * `indices` is now `axes` ([#25057]). This function is not exported from Compat to avoid diff --git a/src/Compat.jl b/src/Compat.jl index fddaa2c52..eed742933 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -12,79 +12,15 @@ module TypeUtils end # module TypeUtils import Base.invokelatest const macros_have_sourceloc = true - -include("compatmacro.jl") - -# https://github.com/JuliaLang/julia/pull/22182 module Sys const KERNEL = Base.Sys.KERNEL - @static if VERSION < v"0.7.0-DEV.914" - isapple(k::Symbol=KERNEL) = k in (:Darwin, :Apple) - isbsd(k::Symbol=KERNEL) = isapple(k) || k in (:FreeBSD, :OpenBSD, :NetBSD, :DragonFly) - islinux(k::Symbol=KERNEL) = k == :Linux - isunix(k::Symbol=KERNEL) = isbsd(k) || islinux(k) - iswindows(k::Symbol=KERNEL) = k in (:Windows, :NT) - else - import Base.Sys: isapple, isbsd, islinux, isunix, iswindows - end - - @static if VERSION < v"0.7.0-DEV.5171" - using ..Compat: pushfirst! - - function isexecutable(path::AbstractString) - if iswindows() - isfile(path) - else - ccall(:access, Cint, (Ptr{UInt8}, Cint), path, 0x01) == 0 - end - end + import Base.Sys: isapple, isbsd, islinux, isunix, iswindows + import Base.Sys: which, isexecutable + BINDIR = Base.Sys.BINDIR +end - function which(program::AbstractString) - progs = String[] - base = basename(program) - if iswindows() - isempty(last(splitext(base))) || push!(progs, base) - for p = [".exe", ".com"] - push!(progs, base * p) - end - else - push!(progs, base) - end - dirs = String[] - dir = dirname(program) - if isempty(dir) - pathsep = iswindows() ? ';' : ':' - append!(dirs, map(abspath, split(get(ENV, "PATH", ""), pathsep))) - iswindows() && pushfirst!(dirs, pwd()) - else - push!(dirs, abspath(dir)) - end - for d in dirs, p in progs - path = joinpath(d, p) - isexecutable(path) && return realpath(path) - end - nothing - end - elseif VERSION < v"0.7.0-alpha.6" - import Base.Sys: isexecutable - - which(program::AbstractString) = try - Base.Sys.which(program) - catch err - err isa ErrorException || rethrow(err) - nothing - end - else - import Base.Sys: which, isexecutable - end - # https://github.com/JuliaLang/julia/pull/25102 - # NOTE: This needs to be in an __init__ because JULIA_HOME is not - # defined when building system images. - function __init__() - global BINDIR = VERSION < v"0.7.0-DEV.3073" ? JULIA_HOME : Base.Sys.BINDIR - end -end +include("compatmacro.jl") @static if VERSION < v"0.7.0-DEV.892" fieldcount(t) = nfields(t) diff --git a/test/old.jl b/test/old.jl index fc4776be3..514d71207 100644 --- a/test/old.jl +++ b/test/old.jl @@ -36,6 +36,28 @@ let foo() = begin @test foo() == 2 end +for os in [:apple, :bsd, :linux, :unix, :windows] + from_base = if VERSION >= v"0.7.0-DEV.914" + Expr(:., Expr(:., :Base, Base.Meta.quot(:Sys)), Base.Meta.quot(Symbol("is", os))) + else + Expr(:., :Base, Base.Meta.quot(Symbol("is_", os))) + end + @eval @test Compat.Sys.$(Symbol("is", os))() == $from_base() +end + +# 0.7.0-DEV.3073 +@test Compat.Sys.BINDIR == Sys.BINDIR + +# 0.7.0-DEV.5171 +let sep = Compat.Sys.iswindows() ? ';' : ':' + withenv("PATH" => string(Compat.Sys.BINDIR, sep, get(ENV, "PATH", ""))) do + jl = joinpath(Compat.Sys.BINDIR, "julia") * (Compat.Sys.iswindows() ? ".exe" : "") + @test Compat.Sys.which("julia") == realpath(jl) + @test Compat.Sys.isexecutable(jl) + @test Compat.Sys.which("reallyseriouslynotathingyoushouldhave") === nothing + end +end + # tests of removed functionality (i.e. justs tests Base) diff --git a/test/runtests.jl b/test/runtests.jl index 23ffbf2ff..928ce834c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -7,15 +7,6 @@ using Compat.SparseArrays const struct_sym = VERSION < v"0.7.0-DEV.1263" ? :type : :struct -for os in [:apple, :bsd, :linux, :unix, :windows] - from_base = if VERSION >= v"0.7.0-DEV.914" - Expr(:., Expr(:., :Base, Base.Meta.quot(:Sys)), Base.Meta.quot(Symbol("is", os))) - else - Expr(:., :Base, Base.Meta.quot(Symbol("is_", os))) - end - @eval @test Compat.Sys.$(Symbol("is", os))() == $from_base() -end - let s = "Koala test: 🐨" @test transcode(UInt16, s) == UInt16[75,111,97,108,97,32,116,101,115,116,58,32,55357,56360] @test transcode(UInt32, s) == UInt32[75,111,97,108,97,32,116,101,115,116,58,32,128040] @@ -320,13 +311,6 @@ end @test ComplexF32 === Complex{Float32} @test ComplexF64 === Complex{Float64} -# 0.7.0-DEV.3073 -if VERSION < v"0.7.0-DEV.3073" - @test Compat.Sys.BINDIR == JULIA_HOME -else - @test Compat.Sys.BINDIR == Sys.BINDIR -end - # 0.7.0-DEV.2915 module Test25021 using Compat @@ -1175,16 +1159,6 @@ let s = "∀α>β:α+1>β" end end -# 0.7.0-DEV.5171 -let sep = Compat.Sys.iswindows() ? ';' : ':' - withenv("PATH" => string(Compat.Sys.BINDIR, sep, get(ENV, "PATH", ""))) do - jl = joinpath(Compat.Sys.BINDIR, "julia") * (Compat.Sys.iswindows() ? ".exe" : "") - @test Compat.Sys.which("julia") == realpath(jl) - @test Compat.Sys.isexecutable(jl) - @test Compat.Sys.which("reallyseriouslynotathingyoushouldhave") === nothing - end -end - # julia#24839 @test permutedims([1 2; 3 4]) == [1 3; 2 4] @test permutedims([1,2,3]) == [1 2 3] From 4115e15a90ec80761ecc598e40078056e31557c4 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 1 Oct 2019 16:56:09 +0200 Subject: [PATCH 017/121] Drop compat code for `fieldcount` from #386 --- README.md | 3 --- src/Compat.jl | 5 ----- test/old.jl | 8 ++++++++ test/runtests.jl | 5 ----- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 78f7d5314..c41848bbe 100644 --- a/README.md +++ b/README.md @@ -120,9 +120,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `isnothing` for testing if a variable is equal to `nothing` ([#29674]). -* `fieldcount` is equivalent to `nfields` for Julia versions 0.6 and below and is used to - determine the number of fields in a data type ([#22350]). - * There are versions of `InexactError`, `DomainError`, and `OverflowError` that take the same arguments as introduced in Julia 0.7-DEV ([#20005], [#22751], [#22761]). * `Base.rtoldefault` how takes a third parameter `atol`. diff --git a/src/Compat.jl b/src/Compat.jl index eed742933..c86e2e021 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -22,11 +22,6 @@ end include("compatmacro.jl") -@static if VERSION < v"0.7.0-DEV.892" - fieldcount(t) = nfields(t) - export fieldcount -end - if VERSION < v"0.7.0-DEV.1053" Base.read(obj::IO, ::Type{String}) = readstring(obj) Base.read(obj::AbstractString, ::Type{String}) = readstring(obj) diff --git a/test/old.jl b/test/old.jl index 514d71207..31b8e3c8e 100644 --- a/test/old.jl +++ b/test/old.jl @@ -196,3 +196,11 @@ let coolvec = [1,2,3] @test pushfirst!(coolvec, 0) == [0,1,2,3] @test popfirst!(coolvec) == 0 end + +# PR 22350 +struct TestType + a::Int + b +end +@test fieldcount(TestType) == 2 +@test fieldcount(Int) == 0 diff --git a/test/runtests.jl b/test/runtests.jl index 928ce834c..4d60ddc0d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -72,11 +72,6 @@ if VERSION < v"0.7.0-DEV.880" end end -# PR 22350 -eval(Expr(struct_sym, false, :TestType, Expr(:block, :(a::Int), :b))) -@test fieldcount(TestType) == 2 -@test fieldcount(Int) == 0 - # PR 20005 @test_throws InexactError throw(InexactError(:func, Int, 3.2)) From 8759c3397f180a057d0ec231284a6f20ce0f2d18 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 1 Oct 2019 17:01:55 +0200 Subject: [PATCH 018/121] Drop compat code for `read(obj, ::Type{String})` from #385 and #580 --- README.md | 5 ----- src/Compat.jl | 6 ------ test/old.jl | 8 ++++++++ test/runtests.jl | 8 -------- 4 files changed, 8 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index c41848bbe..20b5b9cd1 100644 --- a/README.md +++ b/README.md @@ -224,11 +224,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `reprmime(mime, x)` is now `repr(mime, x)` ([#25990]) and `mimewritable` is now `showable` ([#26089]). -* `readstring` is replaced by methods of `read`. ([#22864]) - - `read(::IO, ::Type{String})`, `read(::AbstractString, ::Type{String})`, - and `read(::AbstractCmd, ::Type{String})` are defined for 0.6 and below. - * `Range` is now `AbstractRange` ([#23570]) * `select`* functions (`select`, `select!`, `selectperm`, `selectperm!`) are renamed to diff --git a/src/Compat.jl b/src/Compat.jl index c86e2e021..6877d44ac 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -22,12 +22,6 @@ end include("compatmacro.jl") -if VERSION < v"0.7.0-DEV.1053" - Base.read(obj::IO, ::Type{String}) = readstring(obj) - Base.read(obj::AbstractString, ::Type{String}) = readstring(obj) - Base.read(obj::Base.AbstractCmd, ::Type{String}) = readstring(obj) -end - # https://github.com/JuliaLang/julia/pull/20005 if VERSION < v"0.7.0-DEV.896" Base.InexactError(name::Symbol, T, val) = InexactError() diff --git a/test/old.jl b/test/old.jl index 31b8e3c8e..f9e6f2541 100644 --- a/test/old.jl +++ b/test/old.jl @@ -204,3 +204,11 @@ struct TestType end @test fieldcount(TestType) == 2 @test fieldcount(Int) == 0 + +# 0.7 +@test read(IOBuffer("aaaa"), String) == "aaaa" +@test occursin("read(@__FILE__, String)", read(@__FILE__, String)) +let cmd = `$(Base.julia_cmd()) --startup-file=no -e "println(:aaaa)"` + @test read(cmd, String) == "aaaa\n" + @test read(pipeline(cmd, stderr=devnull), String) == "aaaa\n" +end diff --git a/test/runtests.jl b/test/runtests.jl index 4d60ddc0d..44792cba6 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -110,14 +110,6 @@ let @test vec([b for (a,b) in pairs(IndexCartesian(), A14)]) == [11,12,13,14] end -# 0.7 -@test read(IOBuffer("aaaa"), String) == "aaaa" -@test occursin("read(@__FILE__, String)", read(@__FILE__, String)) -let cmd = `$(Base.julia_cmd()) --startup-file=no -e "println(:aaaa)"` - @test read(cmd, String) == "aaaa\n" - @test read(pipeline(cmd, stderr=devnull), String) == "aaaa\n" -end - # 0.7 @test isa(1:2, AbstractRange) From 6f8c3be426b2125c59c28c1be668263c32843f8a Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 1 Oct 2019 17:05:30 +0200 Subject: [PATCH 019/121] Drop compat code for `InexactError`, `DomainError`, and `OverflowError` constructors from #393 --- README.md | 2 -- src/Compat.jl | 16 ---------------- test/old.jl | 10 ++++++++++ test/runtests.jl | 10 ---------- 4 files changed, 10 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 20b5b9cd1..fc80fbc74 100644 --- a/README.md +++ b/README.md @@ -120,8 +120,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `isnothing` for testing if a variable is equal to `nothing` ([#29674]). -* There are versions of `InexactError`, `DomainError`, and `OverflowError` that take the same arguments as introduced in Julia 0.7-DEV ([#20005], [#22751], [#22761]). - * `Base.rtoldefault` how takes a third parameter `atol`. The two argument form is deprecated in favor of the three arguments form with `atol=0`. diff --git a/src/Compat.jl b/src/Compat.jl index 6877d44ac..79dc9e219 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -22,22 +22,6 @@ end include("compatmacro.jl") -# https://github.com/JuliaLang/julia/pull/20005 -if VERSION < v"0.7.0-DEV.896" - Base.InexactError(name::Symbol, T, val) = InexactError() -end - -# https://github.com/JuliaLang/julia/pull/22751 -if VERSION < v"0.7.0-DEV.924" - Base.DomainError(val) = DomainError() - Base.DomainError(val, msg) = DomainError() -end - -# https://github.com/JuliaLang/julia/pull/22761 -if VERSION < v"0.7.0-DEV.1285" - Base.OverflowError(msg) = OverflowError() -end - if VERSION < v"0.7.0-DEV.755" # This is a hack to only add keyword signature that won't work on all julia versions. # However, since we really only need to support a few (0.5, 0.6 and early 0.7) versions diff --git a/test/old.jl b/test/old.jl index f9e6f2541..beb504fe8 100644 --- a/test/old.jl +++ b/test/old.jl @@ -212,3 +212,13 @@ let cmd = `$(Base.julia_cmd()) --startup-file=no -e "println(:aaaa)"` @test read(cmd, String) == "aaaa\n" @test read(pipeline(cmd, stderr=devnull), String) == "aaaa\n" end + +# PR 20005 +@test_throws InexactError throw(InexactError(:func, Int, 3.2)) + +# PR 22751 +@test_throws DomainError throw(DomainError(-2)) +@test_throws DomainError throw(DomainError(-2, "negative")) + +# PR 22761 +@test_throws OverflowError throw(OverflowError("overflow")) diff --git a/test/runtests.jl b/test/runtests.jl index 44792cba6..b5c4e3c49 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -72,16 +72,6 @@ if VERSION < v"0.7.0-DEV.880" end end -# PR 20005 -@test_throws InexactError throw(InexactError(:func, Int, 3.2)) - -# PR 22751 -@test_throws DomainError throw(DomainError(-2)) -@test_throws DomainError throw(DomainError(-2, "negative")) - -# PR 22761 -@test_throws OverflowError throw(OverflowError("overflow")) - # PR 22907 using Compat: pairs From c980fda799c1d66070bf79ea1f464bec71139ab5 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 1 Oct 2019 17:13:34 +0200 Subject: [PATCH 020/121] Drop compat for `corrected` kw arg to `cov` from #401 --- README.md | 2 -- src/Compat.jl | 29 ----------------------------- test/runtests.jl | 14 -------------- 3 files changed, 45 deletions(-) diff --git a/README.md b/README.md index fc80fbc74..d301c024c 100644 --- a/README.md +++ b/README.md @@ -123,8 +123,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `Base.rtoldefault` how takes a third parameter `atol`. The two argument form is deprecated in favor of the three arguments form with `atol=0`. -* The `corrected` optional argument of `cov` becomes a keyword argument of `Compat.Statistics.cov` ([#21709]). - * `isequal`, `==` and `in` have one argument "curried" forms. For example `isequal(x)` returns a function that compares its arguments to `x` using `isequal` ([#26436]). diff --git a/src/Compat.jl b/src/Compat.jl index 79dc9e219..908509736 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -22,35 +22,6 @@ end include("compatmacro.jl") -if VERSION < v"0.7.0-DEV.755" - # This is a hack to only add keyword signature that won't work on all julia versions. - # However, since we really only need to support a few (0.5, 0.6 and early 0.7) versions - # this should be good enough. - # TODO add deprecation warning to switch to StatsBase - let Tf = typeof(Base.cov), Tkw = Core.Core.kwftype(Tf) - @eval begin - @inline function _get_corrected(kws) - corrected = true - nkw = length(kws) >> 1 - for i in 1:nkw - if kws[i * 2 - 1] !== :corrected - Base.kwerr(kws) - end - corrected = kws[i * 2] - end - return corrected::Bool - end - (::$Tkw)(kws::Vector{Any}, ::$Tf, x::AbstractVector) = Base.cov(x, _get_corrected(kws)) - (::$Tkw)(kws::Vector{Any}, ::$Tf, X::AbstractVector, Y::AbstractVector) = - Base.cov(X, Y, _get_corrected(kws)) - (::$Tkw)(kws::Vector{Any}, ::$Tf, x::AbstractMatrix, vardim::Int) = - Base.cov(x, vardim, _get_corrected(kws)) - (::$Tkw)(kws::Vector{Any}, ::$Tf, X::AbstractVecOrMat, Y::AbstractVecOrMat, - vardim::Int) = Base.cov(X, Y, vardim, _get_corrected(kws)) - end - end -end - # 0.7.0-DEV.1415 @static if !isdefined(Base, :adjoint) const adjoint = ctranspose diff --git a/test/runtests.jl b/test/runtests.jl index b5c4e3c49..d981c2226 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -140,20 +140,6 @@ end @test isa(Base.rtoldefault(Float64, Float64, 0), Float64) @test Base.rtoldefault(Float64, Float64, 1.0) === 0.0 -# 0.7 -if VERSION < v"0.7.0-DEV.5238" - # Test the extended cov if cov is part of Base. In the future, this will be dealt with - # in StatsBase - @test cov([1 2; 3 4], 1, corrected=true) == fill(2.0, 2, 2) - @test cov([1 2; 3 4], 1, corrected=false) == fill(1.0, 2, 2) - @test cov([1 2; 3 4], [0 4; 8 9], 1, corrected=true) == [8.0 5.0; 8.0 5.0] - @test cov([1 2; 3 4], [0 4; 8 9], 1, corrected=false) == [4.0 2.5; 4.0 2.5] - @test cov([1, 2], corrected=true) === 0.5 - @test cov([1, 2], corrected=false) === 0.25 - @test cov([1, 2], [0, 10], corrected=true) === 5.0 - @test cov([1, 2], [0, 10], corrected=false) === 2.5 -end - # 0.7 module Test23876 using Compat From 432238794fabd1f310e8ca5c61579b1a874d7e8e Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 1 Oct 2019 17:16:22 +0200 Subject: [PATCH 021/121] Drop compat code for `adjoint` from #401 --- README.md | 2 -- src/Compat.jl | 7 ------- test/old.jl | 11 +++++++++++ test/runtests.jl | 11 ----------- 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index d301c024c..2d6bc95ac 100644 --- a/README.md +++ b/README.md @@ -225,8 +225,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `select`* functions (`select`, `select!`, `selectperm`, `selectperm!`) are renamed to `partialsort`* (`partialsort`, `partialsort!`, `partialsortperm`, `partialsortperm!`) ([#23051]) -* `ctranspose` and `ctranspose!` are now `adjoint` and `adjoint!` ([#23235]) - * Math constants (`π`, `pi`, `e`, `γ`, `eulergamma`, `catalan`, `φ`, `golden`) are moved to the `MathConstants` module (available as `Compat.MathConstants`). The name exported from `Base` for `e` is changed to `ℯ`. ([#23427]) diff --git a/src/Compat.jl b/src/Compat.jl index 908509736..eeed85436 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -22,13 +22,6 @@ end include("compatmacro.jl") -# 0.7.0-DEV.1415 -@static if !isdefined(Base, :adjoint) - const adjoint = ctranspose - const adjoint! = ctranspose! - export adjoint, adjoint! -end - # 0.7.0-DEV.1592 @static if !isdefined(Base, :MathConstants) @eval module MathConstants diff --git a/test/old.jl b/test/old.jl index beb504fe8..365abfd67 100644 --- a/test/old.jl +++ b/test/old.jl @@ -222,3 +222,14 @@ end # PR 22761 @test_throws OverflowError throw(OverflowError("overflow")) + +# 0.7 +let M = [1 + 2im 3 + 4im; 5 + 6im 7 + 8im], + M2 = adjoint(copy(M)), + Mc = [1 - 2im 5 - 6im; 3 - 4im 7 - 8im] + + @test adjoint(M) == Mc + M2 .= 0 + adjoint!(M2, M) + @test M2 == Mc +end diff --git a/test/runtests.jl b/test/runtests.jl index d981c2226..38bcce16b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -103,17 +103,6 @@ end # 0.7 @test isa(1:2, AbstractRange) -# 0.7 -let M = [1 + 2im 3 + 4im; 5 + 6im 7 + 8im], - M2 = adjoint(copy(M)), - Mc = [1 - 2im 5 - 6im; 3 - 4im 7 - 8im] - - @test adjoint(M) == Mc - M2 .= 0 - adjoint!(M2, M) - @test M2 == Mc -end - # 0.7 module TestMathConstants using Compat.MathConstants From 31d306851749139836b73851a324cb21d8023835 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 1 Oct 2019 17:18:48 +0200 Subject: [PATCH 022/121] Mark `Compat.MathConstants` from #401 for future deprecation --- README.md | 4 ---- src/Compat.jl | 15 +-------------- test/old.jl | 13 +++++++++++++ test/runtests.jl | 13 ------------- 4 files changed, 14 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 2d6bc95ac..a576872fc 100644 --- a/README.md +++ b/README.md @@ -225,10 +225,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `select`* functions (`select`, `select!`, `selectperm`, `selectperm!`) are renamed to `partialsort`* (`partialsort`, `partialsort!`, `partialsortperm`, `partialsortperm!`) ([#23051]) -* Math constants (`π`, `pi`, `e`, `γ`, `eulergamma`, `catalan`, `φ`, `golden`) are moved to the - `MathConstants` module (available as `Compat.MathConstants`). - The name exported from `Base` for `e` is changed to `ℯ`. ([#23427]) - * `IntSet` is now `BitSet` ([#24282]) * `strwidth` and `charwidth` are now merged into `textwidth` ([#23667]). diff --git a/src/Compat.jl b/src/Compat.jl index eeed85436..252508b32 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -18,24 +18,11 @@ module Sys import Base.Sys: which, isexecutable BINDIR = Base.Sys.BINDIR end +import Base.MathConstants include("compatmacro.jl") -# 0.7.0-DEV.1592 -@static if !isdefined(Base, :MathConstants) - @eval module MathConstants - # All other ones are already exported by Base (so should be already in the users namespace) - # and will be automatically be in this module. - export ℯ - const ℯ = e - end - const ℯ = e - export ℯ -else - import Base.MathConstants -end - # 0.7.0-DEV.1535 @static if !isdefined(Base, :partialsort) const partialsort = select diff --git a/test/old.jl b/test/old.jl index 365abfd67..23e15f3c9 100644 --- a/test/old.jl +++ b/test/old.jl @@ -58,6 +58,19 @@ let sep = Compat.Sys.iswindows() ? ';' : ':' end end +# 0.7 +module TestMathConstants +using Compat.MathConstants +end +for name in [:π, :pi, :ℯ, :e, :γ, :eulergamma, :catalan, :φ, :golden] + @test isdefined(TestMathConstants, name) && !Base.isdeprecated(TestMathConstants, name) + @test isdefined(Compat.MathConstants, name) && !Base.isdeprecated(Compat.MathConstants, name) +end +module TestMathConstants2 +using Compat +end +@test isdefined(TestMathConstants2, :ℯ) && !Base.isdeprecated(TestMathConstants, :ℯ) + # tests of removed functionality (i.e. justs tests Base) diff --git a/test/runtests.jl b/test/runtests.jl index 38bcce16b..01f226dfc 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -103,19 +103,6 @@ end # 0.7 @test isa(1:2, AbstractRange) -# 0.7 -module TestMathConstants -using Compat.MathConstants -end -for name in [:π, :pi, :ℯ, :e, :γ, :eulergamma, :catalan, :φ, :golden] - @test isdefined(TestMathConstants, name) && !Base.isdeprecated(TestMathConstants, name) - @test isdefined(Compat.MathConstants, name) && !Base.isdeprecated(Compat.MathConstants, name) -end -module TestMathConstants2 -using Compat -end -@test isdefined(TestMathConstants2, :ℯ) && !Base.isdeprecated(TestMathConstants, :ℯ) - # 0.7 @test partialsort([3,6,30,1,9], 2, rev=true) == 9 @test partialsort([3,6,30,1,9], 2, by=x->1/x) == 9 From 5efb7e59dd79aa83f43b10cf0da29f66a13b212f Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 1 Oct 2019 17:20:43 +0200 Subject: [PATCH 023/121] Drop compat code for `partialsort` from #401 --- README.md | 3 --- src/Compat.jl | 9 --------- test/old.jl | 6 ++++++ test/runtests.jl | 6 ------ 4 files changed, 6 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index a576872fc..26207cc67 100644 --- a/README.md +++ b/README.md @@ -222,9 +222,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `Range` is now `AbstractRange` ([#23570]) -* `select`* functions (`select`, `select!`, `selectperm`, `selectperm!`) are renamed to - `partialsort`* (`partialsort`, `partialsort!`, `partialsortperm`, `partialsortperm!`) ([#23051]) - * `IntSet` is now `BitSet` ([#24282]) * `strwidth` and `charwidth` are now merged into `textwidth` ([#23667]). diff --git a/src/Compat.jl b/src/Compat.jl index 252508b32..32d35847f 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -23,15 +23,6 @@ import Base.MathConstants include("compatmacro.jl") -# 0.7.0-DEV.1535 -@static if !isdefined(Base, :partialsort) - const partialsort = select - const partialsort! = select! - const partialsortperm = selectperm - const partialsortperm! = selectperm! - export partialsort, partialsort!, partialsortperm, partialsortperm! -end - # 0.7.0-DEV.1660 @static if !isdefined(Base, :pairs) pairs(collection) = Base.Generator(=>, keys(collection), values(collection)) diff --git a/test/old.jl b/test/old.jl index 23e15f3c9..6ddccff8c 100644 --- a/test/old.jl +++ b/test/old.jl @@ -246,3 +246,9 @@ let M = [1 + 2im 3 + 4im; 5 + 6im 7 + 8im], adjoint!(M2, M) @test M2 == Mc end + +# 0.7 +@test partialsort([3,6,30,1,9], 2, rev=true) == 9 +@test partialsort([3,6,30,1,9], 2, by=x->1/x) == 9 +@test partialsortperm([3,6,30,1,9], 2, rev=true) == 5 +@test partialsortperm([3,6,30,1,9], 2, by=x->1/x) == 5 diff --git a/test/runtests.jl b/test/runtests.jl index 01f226dfc..0e57e5e84 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -103,12 +103,6 @@ end # 0.7 @test isa(1:2, AbstractRange) -# 0.7 -@test partialsort([3,6,30,1,9], 2, rev=true) == 9 -@test partialsort([3,6,30,1,9], 2, by=x->1/x) == 9 -@test partialsortperm([3,6,30,1,9], 2, rev=true) == 5 -@test partialsortperm([3,6,30,1,9], 2, by=x->1/x) == 5 - # 0.7 @test isa(Base.rtoldefault(1.0, 2.0, 0), Float64) @test isa(Base.rtoldefault(Float64, 2.0, 0), Float64) From 017689aae5b0d8af859a45c926ae5623a2eecfc9 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 1 Oct 2019 17:23:35 +0200 Subject: [PATCH 024/121] Drop compat code for `pairs` from #428 --- README.md | 2 -- src/Compat.jl | 17 ----------------- test/old.jl | 28 ++++++++++++++++++++++++++++ test/runtests.jl | 28 ---------------------------- 4 files changed, 28 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index 26207cc67..ea7c504df 100644 --- a/README.md +++ b/README.md @@ -143,8 +143,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `IOContext` accepting key-value `Pair`s ([#23271]). -* `pairs` for iterating over key-value `Pair`s ([#22907]). - * `get` do-block syntax supported when using `ENV` ([#23412]). * `Some{T}` wraps `T` to signify that a result of `T<:Void` is expected ([#23642]). diff --git a/src/Compat.jl b/src/Compat.jl index 32d35847f..0c7fbc5a3 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -23,23 +23,6 @@ import Base.MathConstants include("compatmacro.jl") -# 0.7.0-DEV.1660 -@static if !isdefined(Base, :pairs) - pairs(collection) = Base.Generator(=>, keys(collection), values(collection)) - pairs(a::Associative) = a - - const IndexValue = Iterators.IndexValue - - pairs(::IndexLinear, A::AbstractArray) = IndexValue(A, linearindices(A)) - pairs(::IndexCartesian, A::AbstractArray) = IndexValue(A, CartesianRange(indices(A))) - - Base.keys(a::AbstractArray) = CartesianRange(indices(a)) - Base.keys(a::AbstractVector) = linearindices(a) - Base.keys(s::IndexStyle, A::AbstractArray, B::AbstractArray...) = eachindex(s, A, B...) - - Base.values(itr) = itr -end - # 0.7.0-DEV.1721 @static if !isdefined(Base, :AbstractRange) const AbstractRange = Range diff --git a/test/old.jl b/test/old.jl index 6ddccff8c..06fe88b52 100644 --- a/test/old.jl +++ b/test/old.jl @@ -252,3 +252,31 @@ end @test partialsort([3,6,30,1,9], 2, by=x->1/x) == 9 @test partialsortperm([3,6,30,1,9], 2, rev=true) == 5 @test partialsortperm([3,6,30,1,9], 2, by=x->1/x) == 5 + +# PR 22907 +using Compat: pairs + +# keys, values, pairs +for A in (rand(2), rand(2,3)) + local A + for (i, v) in pairs(A) + @test A[i] == v + end + @test collect(values(A)) == collect(A) +end + +let A = Dict(:foo=>1, :bar=>3) + for (k, v) in pairs(A) + @test A[k] == v + end + @test sort!(collect(pairs(A))) == sort!(collect(A)) +end + +let + A14 = [11 13; 12 14] + R = CartesianIndices(Compat.axes(A14)) + @test vec([a for (a,b) in pairs(IndexLinear(), A14)]) == [1,2,3,4] + @test vec([a for (a,b) in pairs(IndexCartesian(), A14)]) == vec(collect(R)) + @test vec([b for (a,b) in pairs(IndexLinear(), A14)]) == [11,12,13,14] + @test vec([b for (a,b) in pairs(IndexCartesian(), A14)]) == [11,12,13,14] +end diff --git a/test/runtests.jl b/test/runtests.jl index 0e57e5e84..4a2f9cb0e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -72,34 +72,6 @@ if VERSION < v"0.7.0-DEV.880" end end -# PR 22907 -using Compat: pairs - -# keys, values, pairs -for A in (rand(2), rand(2,3)) - local A - for (i, v) in pairs(A) - @test A[i] == v - end - @test collect(values(A)) == collect(A) -end - -let A = Dict(:foo=>1, :bar=>3) - for (k, v) in pairs(A) - @test A[k] == v - end - @test sort!(collect(pairs(A))) == sort!(collect(A)) -end - -let - A14 = [11 13; 12 14] - R = CartesianIndices(Compat.axes(A14)) - @test vec([a for (a,b) in pairs(IndexLinear(), A14)]) == [1,2,3,4] - @test vec([a for (a,b) in pairs(IndexCartesian(), A14)]) == vec(collect(R)) - @test vec([b for (a,b) in pairs(IndexLinear(), A14)]) == [11,12,13,14] - @test vec([b for (a,b) in pairs(IndexCartesian(), A14)]) == [11,12,13,14] -end - # 0.7 @test isa(1:2, AbstractRange) From 72af01434aa14d8c50c017e22e8c1c25af49c326 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 1 Oct 2019 17:25:12 +0200 Subject: [PATCH 025/121] Drop compat code for `AbstractRange` from #400 --- README.md | 2 -- src/Compat.jl | 6 ------ test/old.jl | 3 +++ test/runtests.jl | 3 --- 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index ea7c504df..84c2760e0 100644 --- a/README.md +++ b/README.md @@ -218,8 +218,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `reprmime(mime, x)` is now `repr(mime, x)` ([#25990]) and `mimewritable` is now `showable` ([#26089]). -* `Range` is now `AbstractRange` ([#23570]) - * `IntSet` is now `BitSet` ([#24282]) * `strwidth` and `charwidth` are now merged into `textwidth` ([#23667]). diff --git a/src/Compat.jl b/src/Compat.jl index 0c7fbc5a3..db75df9b4 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -23,12 +23,6 @@ import Base.MathConstants include("compatmacro.jl") -# 0.7.0-DEV.1721 -@static if !isdefined(Base, :AbstractRange) - const AbstractRange = Range - export AbstractRange -end - if VERSION < v"0.7.0-DEV.1325" function Base.rtoldefault(x, y, atol::Real) T = isa(x, Type) ? x : typeof(x) diff --git a/test/old.jl b/test/old.jl index 06fe88b52..f6e351dc4 100644 --- a/test/old.jl +++ b/test/old.jl @@ -280,3 +280,6 @@ let @test vec([b for (a,b) in pairs(IndexLinear(), A14)]) == [11,12,13,14] @test vec([b for (a,b) in pairs(IndexCartesian(), A14)]) == [11,12,13,14] end + +# 0.7 +@test isa(1:2, AbstractRange) diff --git a/test/runtests.jl b/test/runtests.jl index 4a2f9cb0e..9b696a433 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -72,9 +72,6 @@ if VERSION < v"0.7.0-DEV.880" end end -# 0.7 -@test isa(1:2, AbstractRange) - # 0.7 @test isa(Base.rtoldefault(1.0, 2.0, 0), Float64) @test isa(Base.rtoldefault(Float64, 2.0, 0), Float64) From b7343f7749c83bbedcabc98bb01e4e4f257b25b6 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 1 Oct 2019 17:27:05 +0200 Subject: [PATCH 026/121] Drop compat code for `rtoldefault` from #401 --- README.md | 3 --- src/Compat.jl | 9 --------- test/old.jl | 7 +++++++ test/runtests.jl | 7 ------- 4 files changed, 7 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 84c2760e0..680d7dfcc 100644 --- a/README.md +++ b/README.md @@ -120,9 +120,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `isnothing` for testing if a variable is equal to `nothing` ([#29674]). -* `Base.rtoldefault` how takes a third parameter `atol`. - The two argument form is deprecated in favor of the three arguments form with `atol=0`. - * `isequal`, `==` and `in` have one argument "curried" forms. For example `isequal(x)` returns a function that compares its arguments to `x` using `isequal` ([#26436]). diff --git a/src/Compat.jl b/src/Compat.jl index db75df9b4..8a0d63709 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -23,15 +23,6 @@ import Base.MathConstants include("compatmacro.jl") -if VERSION < v"0.7.0-DEV.1325" - function Base.rtoldefault(x, y, atol::Real) - T = isa(x, Type) ? x : typeof(x) - S = isa(y, Type) ? y : typeof(y) - rtol = max(Base.rtoldefault(real(T)), Base.rtoldefault(real(S))) - return atol > 0 ? zero(rtol) : rtol - end -end - # 0.7.0-DEV.2005 if VERSION < v"0.7.0-DEV.2005" const Mmap = Base.Mmap diff --git a/test/old.jl b/test/old.jl index f6e351dc4..f0c7d17b4 100644 --- a/test/old.jl +++ b/test/old.jl @@ -283,3 +283,10 @@ end # 0.7 @test isa(1:2, AbstractRange) + +# 0.7 +@test isa(Base.rtoldefault(1.0, 2.0, 0), Float64) +@test isa(Base.rtoldefault(Float64, 2.0, 0), Float64) +@test isa(Base.rtoldefault(1.0, Float64, 0), Float64) +@test isa(Base.rtoldefault(Float64, Float64, 0), Float64) +@test Base.rtoldefault(Float64, Float64, 1.0) === 0.0 diff --git a/test/runtests.jl b/test/runtests.jl index 9b696a433..e4011ed37 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -72,13 +72,6 @@ if VERSION < v"0.7.0-DEV.880" end end -# 0.7 -@test isa(Base.rtoldefault(1.0, 2.0, 0), Float64) -@test isa(Base.rtoldefault(Float64, 2.0, 0), Float64) -@test isa(Base.rtoldefault(1.0, Float64, 0), Float64) -@test isa(Base.rtoldefault(Float64, Float64, 0), Float64) -@test Base.rtoldefault(Float64, Float64, 1.0) === 0.0 - # 0.7 module Test23876 using Compat From b50924be594aa37681e9f481dfaa985f6a85ddbe Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 1 Oct 2019 17:36:12 +0200 Subject: [PATCH 027/121] Mark `Compat.Test`, `Compat.SharedArrays`, `Compat.Mmap`, and `Compat.DelimitedFiles` from #404 for deprecation --- README.md | 4 ---- src/Compat.jl | 18 +----------------- test/old.jl | 15 +++++++++++++++ test/runtests.jl | 15 --------------- 4 files changed, 16 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 680d7dfcc..dcf8edb90 100644 --- a/README.md +++ b/README.md @@ -52,10 +52,6 @@ Currently, the `@compat` macro supports the following syntaxes: ## Module Aliases -* `using Compat.Test`, `using Compat.SharedArrays`, `using Compat.Mmap`, and `using - Compat.DelimitedFiles` are provided on versions older than 0.7, where these are not yet - part of the standard library. ([#23931]) - * `using Compat.Base64` is provided on versions older than 0.7, where this library is not yet a part of the standard library. ([#24361]) diff --git a/src/Compat.jl b/src/Compat.jl index 8a0d63709..e134f66b0 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -19,27 +19,11 @@ module Sys BINDIR = Base.Sys.BINDIR end import Base.MathConstants +import Test, SharedArrays, Mmap, DelimitedFiles include("compatmacro.jl") -# 0.7.0-DEV.2005 -if VERSION < v"0.7.0-DEV.2005" - const Mmap = Base.Mmap - const Test = Base.Test - @eval module SharedArrays - if isdefined(Base, :Distributed) - using Base.Distributed.procs - else - using Base.procs - end - export SharedArray, SharedMatrix, SharedVector, indexpids, localindexes, sdata, - procs - end - const DelimitedFiles = Base.DataFmt -else - import Test, SharedArrays, Mmap, DelimitedFiles -end if VERSION < v"0.7.0-DEV.2575" const Dates = Base.Dates diff --git a/test/old.jl b/test/old.jl index f0c7d17b4..826db73a5 100644 --- a/test/old.jl +++ b/test/old.jl @@ -71,6 +71,21 @@ using Compat end @test isdefined(TestMathConstants2, :ℯ) && !Base.isdeprecated(TestMathConstants, :ℯ) +# 0.7 +module Test23876 + using Compat + using Compat.Test + import Compat.DelimitedFiles + using Compat.Mmap, Compat.SharedArrays + using Compat.Distributed + @test isdefined(@__MODULE__, :DelimitedFiles) + @test isdefined(SharedArrays, :SharedArray) + @test isdefined(@__MODULE__, :SharedArray) + @test isdefined(@__MODULE__, :procs) + @test isdefined(@__MODULE__, :remote_do) + @test isdefined(Mmap, :mmap) +end + # tests of removed functionality (i.e. justs tests Base) diff --git a/test/runtests.jl b/test/runtests.jl index e4011ed37..c6f1d8eae 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -72,21 +72,6 @@ if VERSION < v"0.7.0-DEV.880" end end -# 0.7 -module Test23876 - using Compat - using Compat.Test - import Compat.DelimitedFiles - using Compat.Mmap, Compat.SharedArrays - using Compat.Distributed - @test isdefined(@__MODULE__, :DelimitedFiles) - @test isdefined(SharedArrays, :SharedArray) - @test isdefined(@__MODULE__, :SharedArray) - @test isdefined(@__MODULE__, :procs) - @test isdefined(@__MODULE__, :remote_do) - @test isdefined(Mmap, :mmap) -end - # 0.7 module Test24459 using Compat From 75b84115523deca87124fa9d2fe94cf6df16ceb7 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 1 Oct 2019 17:38:08 +0200 Subject: [PATCH 028/121] Mark `Compat.Dates` from #413 for deprecation --- README.md | 3 --- src/Compat.jl | 8 +------- test/old.jl | 8 ++++++++ test/runtests.jl | 8 -------- 4 files changed, 9 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index dcf8edb90..5ff8388ac 100644 --- a/README.md +++ b/README.md @@ -55,9 +55,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `using Compat.Base64` is provided on versions older than 0.7, where this library is not yet a part of the standard library. ([#24361]) -* `using Compat.Dates` is provided on versions older than 0.7, where this library is not - yet a part of the standard library. ([#24459]) - * `using Compat.Unicode` is provided on versions older than 0.7, where this library is not yet a part of the standard library. ([#25021]) diff --git a/src/Compat.jl b/src/Compat.jl index e134f66b0..cd394fe6c 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -20,17 +20,11 @@ module Sys end import Base.MathConstants import Test, SharedArrays, Mmap, DelimitedFiles +import Dates include("compatmacro.jl") - -if VERSION < v"0.7.0-DEV.2575" - const Dates = Base.Dates -else - import Dates -end - if VERSION < v"0.7.0-DEV.3382" const Libdl = Base.Libdl else diff --git a/test/old.jl b/test/old.jl index 826db73a5..06720c64e 100644 --- a/test/old.jl +++ b/test/old.jl @@ -86,6 +86,14 @@ module Test23876 @test isdefined(Mmap, :mmap) end +# 0.7 +module Test24459 + using Compat + using Compat.Test + using Compat.Dates + @test isdefined(@__MODULE__, :Dates) +end + # tests of removed functionality (i.e. justs tests Base) diff --git a/test/runtests.jl b/test/runtests.jl index c6f1d8eae..eacd316f2 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -72,14 +72,6 @@ if VERSION < v"0.7.0-DEV.880" end end -# 0.7 -module Test24459 - using Compat - using Compat.Test - using Compat.Dates - @test isdefined(@__MODULE__, :Dates) -end - # 0.7 module Test25056 using Compat From b3deb1332e1e385bc8cb69d7df3a2895d66ba818 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 1 Oct 2019 17:41:29 +0200 Subject: [PATCH 029/121] Mark `Compat.Libdl` from #465 (and #467) for deprecation --- README.md | 3 --- src/Compat.jl | 7 +------ test/old.jl | 8 ++++++++ test/runtests.jl | 8 -------- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 5ff8388ac..5911cf535 100644 --- a/README.md +++ b/README.md @@ -70,9 +70,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `using Compat.Random` is provided on versions older than 0.7, where this library is not yet part of the standard library ([#24874]). -* `using Compat.Libdl` is provided on versions older than 0.7, where this library is - not yet part of the standard library ([#25459]). - * `using Compat.REPL` is provided on versions older than 0.7, where this library is not yet part of the standard library ([#25544]). diff --git a/src/Compat.jl b/src/Compat.jl index cd394fe6c..eb4f10023 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -21,16 +21,11 @@ end import Base.MathConstants import Test, SharedArrays, Mmap, DelimitedFiles import Dates +import Libdl include("compatmacro.jl") -if VERSION < v"0.7.0-DEV.3382" - const Libdl = Base.Libdl -else - import Libdl -end - # https://github.com/JuliaLang/julia/pull/24182 if VERSION < v"0.7.0-DEV.2402" const ConvertiblePeriod = Union{Compat.Dates.TimePeriod, Compat.Dates.Week, Compat.Dates.Day} diff --git a/test/old.jl b/test/old.jl index 06720c64e..c0981ae85 100644 --- a/test/old.jl +++ b/test/old.jl @@ -94,6 +94,14 @@ module Test24459 @test isdefined(@__MODULE__, :Dates) end +# 0.7.0-DEV.3382 +module TestLibdl + using Compat + using Compat.Libdl + using Compat.Test + @test isdefined(@__MODULE__, :Libdl) +end + # tests of removed functionality (i.e. justs tests Base) diff --git a/test/runtests.jl b/test/runtests.jl index eacd316f2..5b88d3a28 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -412,14 +412,6 @@ end @test nameof(Float64) == :Float64 @test nameof(Array) == :Array -# 0.7.0-DEV.3382 -module TestLibdl - using Compat - using Compat.Libdl - using Compat.Test - @test isdefined(@__MODULE__, :Libdl) -end - # 0.7.0-DEV.3516 @test argmax([10,12,9,11]) == 2 @test argmax([10 12; 9 11]) == CartesianIndex(1, 2) From 53160617149fbdf08de13a356972e6789e69c43a Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 1 Oct 2019 17:48:05 +0200 Subject: [PATCH 030/121] Drop compat code for `Dates.Period` rounding from #462 --- README.md | 2 - src/Compat.jl | 119 ----------------------------------------------- test/old.jl | 73 +++++++++++++++++++++++++++++ test/runtests.jl | 73 ----------------------------- 4 files changed, 73 insertions(+), 194 deletions(-) diff --git a/README.md b/README.md index 5911cf535..c0f38ebd1 100644 --- a/README.md +++ b/README.md @@ -151,8 +151,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `printstyled` prints to a given stream optionally in color and/or bolded ([#25522]). -* `Dates.Period` rounding (e.g., `round(Dates.Hour(36), Dates.Day, RoundNearestTiesUp) == Dates.Day(2)` ([#24182]). - * `firstindex` to obtain the first index of an iterable ([#25458]). * `Compat.names` supporting keyword arguments for `all` and `imported` ([#25647]). diff --git a/src/Compat.jl b/src/Compat.jl index eb4f10023..741df7ca5 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -26,125 +26,6 @@ import Libdl include("compatmacro.jl") -# https://github.com/JuliaLang/julia/pull/24182 -if VERSION < v"0.7.0-DEV.2402" - const ConvertiblePeriod = Union{Compat.Dates.TimePeriod, Compat.Dates.Week, Compat.Dates.Day} - const TimeTypeOrPeriod = Union{Compat.Dates.TimeType, Compat.ConvertiblePeriod} - - """ - floor(x::Period, precision::T) where T <: Union{TimePeriod, Week, Day} -> T - - Rounds `x` down to the nearest multiple of `precision`. If `x` and `precision` are different - subtypes of `Period`, the return value will have the same type as `precision`. - - For convenience, `precision` may be a type instead of a value: `floor(x, Dates.Hour)` is a - shortcut for `floor(x, Dates.Hour(1))`. - - ```jldoctest - julia> floor(Dates.Day(16), Dates.Week) - 2 weeks - - julia> floor(Dates.Minute(44), Dates.Minute(15)) - 30 minutes - - julia> floor(Dates.Hour(36), Dates.Day) - 1 day - ``` - - Rounding to a `precision` of `Month`s or `Year`s is not supported, as these `Period`s are of - inconsistent length. - """ - function Base.floor(x::Compat.ConvertiblePeriod, precision::T) where T <: Compat.ConvertiblePeriod - Compat.Dates.value(precision) < 1 && throw(DomainError(precision)) - _x, _precision = promote(x, precision) - return T(_x - mod(_x, _precision)) - end - - """ - ceil(x::Period, precision::T) where T <: Union{TimePeriod, Week, Day} -> T - - Rounds `x` up to the nearest multiple of `precision`. If `x` and `precision` are different - subtypes of `Period`, the return value will have the same type as `precision`. - - For convenience, `precision` may be a type instead of a value: `ceil(x, Dates.Hour)` is a - shortcut for `ceil(x, Dates.Hour(1))`. - - ```jldoctest - julia> ceil(Dates.Day(16), Dates.Week) - 3 weeks - - julia> ceil(Dates.Minute(44), Dates.Minute(15)) - 45 minutes - - julia> ceil(Dates.Hour(36), Dates.Day) - 3 days - ``` - - Rounding to a `precision` of `Month`s or `Year`s is not supported, as these `Period`s are of - inconsistent length. - """ - function Base.ceil(x::Compat.ConvertiblePeriod, precision::Compat.ConvertiblePeriod) - f = Base.floor(x, precision) - return (x == f) ? f : f + precision - end - - """ - floorceil(x::Period, precision::T) where T <: Union{TimePeriod, Week, Day} -> (T, T) - - Simultaneously return the `floor` and `ceil` of `Period` at resolution `p`. More efficient - than calling both `floor` and `ceil` individually. - """ - function floorceil(x::Compat.ConvertiblePeriod, precision::Compat.ConvertiblePeriod) - f = Base.floor(x, precision) - return f, (x == f) ? f : f + precision - end - - """ - round(x::Period, precision::T, [r::RoundingMode]) where T <: Union{TimePeriod, Week, Day} -> T - - Rounds `x` to the nearest multiple of `precision`. If `x` and `precision` are different - subtypes of `Period`, the return value will have the same type as `precision`. By default - (`RoundNearestTiesUp`), ties (e.g., rounding 90 minutes to the nearest hour) will be rounded - up. - - For convenience, `precision` may be a type instead of a value: `round(x, Dates.Hour)` is a - shortcut for `round(x, Dates.Hour(1))`. - - ```jldoctest - julia> round(Dates.Day(16), Dates.Week) - 2 weeks - - julia> round(Dates.Minute(44), Dates.Minute(15)) - 45 minutes - - julia> round(Dates.Hour(36), Dates.Day) - 3 days - ``` - - Valid rounding modes for `round(::Period, ::T, ::RoundingMode)` are `RoundNearestTiesUp` - (default), `RoundDown` (`floor`), and `RoundUp` (`ceil`). - - Rounding to a `precision` of `Month`s or `Year`s is not supported, as these `Period`s are of - inconsistent length. - """ - function Base.round(x::Compat.ConvertiblePeriod, precision::Compat.ConvertiblePeriod, r::RoundingMode{:NearestTiesUp}) - f, c = floorceil(x, precision) - _x, _f, _c = promote(x, f, c) - return (_x - _f) < (_c - _x) ? f : c - end - - Base.round(x::Compat.TimeTypeOrPeriod, p::Compat.Dates.Period, r::RoundingMode{:Down}) = Base.floor(x, p) - Base.round(x::Compat.TimeTypeOrPeriod, p::Compat.Dates.Period, r::RoundingMode{:Up}) = Base.ceil(x, p) - - Base.round(::Compat.TimeTypeOrPeriod, p::Compat.Dates.Period, ::RoundingMode) = throw(DomainError(p)) - Base.round(x::Compat.TimeTypeOrPeriod, p::Compat.Dates.Period) = Base.round(x, p, RoundNearestTiesUp) - Base.floor(x::Compat.TimeTypeOrPeriod, ::Type{P}) where P <: Compat.Dates.Period = Base.floor(x, oneunit(P)) - Base.ceil(x::Compat.TimeTypeOrPeriod, ::Type{P}) where P <: Compat.Dates.Period = Base.ceil(x, oneunit(P)) - function Base.round(x::Compat.TimeTypeOrPeriod, ::Type{P}, r::RoundingMode=RoundNearestTiesUp) where P <: Compat.Dates.Period - return Base.round(x, oneunit(P), r) - end -end - if VERSION < v"0.7.0-DEV.3216" const AbstractDateTime = Compat.Dates.TimeType else diff --git a/test/old.jl b/test/old.jl index c0981ae85..9fa123bd7 100644 --- a/test/old.jl +++ b/test/old.jl @@ -321,3 +321,76 @@ end @test isa(Base.rtoldefault(1.0, Float64, 0), Float64) @test isa(Base.rtoldefault(Float64, Float64, 0), Float64) @test Base.rtoldefault(Float64, Float64, 1.0) === 0.0 + +# 0.7.0-DEV.2402 + +x = Compat.Dates.Second(172799) +@test floor(x, Compat.Dates.Week) == Compat.Dates.Week(0) +@test floor(x, Compat.Dates.Day) == Compat.Dates.Day(1) +@test floor(x, Compat.Dates.Hour) == Compat.Dates.Hour(47) +@test floor(x, Compat.Dates.Minute) == Compat.Dates.Minute(2879) +@test floor(x, Compat.Dates.Second) == Compat.Dates.Second(172799) +@test floor(x, Compat.Dates.Millisecond) == Compat.Dates.Millisecond(172799000) +@test ceil(x, Compat.Dates.Week) == Compat.Dates.Week(1) +@test ceil(x, Compat.Dates.Day) == Compat.Dates.Day(2) +@test ceil(x, Compat.Dates.Hour) == Compat.Dates.Hour(48) +@test ceil(x, Compat.Dates.Minute) == Compat.Dates.Minute(2880) +@test ceil(x, Compat.Dates.Second) == Compat.Dates.Second(172799) +@test ceil(x, Compat.Dates.Millisecond) == Compat.Dates.Millisecond(172799000) +@test round(x, Compat.Dates.Week) == Compat.Dates.Week(0) +@test round(x, Compat.Dates.Day) == Compat.Dates.Day(2) +@test round(x, Compat.Dates.Hour) == Compat.Dates.Hour(48) +@test round(x, Compat.Dates.Minute) == Compat.Dates.Minute(2880) +@test round(x, Compat.Dates.Second) == Compat.Dates.Second(172799) +@test round(x, Compat.Dates.Millisecond) == Compat.Dates.Millisecond(172799000) + +x = Compat.Dates.Nanosecond(2000999999) +@test floor(x, Compat.Dates.Second) == Compat.Dates.Second(2) +@test floor(x, Compat.Dates.Millisecond) == Compat.Dates.Millisecond(2000) +@test floor(x, Compat.Dates.Microsecond) == Compat.Dates.Microsecond(2000999) +@test floor(x, Compat.Dates.Nanosecond) == x +@test ceil(x, Compat.Dates.Second) == Compat.Dates.Second(3) +@test ceil(x, Compat.Dates.Millisecond) == Compat.Dates.Millisecond(2001) +@test ceil(x, Compat.Dates.Microsecond) == Compat.Dates.Microsecond(2001000) +@test ceil(x, Compat.Dates.Nanosecond) == x +@test round(x, Compat.Dates.Second) == Compat.Dates.Second(2) +@test round(x, Compat.Dates.Millisecond) == Compat.Dates.Millisecond(2001) +@test round(x, Compat.Dates.Microsecond) == Compat.Dates.Microsecond(2001000) +@test round(x, Compat.Dates.Nanosecond) == x + + +for x in [Compat.Dates.Week(3), Compat.Dates.Day(14), Compat.Dates.Second(604800)] + local x + for p in [Compat.Dates.Week, Compat.Dates.Day, Compat.Dates.Hour, Compat.Dates.Second, Compat.Dates.Millisecond, Compat.Dates.Microsecond, Compat.Dates.Nanosecond] + local p + @test floor(x, p) == p(x) + @test ceil(x, p) == p(x) + end +end + +x = Compat.Dates.Hour(36) +@test round(x, Compat.Dates.Day, RoundNearestTiesUp) == Compat.Dates.Day(2) +@test round(x, Compat.Dates.Day, RoundUp) == Compat.Dates.Day(2) +@test round(x, Compat.Dates.Day, RoundDown) == Compat.Dates.Day(1) +@test_throws DomainError round(x, Compat.Dates.Day, RoundNearest) +@test_throws DomainError round(x, Compat.Dates.Day, RoundNearestTiesAway) +@test_throws DomainError round(x, Compat.Dates.Day, RoundToZero) +@test round(x, Compat.Dates.Day) == round(x, Compat.Dates.Day, RoundNearestTiesUp) + +x = Compat.Dates.Hour(86399) +for p in [Compat.Dates.Week, Compat.Dates.Day, Compat.Dates.Hour, Compat.Dates.Second, Compat.Dates.Millisecond, Compat.Dates.Microsecond, Compat.Dates.Nanosecond] + local p + for v in [-1, 0] + @test_throws DomainError floor(x, p(v)) + @test_throws DomainError ceil(x, p(v)) + @test_throws DomainError round(x, p(v)) + end +end +for p in [Compat.Dates.Year, Compat.Dates.Month] + local p + for v in [-1, 0, 1] + @test_throws MethodError floor(x, p(v)) + @test_throws MethodError ceil(x, p(v)) + @test_throws DomainError round(x, p(v)) + end +end diff --git a/test/runtests.jl b/test/runtests.jl index 5b88d3a28..d4aefef1e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -275,79 +275,6 @@ end @test Compat.AbstractDateTime <: Compat.Dates.TimeType @test Compat.Dates.DateTime <: Compat.AbstractDateTime -# 0.7.0-DEV.2402 - -x = Compat.Dates.Second(172799) -@test floor(x, Compat.Dates.Week) == Compat.Dates.Week(0) -@test floor(x, Compat.Dates.Day) == Compat.Dates.Day(1) -@test floor(x, Compat.Dates.Hour) == Compat.Dates.Hour(47) -@test floor(x, Compat.Dates.Minute) == Compat.Dates.Minute(2879) -@test floor(x, Compat.Dates.Second) == Compat.Dates.Second(172799) -@test floor(x, Compat.Dates.Millisecond) == Compat.Dates.Millisecond(172799000) -@test ceil(x, Compat.Dates.Week) == Compat.Dates.Week(1) -@test ceil(x, Compat.Dates.Day) == Compat.Dates.Day(2) -@test ceil(x, Compat.Dates.Hour) == Compat.Dates.Hour(48) -@test ceil(x, Compat.Dates.Minute) == Compat.Dates.Minute(2880) -@test ceil(x, Compat.Dates.Second) == Compat.Dates.Second(172799) -@test ceil(x, Compat.Dates.Millisecond) == Compat.Dates.Millisecond(172799000) -@test round(x, Compat.Dates.Week) == Compat.Dates.Week(0) -@test round(x, Compat.Dates.Day) == Compat.Dates.Day(2) -@test round(x, Compat.Dates.Hour) == Compat.Dates.Hour(48) -@test round(x, Compat.Dates.Minute) == Compat.Dates.Minute(2880) -@test round(x, Compat.Dates.Second) == Compat.Dates.Second(172799) -@test round(x, Compat.Dates.Millisecond) == Compat.Dates.Millisecond(172799000) - -x = Compat.Dates.Nanosecond(2000999999) -@test floor(x, Compat.Dates.Second) == Compat.Dates.Second(2) -@test floor(x, Compat.Dates.Millisecond) == Compat.Dates.Millisecond(2000) -@test floor(x, Compat.Dates.Microsecond) == Compat.Dates.Microsecond(2000999) -@test floor(x, Compat.Dates.Nanosecond) == x -@test ceil(x, Compat.Dates.Second) == Compat.Dates.Second(3) -@test ceil(x, Compat.Dates.Millisecond) == Compat.Dates.Millisecond(2001) -@test ceil(x, Compat.Dates.Microsecond) == Compat.Dates.Microsecond(2001000) -@test ceil(x, Compat.Dates.Nanosecond) == x -@test round(x, Compat.Dates.Second) == Compat.Dates.Second(2) -@test round(x, Compat.Dates.Millisecond) == Compat.Dates.Millisecond(2001) -@test round(x, Compat.Dates.Microsecond) == Compat.Dates.Microsecond(2001000) -@test round(x, Compat.Dates.Nanosecond) == x - - -for x in [Compat.Dates.Week(3), Compat.Dates.Day(14), Compat.Dates.Second(604800)] - local x - for p in [Compat.Dates.Week, Compat.Dates.Day, Compat.Dates.Hour, Compat.Dates.Second, Compat.Dates.Millisecond, Compat.Dates.Microsecond, Compat.Dates.Nanosecond] - local p - @test floor(x, p) == p(x) - @test ceil(x, p) == p(x) - end -end - -x = Compat.Dates.Hour(36) -@test round(x, Compat.Dates.Day, RoundNearestTiesUp) == Compat.Dates.Day(2) -@test round(x, Compat.Dates.Day, RoundUp) == Compat.Dates.Day(2) -@test round(x, Compat.Dates.Day, RoundDown) == Compat.Dates.Day(1) -@test_throws DomainError round(x, Compat.Dates.Day, RoundNearest) -@test_throws DomainError round(x, Compat.Dates.Day, RoundNearestTiesAway) -@test_throws DomainError round(x, Compat.Dates.Day, RoundToZero) -@test round(x, Compat.Dates.Day) == round(x, Compat.Dates.Day, RoundNearestTiesUp) - -x = Compat.Dates.Hour(86399) -for p in [Compat.Dates.Week, Compat.Dates.Day, Compat.Dates.Hour, Compat.Dates.Second, Compat.Dates.Millisecond, Compat.Dates.Microsecond, Compat.Dates.Nanosecond] - local p - for v in [-1, 0] - @test_throws DomainError floor(x, p(v)) - @test_throws DomainError ceil(x, p(v)) - @test_throws DomainError round(x, p(v)) - end -end -for p in [Compat.Dates.Year, Compat.Dates.Month] - local p - for v in [-1, 0, 1] - @test_throws MethodError floor(x, p(v)) - @test_throws MethodError ceil(x, p(v)) - @test_throws DomainError round(x, p(v)) - end -end - # 0.7.0-DEV.3025 let c = CartesianIndices((1:3, 1:2)), l = LinearIndices((1:3, 1:2)) @test LinearIndices(c) == collect(l) From ff6f90753e329ad72c3fb1ee2891b7abb5fbab33 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 1 Oct 2019 19:13:22 +0200 Subject: [PATCH 031/121] Mark `AbstractDateTime` from #443 for deprecation --- README.md | 2 -- src/Compat.jl | 7 +------ test/old.jl | 5 +++++ test/runtests.jl | 4 ---- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index c0f38ebd1..8e900d825 100644 --- a/README.md +++ b/README.md @@ -312,8 +312,6 @@ Currently, the `@compat` macro supports the following syntaxes: ## New types -* `Compat.AbstractDateTime` is an alias for `Compat.Dates.AbstractDateTime` as of ([#25227]) and `Compat.Dates.TimeType` prior to that. - ## Developer tips One of the most important rules for `Compat.jl` is to avoid breaking user code diff --git a/src/Compat.jl b/src/Compat.jl index 741df7ca5..bcd36372c 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -22,16 +22,11 @@ import Base.MathConstants import Test, SharedArrays, Mmap, DelimitedFiles import Dates import Libdl +const AbstractDateTime = Compat.Dates.AbstractDateTime include("compatmacro.jl") -if VERSION < v"0.7.0-DEV.3216" - const AbstractDateTime = Compat.Dates.TimeType -else - const AbstractDateTime = Compat.Dates.AbstractDateTime -end - if VERSION < v"0.7.0-DEV.3052" const Printf = Base.Printf else diff --git a/test/old.jl b/test/old.jl index 9fa123bd7..fe9332bc9 100644 --- a/test/old.jl +++ b/test/old.jl @@ -102,6 +102,11 @@ module TestLibdl @test isdefined(@__MODULE__, :Libdl) end +# 0.7.0-DEV.3216 +@test Compat.AbstractDateTime === (isdefined(Compat.Dates, :AbstractDateTime) ? Compat.Dates.AbstractDateTime : Compat.Dates.TimeType) +@test Compat.AbstractDateTime <: Compat.Dates.TimeType +@test Compat.Dates.DateTime <: Compat.AbstractDateTime + # tests of removed functionality (i.e. justs tests Base) diff --git a/test/runtests.jl b/test/runtests.jl index d4aefef1e..94773cacb 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -270,10 +270,6 @@ end # 0.7.0-DEV.3172 @test replace("abcb", "b"=>"c") == "accc" @test replace("abcb", "b"=>"c", count=1) == "accb" -# 0.7.0-DEV.3216 -@test Compat.AbstractDateTime === (isdefined(Compat.Dates, :AbstractDateTime) ? Compat.Dates.AbstractDateTime : Compat.Dates.TimeType) -@test Compat.AbstractDateTime <: Compat.Dates.TimeType -@test Compat.Dates.DateTime <: Compat.AbstractDateTime # 0.7.0-DEV.3025 let c = CartesianIndices((1:3, 1:2)), l = LinearIndices((1:3, 1:2)) From 19735ae341485bafc639ff207fc0888f41591805 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 1 Oct 2019 19:15:08 +0200 Subject: [PATCH 032/121] Mark `Compat.Printf` from #435 for deprecation --- README.md | 3 --- src/Compat.jl | 7 +------ test/old.jl | 10 ++++++++++ test/runtests.jl | 10 ---------- 4 files changed, 11 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 8e900d825..25a3b9b8b 100644 --- a/README.md +++ b/README.md @@ -58,9 +58,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `using Compat.Unicode` is provided on versions older than 0.7, where this library is not yet a part of the standard library. ([#25021]) -* `using Compat.Printf` is provided on versions older than 0.7, where this library is not - yet a part of the standard library. ([#25056]) - * `using Compat.SparseArrays` is provided on versions older than 0.7, where this library is not yet part of the standard library ([#25249]). diff --git a/src/Compat.jl b/src/Compat.jl index bcd36372c..d48389729 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -23,16 +23,11 @@ import Test, SharedArrays, Mmap, DelimitedFiles import Dates import Libdl const AbstractDateTime = Compat.Dates.AbstractDateTime +import Printf include("compatmacro.jl") -if VERSION < v"0.7.0-DEV.3052" - const Printf = Base.Printf -else - import Printf -end - if VERSION < v"0.7.0-DEV.2655" @eval module IterativeEigensolvers using Base: eigs, svds diff --git a/test/old.jl b/test/old.jl index fe9332bc9..426802080 100644 --- a/test/old.jl +++ b/test/old.jl @@ -107,6 +107,16 @@ end @test Compat.AbstractDateTime <: Compat.Dates.TimeType @test Compat.Dates.DateTime <: Compat.AbstractDateTime +# 0.7 +module Test25056 + using Compat + using Compat.Test + using Compat.Printf + @test isdefined(@__MODULE__, :Printf) + @test isdefined(@__MODULE__, Symbol("@printf")) + @test isdefined(@__MODULE__, Symbol("@sprintf")) +end + # tests of removed functionality (i.e. justs tests Base) diff --git a/test/runtests.jl b/test/runtests.jl index 94773cacb..7ccea8296 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -72,16 +72,6 @@ if VERSION < v"0.7.0-DEV.880" end end -# 0.7 -module Test25056 - using Compat - using Compat.Test - using Compat.Printf - @test isdefined(@__MODULE__, :Printf) - @test isdefined(@__MODULE__, Symbol("@printf")) - @test isdefined(@__MODULE__, Symbol("@sprintf")) -end - # 0.7 let a = [0,1,2,3,0,1,2,3] From b95638c986d2836437ee0d588b0893b867bc02fa Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 1 Oct 2019 20:23:37 +0200 Subject: [PATCH 033/121] Drop compat code for `IterativeEigensolvers` from #435 --- src/Compat.jl | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/Compat.jl b/src/Compat.jl index d48389729..956f679a3 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -28,18 +28,6 @@ import Printf include("compatmacro.jl") -if VERSION < v"0.7.0-DEV.2655" - @eval module IterativeEigensolvers - using Base: eigs, svds - export eigs, svds - end -elseif VERSION < v"0.7.0-DEV.3019" - @eval module IterativeEigensolvers - using IterativeEigenSolvers: eigs, svds - export eigs, svds - end -end - @static if VERSION < v"0.7.0-DEV.3449" const LinearAlgebra = Base.LinAlg else From 3620451a39106453a524a7fc58007f6afd169392 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 1 Oct 2019 20:54:29 +0200 Subject: [PATCH 034/121] Mark `Compat.LinearAlgebra` from #463 for deprecation --- README.md | 3 --- src/Compat.jl | 7 +------ test/old.jl | 5 +++++ test/runtests.jl | 5 ----- 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 25a3b9b8b..ca79f39ed 100644 --- a/README.md +++ b/README.md @@ -61,9 +61,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `using Compat.SparseArrays` is provided on versions older than 0.7, where this library is not yet part of the standard library ([#25249]). -* `using Compat.LinearAlgebra` is provided on versions older than 0.7, where this library is - not yet part of the standard library ([#25571]). - * `using Compat.Random` is provided on versions older than 0.7, where this library is not yet part of the standard library ([#24874]). diff --git a/src/Compat.jl b/src/Compat.jl index 956f679a3..db252624e 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -24,16 +24,11 @@ import Dates import Libdl const AbstractDateTime = Compat.Dates.AbstractDateTime import Printf +import LinearAlgebra include("compatmacro.jl") -@static if VERSION < v"0.7.0-DEV.3449" - const LinearAlgebra = Base.LinAlg -else - import LinearAlgebra -end - if VERSION < v"0.7.0-DEV.3389" const SparseArrays = Base.SparseArrays else diff --git a/test/old.jl b/test/old.jl index 426802080..0c359008a 100644 --- a/test/old.jl +++ b/test/old.jl @@ -117,6 +117,11 @@ module Test25056 @test isdefined(@__MODULE__, Symbol("@sprintf")) end +# 0.7.0-DEV.3449 +let A = [2.0 1.0; 1.0 3.0], b = [2.0, 3.0] + @test diag(A) == b +end + # tests of removed functionality (i.e. justs tests Base) diff --git a/test/runtests.jl b/test/runtests.jl index 7ccea8296..52cfcd848 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -249,11 +249,6 @@ end # 0.7.0-DEV.912 @test occursin('W', "Hello, World!") -# 0.7.0-DEV.3449 -let A = [2.0 1.0; 1.0 3.0], b = [2.0, 3.0] - @test diag(A) == b -end - # 0.7.0-DEV.3173 @test invpermute!(permute!([1, 2], 2:-1:1), 2:-1:1) == [1, 2] From d5d99437062d2d75a89a8cb0491a314e692a8e92 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 16:00:05 +0200 Subject: [PATCH 035/121] Mark `Compat.SparseArrays` from #459 for deprecation --- README.md | 3 --- src/Compat.jl | 8 +------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/README.md b/README.md index ca79f39ed..e16734225 100644 --- a/README.md +++ b/README.md @@ -58,9 +58,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `using Compat.Unicode` is provided on versions older than 0.7, where this library is not yet a part of the standard library. ([#25021]) -* `using Compat.SparseArrays` is provided on versions older than 0.7, where this library is - not yet part of the standard library ([#25249]). - * `using Compat.Random` is provided on versions older than 0.7, where this library is not yet part of the standard library ([#24874]). diff --git a/src/Compat.jl b/src/Compat.jl index db252624e..3e363945c 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -25,17 +25,11 @@ import Libdl const AbstractDateTime = Compat.Dates.AbstractDateTime import Printf import LinearAlgebra +import SparseArrays include("compatmacro.jl") -if VERSION < v"0.7.0-DEV.3389" - const SparseArrays = Base.SparseArrays -else - import SparseArrays -end - - # v"0.7.0-beta.234" introduced Random.gentype (formerly Base.eltype) # v"0.7.0-beta2.171" deprecated Random.srand in favor of Random.seed! (unexported) # v"0.7.0-DEV.3406" moved Base.Random to stdlib Random From f1c2a3f72c802848570b572cb8daba01565ea12b Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 16:05:23 +0200 Subject: [PATCH 036/121] Mark `Compat.Random` from #460, #601, and #647 for deprecation --- README.md | 5 ----- src/Compat.jl | 45 +-------------------------------------------- test/old.jl | 11 +++++++++++ test/runtests.jl | 11 ----------- 4 files changed, 12 insertions(+), 60 deletions(-) diff --git a/README.md b/README.md index e16734225..258ad5b79 100644 --- a/README.md +++ b/README.md @@ -58,9 +58,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `using Compat.Unicode` is provided on versions older than 0.7, where this library is not yet a part of the standard library. ([#25021]) -* `using Compat.Random` is provided on versions older than 0.7, where this library is - not yet part of the standard library ([#24874]). - * `using Compat.REPL` is provided on versions older than 0.7, where this library is not yet part of the standard library ([#25544]). @@ -276,8 +273,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `atan2` is now a 2-argument method of `atan` ([#27253]). -* `srand` is now `Compat.Random.seed!` ([#28295]) - * `realmin` and `realmax` are now `floatmin` and `floatmax` ([#28302]) * `squeeze` is now `dropdims` ([#28303], [#26660]). diff --git a/src/Compat.jl b/src/Compat.jl index 3e363945c..fb557db51 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -26,54 +26,11 @@ const AbstractDateTime = Compat.Dates.AbstractDateTime import Printf import LinearAlgebra import SparseArrays +import Random include("compatmacro.jl") -# v"0.7.0-beta.234" introduced Random.gentype (formerly Base.eltype) -# v"0.7.0-beta2.171" deprecated Random.srand in favor of Random.seed! (unexported) -# v"0.7.0-DEV.3406" moved Base.Random to stdlib Random -if VERSION >= v"0.7.0-beta.234" - import Random -else - const exported_random_fields = [ - :AbstractRNG, :MersenneTwister, :RandomDevice, :bitrand, :rand, :rand!, - :randcycle, :randexp, :randexp!, :randjump, :randn!, - :randperm, :randstring, :randsubseq, :randsubseq!, :shuffle, - :shuffle! - ] - const unexported_random_fields = [ - :GLOBAL_RNG, :RangeGenerator - ] - const random_fields = [exported_random_fields; unexported_random_fields] - @eval module Random - if VERSION < v"0.7.0-DEV.3406" - $((:(using Base.Random: $f) for f in random_fields)...) - const seed! = Base.Random.srand - else - $((:(using Random: $f) for f in random_fields)...) - import Random - if VERSION < v"0.7.0-beta2.171" - const seed! = Random.srand - else - using Random: seed! - end - end - if VERSION < v"0.7.0-DEV.3666" - import ..Compat - Base.@deprecate uuid1() Compat.UUIDs.uuid1() false - Base.@deprecate uuid1(rng) Compat.UUIDs.uuid1(rng) false - Base.@deprecate uuid4() Compat.UUIDs.uuid4() false - Base.@deprecate uuid4(rng) Compat.UUIDs.uuid4(rng) false - Base.@deprecate uuid_version(u) Compat.UUIDs.uuid_version(u) false - end - - gentype(args...) = eltype(args...) - - export $(exported_random_fields...) - end -end - if VERSION < v"0.7.0-DEV.3589" const Markdown = Base.Markdown else diff --git a/test/old.jl b/test/old.jl index 0c359008a..5320545ee 100644 --- a/test/old.jl +++ b/test/old.jl @@ -122,6 +122,17 @@ let A = [2.0 1.0; 1.0 3.0], b = [2.0, 3.0] @test diag(A) == b end +# 0.7.0-DEV.3406 +using Compat.Random +@test rand(MersenneTwister(1234)) == 0.5908446386657102 + +# 0.7.0-beta2.171 +Random.seed!(1) +rng = MersenneTwister(0) +Random.seed!(rng, 1) +@test rand(rng) ≈ 0.23603334566204692 +@test 0 < rand(Random.GLOBAL_RNG, Random.RangeGenerator(1:3)) < 4 + # tests of removed functionality (i.e. justs tests Base) diff --git a/test/runtests.jl b/test/runtests.jl index 52cfcd848..f49d74f62 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -233,10 +233,6 @@ let A = [0, 0, 0], B = [1, 2, 3] @test unsafe_copyto!(A, 2, B, 1, 1) === A == [0, 1, 0] end -# 0.7.0-DEV.3406 -using Compat.Random -@test rand(MersenneTwister(1234)) == 0.5908446386657102 - # 0.7, make sure this works on 0.6 if VERSION < v"0.7.0-DEV.3272" @test contains("Hello, World!", r"World") @@ -1006,13 +1002,6 @@ let a = rand(5,5) end end -# 0.7.0-beta2.171 -Random.seed!(1) -rng = MersenneTwister(0) -Random.seed!(rng, 1) -@test rand(rng) ≈ 0.23603334566204692 -@test 0 < rand(Random.GLOBAL_RNG, Random.RangeGenerator(1:3)) < 4 - # 0.7.0-beta2.169 @test floatmin(Float16) == @eval $(Core.Intrinsics.bitcast(Float16, 0x0400)) @test floatmax(Float32) == @eval $(Core.Intrinsics.bitcast(Float32, 0x7f7fffff)) From b9b25b0831b2642e7e44268eaac923d4a55b8fb2 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 17:14:39 +0200 Subject: [PATCH 037/121] Mark `Compat.Markdown` from #492 for deprecation --- README.md | 3 --- src/Compat.jl | 7 +------ test/old.jl | 4 ++++ test/runtests.jl | 4 ---- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 258ad5b79..1e6af2829 100644 --- a/README.md +++ b/README.md @@ -81,9 +81,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `using Compat.UUIDs` is provided on versions older than 0.7, where this library is not yet part of the standard library ([#25819]). -* `using Compat.Markdown` is provided on versions older than 0.7, where this library is - not yet part of the standard library ([#25738]). - * `using Compat.Statistics` is provided on versions older than 0.7, where this library is not yet part of the standard library ([#27834]). diff --git a/src/Compat.jl b/src/Compat.jl index fb557db51..807511a97 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -27,16 +27,11 @@ import Printf import LinearAlgebra import SparseArrays import Random +import Markdown include("compatmacro.jl") -if VERSION < v"0.7.0-DEV.3589" - const Markdown = Base.Markdown -else - import Markdown -end - if VERSION < v"0.7.0-DEV.2609" @eval module SuiteSparse if Base.USE_GPL_LIBS diff --git a/test/old.jl b/test/old.jl index 5320545ee..2ae2764f5 100644 --- a/test/old.jl +++ b/test/old.jl @@ -133,6 +133,10 @@ Random.seed!(rng, 1) @test rand(rng) ≈ 0.23603334566204692 @test 0 < rand(Random.GLOBAL_RNG, Random.RangeGenerator(1:3)) < 4 +# 0.7.0-DEV.3589 +import Compat.Markdown +@test isa(Markdown.parse("foo"), Markdown.MD) + # tests of removed functionality (i.e. justs tests Base) diff --git a/test/runtests.jl b/test/runtests.jl index f49d74f62..3877fd755 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -483,10 +483,6 @@ module TestUUIDs @test uuid4() isa UUID end -# 0.7.0-DEV.3589 -import Compat.Markdown -@test isa(Markdown.parse("foo"), Markdown.MD) - @test repr("text/plain", "string") == "\"string\"" #25990 @test showable("text/plain", 3.14159) #26089 From 12b9161e22ebd7ef01d05eb4c4fba7d44eb88528 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 17:16:44 +0200 Subject: [PATCH 038/121] Drop `Compat.SuiteSparse` from #435 --- src/Compat.jl | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/Compat.jl b/src/Compat.jl index 807511a97..9489b9a01 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -32,15 +32,6 @@ import Markdown include("compatmacro.jl") -if VERSION < v"0.7.0-DEV.2609" - @eval module SuiteSparse - if Base.USE_GPL_LIBS - using Compat.SparseArrays: CHOLMOD, SPQR, UMFPACK - end - using Compat.SparseArrays: increment, increment!, decrement, decrement! - end -end - @static if VERSION < v"0.7.0-DEV.3500" const REPL = Base.REPL else From ea9371e7edc4d2ca02a3b838bd71b7b5e496c158 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 17:18:12 +0200 Subject: [PATCH 039/121] Mark `Compat.REPL` from #469 for deprecation --- README.md | 3 --- src/Compat.jl | 7 +------ test/old.jl | 8 ++++++++ test/runtests.jl | 8 -------- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 1e6af2829..3883bcf64 100644 --- a/README.md +++ b/README.md @@ -58,9 +58,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `using Compat.Unicode` is provided on versions older than 0.7, where this library is not yet a part of the standard library. ([#25021]) -* `using Compat.REPL` is provided on versions older than 0.7, where this library is - not yet part of the standard library ([#25544]). - * `using Compat.Serialization` is provided on versions older than 0.7, where this library is not yet part of the standard library ([#25628]). diff --git a/src/Compat.jl b/src/Compat.jl index 9489b9a01..6ea179ee4 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -28,16 +28,11 @@ import LinearAlgebra import SparseArrays import Random import Markdown +import REPL include("compatmacro.jl") -@static if VERSION < v"0.7.0-DEV.3500" - const REPL = Base.REPL -else - import REPL -end - if VERSION < v"0.7.0-DEV.3476" @eval module Serialization import Base.Serializer: serialize, deserialize, SerializationState, serialize_type diff --git a/test/old.jl b/test/old.jl index 2ae2764f5..5fdf0a322 100644 --- a/test/old.jl +++ b/test/old.jl @@ -137,6 +137,14 @@ Random.seed!(rng, 1) import Compat.Markdown @test isa(Markdown.parse("foo"), Markdown.MD) +# 0.7.0-DEV.3500 +module TestREPL + using Compat + using Compat.REPL + using Compat.Test + @test isdefined(@__MODULE__, :REPL) +end + # tests of removed functionality (i.e. justs tests Base) diff --git a/test/runtests.jl b/test/runtests.jl index 3877fd755..b3dc10ff1 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -329,14 +329,6 @@ end # 0.7.0-DEV.3415 @test findall(x -> x==1, [1, 2, 3, 2, 1]) == [1, 5] -# 0.7.0-DEV.3500 -module TestREPL - using Compat - using Compat.REPL - using Compat.Test - @test isdefined(@__MODULE__, :REPL) -end - # 0.7.0-DEV.3476 module TestSerialization using Compat From 4071965b7bd0dd5d2ebf5e2e5f4e7904568b1c99 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 17:20:57 +0200 Subject: [PATCH 040/121] Mark `Compat.Serialization` from #473 for deprecation --- README.md | 3 --- src/Compat.jl | 13 +------------ test/old.jl | 13 +++++++++++++ test/runtests.jl | 13 ------------- 4 files changed, 14 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 3883bcf64..05da7fa8d 100644 --- a/README.md +++ b/README.md @@ -58,9 +58,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `using Compat.Unicode` is provided on versions older than 0.7, where this library is not yet a part of the standard library. ([#25021]) -* `using Compat.Serialization` is provided on versions older than 0.7, where this library is - not yet part of the standard library ([#25628]). - * `using Compat.Distributed` is provided on versions older than 0.7, where this library is not yet part of the standard library ([#24443]). diff --git a/src/Compat.jl b/src/Compat.jl index 6ea179ee4..041a20d55 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -29,22 +29,11 @@ import SparseArrays import Random import Markdown import REPL +import Serialization include("compatmacro.jl") -if VERSION < v"0.7.0-DEV.3476" - @eval module Serialization - import Base.Serializer: serialize, deserialize, SerializationState, serialize_type - export serialize, deserialize - @static if VERSION < v"1.0.0-DEV.44" - export SerializationState - end - end -else - import Serialization -end - if VERSION < v"0.7.0-beta.85" @eval module Statistics if VERSION < v"0.7.0-DEV.4064" diff --git a/test/old.jl b/test/old.jl index 5fdf0a322..5923343b1 100644 --- a/test/old.jl +++ b/test/old.jl @@ -145,6 +145,19 @@ module TestREPL @test isdefined(@__MODULE__, :REPL) end +# 0.7.0-DEV.3476 +module TestSerialization + using Compat + using Compat.Serialization + using Compat.Test + @test isdefined(@__MODULE__, :Serialization) + @test isdefined(@__MODULE__, :serialize) + @test isdefined(@__MODULE__, :deserialize) + if VERSION < v"1.0.0-DEV.44" + @test isdefined(@__MODULE__, :SerializationState) + end +end + # tests of removed functionality (i.e. justs tests Base) diff --git a/test/runtests.jl b/test/runtests.jl index b3dc10ff1..29a69693c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -329,19 +329,6 @@ end # 0.7.0-DEV.3415 @test findall(x -> x==1, [1, 2, 3, 2, 1]) == [1, 5] -# 0.7.0-DEV.3476 -module TestSerialization - using Compat - using Compat.Serialization - using Compat.Test - @test isdefined(@__MODULE__, :Serialization) - @test isdefined(@__MODULE__, :serialize) - @test isdefined(@__MODULE__, :deserialize) - if VERSION < v"1.0.0-DEV.44" - @test isdefined(@__MODULE__, :SerializationState) - end -end - module TestPkg using Compat using Compat.Pkg From 9234d210589fdb10a0c9c23ba545c934643ca92a Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 17:23:51 +0200 Subject: [PATCH 041/121] Mark `Compat.Statistics` from #583 for deprecation --- README.md | 7 ++----- src/Compat.jl | 32 +------------------------------- 2 files changed, 3 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 05da7fa8d..1967a5177 100644 --- a/README.md +++ b/README.md @@ -75,9 +75,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `using Compat.UUIDs` is provided on versions older than 0.7, where this library is not yet part of the standard library ([#25819]). -* `using Compat.Statistics` is provided on versions older than 0.7, where this library is - not yet part of the standard library ([#27834]). - ## New functions, macros, and methods * `only(x)` returns the one-and-only element of a collection `x`. ([#33129]) @@ -145,8 +142,8 @@ Currently, the `@compat` macro supports the following syntaxes: * `Compat.accumulate`, `Compat.accumulate!`, `Compat.all`, `Compat.any`, `Compat.cumprod`, `Compat.cumprod!`, `Compat.cumsum`, `Compat.cumsum!`, - `Compat.findmax`, `Compat.findmin`, `Compat.mapreduce`, `Compat.maximum`, `Compat.Statistics.mean`, - `Compat.Statistics.median`, `Compat.minimum`, `Compat.prod`, `Compat.reduce`, `Compat.sort`, + `Compat.findmax`, `Compat.findmin`, `Compat.mapreduce`, `Compat.maximum`, + `Compat.minimum`, `Compat.prod`, `Compat.reduce`, `Compat.sort`, and `Compat.sum` with `dims` keyword argument ([#25989],[#26369]). * `Compat.mapreduce` and `Compat.reduce` with `init` keyword argument ([#27711]). diff --git a/src/Compat.jl b/src/Compat.jl index 041a20d55..64f61eae6 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -30,41 +30,11 @@ import Random import Markdown import REPL import Serialization +import Statistics include("compatmacro.jl") -if VERSION < v"0.7.0-beta.85" - @eval module Statistics - if VERSION < v"0.7.0-DEV.4064" - varm(A::AbstractArray, m; dims=nothing, kwargs...) = - dims===nothing ? Base.varm(A, m; kwargs...) : Base.varm(A, m, dims; kwargs...) - if VERSION < v"0.7.0-DEV.755" - cov(a::AbstractMatrix; dims=1, corrected=true) = Base.cov(a, dims, corrected) - cov(a::AbstractVecOrMat, b::AbstractVecOrMat; dims=1, corrected=true) = - Base.cov(a, b, dims, corrected) - else - cov(a::AbstractMatrix; dims=nothing, kwargs...) = - dims===nothing ? Base.cov(a; kwargs...) : Base.cov(a, dims; kwargs...) - cov(a::AbstractVecOrMat, b::AbstractVecOrMat; dims=nothing, kwargs...) = - dims===nothing ? Base.cov(a, b; kwargs...) : Base.cov(a, b, dims; kwargs...) - end - cor(a::AbstractMatrix; dims=nothing) = dims===nothing ? Base.cor(a) : Base.cor(a, dims) - cor(a::AbstractVecOrMat, b::AbstractVecOrMat; dims=nothing) = - dims===nothing ? Base.cor(a, b) : Base.cor(a, b, dims) - mean(a::AbstractArray; dims=nothing) = dims===nothing ? Base.mean(a) : Base.mean(a, dims) - median(a::AbstractArray; dims=nothing) = dims===nothing ? Base.median(a) : Base.median(a, dims) - var(a::AbstractArray; dims=nothing, kwargs...) = - dims===nothing ? Base.var(a; kwargs...) : Base.var(a, dims; kwargs...) - std(a::AbstractArray; dims=nothing, kwargs...) = - dims===nothing ? Base.std(a; kwargs...) : Base.std(a, dims; kwargs...) - end - export cor, cov, std, stdm, var, varm, mean!, mean, median!, median, middle, quantile!, quantile - end -else - import Statistics -end - @static if VERSION < v"0.7.0-DEV.4592" struct Fix2{F,T} <: Function f::F From fb3f8130586912694807460956bd469b2d2868af Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 17:31:16 +0200 Subject: [PATCH 042/121] Drop compat code for curried `isequal`, `==`, and `in` from #517 And mark `Fix2` for deprecation. --- README.md | 3 --- src/Compat.jl | 36 +----------------------------------- test/old.jl | 25 +++++++++++++++++++++++++ test/runtests.jl | 25 ------------------------- 4 files changed, 26 insertions(+), 63 deletions(-) diff --git a/README.md b/README.md index 1967a5177..2cdeee5cf 100644 --- a/README.md +++ b/README.md @@ -86,9 +86,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `isnothing` for testing if a variable is equal to `nothing` ([#29674]). -* `isequal`, `==` and `in` have one argument "curried" forms. For example `isequal(x)` - returns a function that compares its arguments to `x` using `isequal` ([#26436]). - * `*(::Union{Char,AbstractString},::Union{Char,AbstractString})` concatenation. ([#22512]) * `diagm` and `spdiagm` accept pairs mapping diagonals to vectors ([#24047], [#23757]) diff --git a/src/Compat.jl b/src/Compat.jl index 64f61eae6..fc2b4226c 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -31,45 +31,11 @@ import Markdown import REPL import Serialization import Statistics +import Base: Fix2 include("compatmacro.jl") -@static if VERSION < v"0.7.0-DEV.4592" - struct Fix2{F,T} <: Function - f::F - x::T - Fix2(f::F, x::T) where {F,T} = new{F,T}(f, x) - Fix2(f::Type{F}, x::T) where {F,T} = new{F,T}(f, x) - end - (f::Fix2)(y) = f.f(y, f.x) - - Base.:(==)(x) = Fix2(==, x) - @static if VERSION >= v"0.7.0-DEV.1993" - Base.isequal(x) = Base.equalto(x) - else - Base.isequal(x) = Fix2(isequal, x) - end - @static if VERSION >= v"0.7.0-DEV.3272" - Base.in(x) = Base.occursin(x) - else - Base.in(x) = Fix2(in, x) - end -else - import Base: Fix2 -end -# keep these definitions to be non breaking for 0.6 usage -@static if VERSION < v"0.7.0-DEV.1993" - const EqualTo{T} = Fix2{typeof(isequal),T} - export equalto - equalto(x) = isequal(x) -end -@static if VERSION < v"0.7.0-DEV.3272" - const OccursIn{T} = Fix2{typeof(in),T} - export occursin - occursin(x) = in(x) -end - # PR #26283 if VERSION < v"0.7.0-DEV.4639" if isdefined(Base, :occursin) diff --git a/test/old.jl b/test/old.jl index 5923343b1..0a713d5b5 100644 --- a/test/old.jl +++ b/test/old.jl @@ -450,3 +450,28 @@ for p in [Compat.Dates.Year, Compat.Dates.Month] @test_throws DomainError round(x, p(v)) end end + +# 0.7 + +let a = [0,1,2,3,0,1,2,3] + # curried isequal + @test findfirst(isequal(3), [1,2,4,1,2,3,4]) == 6 + @test findfirst(!isequal(1), [1,2,4,1,2,3,4]) == 2 + @test findnext(isequal(1), a, 4) == 6 + # @test findnext(isequal(5), a, 4) == 0 + @test findlast(isequal(3), [1,2,4,1,2,3,4]) == 6 + @test findprev(isequal(1), a, 4) == 2 + @test findprev(isequal(1), a, 8) == 6 + if VERSION < v"0.7.0-DEV.4592" + # test that equalto work on 0.6 + @test findfirst(equalto(3), [1,2,4,1,2,3,4]) == 6 + @test findfirst(!equalto(1), [1,2,4,1,2,3,4]) == 2 + end + # curried == + @test findfirst(==(3), [1,2,4,1,2,3,4]) == 6 + @test findfirst(!(==(1)), [1,2,4,1,2,3,4]) == 2 + @test findnext(==(1), a, 4) == 6 + @test findlast(==(3), [1,2,4,1,2,3,4]) == 6 + @test findprev(==(1), a, 4) == 2 + @test findprev(==(1), a, 8) == 6 +end diff --git a/test/runtests.jl b/test/runtests.jl index 29a69693c..2003d5407 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -72,31 +72,6 @@ if VERSION < v"0.7.0-DEV.880" end end -# 0.7 - -let a = [0,1,2,3,0,1,2,3] - # curried isequal - @test findfirst(isequal(3), [1,2,4,1,2,3,4]) == 6 - @test findfirst(!isequal(1), [1,2,4,1,2,3,4]) == 2 - @test findnext(isequal(1), a, 4) == 6 - # @test findnext(isequal(5), a, 4) == 0 - @test findlast(isequal(3), [1,2,4,1,2,3,4]) == 6 - @test findprev(isequal(1), a, 4) == 2 - @test findprev(isequal(1), a, 8) == 6 - if VERSION < v"0.7.0-DEV.4592" - # test that equalto work on 0.6 - @test findfirst(equalto(3), [1,2,4,1,2,3,4]) == 6 - @test findfirst(!equalto(1), [1,2,4,1,2,3,4]) == 2 - end - # curried == - @test findfirst(==(3), [1,2,4,1,2,3,4]) == 6 - @test findfirst(!(==(1)), [1,2,4,1,2,3,4]) == 2 - @test findnext(==(1), a, 4) == 6 - @test findlast(==(3), [1,2,4,1,2,3,4]) == 6 - @test findprev(==(1), a, 4) == 2 - @test findprev(==(1), a, 8) == 6 -end - # 0.7 @test 'a'*"b" == "a"*'b' == 'a'*'b' == "ab" From 2bed8a5d00f5bdf8e6fb42ae910c85a2ea1b658b Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 17:35:39 +0200 Subject: [PATCH 043/121] Drop compat code for `occursin` from #520 --- README.md | 6 ------ src/Compat.jl | 20 -------------------- test/old.jl | 7 +++++++ test/runtests.jl | 12 ------------ 4 files changed, 7 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 2cdeee5cf..126cd16e4 100644 --- a/README.md +++ b/README.md @@ -197,12 +197,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `copy!` and `unsafe_copy!` are now `copyto!` and `unsafe_copyto!` ([#24808]). -* `contains(haystack, needle)` is now `occursin(needle, haystack)` ([#26283]). - `occursin` also has a new method for `Char` needles ([#22435]). - -* `ismatch(r::Regex, str::AbstractString, offset=0)` is now `occursin(r, str)` and - `occursin(r, str, offset = offset)` respectively ([#24673],[#26283]). - * `ipermute!` is now `invpermute!` ([#25168]). * `module_parent`, `Base.function_module`, and `Base.datatype_module` are now methods of diff --git a/src/Compat.jl b/src/Compat.jl index fc2b4226c..fb4d59e45 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -36,26 +36,6 @@ import Base: Fix2 include("compatmacro.jl") -# PR #26283 -if VERSION < v"0.7.0-DEV.4639" - if isdefined(Base, :occursin) - import Base: occursin - else - export occursin - end - occursin(needle, haystack) = contains(haystack, needle) - if VERSION < v"0.7.0-DEV.3272" - occursin(r::Regex, s::AbstractString; offset::Integer = 0) = ismatch(r, s, offset) - else - occursin(r::Regex, s::AbstractString; offset::Integer = 0) = contains(s, r, offset) - end - # PR #22435 - if VERSION < v"0.7.0-DEV.702" - occursin(needle::Char, haystack::AbstractString) = searchindex(haystack,needle) != 0 - end -end - - # 0.7.0-DEV.912 if VERSION < v"0.7.0-DEV.912" import Base.* diff --git a/test/old.jl b/test/old.jl index 0a713d5b5..89578a61f 100644 --- a/test/old.jl +++ b/test/old.jl @@ -475,3 +475,10 @@ let a = [0,1,2,3,0,1,2,3] @test findprev(==(1), a, 4) == 2 @test findprev(==(1), a, 8) == 6 end + +# 0.7.0-DEV.4639 +@test occursin(r"World", "Hello, World!") +@test occursin(r"World", "Hello, World!", offset = 4) +@test occursin("World", "Hello, World!") +# 0.7.0-DEV.912 +@test occursin('W', "Hello, World!") diff --git a/test/runtests.jl b/test/runtests.jl index 2003d5407..7a1f96a24 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -208,18 +208,6 @@ let A = [0, 0, 0], B = [1, 2, 3] @test unsafe_copyto!(A, 2, B, 1, 1) === A == [0, 1, 0] end -# 0.7, make sure this works on 0.6 -if VERSION < v"0.7.0-DEV.3272" - @test contains("Hello, World!", r"World") -end - -# 0.7.0-DEV.4639 -@test occursin(r"World", "Hello, World!") -@test occursin(r"World", "Hello, World!", offset = 4) -@test occursin("World", "Hello, World!") -# 0.7.0-DEV.912 -@test occursin('W', "Hello, World!") - # 0.7.0-DEV.3173 @test invpermute!(permute!([1, 2], 2:-1:1), 2:-1:1) == [1, 2] From e204ac0f433796ed02396870e694d9b9ad3ceabc Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 17:38:08 +0200 Subject: [PATCH 044/121] Drop compat code for `Char` concatenation from #406 --- README.md | 2 -- src/Compat.jl | 6 ------ test/old.jl | 3 +++ test/runtests.jl | 3 --- 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 126cd16e4..ca889b48d 100644 --- a/README.md +++ b/README.md @@ -86,8 +86,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `isnothing` for testing if a variable is equal to `nothing` ([#29674]). -* `*(::Union{Char,AbstractString},::Union{Char,AbstractString})` concatenation. ([#22512]) - * `diagm` and `spdiagm` accept pairs mapping diagonals to vectors ([#24047], [#23757]) * Constructors for `Matrix{T}`, `Array{T}`, and `SparseMatrixCSC{T}` from `UniformScaling` ([#24372], [#24657]) diff --git a/src/Compat.jl b/src/Compat.jl index fb4d59e45..3346003f5 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -36,12 +36,6 @@ import Base: Fix2 include("compatmacro.jl") -# 0.7.0-DEV.912 -if VERSION < v"0.7.0-DEV.912" - import Base.* - (*)(s1::Union{Char,AbstractString}, ss::Union{Char,AbstractString}...) = string(s1, ss...) -end - # 0.7.0-DEV.2318 @static if !isdefined(Base, :BitSet) const BitSet = IntSet diff --git a/test/old.jl b/test/old.jl index 89578a61f..deb7a5360 100644 --- a/test/old.jl +++ b/test/old.jl @@ -482,3 +482,6 @@ end @test occursin("World", "Hello, World!") # 0.7.0-DEV.912 @test occursin('W', "Hello, World!") + +# 0.7 +@test 'a'*"b" == "a"*'b' == 'a'*'b' == "ab" diff --git a/test/runtests.jl b/test/runtests.jl index 7a1f96a24..22fa11c37 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -72,9 +72,6 @@ if VERSION < v"0.7.0-DEV.880" end end -# 0.7 -@test 'a'*"b" == "a"*'b' == 'a'*'b' == "ab" - # 0.7 @test 1 in BitSet(1:10) From 9350437500b3db8a665ac1d50a342dbd2b38a35d Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 21:11:46 +0200 Subject: [PATCH 045/121] Drop compat code for `BitSet` from #407 --- README.md | 2 -- src/Compat.jl | 6 ------ test/old.jl | 3 +++ test/runtests.jl | 3 --- 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index ca889b48d..6b8f84a7c 100644 --- a/README.md +++ b/README.md @@ -174,8 +174,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `reprmime(mime, x)` is now `repr(mime, x)` ([#25990]) and `mimewritable` is now `showable` ([#26089]). -* `IntSet` is now `BitSet` ([#24282]) - * `strwidth` and `charwidth` are now merged into `textwidth` ([#23667]). * `Complex32`, `Complex64`, and `Complex128` are now `ComplexF16`, `ComplexF32`, and diff --git a/src/Compat.jl b/src/Compat.jl index 3346003f5..832c93008 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -36,12 +36,6 @@ import Base: Fix2 include("compatmacro.jl") -# 0.7.0-DEV.2318 -@static if !isdefined(Base, :BitSet) - const BitSet = IntSet - export BitSet -end - # 0.7.0-DEV.2116 @static if VERSION < v"0.7.0-DEV.2116" import Compat.SparseArrays: spdiagm diff --git a/test/old.jl b/test/old.jl index deb7a5360..bdc405290 100644 --- a/test/old.jl +++ b/test/old.jl @@ -485,3 +485,6 @@ end # 0.7 @test 'a'*"b" == "a"*'b' == 'a'*'b' == "ab" + +# 0.7 +@test 1 in BitSet(1:10) diff --git a/test/runtests.jl b/test/runtests.jl index 22fa11c37..a09aaf5e0 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -72,9 +72,6 @@ if VERSION < v"0.7.0-DEV.880" end end -# 0.7 -@test 1 in BitSet(1:10) - # 0.7.0-DEV.1930 @test textwidth("A") == 1 @test textwidth('A') == 1 From 012edcb2ace72a6a0027c04a05c8b17972ed38bb Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 21:14:06 +0200 Subject: [PATCH 046/121] Drop compat code for `diagm and `spdiagm` with pairs from #408 --- README.md | 2 -- src/Compat.jl | 27 --------------------------- test/old.jl | 6 ++++++ test/runtests.jl | 6 ------ 4 files changed, 6 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 6b8f84a7c..f00cbbc4d 100644 --- a/README.md +++ b/README.md @@ -86,8 +86,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `isnothing` for testing if a variable is equal to `nothing` ([#29674]). -* `diagm` and `spdiagm` accept pairs mapping diagonals to vectors ([#24047], [#23757]) - * Constructors for `Matrix{T}`, `Array{T}`, and `SparseMatrixCSC{T}` from `UniformScaling` ([#24372], [#24657]) * Constructor for `Matrix` from `UniformScaling` ([#24372], [#24657]). diff --git a/src/Compat.jl b/src/Compat.jl index 832c93008..161672c88 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -36,33 +36,6 @@ import Base: Fix2 include("compatmacro.jl") -# 0.7.0-DEV.2116 -@static if VERSION < v"0.7.0-DEV.2116" - import Compat.SparseArrays: spdiagm - function spdiagm(kv::Pair...) - I, J, V = Compat.SparseArrays.spdiagm_internal(last.(kv), first.(kv)) - m = max(Compat.SparseArrays.dimlub(I), Compat.SparseArrays.dimlub(J)) - return sparse(I, J, V, m, m) - end -end - -# 0.7.0-DEV.2161 -@static if VERSION < v"0.7.0-DEV.2161" - import Base: diagm - function diagm(kv::Pair...) - T = promote_type(map(x -> eltype(x.second), kv)...) - n = Base.mapreduce(x -> length(x.second) + abs(x.first), max, kv) - A = zeros(T, n, n) - for p in kv - inds = diagind(A, p.first) - for (i, val) in enumerate(p.second) - A[inds[i]] += val - end - end - return A - end -end - # 0.7.0-DEV.2338 @static if VERSION >= v"0.7.0-DEV.2338" import Base64 diff --git a/test/old.jl b/test/old.jl index bdc405290..11017ca34 100644 --- a/test/old.jl +++ b/test/old.jl @@ -488,3 +488,9 @@ end # 0.7 @test 1 in BitSet(1:10) + +# 0.7 +@test diagm(0 => ones(2), -1 => ones(2)) == [1.0 0.0 0.0; 1.0 1.0 0.0; 0.0 1.0 0.0] +@test diagm(0 => ones(2), 1 => ones(2)) == [1.0 1.0 0.0; 0.0 1.0 1.0; 0.0 0.0 0.0] +@test spdiagm(0 => ones(2), -1 => ones(2)) == [1.0 0.0 0.0; 1.0 1.0 0.0; 0.0 1.0 0.0] +@test spdiagm(0 => ones(2), 1 => ones(2)) == [1.0 1.0 0.0; 0.0 1.0 1.0; 0.0 0.0 0.0] diff --git a/test/runtests.jl b/test/runtests.jl index a09aaf5e0..6e2d2efe6 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -76,12 +76,6 @@ end @test textwidth("A") == 1 @test textwidth('A') == 1 -# 0.7 -@test diagm(0 => ones(2), -1 => ones(2)) == [1.0 0.0 0.0; 1.0 1.0 0.0; 0.0 1.0 0.0] -@test diagm(0 => ones(2), 1 => ones(2)) == [1.0 1.0 0.0; 0.0 1.0 1.0; 0.0 0.0 0.0] -@test spdiagm(0 => ones(2), -1 => ones(2)) == [1.0 0.0 0.0; 1.0 1.0 0.0; 0.0 1.0 0.0] -@test spdiagm(0 => ones(2), 1 => ones(2)) == [1.0 1.0 0.0; 0.0 1.0 1.0; 0.0 0.0 0.0] - # 0.7 let a = [1 0 0; 0 1 0; 0 0 1] @test Matrix{Int}(I, 3, 3)::Matrix{Int} == a From eb0888846f3884ea376ae7bcc5246ef359a56e92 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 21:15:56 +0200 Subject: [PATCH 047/121] Mark `Compat.Base64` from #418 for deprecation --- README.md | 3 --- src/Compat.jl | 8 +------- test/old.jl | 7 +++++++ test/runtests.jl | 7 ------- 4 files changed, 8 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index f00cbbc4d..226366183 100644 --- a/README.md +++ b/README.md @@ -52,9 +52,6 @@ Currently, the `@compat` macro supports the following syntaxes: ## Module Aliases -* `using Compat.Base64` is provided on versions older than 0.7, where this library is not - yet a part of the standard library. ([#24361]) - * `using Compat.Unicode` is provided on versions older than 0.7, where this library is not yet a part of the standard library. ([#25021]) diff --git a/src/Compat.jl b/src/Compat.jl index 161672c88..4ab177997 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -32,17 +32,11 @@ import REPL import Serialization import Statistics import Base: Fix2 +import Base64 include("compatmacro.jl") -# 0.7.0-DEV.2338 -@static if VERSION >= v"0.7.0-DEV.2338" - import Base64 -else - import Base.Base64 -end - @static if VERSION < v"0.7.0-DEV.2377" (::Type{Matrix{T}}){T}(s::UniformScaling, dims::Dims{2}) = setindex!(zeros(T, dims), T(s.λ), diagind(dims...)) (::Type{Matrix{T}}){T}(s::UniformScaling, m::Integer, n::Integer) = Matrix{T}(s, Dims((m, n))) diff --git a/test/old.jl b/test/old.jl index 11017ca34..289c29cf4 100644 --- a/test/old.jl +++ b/test/old.jl @@ -158,6 +158,13 @@ module TestSerialization end end +# 0.7.0-DEV.2338 +module Test24361 + using Compat + using Compat.Test + @test String(Compat.Base64.base64decode("SGVsbG8h")) == "Hello!" +end + # tests of removed functionality (i.e. justs tests Base) diff --git a/test/runtests.jl b/test/runtests.jl index 6e2d2efe6..f58671a64 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -107,13 +107,6 @@ end @test get(IOContext(IOBuffer(), :arg1=>true, :arg2=>true, :arg3=>true), :arg3, false) @test get(IOContext(IOBuffer(), :arg1=>true, :arg2=>true), :arg2, false) -# 0.7.0-DEV.2338 -module Test24361 - using Compat - using Compat.Test - @test String(Compat.Base64.base64decode("SGVsbG8h")) == "Hello!" -end - # 0.7 let A = [1] local x = 0 From cfd0637b755f62a57ec6bd56b1b7347df8c86afd Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 21:19:46 +0200 Subject: [PATCH 048/121] Drop compat code for `Array` c'tors from `UniformScaling` from #412 and #438 --- README.md | 4 ---- src/Compat.jl | 27 --------------------------- test/old.jl | 15 +++++++++++++++ test/runtests.jl | 15 --------------- 4 files changed, 15 insertions(+), 46 deletions(-) diff --git a/README.md b/README.md index 226366183..df3058a99 100644 --- a/README.md +++ b/README.md @@ -83,10 +83,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `isnothing` for testing if a variable is equal to `nothing` ([#29674]). -* Constructors for `Matrix{T}`, `Array{T}`, and `SparseMatrixCSC{T}` from `UniformScaling` ([#24372], [#24657]) - -* Constructor for `Matrix` from `UniformScaling` ([#24372], [#24657]). - * `UndefInitializer` and `undef` with corresponding `Array` constructors ([#24652], [#26316]). * `BitArray` constructors for `undef` ([#24785], [#26316]). diff --git a/src/Compat.jl b/src/Compat.jl index 4ab177997..0339e4507 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -37,33 +37,6 @@ import Base64 include("compatmacro.jl") -@static if VERSION < v"0.7.0-DEV.2377" - (::Type{Matrix{T}}){T}(s::UniformScaling, dims::Dims{2}) = setindex!(zeros(T, dims), T(s.λ), diagind(dims...)) - (::Type{Matrix{T}}){T}(s::UniformScaling, m::Integer, n::Integer) = Matrix{T}(s, Dims((m, n))) - - (::Type{SparseMatrixCSC{Tv,Ti}}){Tv,Ti}(s::UniformScaling, m::Integer, n::Integer) = SparseMatrixCSC{Tv,Ti}(s, Dims((m, n))) - (::Type{SparseMatrixCSC{Tv}}){Tv}(s::UniformScaling, m::Integer, n::Integer) = SparseMatrixCSC{Tv}(s, Dims((m, n))) - (::Type{SparseMatrixCSC{Tv}}){Tv}(s::UniformScaling, dims::Dims{2}) = SparseMatrixCSC{Tv,Int}(s, dims) - function (::Type{SparseMatrixCSC{Tv,Ti}}){Tv,Ti}(s::UniformScaling, dims::Dims{2}) - @boundscheck first(dims) < 0 && throw(ArgumentError("first dimension invalid ($(first(dims)) < 0)")) - @boundscheck last(dims) < 0 && throw(ArgumentError("second dimension invalid ($(last(dims)) < 0)")) - iszero(s.λ) && return spzeros(Tv, Ti, dims...) - m, n, k = dims..., min(dims...) - nzval = fill!(Vector{Tv}(k), Tv(s.λ)) - rowval = copy!(Vector{Ti}(k), 1:k) - colptr = copy!(Vector{Ti}(n + 1), 1:(k + 1)) - for i in (k + 2):(n + 1) colptr[i] = (k + 1) end - SparseMatrixCSC{Tv,Ti}(dims..., colptr, rowval, nzval) - end -end -@static if VERSION < v"0.7.0-DEV.2543" - (::Type{Array{T}}){T}(s::UniformScaling, dims::Dims{2}) = Matrix{T}(s, dims) - (::Type{Array{T}}){T}(s::UniformScaling, m::Integer, n::Integer) = Matrix{T}(s, m, n) -end -@static if VERSION < v"0.7.0-DEV.2541" - (::Type{Matrix})(s::UniformScaling{T}, dims...) where {T} = Matrix{T}(s, dims...) -end - # https://github.com/JuliaLang/julia/pull/23271 @static if VERSION < v"0.7.0-DEV.1472" Base.IOContext(io::IO, arg1::Pair, arg2::Pair, args::Pair...) = IOContext(IOContext(io, arg1), arg2, args...) diff --git a/test/old.jl b/test/old.jl index 289c29cf4..ef302effd 100644 --- a/test/old.jl +++ b/test/old.jl @@ -501,3 +501,18 @@ end @test diagm(0 => ones(2), 1 => ones(2)) == [1.0 1.0 0.0; 0.0 1.0 1.0; 0.0 0.0 0.0] @test spdiagm(0 => ones(2), -1 => ones(2)) == [1.0 0.0 0.0; 1.0 1.0 0.0; 0.0 1.0 0.0] @test spdiagm(0 => ones(2), 1 => ones(2)) == [1.0 1.0 0.0; 0.0 1.0 1.0; 0.0 0.0 0.0] + +# 0.7 +let a = [1 0 0; 0 1 0; 0 0 1] + @test Matrix{Int}(I, 3, 3)::Matrix{Int} == a + @test Matrix{Float64}(I, (3, 2))::Matrix{Float64} == a[:,1:2] + @test Array{Int}(I, (3, 3))::Matrix{Int} == a + @test Array{Float64}(I, 3, 2)::Matrix{Float64} == a[:,1:2] + @test SparseMatrixCSC{Int}(I, 3, 3)::SparseMatrixCSC{Int,Int} == a + @test SparseMatrixCSC{Float64}(I, (3, 2))::SparseMatrixCSC{Float64,Int} == a[:,1:2] + @test SparseMatrixCSC{Bool,Int16}(I, (3, 3))::SparseMatrixCSC{Bool,Int16} == a + @test SparseMatrixCSC{ComplexF64,Int8}(I, 3, 2)::SparseMatrixCSC{ComplexF64,Int8} == a[:,1:2] + + @test Matrix(2I, 3, 3)::Matrix{Int} == Matrix(2I, (3, 3))::Matrix{Int} == 2a + @test Matrix(2.0I, 3, 3)::Matrix{Float64} == Matrix(2.0I, (3, 3))::Matrix{Float64} == 2a +end diff --git a/test/runtests.jl b/test/runtests.jl index f58671a64..fb2d7d11f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -76,21 +76,6 @@ end @test textwidth("A") == 1 @test textwidth('A') == 1 -# 0.7 -let a = [1 0 0; 0 1 0; 0 0 1] - @test Matrix{Int}(I, 3, 3)::Matrix{Int} == a - @test Matrix{Float64}(I, (3, 2))::Matrix{Float64} == a[:,1:2] - @test Array{Int}(I, (3, 3))::Matrix{Int} == a - @test Array{Float64}(I, 3, 2)::Matrix{Float64} == a[:,1:2] - @test SparseMatrixCSC{Int}(I, 3, 3)::SparseMatrixCSC{Int,Int} == a - @test SparseMatrixCSC{Float64}(I, (3, 2))::SparseMatrixCSC{Float64,Int} == a[:,1:2] - @test SparseMatrixCSC{Bool,Int16}(I, (3, 3))::SparseMatrixCSC{Bool,Int16} == a - @test SparseMatrixCSC{ComplexF64,Int8}(I, 3, 2)::SparseMatrixCSC{ComplexF64,Int8} == a[:,1:2] - - @test Matrix(2I, 3, 3)::Matrix{Int} == Matrix(2I, (3, 3))::Matrix{Int} == 2a - @test Matrix(2.0I, 3, 3)::Matrix{Float64} == Matrix(2.0I, (3, 3))::Matrix{Float64} == 2a -end - # 0.7.0-DEV.2581, 0.7.0-DEV.4527 @test isa(Vector(undef, 2), Vector{Any}) @test isa(Vector{Float64}(undef, 2), Vector{Float64}) From 4384180e17f5c587f0e2005b5328cde3847fa5bb Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 21:21:49 +0200 Subject: [PATCH 049/121] Drop compat code for `IOContext` ctor taking pairs from #427 --- README.md | 2 -- src/Compat.jl | 7 ------- test/old.jl | 4 ++++ test/runtests.jl | 4 ---- 4 files changed, 4 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index df3058a99..b180130e6 100644 --- a/README.md +++ b/README.md @@ -90,8 +90,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `@compat finalizer(func, obj)` with the finalizer to run as the first argument and the object to be finalized as the second ([#24605]). -* `IOContext` accepting key-value `Pair`s ([#23271]). - * `get` do-block syntax supported when using `ENV` ([#23412]). * `Some{T}` wraps `T` to signify that a result of `T<:Void` is expected ([#23642]). diff --git a/src/Compat.jl b/src/Compat.jl index 0339e4507..393408c2d 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -37,13 +37,6 @@ import Base64 include("compatmacro.jl") -# https://github.com/JuliaLang/julia/pull/23271 -@static if VERSION < v"0.7.0-DEV.1472" - Base.IOContext(io::IO, arg1::Pair, arg2::Pair, args::Pair...) = IOContext(IOContext(io, arg1), arg2, args...) - # needed for ambiguity resolution - Base.IOContext(io::IOContext, arg1::Pair, arg2::Pair) = IOContext(IOContext(io, arg1), arg2) -end - # 0.7.0-DEV.4527 @static if !isdefined(Base, :UndefInitializer) import Base: Array, Matrix, Vector diff --git a/test/old.jl b/test/old.jl index ef302effd..0f2059ec1 100644 --- a/test/old.jl +++ b/test/old.jl @@ -516,3 +516,7 @@ let a = [1 0 0; 0 1 0; 0 0 1] @test Matrix(2I, 3, 3)::Matrix{Int} == Matrix(2I, (3, 3))::Matrix{Int} == 2a @test Matrix(2.0I, 3, 3)::Matrix{Float64} == Matrix(2.0I, (3, 3))::Matrix{Float64} == 2a end + +# 0.7.0-DEV.1472 +@test get(IOContext(IOBuffer(), :arg1=>true, :arg2=>true, :arg3=>true), :arg3, false) +@test get(IOContext(IOBuffer(), :arg1=>true, :arg2=>true), :arg2, false) diff --git a/test/runtests.jl b/test/runtests.jl index fb2d7d11f..5b8a12499 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -88,10 +88,6 @@ end @test isa(BitVector(undef, 2), BitVector) @test isa(BitArray(undef, 2, 2), BitMatrix) -# 0.7.0-DEV.1472 -@test get(IOContext(IOBuffer(), :arg1=>true, :arg2=>true, :arg3=>true), :arg3, false) -@test get(IOContext(IOBuffer(), :arg1=>true, :arg2=>true), :arg2, false) - # 0.7 let A = [1] local x = 0 From 8b628e772e09496aaccce8f610480c718c4da51a Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 21:25:22 +0200 Subject: [PATCH 050/121] Remove compat code `undef` from #417 and #514 --- README.md | 4 ---- src/Compat.jl | 27 --------------------------- test/old.jl | 12 ++++++++++++ test/runtests.jl | 12 ------------ 4 files changed, 12 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index b180130e6..b9410bc3b 100644 --- a/README.md +++ b/README.md @@ -83,10 +83,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `isnothing` for testing if a variable is equal to `nothing` ([#29674]). -* `UndefInitializer` and `undef` with corresponding `Array` constructors ([#24652], [#26316]). - -* `BitArray` constructors for `undef` ([#24785], [#26316]). - * `@compat finalizer(func, obj)` with the finalizer to run as the first argument and the object to be finalized as the second ([#24605]). diff --git a/src/Compat.jl b/src/Compat.jl index 393408c2d..a3ea44b08 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -37,33 +37,6 @@ import Base64 include("compatmacro.jl") -# 0.7.0-DEV.4527 -@static if !isdefined(Base, :UndefInitializer) - import Base: Array, Matrix, Vector - @static if isdefined(Base, :Uninitialized) - useuninit(args) = (Base.uninitialized, args...) - else - useuninit(args) = args - end - struct UndefInitializer end - const undef = UndefInitializer() - export undef, UndefInitializer - Base.show(io::IO, ::UndefInitializer) = - print(io, "array initializer with undefined values") - Array{T}(::UndefInitializer, args...) where {T} = Array{T}(useuninit(args)...) - Array{T,N}(::UndefInitializer, args...) where {T,N} = Array{T,N}(useuninit(args)...) - Vector(::UndefInitializer, args...) = Vector(useuninit(args)...) - Matrix(::UndefInitializer, args...) = Matrix(useuninit(args)...) - - BitArray{N}(::UndefInitializer, args...) where {N} = BitArray{N}(useuninit(args)...) - BitArray(::UndefInitializer, args...) = BitArray(useuninit(args)...) -end -@static if VERSION < v"0.7.0-DEV.2581" - export uninitialized, Uninitialized - const uninitialized = undef - const Uninitialized = UndefInitializer -end - # 0.7.0-DEV.1499 if VERSION < v"0.7.0-DEV.1499" function Base.get(f::Base.Callable, ::Base.EnvHash, k::AbstractString) diff --git a/test/old.jl b/test/old.jl index 0f2059ec1..4639763db 100644 --- a/test/old.jl +++ b/test/old.jl @@ -520,3 +520,15 @@ end # 0.7.0-DEV.1472 @test get(IOContext(IOBuffer(), :arg1=>true, :arg2=>true, :arg3=>true), :arg3, false) @test get(IOContext(IOBuffer(), :arg1=>true, :arg2=>true), :arg2, false) + +# 0.7.0-DEV.2581, 0.7.0-DEV.4527 +@test isa(Vector(undef, 2), Vector{Any}) +@test isa(Vector{Float64}(undef, 2), Vector{Float64}) +@test isa(Matrix(undef, 2, 2), Matrix{Any}) +@test isa(Matrix{Float64}(undef, 2, 2), Matrix{Float64}) +@test isa(Array{Float64}(undef, 2, 2), Matrix{Float64}) +@test isa(Array{Float64,3}(undef, 2, 2, 2), Array{Float64,3}) + +# 0.7.0-DEV.2687, 0.7.0-DEV.4527 +@test isa(BitVector(undef, 2), BitVector) +@test isa(BitArray(undef, 2, 2), BitMatrix) diff --git a/test/runtests.jl b/test/runtests.jl index 5b8a12499..ff9563f6a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -76,18 +76,6 @@ end @test textwidth("A") == 1 @test textwidth('A') == 1 -# 0.7.0-DEV.2581, 0.7.0-DEV.4527 -@test isa(Vector(undef, 2), Vector{Any}) -@test isa(Vector{Float64}(undef, 2), Vector{Float64}) -@test isa(Matrix(undef, 2, 2), Matrix{Any}) -@test isa(Matrix{Float64}(undef, 2, 2), Matrix{Float64}) -@test isa(Array{Float64}(undef, 2, 2), Matrix{Float64}) -@test isa(Array{Float64,3}(undef, 2, 2, 2), Array{Float64,3}) - -# 0.7.0-DEV.2687, 0.7.0-DEV.4527 -@test isa(BitVector(undef, 2), BitVector) -@test isa(BitArray(undef, 2, 2), BitMatrix) - # 0.7 let A = [1] local x = 0 From 326d1b173e64801aebfa4f4e8323e20a08900272 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 21:30:17 +0200 Subject: [PATCH 051/121] Drop compat code for `get` on `ENV` from #430 --- README.md | 2 -- src/Compat.jl | 7 ------- test/old.jl | 6 ++++++ test/runtests.jl | 6 ------ 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index b9410bc3b..4f9595818 100644 --- a/README.md +++ b/README.md @@ -86,8 +86,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `@compat finalizer(func, obj)` with the finalizer to run as the first argument and the object to be finalized as the second ([#24605]). -* `get` do-block syntax supported when using `ENV` ([#23412]). - * `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 diff --git a/src/Compat.jl b/src/Compat.jl index a3ea44b08..b341cdc74 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -37,13 +37,6 @@ import Base64 include("compatmacro.jl") -# 0.7.0-DEV.1499 -if VERSION < v"0.7.0-DEV.1499" - function Base.get(f::Base.Callable, ::Base.EnvHash, k::AbstractString) - Base.access_env(k->f(), k) - end -end - # 0.7.0-DEV.2919 @static if !isdefined(Base, :ComplexF16) const ComplexF16 = Complex{Float16} diff --git a/test/old.jl b/test/old.jl index 4639763db..7cea97632 100644 --- a/test/old.jl +++ b/test/old.jl @@ -532,3 +532,9 @@ end # 0.7.0-DEV.2687, 0.7.0-DEV.4527 @test isa(BitVector(undef, 2), BitVector) @test isa(BitArray(undef, 2, 2), BitMatrix) + +# 0.7.0-DEV.1499 +let key = "TEST_23412" + @test !haskey(ENV, key) + @test get(() -> "default", ENV, key) == "default" +end diff --git a/test/runtests.jl b/test/runtests.jl index ff9563f6a..af2189075 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -87,12 +87,6 @@ let A = [1] @test x == 1 end -# 0.7.0-DEV.1499 -let key = "TEST_23412" - @test !haskey(ENV, key) - @test get(() -> "default", ENV, key) == "default" -end - # 0.7.0-DEV.2919 @test ComplexF16 === Complex{Float16} @test ComplexF32 === Complex{Float32} From 9e64b41286dd4b3f4b810dab688e191acbdad4cd Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 21:33:09 +0200 Subject: [PATCH 052/121] Drop compat code for `ComplexF...` from #431 --- README.md | 3 --- src/Compat.jl | 14 -------------- test/old.jl | 5 +++++ test/runtests.jl | 5 ----- 4 files changed, 5 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 4f9595818..98147cb83 100644 --- a/README.md +++ b/README.md @@ -159,9 +159,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `strwidth` and `charwidth` are now merged into `textwidth` ([#23667]). -* `Complex32`, `Complex64`, and `Complex128` are now `ComplexF16`, `ComplexF32`, and - `ComplexF64`, respectively ([#24647]). - * `trace` is now `tr`, available as `Compat.tr` ([#26365]). * `Associative` is now `AbstractDict` ([#25012]). diff --git a/src/Compat.jl b/src/Compat.jl index b341cdc74..920b93ce5 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -37,20 +37,6 @@ import Base64 include("compatmacro.jl") -# 0.7.0-DEV.2919 -@static if !isdefined(Base, :ComplexF16) - const ComplexF16 = Complex{Float16} - export ComplexF16 -end -@static if !isdefined(Base, :ComplexF32) - const ComplexF32 = Complex{Float32} - export ComplexF32 -end -@static if !isdefined(Base, :ComplexF64) - const ComplexF64 = Complex{Float64} - export ComplexF64 -end - # julia #26365 @static if isdefined(LinearAlgebra, :tr) const tr = LinearAlgebra.tr diff --git a/test/old.jl b/test/old.jl index 7cea97632..0ff028890 100644 --- a/test/old.jl +++ b/test/old.jl @@ -538,3 +538,8 @@ let key = "TEST_23412" @test !haskey(ENV, key) @test get(() -> "default", ENV, key) == "default" end + +# 0.7.0-DEV.2919 +@test ComplexF16 === Complex{Float16} +@test ComplexF32 === Complex{Float32} +@test ComplexF64 === Complex{Float64} diff --git a/test/runtests.jl b/test/runtests.jl index af2189075..d96fbda0c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -87,11 +87,6 @@ let A = [1] @test x == 1 end -# 0.7.0-DEV.2919 -@test ComplexF16 === Complex{Float16} -@test ComplexF32 === Complex{Float32} -@test ComplexF64 === Complex{Float64} - # 0.7.0-DEV.2915 module Test25021 using Compat From 563f2bf386edb140784bc54e48859b18d7f18bb6 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 21:35:12 +0200 Subject: [PATCH 053/121] Drop compat code for `tr` from #614 --- README.md | 2 -- src/Compat.jl | 9 +-------- test/old.jl | 3 +++ test/runtests.jl | 3 --- 4 files changed, 4 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 98147cb83..cf6a478db 100644 --- a/README.md +++ b/README.md @@ -159,8 +159,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `strwidth` and `charwidth` are now merged into `textwidth` ([#23667]). -* `trace` is now `tr`, available as `Compat.tr` ([#26365]). - * `Associative` is now `AbstractDict` ([#25012]). * `indices` is now `axes` ([#25057]). This function is not exported from Compat to avoid diff --git a/src/Compat.jl b/src/Compat.jl index 920b93ce5..37ffa7642 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -33,18 +33,11 @@ import Serialization import Statistics import Base: Fix2 import Base64 +const tr = LinearAlgebra.tr include("compatmacro.jl") -# julia #26365 -@static if isdefined(LinearAlgebra, :tr) - const tr = LinearAlgebra.tr -else - # 0.6 - const tr = LinearAlgebra.trace -end - if VERSION < v"0.7.0-DEV.1930" # no textwidth definition in Base export textwidth diff --git a/test/old.jl b/test/old.jl index 0ff028890..a396a3987 100644 --- a/test/old.jl +++ b/test/old.jl @@ -165,6 +165,9 @@ module Test24361 @test String(Compat.Base64.base64decode("SGVsbG8h")) == "Hello!" end +# julia#26365 +@test Compat.tr([1 2; 3 5]) == 6 + # tests of removed functionality (i.e. justs tests Base) diff --git a/test/runtests.jl b/test/runtests.jl index d96fbda0c..02c468490 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -38,9 +38,6 @@ if VERSION >= v"0.7" end end -# julia#26365 -@test Compat.tr([1 2; 3 5]) == 6 - let x = view(1:10, 2:4) D = Diagonal(x) From 221984a5576cd5822c2f3ee2280fd0dece5aec24 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 21:38:04 +0200 Subject: [PATCH 054/121] Drop compat code for `textwidth` from #644 --- README.md | 2 -- src/Compat.jl | 12 ------------ test/old.jl | 4 ++++ test/runtests.jl | 4 ---- 4 files changed, 4 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index cf6a478db..3d40598fb 100644 --- a/README.md +++ b/README.md @@ -157,8 +157,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `reprmime(mime, x)` is now `repr(mime, x)` ([#25990]) and `mimewritable` is now `showable` ([#26089]). -* `strwidth` and `charwidth` are now merged into `textwidth` ([#23667]). - * `Associative` is now `AbstractDict` ([#25012]). * `indices` is now `axes` ([#25057]). This function is not exported from Compat to avoid diff --git a/src/Compat.jl b/src/Compat.jl index 37ffa7642..5d551efc3 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -38,18 +38,6 @@ const tr = LinearAlgebra.tr include("compatmacro.jl") -if VERSION < v"0.7.0-DEV.1930" - # no textwidth definition in Base - export textwidth - textwidth(c::Char) = charwidth(c) - textwidth(c::AbstractString) = strwidth(c) -elseif v"0.7.0-DEV.2915" ≤ VERSION < v"0.7.0-DEV.3393" - # textwidth definition moved to Unicode module - import Unicode - const textwidth = Unicode.textwidth - export textwidth -end - # 0.7.0-DEV.2915 module Unicode export graphemes, textwidth, isvalid, diff --git a/test/old.jl b/test/old.jl index a396a3987..86537ac67 100644 --- a/test/old.jl +++ b/test/old.jl @@ -546,3 +546,7 @@ end @test ComplexF16 === Complex{Float16} @test ComplexF32 === Complex{Float32} @test ComplexF64 === Complex{Float64} + +# 0.7.0-DEV.1930 +@test textwidth("A") == 1 +@test textwidth('A') == 1 diff --git a/test/runtests.jl b/test/runtests.jl index 02c468490..47785e08c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -69,10 +69,6 @@ if VERSION < v"0.7.0-DEV.880" end end -# 0.7.0-DEV.1930 -@test textwidth("A") == 1 -@test textwidth('A') == 1 - # 0.7 let A = [1] local x = 0 From 5a06c75cfabae30168c5a27176fe2dd988a14ef6 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 21:42:01 +0200 Subject: [PATCH 055/121] Mark `Compat.Unicode` from #432 and #507 for deprecation --- README.md | 3 --- src/Compat.jl | 22 ++++------------------ test/old.jl | 15 +++++++++++++++ test/runtests.jl | 15 --------------- 4 files changed, 19 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 3d40598fb..c16d05ec3 100644 --- a/README.md +++ b/README.md @@ -52,9 +52,6 @@ Currently, the `@compat` macro supports the following syntaxes: ## Module Aliases -* `using Compat.Unicode` is provided on versions older than 0.7, where this library is not - yet a part of the standard library. ([#25021]) - * `using Compat.Distributed` is provided on versions older than 0.7, where this library is not yet part of the standard library ([#24443]). diff --git a/src/Compat.jl b/src/Compat.jl index 5d551efc3..c23994542 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -34,31 +34,17 @@ import Statistics import Base: Fix2 import Base64 const tr = LinearAlgebra.tr - - -include("compatmacro.jl") - -# 0.7.0-DEV.2915 module Unicode export graphemes, textwidth, isvalid, islower, isupper, isalpha, isdigit, isxdigit, isnumeric, isalnum, iscntrl, ispunct, isspace, isprint, isgraph, lowercase, uppercase, titlecase, lcfirst, ucfirst + using Unicode + import Unicode: isassigned, normalize # not exported from Unicode module due to conflicts +end - if VERSION < v"0.7.0-DEV.2915" - if VERSION < v"0.7.0-DEV.1930" - import ..Compat: textwidth - end - isnumeric(c::Char) = isnumber(c) - isassigned(c) = is_assigned_char(c) - normalize(s::AbstractString; kws...) = normalize_string(s; kws...) - normalize(s::AbstractString, nf::Symbol) = normalize_string(s, nf) - else - using Unicode - import Unicode: isassigned, normalize # not exported from Unicode module due to conflicts - end -end +include("compatmacro.jl") # 0.7.0-DEV.3393 @static if VERSION < v"0.7.0-DEV.3393" diff --git a/test/old.jl b/test/old.jl index 86537ac67..d36abbbe3 100644 --- a/test/old.jl +++ b/test/old.jl @@ -168,6 +168,21 @@ end # julia#26365 @test Compat.tr([1 2; 3 5]) == 6 +# 0.7.0-DEV.2915 +module Test25021 + using Compat + using Compat.Test + using Compat.Unicode + @test isdefined(@__MODULE__, :Unicode) + + @test !isnumeric('a') + @test isnumeric('1') + @test titlecase("firstname lastname") == "Firstname Lastname" + @test Compat.Unicode.isassigned('柒') && !Compat.Unicode.isassigned(0xfffe) + @test Compat.Unicode.normalize("\U1e9b\U0323", :NFKC) == "\U1e69" + @test Compat.Unicode.normalize("\t\r", stripcc=true) == " " +end + # tests of removed functionality (i.e. justs tests Base) diff --git a/test/runtests.jl b/test/runtests.jl index 47785e08c..14223cf96 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -80,21 +80,6 @@ let A = [1] @test x == 1 end -# 0.7.0-DEV.2915 -module Test25021 - using Compat - using Compat.Test - using Compat.Unicode - @test isdefined(@__MODULE__, :Unicode) - - @test !isnumeric('a') - @test isnumeric('1') - @test titlecase("firstname lastname") == "Firstname Lastname" - @test Compat.Unicode.isassigned('柒') && !Compat.Unicode.isassigned(0xfffe) - @test Compat.Unicode.normalize("\U1e9b\U0323", :NFKC) == "\U1e69" - @test Compat.Unicode.normalize("\t\r", stripcc=true) == " " -end - # 0.7.0-DEV.3393 @test !isnumeric('a') @test isnumeric('1') From f6ab8aaf81305ae24f9e360443c6d0001becdf92 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 21:43:34 +0200 Subject: [PATCH 056/121] Drop compat code for `isnumeric` from #543 --- README.md | 2 -- src/Compat.jl | 6 ------ test/old.jl | 4 ++++ test/runtests.jl | 4 ---- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index c16d05ec3..c44eac0d3 100644 --- a/README.md +++ b/README.md @@ -213,8 +213,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `cfunction` is now `@cfunction` ([#26486]). -* `Unicode.isnumeric` is now available as `isnumeric` ([#25479]). - * `vecnorm` and `vecdot` are now `Compat.norm` and `Compat.dot`, respectively, while the old `norm(A::AbstractMatrix, p=2)` is now `Compat.opnorm` ([#27401]). `import Compat: ⋅` to get `Compat.dot` as the binary operator `⋅`. diff --git a/src/Compat.jl b/src/Compat.jl index c23994542..6ea0ffa8b 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -46,12 +46,6 @@ end include("compatmacro.jl") -# 0.7.0-DEV.3393 -@static if VERSION < v"0.7.0-DEV.3393" - import .Unicode.isnumeric - export isnumeric -end - # 0.7.0-DEV.2951 @static if !isdefined(Base, :AbstractDict) const AbstractDict = Associative diff --git a/test/old.jl b/test/old.jl index d36abbbe3..4577d808e 100644 --- a/test/old.jl +++ b/test/old.jl @@ -565,3 +565,7 @@ end # 0.7.0-DEV.1930 @test textwidth("A") == 1 @test textwidth('A') == 1 + +# 0.7.0-DEV.3393 +@test !isnumeric('a') +@test isnumeric('1') diff --git a/test/runtests.jl b/test/runtests.jl index 14223cf96..c3764a35c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -80,10 +80,6 @@ let A = [1] @test x == 1 end -# 0.7.0-DEV.3393 -@test !isnumeric('a') -@test isnumeric('1') - # 0.7.0-DEV.2951 @test AbstractDict === (isdefined(Base, :AbstractDict) ? Base.AbstractDict : Base.Associative) From 27a178c64ad747ee90d01b24e5330296a3447c2f Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 21:45:32 +0200 Subject: [PATCH 057/121] Drop compat code for `AbstractDict` from #435 --- README.md | 2 -- src/Compat.jl | 6 ------ test/old.jl | 3 +++ test/runtests.jl | 3 --- 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index c44eac0d3..86464b119 100644 --- a/README.md +++ b/README.md @@ -154,8 +154,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `reprmime(mime, x)` is now `repr(mime, x)` ([#25990]) and `mimewritable` is now `showable` ([#26089]). -* `Associative` is now `AbstractDict` ([#25012]). - * `indices` is now `axes` ([#25057]). This function is not exported from Compat to avoid conflicts with AxisArrays and other such packages. diff --git a/src/Compat.jl b/src/Compat.jl index 6ea0ffa8b..338a4c711 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -46,12 +46,6 @@ end include("compatmacro.jl") -# 0.7.0-DEV.2951 -@static if !isdefined(Base, :AbstractDict) - const AbstractDict = Associative - export AbstractDict -end - # 0.7.0-DEV.2978 @static if !isdefined(Base, :axes) const axes = Base.indices diff --git a/test/old.jl b/test/old.jl index 4577d808e..903546531 100644 --- a/test/old.jl +++ b/test/old.jl @@ -569,3 +569,6 @@ end # 0.7.0-DEV.3393 @test !isnumeric('a') @test isnumeric('1') + +# 0.7.0-DEV.2951 +@test AbstractDict === (isdefined(Base, :AbstractDict) ? Base.AbstractDict : Base.Associative) diff --git a/test/runtests.jl b/test/runtests.jl index c3764a35c..610f3a59b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -80,9 +80,6 @@ let A = [1] @test x == 1 end -# 0.7.0-DEV.2951 -@test AbstractDict === (isdefined(Base, :AbstractDict) ? Base.AbstractDict : Base.Associative) - # 0.7.0-DEV.2978 @test Compat.axes === (isdefined(Base, :axes) ? Base.axes : Base.indices) @test Compat.axes(1) == () From 5522d246bbe691b23ce6d4f5e8ecd820dda27a40 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 21:47:19 +0200 Subject: [PATCH 058/121] Drop compat for `axes` #435 and #442 --- README.md | 3 --- src/Compat.jl | 7 ------- test/old.jl | 5 +++++ test/runtests.jl | 5 ----- 4 files changed, 5 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 86464b119..7d7b43a52 100644 --- a/README.md +++ b/README.md @@ -154,9 +154,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `reprmime(mime, x)` is now `repr(mime, x)` ([#25990]) and `mimewritable` is now `showable` ([#26089]). -* `indices` is now `axes` ([#25057]). This function is not exported from Compat to avoid - conflicts with AxisArrays and other such packages. - * `Void` is now `Nothing` with an alias `Cvoid` for C interop ([#25162]). * `Base.IteratorSize` and `Base.IteratorEltype` are available as diff --git a/src/Compat.jl b/src/Compat.jl index 338a4c711..c1f69e772 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -46,13 +46,6 @@ end include("compatmacro.jl") -# 0.7.0-DEV.2978 -@static if !isdefined(Base, :axes) - const axes = Base.indices - # NOTE: Intentionally not exported to avoid conflicts with AxisArrays - #export axes -end - # 0.7.0-DEV.3137 @static if !isdefined(Base, :Nothing) const Nothing = Void diff --git a/test/old.jl b/test/old.jl index 903546531..479abccd9 100644 --- a/test/old.jl +++ b/test/old.jl @@ -572,3 +572,8 @@ end # 0.7.0-DEV.2951 @test AbstractDict === (isdefined(Base, :AbstractDict) ? Base.AbstractDict : Base.Associative) + +# 0.7.0-DEV.2978 +@test Compat.axes === (isdefined(Base, :axes) ? Base.axes : Base.indices) +@test Compat.axes(1) == () +@test Compat.axes(1,1) == 1:1 diff --git a/test/runtests.jl b/test/runtests.jl index 610f3a59b..8dbdff7bc 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -80,11 +80,6 @@ let A = [1] @test x == 1 end -# 0.7.0-DEV.2978 -@test Compat.axes === (isdefined(Base, :axes) ? Base.axes : Base.indices) -@test Compat.axes(1) == () -@test Compat.axes(1,1) == 1:1 - # 0.7.0-DEV.3137 @test Nothing === (isdefined(Base, :Nothing) ? Base.Nothing : Base.Void) @test Nothing === Cvoid From d744d248a799ac53fdf134f3a5603d179274cc39 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 21:49:03 +0200 Subject: [PATCH 059/121] Drop compat code for `Nothing` and `Cvoid` from #435 --- README.md | 2 -- src/Compat.jl | 7 ------- test/old.jl | 4 ++++ test/runtests.jl | 4 ---- 4 files changed, 4 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 7d7b43a52..452770b76 100644 --- a/README.md +++ b/README.md @@ -154,8 +154,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `reprmime(mime, x)` is now `repr(mime, x)` ([#25990]) and `mimewritable` is now `showable` ([#26089]). -* `Void` is now `Nothing` with an alias `Cvoid` for C interop ([#25162]). - * `Base.IteratorSize` and `Base.IteratorEltype` are available as `Compat.IteratorSize` and `Compat.IteratorEltype` ([#25402]). diff --git a/src/Compat.jl b/src/Compat.jl index c1f69e772..8a7e68ada 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -46,13 +46,6 @@ end include("compatmacro.jl") -# 0.7.0-DEV.3137 -@static if !isdefined(Base, :Nothing) - const Nothing = Void - const Cvoid = Void - export Nothing, Cvoid -end - # https://github.com/JuliaLang/julia/pull/29679 if VERSION < v"1.1.0-DEV.472" export isnothing diff --git a/test/old.jl b/test/old.jl index 479abccd9..a08f10505 100644 --- a/test/old.jl +++ b/test/old.jl @@ -577,3 +577,7 @@ end @test Compat.axes === (isdefined(Base, :axes) ? Base.axes : Base.indices) @test Compat.axes(1) == () @test Compat.axes(1,1) == 1:1 + +# 0.7.0-DEV.3137 +@test Nothing === (isdefined(Base, :Nothing) ? Base.Nothing : Base.Void) +@test Nothing === Cvoid diff --git a/test/runtests.jl b/test/runtests.jl index 8dbdff7bc..95d36b7f2 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -80,10 +80,6 @@ let A = [1] @test x == 1 end -# 0.7.0-DEV.3137 -@test Nothing === (isdefined(Base, :Nothing) ? Base.Nothing : Base.Void) -@test Nothing === Cvoid - # 0.7.0-DEV.3017 @test isa(Some(1), Some{Int}) @test convert(Some{Float64}, Some(1)) == Some(1.0) From f93afea5a73fa4c62c6f22dfb79202e836863af0 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 21:56:11 +0200 Subject: [PATCH 060/121] Drop compat code for `Some` from #435 and #563 But only mark `notnothing` for deprecation. --- README.md | 2 -- src/Compat.jl | 35 +---------------------------------- test/old.jl | 11 +++++++++++ test/runtests.jl | 15 --------------- 4 files changed, 12 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index 452770b76..3df0d9e50 100644 --- a/README.md +++ b/README.md @@ -83,8 +83,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `@compat finalizer(func, obj)` with the finalizer to run as the first argument and the object to be finalized as the second ([#24605]). -* `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]). diff --git a/src/Compat.jl b/src/Compat.jl index 8a7e68ada..d812a305a 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -42,6 +42,7 @@ module Unicode using Unicode import Unicode: isassigned, normalize # not exported from Unicode module due to conflicts end +import Base: notnothing include("compatmacro.jl") @@ -67,40 +68,6 @@ end end end - - -@static if !isdefined(Base, :Some) - import Base: promote_rule, convert - struct Some{T} - value::T - end - promote_rule(::Type{Some{T}}, ::Type{Some{S}}) where {T,S<:T} = Some{T} - promote_rule(::Type{Some{T}}, ::Type{Nothing}) where {T} = Union{Some{T}, Nothing} - convert(::Type{Some{T}}, x::Some) where {T} = Some{T}(convert(T, x.value)) - convert(::Type{Union{Some{T}, Nothing}}, x::Some) where {T} = convert(Some{T}, x) - - convert(::Type{Union{T, Nothing}}, x::Any) where {T} = convert(T, x) - convert(::Type{Nothing}, x::Any) = throw(MethodError(convert, (Nothing, x))) - convert(::Type{Nothing}, x::Nothing) = nothing - - # Note: this is the definition of coalasce prior to 0.7.0-DEV.5278; kept to avoid - # breakage in packages already using it - coalesce(x::Any) = x - coalesce(x::Some) = x.value - coalesce(x::Nothing) = nothing - #coalesce(x::Missing) = missing - coalesce(x::Any, y...) = x - coalesce(x::Some, y...) = x.value - coalesce(x::Nothing, y...) = coalesce(y...) - #coalesce(x::Union{Nothing, Missing}, y...) = coalesce(y...) - - notnothing(x::Any) = x - notnothing(::Nothing) = throw(ArgumentError("nothing passed to notnothing")) - export Some, coalesce -else - import Base: notnothing -end - # 0.7.0-DEV.3309 @static if VERSION < v"0.7.0-DEV.3309" const IteratorSize = Base.iteratorsize diff --git a/test/old.jl b/test/old.jl index a08f10505..b1683825f 100644 --- a/test/old.jl +++ b/test/old.jl @@ -183,6 +183,10 @@ module Test25021 @test Compat.Unicode.normalize("\t\r", stripcc=true) == " " end +# 0.7.0-DEV.3017 +@test Compat.notnothing(1) == 1 +@test_throws ArgumentError Compat.notnothing(nothing) + # tests of removed functionality (i.e. justs tests Base) @@ -581,3 +585,10 @@ end # 0.7.0-DEV.3137 @test Nothing === (isdefined(Base, :Nothing) ? Base.Nothing : Base.Void) @test Nothing === Cvoid + +# 0.7.0-DEV.3017 +@test isa(Some(1), Some{Int}) +@test convert(Some{Float64}, Some(1)) == Some(1.0) +@test convert(Nothing, nothing) == nothing +@test_throws MethodError convert(Nothing, 1) +@test Some(nothing) != nothing diff --git a/test/runtests.jl b/test/runtests.jl index 95d36b7f2..4cad8895b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -80,21 +80,6 @@ let A = [1] @test x == 1 end -# 0.7.0-DEV.3017 -@test isa(Some(1), Some{Int}) -@test convert(Some{Float64}, Some(1)) == Some(1.0) -@test convert(Nothing, nothing) == nothing -@test_throws MethodError convert(Nothing, 1) -@test Some(nothing) != nothing -if VERSION < v"0.7.0-DEV.5278" - # coalesce has changed; old behavior kept and tested to avoid accidental breakage - @test coalesce(Some(1)) == 1 - @test coalesce(nothing) == nothing - @test coalesce(nothing, Some(1), Some(2)) == 1 -end -@test Compat.notnothing(1) == 1 -@test_throws ArgumentError Compat.notnothing(nothing) - # 0.7.0-DEV.3309 let v = [1, 2, 3] @test Compat.IteratorSize(v) isa Base.HasShape From 734c8ac0f15a4cca44991842af016b2958a89899 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 22:32:38 +0200 Subject: [PATCH 061/121] Mark `Compat.IteratorSize` and -`Eltype` from #451 for deprecation --- README.md | 3 --- src/Compat.jl | 11 ++--------- test/old.jl | 6 ++++++ test/runtests.jl | 6 ------ 4 files changed, 8 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 3df0d9e50..5b5c74d0e 100644 --- a/README.md +++ b/README.md @@ -152,9 +152,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `reprmime(mime, x)` is now `repr(mime, x)` ([#25990]) and `mimewritable` is now `showable` ([#26089]). -* `Base.IteratorSize` and `Base.IteratorEltype` are available as - `Compat.IteratorSize` and `Compat.IteratorEltype` ([#25402]). - * `copy!` and `unsafe_copy!` are now `copyto!` and `unsafe_copyto!` ([#24808]). * `ipermute!` is now `invpermute!` ([#25168]). diff --git a/src/Compat.jl b/src/Compat.jl index d812a305a..05f766830 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -43,6 +43,8 @@ module Unicode import Unicode: isassigned, normalize # not exported from Unicode module due to conflicts end import Base: notnothing +const IteratorSize = Base.IteratorSize +const IteratorEltype = Base.IteratorEltype include("compatmacro.jl") @@ -68,15 +70,6 @@ end end end -# 0.7.0-DEV.3309 -@static if VERSION < v"0.7.0-DEV.3309" - const IteratorSize = Base.iteratorsize - const IteratorEltype = Base.iteratoreltype -else - const IteratorSize = Base.IteratorSize - const IteratorEltype = Base.IteratorEltype -end - # 0.7.0-DEV.3173 @static if !isdefined(Base, :invpermute!) const invpermute! = ipermute! diff --git a/test/old.jl b/test/old.jl index b1683825f..1783df6f1 100644 --- a/test/old.jl +++ b/test/old.jl @@ -187,6 +187,12 @@ end @test Compat.notnothing(1) == 1 @test_throws ArgumentError Compat.notnothing(nothing) +# 0.7.0-DEV.3309 +let v = [1, 2, 3] + @test Compat.IteratorSize(v) isa Base.HasShape + @test Compat.IteratorEltype(v) == Base.HasEltype() +end + # tests of removed functionality (i.e. justs tests Base) diff --git a/test/runtests.jl b/test/runtests.jl index 4cad8895b..6a7b45c1b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -80,12 +80,6 @@ let A = [1] @test x == 1 end -# 0.7.0-DEV.3309 -let v = [1, 2, 3] - @test Compat.IteratorSize(v) isa Base.HasShape - @test Compat.IteratorEltype(v) == Base.HasEltype() -end - # 0.7.0-DEV.3057 let A = [0, 0, 0], B = [1, 2, 3] @test copyto!(A, B) === A == B From 382bc0b4e25622225a99171c999ccb734feba8d3 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 22:34:01 +0200 Subject: [PATCH 062/121] Drop compat code for `invpermute!` from #445 --- README.md | 2 -- src/Compat.jl | 6 ------ test/old.jl | 3 +++ test/runtests.jl | 3 --- 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 5b5c74d0e..44c622327 100644 --- a/README.md +++ b/README.md @@ -154,8 +154,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `copy!` and `unsafe_copy!` are now `copyto!` and `unsafe_copyto!` ([#24808]). -* `ipermute!` is now `invpermute!` ([#25168]). - * `module_parent`, `Base.function_module`, and `Base.datatype_module` are now methods of a new function called `parentmodule` ([#25629]). diff --git a/src/Compat.jl b/src/Compat.jl index 05f766830..866728f6b 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -70,12 +70,6 @@ end end end -# 0.7.0-DEV.3173 -@static if !isdefined(Base, :invpermute!) - const invpermute! = ipermute! - 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) diff --git a/test/old.jl b/test/old.jl index 1783df6f1..89a8250d1 100644 --- a/test/old.jl +++ b/test/old.jl @@ -598,3 +598,6 @@ end @test convert(Nothing, nothing) == nothing @test_throws MethodError convert(Nothing, 1) @test Some(nothing) != nothing + +# 0.7.0-DEV.3173 +@test invpermute!(permute!([1, 2], 2:-1:1), 2:-1:1) == [1, 2] diff --git a/test/runtests.jl b/test/runtests.jl index 6a7b45c1b..834a9ffd3 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -88,9 +88,6 @@ let A = [0, 0, 0], B = [1, 2, 3] @test unsafe_copyto!(A, 2, B, 1, 1) === A == [0, 1, 0] 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" From 771589717d9437d763a53514ad7c7257a4c06c89 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 22:35:35 +0200 Subject: [PATCH 063/121] Drop compat code for `replace` with a pair from #445 --- README.md | 3 --- src/Compat.jl | 5 ----- test/old.jl | 4 ++++ test/runtests.jl | 4 ---- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 44c622327..383672629 100644 --- a/README.md +++ b/README.md @@ -83,9 +83,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `@compat finalizer(func, obj)` with the finalizer to run as the first argument and the object to be finalized as the second ([#24605]). -* `replace` accepts a pair of pattern and replacement, with the number of replacements as - a keyword argument ([#25165]). - * `CartesianIndices` and `LinearIndices` types represent cartesian and linear indices of an array (respectively), and indexing such objects allows translating from one kind of index to the other ([#25113]). diff --git a/src/Compat.jl b/src/Compat.jl index 866728f6b..0bbc7ddf5 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -70,11 +70,6 @@ end end 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 - # 0.7.0-DEV.3057 @static if !isdefined(Base, :copyto!) const copyto! = Base.copy! diff --git a/test/old.jl b/test/old.jl index 89a8250d1..0cc102c3d 100644 --- a/test/old.jl +++ b/test/old.jl @@ -601,3 +601,7 @@ 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" diff --git a/test/runtests.jl b/test/runtests.jl index 834a9ffd3..d899a094c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -88,10 +88,6 @@ let A = [0, 0, 0], B = [1, 2, 3] @test unsafe_copyto!(A, 2, B, 1, 1) === A == [0, 1, 0] end -# 0.7.0-DEV.3172 -@test replace("abcb", "b"=>"c") == "accc" -@test replace("abcb", "b"=>"c", count=1) == "accb" - # 0.7.0-DEV.3025 let c = CartesianIndices((1:3, 1:2)), l = LinearIndices((1:3, 1:2)) @test LinearIndices(c) == collect(l) From 6ebe0418d05546435cb448456ea2b6c3f25d92ee Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 22:53:55 +0200 Subject: [PATCH 064/121] Drop compat code for `copyto!` from #448 --- README.md | 2 -- src/Compat.jl | 7 ------- test/old.jl | 8 ++++++++ test/runtests.jl | 8 -------- 4 files changed, 8 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 383672629..fda823819 100644 --- a/README.md +++ b/README.md @@ -149,8 +149,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `reprmime(mime, x)` is now `repr(mime, x)` ([#25990]) and `mimewritable` is now `showable` ([#26089]). -* `copy!` and `unsafe_copy!` are now `copyto!` and `unsafe_copyto!` ([#24808]). - * `module_parent`, `Base.function_module`, and `Base.datatype_module` are now methods of a new function called `parentmodule` ([#25629]). diff --git a/src/Compat.jl b/src/Compat.jl index 0bbc7ddf5..a41060739 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -70,13 +70,6 @@ end end end -# 0.7.0-DEV.3057 -@static if !isdefined(Base, :copyto!) - const copyto! = Base.copy! - const unsafe_copyto! = Base.unsafe_copy! - export copyto!, unsafe_copyto! -end - # 0.7.0-DEV.3272, keep this definition for 0.6 compatibility @static if VERSION < v"0.7.0-DEV.3272" Base.contains(str::AbstractString, r::Regex) = ismatch(r, str) diff --git a/test/old.jl b/test/old.jl index 0cc102c3d..a5fc1fe55 100644 --- a/test/old.jl +++ b/test/old.jl @@ -605,3 +605,11 @@ end # 0.7.0-DEV.3172 @test replace("abcb", "b"=>"c") == "accc" @test replace("abcb", "b"=>"c", count=1) == "accb" + +# 0.7.0-DEV.3057 +let A = [0, 0, 0], B = [1, 2, 3] + @test copyto!(A, B) === A == B +end +let A = [0, 0, 0], B = [1, 2, 3] + @test unsafe_copyto!(A, 2, B, 1, 1) === A == [0, 1, 0] +end diff --git a/test/runtests.jl b/test/runtests.jl index d899a094c..0b4a96bad 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -80,14 +80,6 @@ let A = [1] @test x == 1 end -# 0.7.0-DEV.3057 -let A = [0, 0, 0], B = [1, 2, 3] - @test copyto!(A, B) === A == B -end -let A = [0, 0, 0], B = [1, 2, 3] - @test unsafe_copyto!(A, 2, B, 1, 1) === A == [0, 1, 0] -end - # 0.7.0-DEV.3025 let c = CartesianIndices((1:3, 1:2)), l = LinearIndices((1:3, 1:2)) @test LinearIndices(c) == collect(l) From 6291908456144ed10845914fc5713c1cc34ab467 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 22:56:40 +0200 Subject: [PATCH 065/121] Drop compat code for `contains` from #452 --- src/Compat.jl | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Compat.jl b/src/Compat.jl index a41060739..77dd18665 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -70,11 +70,6 @@ end end end -# 0.7.0-DEV.3272, keep this definition for 0.6 compatibility -@static if VERSION < v"0.7.0-DEV.3272" - Base.contains(str::AbstractString, r::Regex) = ismatch(r, str) -end - @static if VERSION < v"0.7.0-DEV.3025" import Base: convert, ndims, getindex, size, length, eltype, start, next, done, first, last, in, tail From 8b77d318d8323d6a8bf1ce76b93bccb919c8dd8c Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Fri, 4 Oct 2019 23:00:09 +0200 Subject: [PATCH 066/121] Drop compat code for `CartesianIndices` and `LinearIndices` from #446, #455, and #524 --- README.md | 4 -- src/Compat.jl | 128 ----------------------------------------------- test/old.jl | 28 +++++++++++ test/runtests.jl | 27 ---------- 4 files changed, 28 insertions(+), 159 deletions(-) diff --git a/README.md b/README.md index fda823819..889fa518a 100644 --- a/README.md +++ b/README.md @@ -83,10 +83,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `@compat finalizer(func, obj)` with the finalizer to run as the first argument and the object to be finalized as the second ([#24605]). -* `CartesianIndices` and `LinearIndices` types represent cartesian and linear indices of - an array (respectively), and indexing such objects allows translating from one kind of index - to the other ([#25113]). - * `codeunits(s)` returns an array-like view of the `UInt8` code units of a string and `ncodeunits(s)` returns the number of code units ([#25241]). `codeunit(s)` returns the type of the code units of `s` ([#24999]). diff --git a/src/Compat.jl b/src/Compat.jl index 77dd18665..0b154e2bc 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -70,134 +70,6 @@ end end end -@static if VERSION < v"0.7.0-DEV.3025" - import Base: convert, ndims, getindex, size, length, eltype, - start, next, done, first, last, in, tail - export CartesianIndices, LinearIndices - - struct CartesianIndices{N,R<:NTuple{N,AbstractUnitRange{Int}}} <: AbstractArray{CartesianIndex{N},N} - indices::R - end - - CartesianIndices(::Tuple{}) = CartesianIndices{0,typeof(())}(()) - CartesianIndices(inds::NTuple{N,AbstractUnitRange{Int}}) where {N} = - CartesianIndices{N,typeof(inds)}(inds) - CartesianIndices(inds::Vararg{AbstractUnitRange{Int},N}) where {N} = - CartesianIndices(inds) - CartesianIndices(inds::NTuple{N,AbstractUnitRange{<:Integer}}) where {N} = - CartesianIndices(map(r->convert(AbstractUnitRange{Int}, r), inds)) - CartesianIndices(inds::Vararg{AbstractUnitRange{<:Integer},N}) where {N} = - CartesianIndices(inds) - - CartesianIndices(index::CartesianIndex) = CartesianIndices(index.I) - CartesianIndices(sz::NTuple{N,<:Integer}) where {N} = CartesianIndices(map(Base.OneTo, sz)) - CartesianIndices(inds::NTuple{N,Union{<:Integer,AbstractUnitRange{<:Integer}}}) where {N} = - CartesianIndices(map(i->first(i):last(i), inds)) - - CartesianIndices(A::AbstractArray) = CartesianIndices(axes(A)) - - convert(::Type{Tuple{}}, R::CartesianIndices{0}) = () - convert(::Type{NTuple{N,AbstractUnitRange{Int}}}, R::CartesianIndices{N}) where {N} = - R.indices - - convert(::Type{NTuple{N,AbstractUnitRange}}, R::CartesianIndices{N}) where {N} = - convert(NTuple{N,AbstractUnitRange{Int}}, R) - convert(::Type{NTuple{N,UnitRange{Int}}}, R::CartesianIndices{N}) where {N} = - UnitRange{Int}.(convert(NTuple{N,AbstractUnitRange}, R)) - convert(::Type{NTuple{N,UnitRange}}, R::CartesianIndices{N}) where {N} = - UnitRange.(convert(NTuple{N,AbstractUnitRange}, R)) - convert(::Type{Tuple{Vararg{AbstractUnitRange{Int}}}}, R::CartesianIndices{N}) where {N} = - convert(NTuple{N,AbstractUnitRange{Int}}, R) - convert(::Type{Tuple{Vararg{AbstractUnitRange}}}, R::CartesianIndices) = - convert(Tuple{Vararg{AbstractUnitRange{Int}}}, R) - convert(::Type{Tuple{Vararg{UnitRange{Int}}}}, R::CartesianIndices{N}) where {N} = - convert(NTuple{N,UnitRange{Int}}, R) - convert(::Type{Tuple{Vararg{UnitRange}}}, R::CartesianIndices) = - convert(Tuple{Vararg{UnitRange{Int}}}, R) - - # AbstractArray implementation - Base.IndexStyle(::Type{CartesianIndices{N,R}}) where {N,R} = IndexCartesian() - @inline Base.getindex(iter::CartesianIndices{N,R}, I::Vararg{Int, N}) where {N,R} = CartesianIndex(first.(iter.indices) .- 1 .+ I) - - ndims(R::CartesianIndices) = ndims(typeof(R)) - ndims(::Type{CartesianIndices{N}}) where {N} = N - ndims(::Type{CartesianIndices{N,TT}}) where {N,TT} = N - - eltype(R::CartesianIndices) = eltype(typeof(R)) - eltype(::Type{CartesianIndices{N}}) where {N} = CartesianIndex{N} - eltype(::Type{CartesianIndices{N,TT}}) where {N,TT} = CartesianIndex{N} - Base.iteratorsize(::Type{<:CartesianIndices}) = Base.HasShape() - - @inline function start(iter::CartesianIndices) - iterfirst, iterlast = first(iter), last(iter) - if Base.any(map(>, iterfirst.I, iterlast.I)) - return iterlast+1 - end - iterfirst - end - @inline function next(iter::CartesianIndices, state) - state, CartesianIndex(inc(state.I, first(iter).I, last(iter).I)) - end - # increment & carry - @inline inc(::Tuple{}, ::Tuple{}, ::Tuple{}) = () - @inline inc(state::Tuple{Int}, start::Tuple{Int}, stop::Tuple{Int}) = (state[1]+1,) - @inline function inc(state, start, stop) - if state[1] < stop[1] - return (state[1]+1,Base.tail(state)...) - end - newtail = inc(Base.tail(state), Base.tail(start), Base.tail(stop)) - (start[1], newtail...) - end - @inline done(iter::CartesianIndices, state) = state.I[end] > last(iter.indices[end]) - - # 0-d cartesian ranges are special-cased to iterate once and only once - start(iter::CartesianIndices{0}) = false - next(iter::CartesianIndices{0}, state) = CartesianIndex(), true - done(iter::CartesianIndices{0}, state) = state - - size(iter::CartesianIndices) = map(dimlength, first(iter).I, last(iter).I) - dimlength(start, stop) = stop-start+1 - - length(iter::CartesianIndices) = Base.prod(size(iter)) - - first(iter::CartesianIndices) = CartesianIndex(map(first, iter.indices)) - last(iter::CartesianIndices) = CartesianIndex(map(last, iter.indices)) - - @inline function in(i::CartesianIndex{N}, r::CartesianIndices{N}) where {N} - _in(true, i.I, first(r).I, last(r).I) - end - _in(b, ::Tuple{}, ::Tuple{}, ::Tuple{}) = b - @inline _in(b, i, start, stop) = _in(b & (start[1] <= i[1] <= stop[1]), tail(i), tail(start), tail(stop)) - - struct LinearIndices{N,R<:NTuple{N,AbstractUnitRange{Int}}} <: AbstractArray{Int,N} - indices::R - end - - LinearIndices(inds::CartesianIndices{N,R}) where {N,R} = LinearIndices{N,R}(inds.indices) - LinearIndices(::Tuple{}) = LinearIndices(CartesianIndices(())) - LinearIndices(inds::NTuple{N,AbstractUnitRange{Int}}) where {N} = LinearIndices(CartesianIndices(inds)) - LinearIndices(inds::Vararg{AbstractUnitRange{Int},N}) where {N} = LinearIndices(CartesianIndices(inds)) - LinearIndices(inds::NTuple{N,AbstractUnitRange{<:Integer}}) where {N} = LinearIndices(CartesianIndices(inds)) - LinearIndices(inds::Vararg{AbstractUnitRange{<:Integer},N}) where {N} = LinearIndices(CartesianIndices(inds)) - LinearIndices(index::CartesianIndex) = LinearIndices(CartesianIndices(index)) - LinearIndices(sz::NTuple{N,<:Integer}) where {N} = LinearIndices(CartesianIndices(sz)) - LinearIndices(inds::NTuple{N,Union{<:Integer,AbstractUnitRange{<:Integer}}}) where {N} = LinearIndices(CartesianIndices(inds)) - LinearIndices(A::AbstractArray) = LinearIndices(CartesianIndices(A)) - - # AbstractArray implementation - Base.IndexStyle(::Type{LinearIndices{N,R}}) where {N,R} = IndexCartesian() - Compat.axes(iter::LinearIndices{N,R}) where {N,R} = iter.indices - Base.size(iter::LinearIndices{N,R}) where {N,R} = length.(iter.indices) - @inline function Base.getindex(iter::LinearIndices{N,R}, I::Vararg{Int, N}) where {N,R} - dims = length.(iter.indices) - #without the inbounds, this is slower than Base._sub2ind(iter.indices, I...) - @inbounds result = reshape(1:Base.prod(dims), dims)[(I .- first.(iter.indices) .+ 1)...] - return result - end -elseif VERSION < v"0.7.0-DEV.3395" - Base.size(iter::LinearIndices{N,R}) where {N,R} = length.(iter.indices) -end - @static if !isdefined(Base, Symbol("@info")) macro info(msg, args...) return :(info($(esc(msg)), prefix = "Info: ")) diff --git a/test/old.jl b/test/old.jl index a5fc1fe55..a91318140 100644 --- a/test/old.jl +++ b/test/old.jl @@ -613,3 +613,31 @@ end let A = [0, 0, 0], B = [1, 2, 3] @test unsafe_copyto!(A, 2, B, 1, 1) === A == [0, 1, 0] end + +# 0.7.0-DEV.3025 +let c = CartesianIndices((1:3, 1:2)), l = LinearIndices((1:3, 1:2)) + @test LinearIndices(c) == collect(l) + @test CartesianIndices(l) == collect(c) + @test first(c) == CartesianIndex(1, 1) + @test CartesianIndex(1, 1) in c + @test first(l) == 1 + @test size(c) == size(l) == (3, 2) + @test c == collect(c) == [CartesianIndex(1, 1) CartesianIndex(1, 2) + CartesianIndex(2, 1) CartesianIndex(2, 2) + CartesianIndex(3, 1) CartesianIndex(3, 2)] + @test l == collect(l) == reshape(1:6, 3, 2) + @test c[1:6] == vec(c) + @test l[1:6] == vec(l) + # TODO the following test fails on current Julia master (since 0.7.0-DEV.4742), and + # it's not clear yet whether it should work or not. See + # https://github.com/JuliaLang/julia/pull/26682#issuecomment-379762632 and the + # discussion following it + #@test l == l[c] == map(i -> l[i], c) + @test l[vec(c)] == collect(1:6) + @test CartesianIndex(1, 1) in CartesianIndices((3, 4)) +end + +# Issue #523 +@test length(Compat.CartesianIndices((1:1,))) == 1 +@test length(Compat.CartesianIndices((1:2,))) == 2 +@test length(Compat.CartesianIndices((1:2, -1:1))) == 6 diff --git a/test/runtests.jl b/test/runtests.jl index 0b4a96bad..69e2039fc 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -80,29 +80,6 @@ let A = [1] @test x == 1 end -# 0.7.0-DEV.3025 -let c = CartesianIndices((1:3, 1:2)), l = LinearIndices((1:3, 1:2)) - @test LinearIndices(c) == collect(l) - @test CartesianIndices(l) == collect(c) - @test first(c) == CartesianIndex(1, 1) - @test CartesianIndex(1, 1) in c - @test first(l) == 1 - @test size(c) == size(l) == (3, 2) - @test c == collect(c) == [CartesianIndex(1, 1) CartesianIndex(1, 2) - CartesianIndex(2, 1) CartesianIndex(2, 2) - CartesianIndex(3, 1) CartesianIndex(3, 2)] - @test l == collect(l) == reshape(1:6, 3, 2) - @test c[1:6] == vec(c) - @test l[1:6] == vec(l) - # TODO the following test fails on current Julia master (since 0.7.0-DEV.4742), and - # it's not clear yet whether it should work or not. See - # https://github.com/JuliaLang/julia/pull/26682#issuecomment-379762632 and the - # discussion following it - #@test l == l[c] == map(i -> l[i], c) - @test l[vec(c)] == collect(1:6) - @test CartesianIndex(1, 1) in CartesianIndices((3, 4)) -end - if !isdefined(Base, Symbol("@info")) let fname = tempname() try @@ -516,10 +493,6 @@ end @test Compat.reverse([1, 2, 3, 4]) == [4, 3, 2, 1] @test Compat.reverse([1 2; 3 4], dims=1) == [3 4; 1 2] @test Compat.reverse([1 2; 3 4], dims=2) == [2 1; 4 3] -# Issue #523 -@test length(Compat.CartesianIndices((1:1,))) == 1 -@test length(Compat.CartesianIndices((1:2,))) == 2 -@test length(Compat.CartesianIndices((1:2, -1:1))) == 6 # 0.7.0-DEV.4738 if VERSION < v"0.7.0-beta2.143" From 833a0b0dc8b06dab390f928c892b4dc8d57e4cb7 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 16:45:19 +0200 Subject: [PATCH 067/121] Drop compat code for `at-warn` and friends from #458 And mark `enable_debug(::Bool)` for deprecation. --- README.md | 11 ----------- src/Compat.jl | 42 +----------------------------------------- test/runtests.jl | 24 ------------------------ 3 files changed, 1 insertion(+), 76 deletions(-) diff --git a/README.md b/README.md index 889fa518a..4fcdeb552 100644 --- a/README.md +++ b/README.md @@ -204,17 +204,6 @@ Currently, the `@compat` macro supports the following syntaxes: ## New macros -* The logging macros `@error`, `@warn`, `@info` and `@debug` can be used as - `Compat.@error`, `Compat.@warn`, `Compat.@info` and `Compat.@debug` on Julia 0.6 ([#24490]). - Note that the behavior do not mirror the logging macros in Julia 0.7, instead on Julia 0.6: - - Messages are printed to `STDERR` (like `info` and `warn` on Julia 0.6) and not to a - dedicated logging stream. - - The loglevel can not be controlled, but `Compat.@debug` messages can be turned on/off - by calling `Compat.enable_debug(true/false)`. - - Extra metadata sent to the macros are ignored. - - As an alternative, see the MicroLogging.jl package for a logging interface similar to the one in Julia 0.7. - ## Other changes * On versions of Julia that do not contain a Base.Threads module, Compat defines a Threads module containing a no-op `@threads` macro. diff --git a/src/Compat.jl b/src/Compat.jl index 0b154e2bc..d277191ce 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -45,6 +45,7 @@ end import Base: notnothing const IteratorSize = Base.IteratorSize const IteratorEltype = Base.IteratorEltype +enable_debug(x::Bool) = x include("compatmacro.jl") @@ -70,47 +71,6 @@ end end end -@static if !isdefined(Base, Symbol("@info")) - macro info(msg, args...) - return :(info($(esc(msg)), prefix = "Info: ")) - end -end -@static if !isdefined(Base, Symbol("@warn")) - macro warn(msg, args...) - return :(warn($(esc(msg)), prefix = "Warning: ")) - end -end - -const DEBUG = Ref(false) # debug printing off by default, as on 0.7 -enable_debug(x::Bool) = DEBUG[] = x -@static if !isdefined(Base, Symbol("@debug")) - function debug(msg) - DEBUG[] || return - buf = Base.IOBuffer() - iob = Base.redirect(IOContext(buf, STDERR), Base.log_info_to, :debug) - print_with_color(:blue, iob, "Debug: "; bold = true) - Base.println_with_color(:blue, iob, chomp(string(msg))) - print(STDERR, String(take!(buf))) - return - end - macro debug(msg, args...) - return :(debug($(esc(msg)))) - end -end -@static if !isdefined(Base, Symbol("@error")) - function _error(msg) - buf = Base.IOBuffer() - iob = Base.redirect(IOContext(buf, STDERR), Base.log_error_to, :error) - print_with_color(Base.error_color(), iob, "Error: "; bold = true) - Base.println_with_color(Base.error_color(), iob, chomp(string(msg))) - print(STDERR, String(take!(buf))) - return - end - macro error(msg, args...) - return :(_error($(esc(msg)))) - end -end - # 0.7.0-DEV.3415 if !isdefined(Base, :findall) const findall = find diff --git a/test/runtests.jl b/test/runtests.jl index 69e2039fc..0337be3d1 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -80,30 +80,6 @@ let A = [1] @test x == 1 end -if !isdefined(Base, Symbol("@info")) - let fname = tempname() - try - open(fname, "w") do fout - redirect_stderr(fout) do - Compat.@info "A" - Compat.@warn "B" - oldstate = Compat.DEBUG[] - Compat.enable_debug(false) - Compat.@debug "C" - Compat.enable_debug(true) - Compat.@debug "D" - Compat.enable_debug(oldstate) - Compat.@error "E" - end - end - @test read(fname, String) == (Base.have_color ? "\e[1m\e[36mInfo: \e[39m\e[22m\e[36mA\n\e[39m\e[1m\e[33mWarning: \e[39m\e[22m\e[33mB\e[39m\n\e[1m\e[34mDebug: \e[39m\e[22m\e[34mD\n\e[39m\e[1m\e[91mError: \e[39m\e[22m\e[91mE\n\e[39m" : - "Info: A\nWarning: B\nDebug: D\nError: E\n") - finally - rm(fname, force=true) - end - end -end - # 0.7.0-DEV.3460 @test parentmodule(Compat.Sys) == Compat @test parentmodule(sin) == Base From 8a70ad30fe5a5ce7eb4c66cc6a71912f4d127a7d Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 16:47:51 +0200 Subject: [PATCH 068/121] Drop compat code for `findall` from #466 (and #467). --- README.md | 2 -- src/Compat.jl | 6 ------ test/old.jl | 3 +++ test/runtests.jl | 3 --- 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 4fcdeb552..894b50ae4 100644 --- a/README.md +++ b/README.md @@ -151,8 +151,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `module_name`, `Base.function_name`, and `Base.datatype_name` are now methods of a new function called `nameof` ([#25622]). -* `find` is now `findall` ([#25545]). - * `search` is now `findfirst`/`findnext` and `rsearch` is now `findlast`/`findprev`, sometimes combined with `isequal` or `in` ([#24673], [#26436]). diff --git a/src/Compat.jl b/src/Compat.jl index d277191ce..7b3f6c707 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -71,12 +71,6 @@ end end end -# 0.7.0-DEV.3415 -if !isdefined(Base, :findall) - const findall = find - export findall -end - @static if !isdefined(Base, :argmin) if VERSION >= v"0.7.0-DEV.1660" # indmin/indmax return key const argmin = indmin diff --git a/test/old.jl b/test/old.jl index a91318140..2e1cf55a2 100644 --- a/test/old.jl +++ b/test/old.jl @@ -641,3 +641,6 @@ end @test length(Compat.CartesianIndices((1:1,))) == 1 @test length(Compat.CartesianIndices((1:2,))) == 2 @test length(Compat.CartesianIndices((1:2, -1:1))) == 6 + +# 0.7.0-DEV.3415 +@test findall(x -> x==1, [1, 2, 3, 2, 1]) == [1, 5] diff --git a/test/runtests.jl b/test/runtests.jl index 0337be3d1..9e490dae3 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -107,9 +107,6 @@ end @test argmin(Dict(:z=>10, :y=>12, :x=>9, :w=>11)) == :x @test argmin((1.0, -3, 0.f0)) == 2 -# 0.7.0-DEV.3415 -@test findall(x -> x==1, [1, 2, 3, 2, 1]) == [1, 5] - module TestPkg using Compat using Compat.Pkg From 8d7d92e47d443ab917445107425ccb520821ce8d Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 16:51:36 +0200 Subject: [PATCH 069/121] Drop compat code for `argmin` and `argmax` from #470, #472, and #622 --- README.md | 2 -- src/Compat.jl | 17 ----------------- test/old.jl | 10 ++++++++++ test/runtests.jl | 10 ---------- 4 files changed, 10 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 894b50ae4..acd8fd5dd 100644 --- a/README.md +++ b/README.md @@ -160,8 +160,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `findin(a, b)` is now `findall(in(b), a)` ([#24673]). -* `indmin` and `indmax` are now `argmin` and `argmax`, respectively ([#25654]). - * `Compat.indexin` accepts any iterable as first argument, returns `nothing` (rather than `0`) for entries with no match and gives the index of the first (rather than the last) match ([#25662], [#25998]). diff --git a/src/Compat.jl b/src/Compat.jl index 7b3f6c707..6e13641d5 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -71,23 +71,6 @@ end end end -@static if !isdefined(Base, :argmin) - if VERSION >= v"0.7.0-DEV.1660" # indmin/indmax return key - const argmin = indmin - const argmax = indmax - else - argmin(x::AbstractArray) = CartesianIndex(ind2sub(x, indmin(x))) - argmin(x::AbstractVector) = indmin(x) - argmin(x::Associative) = first(Iterators.drop(keys(x), indmin(values(x))-1)) - argmin(x::Tuple) = indmin(x) - argmax(x::AbstractArray) = CartesianIndex(ind2sub(x, indmax(x))) - argmax(x::AbstractVector) = indmax(x) - argmax(x::Associative) = first(Iterators.drop(keys(x), indmax(values(x))-1)) - argmax(x::Tuple) = indmax(x) - end - export argmin, argmax -end - @static if !isdefined(Base, :parentmodule) parentmodule(m::Module) = Base.module_parent(m) parentmodule(f::Function) = Base.function_module(f) diff --git a/test/old.jl b/test/old.jl index 2e1cf55a2..f9d60cd76 100644 --- a/test/old.jl +++ b/test/old.jl @@ -644,3 +644,13 @@ end # 0.7.0-DEV.3415 @test findall(x -> x==1, [1, 2, 3, 2, 1]) == [1, 5] + +# 0.7.0-DEV.3516 +@test argmax([10,12,9,11]) == 2 +@test argmax([10 12; 9 11]) == CartesianIndex(1, 2) +@test argmax(Dict(:z=>10, :y=>12, :x=>9, :w=>11)) == :y +@test argmax((-5, 6, 10)) == 3 +@test argmin([10,12,9,11]) == 3 +@test argmin([10 12; 9 11]) == CartesianIndex(2, 1) +@test argmin(Dict(:z=>10, :y=>12, :x=>9, :w=>11)) == :x +@test argmin((1.0, -3, 0.f0)) == 2 diff --git a/test/runtests.jl b/test/runtests.jl index 9e490dae3..47bf60f63 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -97,16 +97,6 @@ end @test nameof(Float64) == :Float64 @test nameof(Array) == :Array -# 0.7.0-DEV.3516 -@test argmax([10,12,9,11]) == 2 -@test argmax([10 12; 9 11]) == CartesianIndex(1, 2) -@test argmax(Dict(:z=>10, :y=>12, :x=>9, :w=>11)) == :y -@test argmax((-5, 6, 10)) == 3 -@test argmin([10,12,9,11]) == 3 -@test argmin([10 12; 9 11]) == CartesianIndex(2, 1) -@test argmin(Dict(:z=>10, :y=>12, :x=>9, :w=>11)) == :x -@test argmin((1.0, -3, 0.f0)) == 2 - module TestPkg using Compat using Compat.Pkg From dff3b6972209357d316a1dc444a948123c21fa51 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 16:53:29 +0200 Subject: [PATCH 070/121] Drop compat code for `parentmodule` from #461 --- README.md | 3 --- src/Compat.jl | 9 --------- test/old.jl | 7 +++++++ test/runtests.jl | 7 ------- 4 files changed, 7 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index acd8fd5dd..3e7667158 100644 --- a/README.md +++ b/README.md @@ -145,9 +145,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `reprmime(mime, x)` is now `repr(mime, x)` ([#25990]) and `mimewritable` is now `showable` ([#26089]). -* `module_parent`, `Base.function_module`, and `Base.datatype_module` are now methods of - a new function called `parentmodule` ([#25629]). - * `module_name`, `Base.function_name`, and `Base.datatype_name` are now methods of a new function called `nameof` ([#25622]). diff --git a/src/Compat.jl b/src/Compat.jl index 6e13641d5..c61393d21 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -71,15 +71,6 @@ end end end -@static if !isdefined(Base, :parentmodule) - parentmodule(m::Module) = Base.module_parent(m) - parentmodule(f::Function) = Base.function_module(f) - parentmodule(@nospecialize(f), @nospecialize(t)) = Base.function_module(f, t) - parentmodule(t::DataType) = Base.datatype_module(t) - parentmodule(t::UnionAll) = Base.datatype_module(Base.unwrap_unionall(t)) - export parentmodule -end - @static if !isdefined(Base, :codeunits) codeunits(s::String) = Vector{UInt8}(s) ncodeunits(s::Union{String,SubString{String}}) = sizeof(s) diff --git a/test/old.jl b/test/old.jl index f9d60cd76..0d1332024 100644 --- a/test/old.jl +++ b/test/old.jl @@ -654,3 +654,10 @@ end @test argmin([10 12; 9 11]) == CartesianIndex(2, 1) @test argmin(Dict(:z=>10, :y=>12, :x=>9, :w=>11)) == :x @test argmin((1.0, -3, 0.f0)) == 2 + +# 0.7.0-DEV.3460 +@test parentmodule(Compat.Sys) == Compat +@test parentmodule(sin) == Base +@test parentmodule(sin, Tuple{Int}) == Base.Math +@test parentmodule(Int) == Core +@test parentmodule(Array) == Core diff --git a/test/runtests.jl b/test/runtests.jl index 47bf60f63..e082fac6e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -80,13 +80,6 @@ let A = [1] @test x == 1 end -# 0.7.0-DEV.3460 -@test parentmodule(Compat.Sys) == Compat -@test parentmodule(sin) == Base -@test parentmodule(sin, Tuple{Int}) == Base.Math -@test parentmodule(Int) == Core -@test parentmodule(Array) == Core - @test codeunits("foo") == [0x66,0x6f,0x6f] == codeunits(SubString("fooαβγ",1,3)) @test ncodeunits("αβγ") == 6 == ncodeunits(SubString("fooαβγ",4,8)) @test codeunit("foo") == codeunit(SubString("fooαβγ",1,3)) == UInt8 From d1e64d99535ff15091b3df165d7602612d56c7d3 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 16:55:28 +0200 Subject: [PATCH 071/121] Drop compat code for `codeunits` from #474 --- README.md | 4 +--- src/Compat.jl | 7 ------- test/old.jl | 3 +++ test/runtests.jl | 2 -- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 3e7667158..7b1ee49b1 100644 --- a/README.md +++ b/README.md @@ -83,9 +83,7 @@ Currently, the `@compat` macro supports the following syntaxes: * `@compat finalizer(func, obj)` with the finalizer to run as the first argument and the object to be finalized as the second ([#24605]). -* `codeunits(s)` returns an array-like view of the `UInt8` code units of - a string and `ncodeunits(s)` returns the number of code units ([#25241]). - `codeunit(s)` returns the type of the code units of `s` ([#24999]). +* `codeunit(s)` returns the type of the code units of `s` ([#24999]). * `thisind(s, i)` returns the character index for codeunit `i` ([#24414]). diff --git a/src/Compat.jl b/src/Compat.jl index c61393d21..7e32a9ce0 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -71,13 +71,6 @@ end end end -@static if !isdefined(Base, :codeunits) - codeunits(s::String) = Vector{UInt8}(s) - ncodeunits(s::Union{String,SubString{String}}) = sizeof(s) - codeunits(s::SubString{String}) = view(codeunits(s.string),1+s.offset:s.offset+sizeof(s)) - export codeunits, ncodeunits -end - @static if !isdefined(Base, :nameof) nameof(m::Module) = Base.module_name(m) nameof(f::Function) = Base.function_name(f) diff --git a/test/old.jl b/test/old.jl index 0d1332024..13cc97c83 100644 --- a/test/old.jl +++ b/test/old.jl @@ -661,3 +661,6 @@ end @test parentmodule(sin, Tuple{Int}) == Base.Math @test parentmodule(Int) == Core @test parentmodule(Array) == Core + +@test codeunits("foo") == [0x66,0x6f,0x6f] == codeunits(SubString("fooαβγ",1,3)) +@test ncodeunits("αβγ") == 6 == ncodeunits(SubString("fooαβγ",4,8)) diff --git a/test/runtests.jl b/test/runtests.jl index e082fac6e..52d4190d4 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -80,8 +80,6 @@ let A = [1] @test x == 1 end -@test codeunits("foo") == [0x66,0x6f,0x6f] == codeunits(SubString("fooαβγ",1,3)) -@test ncodeunits("αβγ") == 6 == ncodeunits(SubString("fooαβγ",4,8)) @test codeunit("foo") == codeunit(SubString("fooαβγ",1,3)) == UInt8 # 0.7.0-DEV.3539 From 8ce815347122c0c37c212185c8fde00f75778a90 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 16:57:16 +0200 Subject: [PATCH 072/121] Drop compat code for `nameof` from #471 --- README.md | 3 --- src/Compat.jl | 7 ------- test/old.jl | 6 ++++++ test/runtests.jl | 6 ------ 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 7b1ee49b1..b78e3ba7f 100644 --- a/README.md +++ b/README.md @@ -143,9 +143,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `reprmime(mime, x)` is now `repr(mime, x)` ([#25990]) and `mimewritable` is now `showable` ([#26089]). -* `module_name`, `Base.function_name`, and `Base.datatype_name` are now methods of a - new function called `nameof` ([#25622]). - * `search` is now `findfirst`/`findnext` and `rsearch` is now `findlast`/`findprev`, sometimes combined with `isequal` or `in` ([#24673], [#26436]). diff --git a/src/Compat.jl b/src/Compat.jl index 7e32a9ce0..c9a7448a1 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -71,13 +71,6 @@ end end end -@static if !isdefined(Base, :nameof) - nameof(m::Module) = Base.module_name(m) - nameof(f::Function) = Base.function_name(f) - nameof(t::Union{DataType,UnionAll}) = Base.datatype_name(t) - export nameof -end - # 0.7.0-DEV.3469 @static if !isdefined(Base, :GC) @eval module GC diff --git a/test/old.jl b/test/old.jl index 13cc97c83..cff9f804f 100644 --- a/test/old.jl +++ b/test/old.jl @@ -664,3 +664,9 @@ end @test codeunits("foo") == [0x66,0x6f,0x6f] == codeunits(SubString("fooαβγ",1,3)) @test ncodeunits("αβγ") == 6 == ncodeunits(SubString("fooαβγ",4,8)) + +# 0.7.0-DEV.3539 +@test nameof(Compat.Sys) == :Sys +@test nameof(sin) == :sin +@test nameof(Float64) == :Float64 +@test nameof(Array) == :Array diff --git a/test/runtests.jl b/test/runtests.jl index 52d4190d4..a0949dd31 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -82,12 +82,6 @@ end @test codeunit("foo") == codeunit(SubString("fooαβγ",1,3)) == UInt8 -# 0.7.0-DEV.3539 -@test nameof(Compat.Sys) == :Sys -@test nameof(sin) == :sin -@test nameof(Float64) == :Float64 -@test nameof(Array) == :Array - module TestPkg using Compat using Compat.Pkg From be18b7c3c02a05cf163fdaa1c33114aa80d81cba Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 16:59:20 +0200 Subject: [PATCH 073/121] Drop compat code for `GC` from #477 --- README.md | 2 -- src/Compat.jl | 9 --------- test/old.jl | 7 +++++++ test/runtests.jl | 7 ------- 4 files changed, 7 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index b78e3ba7f..778e90865 100644 --- a/README.md +++ b/README.md @@ -156,8 +156,6 @@ Currently, the `@compat` macro supports the following syntaxes: for entries with no match and gives the index of the first (rather than the last) match ([#25662], [#25998]). -* `gc` and `gc_enable` are now `GC.gc` and `GC.enable`, respectively ([#25616]). - * `endof` is now `lastindex` ([#25458]). (Note that `lastindex(A, n)` is not supported.) * `nb_available` is now `bytesavailable` ([#25634]). diff --git a/src/Compat.jl b/src/Compat.jl index c9a7448a1..5b3a747c0 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -71,15 +71,6 @@ end end end -# 0.7.0-DEV.3469 -@static if !isdefined(Base, :GC) - @eval module GC - using Base: gc - const enable = Base.gc_enable - end - export GC -end - if VERSION < v"0.7.0-DEV.2954" const Distributed = Base.Distributed else diff --git a/test/old.jl b/test/old.jl index cff9f804f..ec74626dc 100644 --- a/test/old.jl +++ b/test/old.jl @@ -670,3 +670,10 @@ end @test nameof(sin) == :sin @test nameof(Float64) == :Float64 @test nameof(Array) == :Array + +# 0.7.0-DEV.3469 +@test GC.enable(true) +@test GC.enable(false) +@test !GC.enable(false) +@test !GC.enable(true) +@test GC.enable(true) diff --git a/test/runtests.jl b/test/runtests.jl index a0949dd31..f0fdf3ea9 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -106,13 +106,6 @@ module TestLibGit2 @test isdefined(@__MODULE__, :GitRepo) end -# 0.7.0-DEV.3469 -@test GC.enable(true) -@test GC.enable(false) -@test !GC.enable(false) -@test !GC.enable(true) -@test GC.enable(true) - @test eltype(Base.Multimedia.displays) <: AbstractDisplay # 0.7.0-DEV.3481 From 915052a03ed13cbe278c54d0507ea6c98d3533fb Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 17:02:01 +0200 Subject: [PATCH 074/121] Mark `Compat.Distributed` from #477 for deprecation --- README.md | 3 --- src/Compat.jl | 7 +------ 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/README.md b/README.md index 778e90865..20e7a2fa9 100644 --- a/README.md +++ b/README.md @@ -52,9 +52,6 @@ Currently, the `@compat` macro supports the following syntaxes: ## Module Aliases -* `using Compat.Distributed` is provided on versions older than 0.7, where this library is - not yet part of the standard library ([#24443]). - * `using Compat.Pkg` is provided on versions older than 0.7, where this library is not yet part of the standard library ([#25705]). Note that `Compat.Pkg` will point to the new package manager on 0.7 which does not have a fully compatible API with the old diff --git a/src/Compat.jl b/src/Compat.jl index 5b3a747c0..276436ffb 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -46,6 +46,7 @@ import Base: notnothing const IteratorSize = Base.IteratorSize const IteratorEltype = Base.IteratorEltype enable_debug(x::Bool) = x +import Distributed include("compatmacro.jl") @@ -71,12 +72,6 @@ end end end -if VERSION < v"0.7.0-DEV.2954" - const Distributed = Base.Distributed -else - import Distributed -end - @static if VERSION < v"0.7.0-DEV.3656" const Pkg = Base.Pkg else From 556c76714bce78f98ac2c6f12cc3798550d01cf4 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 17:05:11 +0200 Subject: [PATCH 075/121] Mark `Compat.Pkg` from #485 for deprecation --- README.md | 5 ----- src/Compat.jl | 7 +------ test/old.jl | 8 ++++++++ test/runtests.jl | 8 -------- 4 files changed, 9 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 20e7a2fa9..4f26c26d9 100644 --- a/README.md +++ b/README.md @@ -52,11 +52,6 @@ Currently, the `@compat` macro supports the following syntaxes: ## Module Aliases -* `using Compat.Pkg` is provided on versions older than 0.7, where this library is - not yet part of the standard library ([#25705]). Note that `Compat.Pkg` will point to - the new package manager on 0.7 which does not have a fully compatible API with the old - package manager. - * `using Compat.InteractiveUtils` is provided on versions older than 0.7, where this library is not yet part of the standard library ([#25780]). diff --git a/src/Compat.jl b/src/Compat.jl index 276436ffb..53e7460bf 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -47,6 +47,7 @@ const IteratorSize = Base.IteratorSize const IteratorEltype = Base.IteratorEltype enable_debug(x::Bool) = x import Distributed +import Pkg include("compatmacro.jl") @@ -72,12 +73,6 @@ end end end -@static if VERSION < v"0.7.0-DEV.3656" - const Pkg = Base.Pkg -else - import Pkg -end - @static if VERSION < v"0.7.0-DEV.3630" @eval module InteractiveUtils using Base: @code_llvm, @code_lowered, @code_native, @code_typed, diff --git a/test/old.jl b/test/old.jl index ec74626dc..f25df33a3 100644 --- a/test/old.jl +++ b/test/old.jl @@ -193,6 +193,14 @@ let v = [1, 2, 3] @test Compat.IteratorEltype(v) == Base.HasEltype() end +module TestPkg + using Compat + using Compat.Pkg + using Compat.Test + @test isdefined(@__MODULE__, :Pkg) + @test isdefined(Compat.Pkg, :add) +end + # tests of removed functionality (i.e. justs tests Base) diff --git a/test/runtests.jl b/test/runtests.jl index f0fdf3ea9..64e94ce90 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -82,14 +82,6 @@ end @test codeunit("foo") == codeunit(SubString("fooαβγ",1,3)) == UInt8 -module TestPkg - using Compat - using Compat.Pkg - using Compat.Test - @test isdefined(@__MODULE__, :Pkg) - @test isdefined(Compat.Pkg, :add) -end - module TestInteractiveUtils using Compat using Compat.InteractiveUtils From 838ef8b370c98638099339849381d1900627b657 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 17:06:40 +0200 Subject: [PATCH 076/121] Mark `Compat.InteractiveUtils` from #485 for deprecation --- README.md | 3 --- src/Compat.jl | 24 +----------------------- test/old.jl | 8 ++++++++ test/runtests.jl | 8 -------- 4 files changed, 9 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 4f26c26d9..3199eaf5a 100644 --- a/README.md +++ b/README.md @@ -52,9 +52,6 @@ Currently, the `@compat` macro supports the following syntaxes: ## Module Aliases -* `using Compat.InteractiveUtils` is provided on versions older than 0.7, where this library is - not yet part of the standard library ([#25780]). - * `using Compat.LibGit2` is provided on versions older than 0.7, where this library is not yet part of the standard library ([#25706]). diff --git a/src/Compat.jl b/src/Compat.jl index 53e7460bf..ba15b60cf 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -48,6 +48,7 @@ const IteratorEltype = Base.IteratorEltype enable_debug(x::Bool) = x import Distributed import Pkg +import InteractiveUtils include("compatmacro.jl") @@ -73,29 +74,6 @@ end end end -@static if VERSION < v"0.7.0-DEV.3630" - @eval module InteractiveUtils - using Base: @code_llvm, @code_lowered, @code_native, @code_typed, - @code_warntype, @edit, @functionloc, @less, @which, - apropos, code_llvm, code_native, code_warntype, edit, - less, methodswith, subtypes, versioninfo - export @code_llvm, @code_lowered, @code_native, @code_typed, - @code_warntype, @edit, @functionloc, @less, @which, - apropos, code_llvm, code_native, code_warntype, edit, - less, methodswith, subtypes, versioninfo - - @static if VERSION >= v"0.7.0-DEV.2582" - using Base: varinfo - export varinfo - else - const varinfo = whos - export varinfo - end - end -else - import InteractiveUtils -end - @static if VERSION < v"0.7.0-DEV.3724" const LibGit2 = Base.LibGit2 else diff --git a/test/old.jl b/test/old.jl index f25df33a3..1ff6a7f61 100644 --- a/test/old.jl +++ b/test/old.jl @@ -201,6 +201,14 @@ module TestPkg @test isdefined(Compat.Pkg, :add) end +module TestInteractiveUtils + using Compat + using Compat.InteractiveUtils + using Compat.Test + @test isdefined(@__MODULE__, :InteractiveUtils) + @test isdefined(@__MODULE__, :varinfo) +end + # tests of removed functionality (i.e. justs tests Base) diff --git a/test/runtests.jl b/test/runtests.jl index 64e94ce90..b9f6410b6 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -82,14 +82,6 @@ end @test codeunit("foo") == codeunit(SubString("fooαβγ",1,3)) == UInt8 -module TestInteractiveUtils - using Compat - using Compat.InteractiveUtils - using Compat.Test - @test isdefined(@__MODULE__, :InteractiveUtils) - @test isdefined(@__MODULE__, :varinfo) -end - module TestLibGit2 using Compat using Compat.LibGit2 From 40a5bb268ecb3242888da32c79629d95860324a6 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 17:08:04 +0200 Subject: [PATCH 077/121] Mark `Compat.LibGit2` from #487 for deprecation --- README.md | 3 --- src/Compat.jl | 7 +------ test/old.jl | 8 ++++++++ test/runtests.jl | 8 -------- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 3199eaf5a..38d812d96 100644 --- a/README.md +++ b/README.md @@ -52,9 +52,6 @@ Currently, the `@compat` macro supports the following syntaxes: ## Module Aliases -* `using Compat.LibGit2` is provided on versions older than 0.7, where this library is - not yet part of the standard library ([#25706]). - * `using Compat.UUIDs` is provided on versions older than 0.7, where this library is not yet part of the standard library ([#25819]). diff --git a/src/Compat.jl b/src/Compat.jl index ba15b60cf..a6c28b60e 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -49,6 +49,7 @@ enable_debug(x::Bool) = x import Distributed import Pkg import InteractiveUtils +import LibGit2 include("compatmacro.jl") @@ -74,12 +75,6 @@ end end end -@static if VERSION < v"0.7.0-DEV.3724" - const LibGit2 = Base.LibGit2 -else - import LibGit2 -end - # 0.7.0-DEV.2695 @static if !isdefined(Base, :AbstractDisplay) const AbstractDisplay = Display diff --git a/test/old.jl b/test/old.jl index 1ff6a7f61..0fb733389 100644 --- a/test/old.jl +++ b/test/old.jl @@ -209,6 +209,14 @@ module TestInteractiveUtils @test isdefined(@__MODULE__, :varinfo) end +module TestLibGit2 + using Compat + using Compat.LibGit2 + using Compat.Test + @test isdefined(@__MODULE__, :LibGit2) + @test isdefined(@__MODULE__, :GitRepo) +end + # tests of removed functionality (i.e. justs tests Base) diff --git a/test/runtests.jl b/test/runtests.jl index b9f6410b6..05ae89e58 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -82,14 +82,6 @@ end @test codeunit("foo") == codeunit(SubString("fooαβγ",1,3)) == UInt8 -module TestLibGit2 - using Compat - using Compat.LibGit2 - using Compat.Test - @test isdefined(@__MODULE__, :LibGit2) - @test isdefined(@__MODULE__, :GitRepo) -end - @test eltype(Base.Multimedia.displays) <: AbstractDisplay # 0.7.0-DEV.3481 From 03411e5f218042156e5f42d15ce034f310a5a6b4 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 17:10:19 +0200 Subject: [PATCH 078/121] Drop compat code for `AbstractDisplay` from #482 --- README.md | 2 -- src/Compat.jl | 6 ------ test/old.jl | 2 ++ test/runtests.jl | 2 -- 4 files changed, 2 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 38d812d96..3c55457b5 100644 --- a/README.md +++ b/README.md @@ -125,8 +125,6 @@ Currently, the `@compat` macro supports the following syntaxes: ## Renaming -* `Display` is now `AbstractDisplay` ([#24831]). - * `reprmime(mime, x)` is now `repr(mime, x)` ([#25990]) and `mimewritable` is now `showable` ([#26089]). * `search` is now `findfirst`/`findnext` and `rsearch` is now `findlast`/`findprev`, diff --git a/src/Compat.jl b/src/Compat.jl index a6c28b60e..d6c32fab9 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -75,12 +75,6 @@ end end end -# 0.7.0-DEV.2695 -@static if !isdefined(Base, :AbstractDisplay) - const AbstractDisplay = Display - export AbstractDisplay -end - # 0.7.0-DEV.3481 @static if !isdefined(Base, :bytesavailable) const bytesavailable = nb_available diff --git a/test/old.jl b/test/old.jl index 0fb733389..0039c7997 100644 --- a/test/old.jl +++ b/test/old.jl @@ -701,3 +701,5 @@ end @test !GC.enable(false) @test !GC.enable(true) @test GC.enable(true) + +@test eltype(Base.Multimedia.displays) <: AbstractDisplay diff --git a/test/runtests.jl b/test/runtests.jl index 05ae89e58..3a46a82ec 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -82,8 +82,6 @@ end @test codeunit("foo") == codeunit(SubString("fooαβγ",1,3)) == UInt8 -@test eltype(Base.Multimedia.displays) <: AbstractDisplay - # 0.7.0-DEV.3481 let b = IOBuffer() write(b, "hi") From cd9a04d90cc75367f6701e6a9bdea5683585ea40 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 17:11:42 +0200 Subject: [PATCH 079/121] Drop compat code for `bytesavailable` from #483 --- README.md | 2 -- src/Compat.jl | 6 ------ test/old.jl | 6 ++++++ test/runtests.jl | 6 ------ 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 3c55457b5..1b3be6fe6 100644 --- a/README.md +++ b/README.md @@ -142,8 +142,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `endof` is now `lastindex` ([#25458]). (Note that `lastindex(A, n)` is not supported.) -* `nb_available` is now `bytesavailable` ([#25634]). - * `method_exists` is now `hasmethod` ([#25615]). * `object_id` is now `objectid` ([#25615]). diff --git a/src/Compat.jl b/src/Compat.jl index d6c32fab9..4b2c46cd6 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -75,12 +75,6 @@ end end end -# 0.7.0-DEV.3481 -@static if !isdefined(Base, :bytesavailable) - const bytesavailable = nb_available - export bytesavailable -end - # 0.7.0-DEV.3583 @static if !isdefined(Base, :lastindex) const lastindex = endof diff --git a/test/old.jl b/test/old.jl index 0039c7997..c78c571c1 100644 --- a/test/old.jl +++ b/test/old.jl @@ -703,3 +703,9 @@ end @test GC.enable(true) @test eltype(Base.Multimedia.displays) <: AbstractDisplay + +# 0.7.0-DEV.3481 +let b = IOBuffer() + write(b, "hi") + @test bytesavailable(b) == 0 +end diff --git a/test/runtests.jl b/test/runtests.jl index 3a46a82ec..30c8b90ff 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -82,12 +82,6 @@ end @test codeunit("foo") == codeunit(SubString("fooαβγ",1,3)) == UInt8 -# 0.7.0-DEV.3481 -let b = IOBuffer() - write(b, "hi") - @test bytesavailable(b) == 0 -end - # 0.7.0-DEV.3583 @test lastindex(zeros(4)) == 4 @test lastindex(zeros(4,4)) == 16 From 8b5ea3311ac3fc817bfca242ee5929ce4cfb1644 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 17:13:49 +0200 Subject: [PATCH 080/121] Drop compat code for `firstindex` and `lastindex` from #480 and #494 --- README.md | 4 ---- src/Compat.jl | 14 -------------- test/old.jl | 5 +++++ test/runtests.jl | 5 ----- 4 files changed, 5 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 1b3be6fe6..c54e3afd8 100644 --- a/README.md +++ b/README.md @@ -77,8 +77,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `printstyled` prints to a given stream optionally in color and/or bolded ([#25522]). -* `firstindex` to obtain the first index of an iterable ([#25458]). - * `Compat.names` supporting keyword arguments for `all` and `imported` ([#25647]). * `Compat.IOBuffer` supporting keyword arguments ([#25873]). @@ -140,8 +138,6 @@ Currently, the `@compat` macro supports the following syntaxes: for entries with no match and gives the index of the first (rather than the last) match ([#25662], [#25998]). -* `endof` is now `lastindex` ([#25458]). (Note that `lastindex(A, n)` is not supported.) - * `method_exists` is now `hasmethod` ([#25615]). * `object_id` is now `objectid` ([#25615]). diff --git a/src/Compat.jl b/src/Compat.jl index 4b2c46cd6..ee2d96ba2 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -75,20 +75,6 @@ end end end -# 0.7.0-DEV.3583 -@static if !isdefined(Base, :lastindex) - const lastindex = endof - export lastindex - firstindex(a::AbstractArray) = (Base.@_inline_meta; first(linearindices(a))) - firstindex(c::Char) = 1 - firstindex(c::Number) = 1 - firstindex(p::Pair) = 1 - firstindex(cmd::Cmd) = firstindex(cmd.exec) - firstindex(s::AbstractString) = 1 - firstindex(t::Tuple) = 1 - export firstindex -end - # 0.7.0-DEV.3585 @static if !isdefined(Base, :printstyled) printstyled(io::IO, msg...; bold=false, color=:normal) = diff --git a/test/old.jl b/test/old.jl index c78c571c1..4f14ff617 100644 --- a/test/old.jl +++ b/test/old.jl @@ -709,3 +709,8 @@ let b = IOBuffer() write(b, "hi") @test bytesavailable(b) == 0 end + +# 0.7.0-DEV.3583 +@test lastindex(zeros(4)) == 4 +@test lastindex(zeros(4,4)) == 16 +@test all(x -> firstindex(x) == 1, ([1, 2], [1 2; 3 4], 'a', 1, 1=>2, `foo`, "foo", (1, 2))) diff --git a/test/runtests.jl b/test/runtests.jl index 30c8b90ff..4dd4a3b29 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -82,11 +82,6 @@ end @test codeunit("foo") == codeunit(SubString("fooαβγ",1,3)) == UInt8 -# 0.7.0-DEV.3583 -@test lastindex(zeros(4)) == 4 -@test lastindex(zeros(4,4)) == 16 -@test all(x -> firstindex(x) == 1, ([1, 2], [1 2; 3 4], 'a', 1, 1=>2, `foo`, "foo", (1, 2))) - # 0.7.0-DEV.3585 let buf = IOBuffer() if VERSION < v"0.7.0-DEV.3077" From 490a6bce107301216effd44491e534999e800a1f Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 17:15:13 +0200 Subject: [PATCH 081/121] Drop compat code for `printstyled` from #481 --- README.md | 2 -- src/Compat.jl | 9 --------- test/old.jl | 13 +++++++++++++ test/runtests.jl | 13 ------------- 4 files changed, 13 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index c54e3afd8..da2b4449a 100644 --- a/README.md +++ b/README.md @@ -75,8 +75,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. -* `printstyled` prints to a given stream optionally in color and/or bolded ([#25522]). - * `Compat.names` supporting keyword arguments for `all` and `imported` ([#25647]). * `Compat.IOBuffer` supporting keyword arguments ([#25873]). diff --git a/src/Compat.jl b/src/Compat.jl index ee2d96ba2..5a4881402 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -75,15 +75,6 @@ end end end -# 0.7.0-DEV.3585 -@static if !isdefined(Base, :printstyled) - printstyled(io::IO, msg...; bold=false, color=:normal) = - Base.print_with_color(color, io, msg...; bold=bold) - printstyled(msg...; bold=false, color=:normal) = - Base.print_with_color(color, STDOUT, msg...; bold=bold) - export printstyled -end - # 0.7.0-DEV.3455 @static if !isdefined(Base, :hasmethod) const hasmethod = method_exists diff --git a/test/old.jl b/test/old.jl index 4f14ff617..79134c5df 100644 --- a/test/old.jl +++ b/test/old.jl @@ -714,3 +714,16 @@ end @test lastindex(zeros(4)) == 4 @test lastindex(zeros(4,4)) == 16 @test all(x -> firstindex(x) == 1, ([1, 2], [1 2; 3 4], 'a', 1, 1=>2, `foo`, "foo", (1, 2))) + +# 0.7.0-DEV.3585 +let buf = IOBuffer() + if VERSION < v"0.7.0-DEV.3077" + col = Base.have_color + eval(Base, :(have_color = true)) + printstyled(buf, "foo", color=:red) + eval(Base, :(have_color = $col)) + else + printstyled(IOContext(buf, :color=>true), "foo", color=:red) + end + @test startswith(String(take!(buf)), Base.text_colors[:red]) +end diff --git a/test/runtests.jl b/test/runtests.jl index 4dd4a3b29..dba32875f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -82,19 +82,6 @@ end @test codeunit("foo") == codeunit(SubString("fooαβγ",1,3)) == UInt8 -# 0.7.0-DEV.3585 -let buf = IOBuffer() - if VERSION < v"0.7.0-DEV.3077" - col = Base.have_color - eval(Base, :(have_color = true)) - printstyled(buf, "foo", color=:red) - eval(Base, :(have_color = $col)) - else - printstyled(IOContext(buf, :color=>true), "foo", color=:red) - end - @test startswith(String(take!(buf)), Base.text_colors[:red]) -end - # 0.7.0-DEV.3455 @test hasmethod(sin, Tuple{Float64}) let x = y = 1 From ae7165b2a2db70b0e4babb738da8dd9d594ccf38 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 17:17:10 +0200 Subject: [PATCH 082/121] Drop compat code for `hasmethod` from #486 --- README.md | 2 -- src/Compat.jl | 4 ---- test/old.jl | 3 +++ test/runtests.jl | 1 - 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index da2b4449a..65300e85a 100644 --- a/README.md +++ b/README.md @@ -136,8 +136,6 @@ Currently, the `@compat` macro supports the following syntaxes: for entries with no match and gives the index of the first (rather than the last) match ([#25662], [#25998]). -* `method_exists` is now `hasmethod` ([#25615]). - * `object_id` is now `objectid` ([#25615]). * `LinSpace` is now `LinRange` ([#25896]). diff --git a/src/Compat.jl b/src/Compat.jl index 5a4881402..29de7552f 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -76,10 +76,6 @@ end end # 0.7.0-DEV.3455 -@static if !isdefined(Base, :hasmethod) - const hasmethod = method_exists - export hasmethod -end @static if !isdefined(Base, :objectid) const objectid = object_id export objectid diff --git a/test/old.jl b/test/old.jl index 79134c5df..0402e5ee6 100644 --- a/test/old.jl +++ b/test/old.jl @@ -727,3 +727,6 @@ let buf = IOBuffer() end @test startswith(String(take!(buf)), Base.text_colors[:red]) end + +# 0.7.0-DEV.3455 +@test hasmethod(sin, Tuple{Float64}) diff --git a/test/runtests.jl b/test/runtests.jl index dba32875f..6e69d8cfc 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -83,7 +83,6 @@ end @test codeunit("foo") == codeunit(SubString("fooαβγ",1,3)) == UInt8 # 0.7.0-DEV.3455 -@test hasmethod(sin, Tuple{Float64}) let x = y = 1 @test objectid(x) == objectid(y) end From 2d382cf69401bc02622d81f383a3a3c14c58e0f3 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 17:17:46 +0200 Subject: [PATCH 083/121] Drop compat code for `objectid` from #486 --- README.md | 2 -- src/Compat.jl | 6 ------ test/old.jl | 3 +++ test/runtests.jl | 5 ----- 4 files changed, 3 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 65300e85a..8384a934e 100644 --- a/README.md +++ b/README.md @@ -136,8 +136,6 @@ Currently, the `@compat` macro supports the following syntaxes: for entries with no match and gives the index of the first (rather than the last) match ([#25662], [#25998]). -* `object_id` is now `objectid` ([#25615]). - * `LinSpace` is now `LinRange` ([#25896]). * `isupper`, `islower`, `ucfirst` and `lcfirst` are now `isuppercase`, `islowercase`, diff --git a/src/Compat.jl b/src/Compat.jl index 29de7552f..0e108b096 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -75,12 +75,6 @@ end end end -# 0.7.0-DEV.3455 -@static if !isdefined(Base, :objectid) - const objectid = object_id - export objectid -end - @static if VERSION < v"0.7.0-DEV.3272" zero2nothing(x::Integer) = x == 0 ? nothing : x zero2nothing(x::AbstractUnitRange{<:Integer}) = x == 0:-1 ? nothing : x diff --git a/test/old.jl b/test/old.jl index 0402e5ee6..d5184a6bc 100644 --- a/test/old.jl +++ b/test/old.jl @@ -730,3 +730,6 @@ end # 0.7.0-DEV.3455 @test hasmethod(sin, Tuple{Float64}) +let x = y = 1 + @test objectid(x) == objectid(y) +end diff --git a/test/runtests.jl b/test/runtests.jl index 6e69d8cfc..c72eade47 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -82,11 +82,6 @@ end @test codeunit("foo") == codeunit(SubString("fooαβγ",1,3)) == UInt8 -# 0.7.0-DEV.3455 -let x = y = 1 - @test objectid(x) == objectid(y) -end - # 0.7.0-DEV.3415 for (f1, f2, i) in ((Compat.findfirst, Compat.findnext, 1), (Compat.findlast, Compat.findprev, 2)) From e7ff2546d9633a2f608c4216af553860f832f61c Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 17:26:18 +0200 Subject: [PATCH 084/121] Drop compat code for `Compat.find*` from #484 and #513 --- README.md | 9 -------- src/Compat.jl | 49 ------------------------------------------ test/old.jl | 40 +++++++++++++++++++++++++++++++++++ test/runtests.jl | 55 ------------------------------------------------ 4 files changed, 40 insertions(+), 113 deletions(-) diff --git a/README.md b/README.md index 8384a934e..5c3466c7c 100644 --- a/README.md +++ b/README.md @@ -123,15 +123,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `reprmime(mime, x)` is now `repr(mime, x)` ([#25990]) and `mimewritable` is now `showable` ([#26089]). -* `search` is now `findfirst`/`findnext` and `rsearch` is now `findlast`/`findprev`, - sometimes combined with `isequal` or `in` ([#24673], [#26436]). - -* `Compat.findfirst`, `Compat.findnext`, `Compat.findlast` and `Compat.findprev`, - return `nothing` when no match is found (rather than `0` or `0:-1`) - as on Julia 0.7 ([#24673], [#26149]). - -* `findin(a, b)` is now `findall(in(b), a)` ([#24673]). - * `Compat.indexin` accepts any iterable as first argument, returns `nothing` (rather than `0`) for entries with no match and gives the index of the first (rather than the last) match ([#25662], [#25998]). diff --git a/src/Compat.jl b/src/Compat.jl index 0e108b096..fdae59438 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -75,55 +75,6 @@ end end end -@static if VERSION < v"0.7.0-DEV.3272" - zero2nothing(x::Integer) = x == 0 ? nothing : x - zero2nothing(x::AbstractUnitRange{<:Integer}) = x == 0:-1 ? nothing : x - zero2nothing(x) = x - - findnext(xs...) = zero2nothing(Base.findnext(xs...)) - findfirst(xs...) = zero2nothing(Base.findfirst(xs...)) - findprev(xs...) = zero2nothing(Base.findprev(xs...)) - findlast(xs...) = zero2nothing(Base.findlast(xs...)) - - Base.findnext(r::Regex, s::AbstractString, idx::Integer) = search(s, r, idx) - Base.findfirst(r::Regex, s::AbstractString) = search(s, r) - Base.findnext(c::Fix2{typeof(isequal),Char}, s::AbstractString, i::Integer) = search(s, c.x, i) - Base.findfirst(c::Fix2{typeof(isequal),Char}, s::AbstractString) = search(s, c.x) - Base.findnext(b::Fix2{typeof(isequal),<:Union{Int8,UInt8}}, a::Vector{<:Union{Int8,UInt8}}, i::Integer) = - search(a, b.x, i) - Base.findfirst(b::Fix2{typeof(isequal),<:Union{Int8,UInt8}}, a::Vector{<:Union{Int8,UInt8}}) = - search(a, b.x) - - Base.findnext(c::Fix2{typeof(in),<:Union{Tuple{Vararg{Char}},AbstractVector{Char},Set{Char}}}, - s::AbstractString, i::Integer) = - search(s, c.x, i) - Base.findfirst(c::Fix2{typeof(in),<:Union{Tuple{Vararg{Char}},AbstractVector{Char},Set{Char}}}, - s::AbstractString) = - search(s, c.x) - Base.findnext(t::AbstractString, s::AbstractString, i::Integer) = search(s, t, i) - Base.findfirst(t::AbstractString, s::AbstractString) = search(s, t) - - Base.findfirst(delim::Fix2{typeof(isequal),UInt8}, buf::Base.IOBuffer) = search(buf, delim.x) - - Base.findprev(c::Fix2{typeof(isequal),Char}, s::AbstractString, i::Integer) = rsearch(s, c.x, i) - Base.findlast(c::Fix2{typeof(isequal),Char}, s::AbstractString) = rsearch(s, c.x) - Base.findprev(b::Fix2{typeof(isequal),<:Union{Int8,UInt8}}, a::Vector{<:Union{Int8,UInt8}}, i::Integer) = - rsearch(a, b.x, i) - Base.findlast(b::Fix2{typeof(isequal),<:Union{Int8,UInt8}}, a::Vector{<:Union{Int8,UInt8}}) = - rsearch(a, b.x) - - Base.findprev(c::Fix2{typeof(in),<:Union{Tuple{Vararg{Char}},AbstractVector{Char},Set{Char}}}, - s::AbstractString, i::Integer) = rsearch(s, c.x, i) - Base.findlast(c::Fix2{typeof(in),<:Union{Tuple{Vararg{Char}},AbstractVector{Char},Set{Char}}}, - s::AbstractString) = rsearch(s, c.x) - Base.findprev(t::AbstractString, s::AbstractString, i::Integer) = rsearch(s, t, i) - Base.findlast(t::AbstractString, s::AbstractString) = rsearch(s, t) - - findall(b::Fix2{typeof(in)}, a) = findin(a, b.x) - # To fix ambiguity - findall(b::Fix2{typeof(in)}, a::Number) = a in b.x ? [1] : Vector{Int}() -end - @static if VERSION < v"0.7.0-DEV.4047" #26089 showable(mime, x) = mimewritable(mime, x) export showable diff --git a/test/old.jl b/test/old.jl index d5184a6bc..72e5a74d1 100644 --- a/test/old.jl +++ b/test/old.jl @@ -733,3 +733,43 @@ end let x = y = 1 @test objectid(x) == objectid(y) end + +# 0.7.0-DEV.3415 +for (f1, f2, i) in ((Compat.findfirst, Compat.findnext, 1), + (Compat.findlast, Compat.findprev, 2)) + # Generic methods + @test f1(isequal(0), [1, 0]) == f2(isequal(0), [1, 0], i) == 2 + @test f1(isequal(9), [1, 0]) == f2(isequal(9), [1, 0], i) == nothing + @test f1(in([0, 2]), [1, 0]) == f2(in([0, 2]), [1, 0], i) == 2 + @test f1(in([0, 2]), [1, 9]) == f2(in([0, 2]), [1, 9], i) == nothing + @test f1([true, false]) == f2([true, false], i) == 1 + @test f1([false, false]) == f2([false, false], i) == nothing + + # Specific methods + @test f2(isequal('a'), "ba", i) == f1(isequal('a'), "ba") == 2 + for S in (Int8, UInt8), T in (Int8, UInt8) + # Bug in Julia 0.6 + @test f2(isequal(S(1)), T[0, 1], i) == f1(isequal(S(1)), T[0, 1]) == 2 + @test f2(isequal(S(9)), T[0, 1], i) == f1(isequal(S(9)), T[0, 1]) == nothing + end + for chars in (['a', 'z'], Set(['a', 'z']), ('a', 'z')) + @test f2(in(chars), "ba", i) == f1(in(chars), "ba") == 2 + @test f2(in(chars), "bx", i) == f1(in(chars), "bx") == nothing + end +end +@test findnext("a", "ba", 1) == findfirst("a", "ba") == 2:2 +@test findnext("z", "ba", 1) == findfirst("z", "ba") == nothing +@test findprev("a", "ba", 2) == findlast("a", "ba") == 2:2 +@test findprev("z", "ba", 2) == findlast("z", "ba") == nothing +@test Compat.findnext("a", "ba", 1) == Compat.findfirst("a", "ba") == 2:2 +@test Compat.findnext("z", "ba", 1) == Compat.findfirst("z", "ba") == nothing +@test Compat.findprev("a", "ba", 2) == Compat.findlast("a", "ba") == 2:2 +@test Compat.findprev("z", "ba", 2) == Compat.findlast("z", "ba") == nothing + +@test findnext(r"a", "ba", 1) == findfirst(r"a", "ba") == 2:2 +@test findnext(r"z", "ba", 1) == findfirst(r"z", "ba") == nothing +@test Compat.findnext(r"a", "ba", 1) == Compat.findfirst(r"a", "ba") == 2:2 +@test Compat.findnext(r"z", "ba", 1) == Compat.findfirst(r"z", "ba") == nothing + +@test findall([true, false, true]) == [1, 3] +@test findall(in([1, 2]), [1]) == [1] diff --git a/test/runtests.jl b/test/runtests.jl index c72eade47..70604c3fb 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -82,61 +82,6 @@ end @test codeunit("foo") == codeunit(SubString("fooαβγ",1,3)) == UInt8 -# 0.7.0-DEV.3415 -for (f1, f2, i) in ((Compat.findfirst, Compat.findnext, 1), - (Compat.findlast, Compat.findprev, 2)) - # Generic methods - @test f1(isequal(0), [1, 0]) == f2(isequal(0), [1, 0], i) == 2 - @test f1(isequal(9), [1, 0]) == f2(isequal(9), [1, 0], i) == nothing - @test f1(in([0, 2]), [1, 0]) == f2(in([0, 2]), [1, 0], i) == 2 - @test f1(in([0, 2]), [1, 9]) == f2(in([0, 2]), [1, 9], i) == nothing - if VERSION < v"0.7.0-DEV.4592" - # test that occursin work on 0.6 - @test f1(occursin([0, 2]), [1, 0]) == f2(occursin([0, 2]), [1, 0], i) == 2 - @test f1(occursin([0, 2]), [1, 9]) == f2(occursin([0, 2]), [1, 9], i) == nothing - end - @test f1([true, false]) == f2([true, false], i) == 1 - @test f1([false, false]) == f2([false, false], i) == nothing - - # Specific methods - @test f2(isequal('a'), "ba", i) == f1(isequal('a'), "ba") == 2 - for S in (Int8, UInt8), T in (Int8, UInt8) - # Bug in Julia 0.6 - f1 === Compat.findlast && VERSION < v"0.7.0-DEV.3272" && continue - @test f2(isequal(S(1)), T[0, 1], i) == f1(isequal(S(1)), T[0, 1]) == 2 - @test f2(isequal(S(9)), T[0, 1], i) == f1(isequal(S(9)), T[0, 1]) == nothing - end - for chars in (['a', 'z'], Set(['a', 'z']), ('a', 'z')) - @test f2(in(chars), "ba", i) == f1(in(chars), "ba") == 2 - @test f2(in(chars), "bx", i) == f1(in(chars), "bx") == nothing - if VERSION < v"0.7.0-DEV.4592" - # test that occursin work on 0.6 - @test f2(occursin(chars), "ba", i) == f1(occursin(chars), "ba") == 2 - @test f2(occursin(chars), "bx", i) == f1(occursin(chars), "bx") == nothing - end - end -end -@test findnext("a", "ba", 1) == findfirst("a", "ba") == 2:2 -@test findnext("z", "ba", 1) == findfirst("z", "ba") == (VERSION < v"0.7.0-DEV.4480" ? (0:-1) : nothing) -@test findprev("a", "ba", 2) == findlast("a", "ba") == 2:2 -@test findprev("z", "ba", 2) == findlast("z", "ba") == (VERSION < v"0.7.0-DEV.4480" ? (0:-1) : nothing) -@test Compat.findnext("a", "ba", 1) == Compat.findfirst("a", "ba") == 2:2 -@test Compat.findnext("z", "ba", 1) == Compat.findfirst("z", "ba") == nothing -@test Compat.findprev("a", "ba", 2) == Compat.findlast("a", "ba") == 2:2 -@test Compat.findprev("z", "ba", 2) == Compat.findlast("z", "ba") == nothing - -@test findnext(r"a", "ba", 1) == findfirst(r"a", "ba") == 2:2 -@test findnext(r"z", "ba", 1) == findfirst(r"z", "ba") == (VERSION < v"0.7.0-DEV.4480" ? (0:-1) : nothing) -@test Compat.findnext(r"a", "ba", 1) == Compat.findfirst(r"a", "ba") == 2:2 -@test Compat.findnext(r"z", "ba", 1) == Compat.findfirst(r"z", "ba") == nothing - -@test findall([true, false, true]) == [1, 3] -@test findall(in([1, 2]), [1]) == [1] -if VERSION < v"0.7.0-DEV.4592" - # test that occursin work on 0.6 - @test findall(occursin([1, 2]), [1]) == [1] -end - # 0.7.0-DEV.3666 module TestUUIDs using Compat From cfa046ecb725ec8110e1647e2bf9211d602ca314 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 17:28:58 +0200 Subject: [PATCH 085/121] Drop compat code for `repr` and `showable` from #497 --- README.md | 2 -- src/Compat.jl | 9 --------- test/old.jl | 3 +++ test/runtests.jl | 3 --- 4 files changed, 3 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 5c3466c7c..8fcd5c556 100644 --- a/README.md +++ b/README.md @@ -121,8 +121,6 @@ Currently, the `@compat` macro supports the following syntaxes: ## Renaming -* `reprmime(mime, x)` is now `repr(mime, x)` ([#25990]) and `mimewritable` is now `showable` ([#26089]). - * `Compat.indexin` accepts any iterable as first argument, returns `nothing` (rather than `0`) for entries with no match and gives the index of the first (rather than the last) match ([#25662], [#25998]). diff --git a/src/Compat.jl b/src/Compat.jl index fdae59438..ea1b3dbda 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -75,15 +75,6 @@ end end end -@static if VERSION < v"0.7.0-DEV.4047" #26089 - showable(mime, x) = mimewritable(mime, x) - export showable -end - -@static if VERSION < v"0.7.0-DEV.4010" #25990 - Base.repr(mime::Union{AbstractString,MIME}, x) = reprmime(mime, x) -end - # https://github.com/JuliaLang/julia/pull/25647 @static if VERSION < v"0.7.0-DEV.3526" names(m; all=false, imported=false) = Base.names(m, all, imported) diff --git a/test/old.jl b/test/old.jl index 72e5a74d1..821b587e8 100644 --- a/test/old.jl +++ b/test/old.jl @@ -773,3 +773,6 @@ end @test findall([true, false, true]) == [1, 3] @test findall(in([1, 2]), [1]) == [1] + +@test repr("text/plain", "string") == "\"string\"" #25990 +@test showable("text/plain", 3.14159) #26089 diff --git a/test/runtests.jl b/test/runtests.jl index 70604c3fb..d35f5c3e2 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -97,9 +97,6 @@ module TestUUIDs @test uuid4() isa UUID end -@test repr("text/plain", "string") == "\"string\"" #25990 -@test showable("text/plain", 3.14159) #26089 - # 0.7.0-DEV.3526 module TestNames export foo From cc9c701b4eb3130bc68348eb4ff404785b4a0ab1 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 17:30:46 +0200 Subject: [PATCH 086/121] Drop compat code for `Compat.names` from #493 and #505 --- README.md | 2 -- src/Compat.jl | 5 ----- test/old.jl | 8 ++++++++ test/runtests.jl | 8 -------- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 8fcd5c556..1e59137b0 100644 --- a/README.md +++ b/README.md @@ -75,8 +75,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.names` supporting keyword arguments for `all` and `imported` ([#25647]). - * `Compat.IOBuffer` supporting keyword arguments ([#25873]). * `Compat.range` supporting positional and keyword arguments flavors ([#25896]), ([#28708]). diff --git a/src/Compat.jl b/src/Compat.jl index ea1b3dbda..177b8c893 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -75,11 +75,6 @@ end end end -# https://github.com/JuliaLang/julia/pull/25647 -@static if VERSION < v"0.7.0-DEV.3526" - names(m; all=false, imported=false) = Base.names(m, all, imported) -end - if VERSION >= v"0.7.0-DEV.3666" import UUIDs else diff --git a/test/old.jl b/test/old.jl index 821b587e8..9c7554563 100644 --- a/test/old.jl +++ b/test/old.jl @@ -776,3 +776,11 @@ end @test repr("text/plain", "string") == "\"string\"" #25990 @test showable("text/plain", 3.14159) #26089 + +# 0.7.0-DEV.3526 +module TestNames + export foo + function bar end +end +@test :foo in Compat.names(TestNames) +@test :bar in Compat.names(TestNames, all=true) diff --git a/test/runtests.jl b/test/runtests.jl index d35f5c3e2..2fb15825d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -97,14 +97,6 @@ module TestUUIDs @test uuid4() isa UUID end -# 0.7.0-DEV.3526 -module TestNames - export foo - function bar end -end -@test :foo in Compat.names(TestNames) -@test :bar in Compat.names(TestNames, all=true) - # 0.7.0-DEV.4804 @test Compat.trunc(pi) == 3.0 @test Compat.floor(pi) == 3.0 From ae230646a7249e07926d72b6f803a26b52ee9597 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 17:34:01 +0200 Subject: [PATCH 087/121] Mark `Compat.UUIDs` from #490 for deprecation --- README.md | 3 --- src/Compat.jl | 14 +------------- test/old.jl | 15 +++++++++++++++ test/runtests.jl | 15 --------------- 4 files changed, 16 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 1e59137b0..f23d175be 100644 --- a/README.md +++ b/README.md @@ -52,9 +52,6 @@ Currently, the `@compat` macro supports the following syntaxes: ## Module Aliases -* `using Compat.UUIDs` is provided on versions older than 0.7, where this library is - not yet part of the standard library ([#25819]). - ## New functions, macros, and methods * `only(x)` returns the one-and-only element of a collection `x`. ([#33129]) diff --git a/src/Compat.jl b/src/Compat.jl index 177b8c893..881c6a569 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -50,6 +50,7 @@ import Distributed import Pkg import InteractiveUtils import LibGit2 +import UUIDs include("compatmacro.jl") @@ -75,19 +76,6 @@ end end end -if VERSION >= v"0.7.0-DEV.3666" - import UUIDs -else - @eval module UUIDs - if VERSION < v"0.7.0-DEV.3406" - import Base.Random: uuid1, uuid4, uuid_version, UUID - else - import Random: uuid1, uuid4, uuid_version, UUID - end - export uuid1, uuid4, uuid_version, UUID - end -end - # https://github.com/JuliaLang/julia/pull/26670 @static if VERSION < v"0.7.0-DEV.4062" trunc(x; digits = 0, base = 10) = Base.trunc(x, digits, base) diff --git a/test/old.jl b/test/old.jl index 9c7554563..f2efccfe5 100644 --- a/test/old.jl +++ b/test/old.jl @@ -217,6 +217,21 @@ module TestLibGit2 @test isdefined(@__MODULE__, :GitRepo) end +# 0.7.0-DEV.3666 +module TestUUIDs + using Compat + using Compat.UUIDs + using Compat.Test + @test isdefined(@__MODULE__, :uuid1) + @test isdefined(@__MODULE__, :uuid4) + @test isdefined(@__MODULE__, :uuid_version) + + @test uuid_version(uuid1()) == 1 + @test uuid_version(uuid4()) == 4 + @test uuid1() isa UUID + @test uuid4() isa UUID +end + # tests of removed functionality (i.e. justs tests Base) diff --git a/test/runtests.jl b/test/runtests.jl index 2fb15825d..551176cf1 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.3666 -module TestUUIDs - using Compat - using Compat.UUIDs - using Compat.Test - @test isdefined(@__MODULE__, :uuid1) - @test isdefined(@__MODULE__, :uuid4) - @test isdefined(@__MODULE__, :uuid_version) - - @test uuid_version(uuid1()) == 1 - @test uuid_version(uuid4()) == 4 - @test uuid1() isa UUID - @test uuid4() isa UUID -end - # 0.7.0-DEV.4804 @test Compat.trunc(pi) == 3.0 @test Compat.floor(pi) == 3.0 From c08c8a7a5405b5baddc4f87853ab81d4f71ff96c Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 17:49:14 +0200 Subject: [PATCH 088/121] Drop compat code for `Compat.round` and friends #500, #530, and #537 --- README.md | 3 --- src/Compat.jl | 52 ----------------------------------------------- src/deprecated.jl | 6 ++++++ test/old.jl | 20 ++++++++++++++++++ test/runtests.jl | 20 ------------------ 5 files changed, 26 insertions(+), 75 deletions(-) diff --git a/README.md b/README.md index f23d175be..a86e691e0 100644 --- a/README.md +++ b/README.md @@ -76,9 +76,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `Compat.range` supporting positional and keyword arguments flavors ([#25896]), ([#28708]). -* `Compat.trunc`, `Compat.floor`, `Compat.ceil`, `Compat.round`, take a keyword argument - for `base` and `digits`, `Compat.round` also takes `sigdigits` ([#26156], [#26670]). - * `Compat.mv` and `Compat.cp` with `force` keyword argument ([#26069]). * `Compat.accumulate`, `Compat.accumulate!`, `Compat.all`, `Compat.any`, diff --git a/src/Compat.jl b/src/Compat.jl index 881c6a569..442596490 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -76,58 +76,6 @@ end end end -# https://github.com/JuliaLang/julia/pull/26670 -@static if VERSION < v"0.7.0-DEV.4062" - trunc(x; digits = 0, base = 10) = Base.trunc(x, digits, base) - floor(x; digits = 0, base = 10) = Base.floor(x, digits, base) - ceil(x; digits = 0, base = 10) = Base.ceil(x, digits, base) - function round(x; digits = nothing, sigdigits = nothing, base = 10) - if digits === nothing - if sigdigits === nothing - Base.round(x, 0, base) - else - Base.signif(x, sigdigits, base) - end - else - sigdigits === nothing || throw(AgrumentError("`round` cannot use both `digits` and `sigdigits` arguments")) - Base.round(x, digits, base) - end - end -elseif VERSION < v"0.7.0-DEV.4804" - trunc(x; digits = 0, base = 10) = Base.trunc(x, digits, base = base) - floor(x; digits = 0, base = 10) = Base.floor(x, digits, base = base) - ceil(x; digits = 0, base = 10) = Base.ceil(x, digits, base = base) - function round(x; digits = nothing, sigdigits = nothing, base = 10) - if digits === nothing - if sigdigits === nothing - Base.round(x, 0, base = base) - else - Base.signif(x, sigdigits, base = base) - end - else - sigdigits === nothing || throw(AgrumentError("`round` cannot use both `digits` and `sigdigits` arguments")) - Base.round(x, digits, base = base) - end - end -elseif VERSION < v"0.7.0-beta2.86" - # https://github.com/JuliaLang/julia/pull/28199 - trunc(x; digits = 0, base = 10) = Base.trunc(x, digits = digits, base = base) - floor(x; digits = 0, base = 10) = Base.floor(x, digits = digits, base = base) - ceil(x; digits = 0, base = 10) = Base.ceil(x, digits = digits, base = base) - function round(x; digits = nothing, sigdigits = nothing, base = 10) - if digits === nothing && sigdigits === nothing - Base.round(x, digits = 0, base = base) - else - Base.round(x, digits = digits, sigdigits = sigdigits, base = base) - end - end -else - trunc(x; digits = 0, base = 10) = Base.trunc(x, digits = digits, base = base) - floor(x; digits = 0, base = 10) = Base.floor(x, digits = digits, base = base) - ceil(x; digits = 0, base = 10) = Base.ceil(x, digits = digits, base = base) - round(x; digits = nothing, sigdigits = nothing, base = 10) = Base.round(x, digits = digits, sigdigits = sigdigits, base = base) -end - # https://github.com/JuliaLang/julia/pull/25872 if VERSION < v"0.7.0-DEV.3734" if isdefined(Base, :open_flags) diff --git a/src/deprecated.jl b/src/deprecated.jl index e76dc980f..4b1488b03 100644 --- a/src/deprecated.jl +++ b/src/deprecated.jl @@ -62,6 +62,12 @@ Base.@deprecate floor(x, digits; base = 10) Compat.floor(x, digits = digits, bas Base.@deprecate ceil(x, digits; base = 10) Compat.ceil(x, digits = digits, base = base) false Base.@deprecate round(x, digits; base = 10) Compat.round(x, digits = digits, base = base) false Base.@deprecate signif(x, digits; base = 10) Compat.round(x, sigdigits = digits, base = base) false +# standard methods from Base; can be removed (so that Compat just inherits the functions +# from Base) once above deprecations are removed +trunc(x; digits = 0, base = 10) = Base.trunc(x, digits = digits, base = base) +floor(x; digits = 0, base = 10) = Base.floor(x, digits = digits, base = base) +ceil(x; digits = 0, base = 10) = Base.ceil(x, digits = digits, base = base) +round(x; digits = nothing, sigdigits = nothing, base = 10) = Base.round(x, digits = digits, sigdigits = sigdigits, base = base) if VERSION >= v"1.1.0-DEV.506" # deprecation of range(start, stop) for earlier versions is done in Compat.jl diff --git a/test/old.jl b/test/old.jl index f2efccfe5..77aa6770d 100644 --- a/test/old.jl +++ b/test/old.jl @@ -799,3 +799,23 @@ module TestNames end @test :foo in Compat.names(TestNames) @test :bar in Compat.names(TestNames, all=true) + +# 0.7.0-DEV.4804 +@test Compat.trunc(pi) == 3.0 +@test Compat.floor(pi) == 3.0 +@test Compat.ceil(pi) == 4.0 +@test Compat.round(pi) == 3.0 +@test Compat.trunc(pi, digits = 3) == 3.141 +@test Compat.floor(pi, digits = 3) == 3.141 +@test Compat.ceil(pi, digits = 3) == 3.142 +@test Compat.round(pi, digits = 3) == 3.142 +@test Compat.round(pi, sigdigits = 5) == 3.1416 +@test Compat.trunc(pi, base = 2) == 3.0 +@test Compat.floor(pi, base = 2) == 3.0 +@test Compat.ceil(pi, base = 2) == 4.0 +@test Compat.round(pi, base = 2) == 3.0 +@test Compat.trunc(pi, digits = 3, base = 2) == 3.125 +@test Compat.floor(pi, digits = 3, base = 2) == 3.125 +@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 diff --git a/test/runtests.jl b/test/runtests.jl index 551176cf1..d25db015c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -82,26 +82,6 @@ end @test codeunit("foo") == codeunit(SubString("fooαβγ",1,3)) == UInt8 -# 0.7.0-DEV.4804 -@test Compat.trunc(pi) == 3.0 -@test Compat.floor(pi) == 3.0 -@test Compat.ceil(pi) == 4.0 -@test Compat.round(pi) == 3.0 -@test Compat.trunc(pi, digits = 3) == 3.141 -@test Compat.floor(pi, digits = 3) == 3.141 -@test Compat.ceil(pi, digits = 3) == 3.142 -@test Compat.round(pi, digits = 3) == 3.142 -@test Compat.round(pi, sigdigits = 5) == 3.1416 -@test Compat.trunc(pi, base = 2) == 3.0 -@test Compat.floor(pi, base = 2) == 3.0 -@test Compat.ceil(pi, base = 2) == 4.0 -@test Compat.round(pi, base = 2) == 3.0 -@test Compat.trunc(pi, digits = 3, base = 2) == 3.125 -@test Compat.floor(pi, digits = 3, base = 2) == 3.125 -@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 From 7078a2ce0e3750273582ff8099127c3706115abe Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 17:53:52 +0200 Subject: [PATCH 089/121] Drop compat code for `IOBuffer` from #501 and #504 --- README.md | 2 -- src/Compat.jl | 51 ------------------------------------------------ test/old.jl | 15 ++++++++++++++ test/runtests.jl | 15 -------------- 4 files changed, 15 insertions(+), 68 deletions(-) diff --git a/README.md b/README.md index a86e691e0..fd543c089 100644 --- a/README.md +++ b/README.md @@ -72,8 +72,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 442596490..daf3aed65 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 d25db015c..f68e4e9b9 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) From fa49e7ad91c891a30dab2366e64fa55de0acf5e2 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 18:08:55 +0200 Subject: [PATCH 090/121] Drop compat code for `range` with kw args and `LinRange` from #511 --- README.md | 4 +--- src/Compat.jl | 34 +--------------------------------- src/deprecated.jl | 2 +- test/old.jl | 10 ++++++++++ test/runtests.jl | 10 ---------- 5 files changed, 13 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index fd543c089..0d4d4ce5b 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ 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.range` supporting positional and keyword arguments flavors ([#25896]), ([#28708]). +* `range` supporting `stop` as positional argument ([#28708]). * `Compat.mv` and `Compat.cp` with `force` keyword argument ([#26069]). @@ -115,8 +115,6 @@ Currently, the `@compat` macro supports the following syntaxes: for entries with no match and gives the index of the first (rather than the last) match ([#25662], [#25998]). -* `LinSpace` is now `LinRange` ([#25896]). - * `isupper`, `islower`, `ucfirst` and `lcfirst` are now `isuppercase`, `islowercase`, `uppercasefirst` and `lowercasefirst` ([#26442]). diff --git a/src/Compat.jl b/src/Compat.jl index daf3aed65..667b26c22 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -76,38 +76,6 @@ end end end -@static if VERSION < v"0.7.0-DEV.3986" - const LinRange = Base.LinSpace - export LinRange - - function range(start; step=nothing, stop=nothing, length=nothing) - have_step = step !== nothing - have_stop = stop !== nothing - have_length = length !== nothing - - if !(have_stop || have_length) - throw(ArgumentError("At least one of `length` or `stop` must be specified")) - elseif have_step && have_stop && have_length - throw(ArgumentError("Too many arguments specified; try passing only one of `stop` or `length`")) - elseif start === nothing - throw(ArgumentError("Can't start a range at `nothing`")) - end - - if have_stop && !have_length - return have_step ? (start:step:stop) : (start:stop) - elseif have_length && !have_stop - return have_step ? Base.range(start, step, length) : Base.range(start, length) - elseif !have_step - return linspace(start, stop, length) - end - end -elseif VERSION < v"1.0.0-DEV.57" - import Base: LinRange - range(start; kwargs...) = Base.range(start; kwargs...) -else - import Base: range # import as it is further extended below -end - @static if VERSION < v"0.7.0-DEV.3995" cp(src::AbstractString, dst::AbstractString; force::Bool=false, follow_symlinks::Bool=false) = Base.cp(src, dst; remove_destination = force, follow_symlinks = follow_symlinks) @@ -419,7 +387,7 @@ function rangedepwarn(;step=nothing, length=nothing, kwargs...) end if VERSION < v"1.1.0-DEV.506" - function range(start, stop; kwargs...) + function Base.range(start, stop; kwargs...) rangedepwarn(;kwargs...) range(start; stop=stop, kwargs...) end diff --git a/src/deprecated.jl b/src/deprecated.jl index 4b1488b03..e0d937245 100644 --- a/src/deprecated.jl +++ b/src/deprecated.jl @@ -73,7 +73,7 @@ if VERSION >= v"1.1.0-DEV.506" # deprecation of range(start, stop) for earlier versions is done in Compat.jl # This method is restricted to Number, since we don't # want to overwrite the (::Any, ::Any) method in Base. - function range(start::Number, stop::Number; kwargs...) + function Base.range(start::Number, stop::Number; kwargs...) rangedepwarn(;kwargs...) range(start; stop=stop, kwargs...) end diff --git a/test/old.jl b/test/old.jl index 9025dee09..9c0da97ab 100644 --- a/test/old.jl +++ b/test/old.jl @@ -834,3 +834,13 @@ 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) +@test_throws ArgumentError Compat.range(1, step=1) +@test_throws ArgumentError Compat.range(1, step=1, stop=4, length=3) +@test Compat.range(2, step=2, stop=8) == 2:2:8 +@test Compat.range(2, stop=8) == 2:8 +@test Compat.range(2, step=2, length=8) == 2:2:16 +@test Compat.range(1.0, stop=2.0, length=3) == 1.0:0.5:2.0 diff --git a/test/runtests.jl b/test/runtests.jl index f68e4e9b9..694c2e708 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -82,16 +82,6 @@ end @test codeunit("foo") == codeunit(SubString("fooαβγ",1,3)) == UInt8 -# 0.7.0-DEV.3986 -@test_throws ArgumentError Compat.range(1) -@test_throws ArgumentError Compat.range(nothing) -@test_throws ArgumentError Compat.range(1, step=1) -@test_throws ArgumentError Compat.range(1, step=1, stop=4, length=3) -@test Compat.range(2, step=2, stop=8) == 2:2:8 -@test Compat.range(2, stop=8) == 2:8 -@test Compat.range(2, step=2, length=8) == 2:2:16 -@test Compat.range(1.0, stop=2.0, length=3) == 1.0:0.5:2.0 - # 0.7.0-DEV.3995 mktempdir(@__DIR__) do dir src = joinpath(dir, "src.jl") From f57f7e67098a1fa460dd91620708b381d7210249 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 18:10:59 +0200 Subject: [PATCH 091/121] Drop compat code for `cp` and `mv` from #512 --- README.md | 2 -- src/Compat.jl | 7 ------- test/old.jl | 20 ++++++++++++++++++++ test/runtests.jl | 20 -------------------- 4 files changed, 20 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 0d4d4ce5b..17f0ebc76 100644 --- a/README.md +++ b/README.md @@ -74,8 +74,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `range` supporting `stop` as positional argument ([#28708]). -* `Compat.mv` and `Compat.cp` with `force` keyword argument ([#26069]). - * `Compat.accumulate`, `Compat.accumulate!`, `Compat.all`, `Compat.any`, `Compat.cumprod`, `Compat.cumprod!`, `Compat.cumsum`, `Compat.cumsum!`, `Compat.findmax`, `Compat.findmin`, `Compat.mapreduce`, `Compat.maximum`, diff --git a/src/Compat.jl b/src/Compat.jl index 667b26c22..f056c32e7 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -76,13 +76,6 @@ end end end -@static if VERSION < v"0.7.0-DEV.3995" - cp(src::AbstractString, dst::AbstractString; force::Bool=false, follow_symlinks::Bool=false) = - Base.cp(src, dst; remove_destination = force, follow_symlinks = follow_symlinks) - mv(src::AbstractString, dst::AbstractString; force::Bool=false) = - Base.mv(src, dst; remove_destination = force) -end - if VERSION < v"0.7.0-DEV.3972" function indexin(a, b::AbstractArray) inds = keys(b) diff --git a/test/old.jl b/test/old.jl index 9c0da97ab..8a7d2ef77 100644 --- a/test/old.jl +++ b/test/old.jl @@ -844,3 +844,23 @@ end @test Compat.range(2, stop=8) == 2:8 @test Compat.range(2, step=2, length=8) == 2:2:16 @test Compat.range(1.0, stop=2.0, length=3) == 1.0:0.5:2.0 + +# 0.7.0-DEV.3995 +mktempdir(@__DIR__) do dir + src = joinpath(dir, "src.jl") + touch(src) + dest = joinpath(dir, "dest.jl") + touch(dest) + open(src, "w") do f + write(f, "Hello, world!") + end + Compat.cp(src, dest, force = true) + open(dest, "r") do f + @test read(f, String) == "Hello, world!" + end + Compat.mv(src, dest, force = true) + open(dest, "r") do f + @test read(f, String) == "Hello, world!" + end + @test readdir(dir) == ["dest.jl"] +end diff --git a/test/runtests.jl b/test/runtests.jl index 694c2e708..1fae119d4 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -82,26 +82,6 @@ end @test codeunit("foo") == codeunit(SubString("fooαβγ",1,3)) == UInt8 -# 0.7.0-DEV.3995 -mktempdir(@__DIR__) do dir - src = joinpath(dir, "src.jl") - touch(src) - dest = joinpath(dir, "dest.jl") - touch(dest) - open(src, "w") do f - write(f, "Hello, world!") - end - Compat.cp(src, dest, force = true) - open(dest, "r") do f - @test read(f, String) == "Hello, world!" - end - Compat.mv(src, dest, force = true) - open(dest, "r") do f - @test read(f, String) == "Hello, world!" - end - @test readdir(dir) == ["dest.jl"] -end - # 0.7.0-DEV.3972 @test Compat.indexin([1, 2], [1, 0, 1]) == [1, nothing] From 58878844f917231848a51931e4f374a14efc0547 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 18:13:28 +0200 Subject: [PATCH 092/121] Drop compat code for `indexin` from #515 --- README.md | 4 ---- src/Compat.jl | 13 ------------- test/old.jl | 3 +++ test/runtests.jl | 3 --- 4 files changed, 3 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 17f0ebc76..9b5701fb5 100644 --- a/README.md +++ b/README.md @@ -109,10 +109,6 @@ Currently, the `@compat` macro supports the following syntaxes: ## Renaming -* `Compat.indexin` accepts any iterable as first argument, returns `nothing` (rather than `0`) - for entries with no match and gives the index of the first (rather than the last) match - ([#25662], [#25998]). - * `isupper`, `islower`, `ucfirst` and `lcfirst` are now `isuppercase`, `islowercase`, `uppercasefirst` and `lowercasefirst` ([#26442]). diff --git a/src/Compat.jl b/src/Compat.jl index f056c32e7..e92b2d42d 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -76,19 +76,6 @@ end end end -if VERSION < v"0.7.0-DEV.3972" - function indexin(a, b::AbstractArray) - inds = keys(b) - bdict = Dict{eltype(b),eltype(inds)}() - for (val, ind) in zip(b, inds) - get!(bdict, val, ind) - end - return Union{eltype(inds), Nothing}[ - get(bdict, i, nothing) for i in a - ] - end -end - if VERSION < v"0.7.0-DEV.4585" export isuppercase, islowercase, uppercasefirst, lowercasefirst const isuppercase = isupper diff --git a/test/old.jl b/test/old.jl index 8a7d2ef77..62634fc74 100644 --- a/test/old.jl +++ b/test/old.jl @@ -864,3 +864,6 @@ mktempdir(@__DIR__) do dir end @test readdir(dir) == ["dest.jl"] end + +# 0.7.0-DEV.3972 +@test Compat.indexin([1, 2], [1, 0, 1]) == [1, nothing] diff --git a/test/runtests.jl b/test/runtests.jl index 1fae119d4..736bce3e9 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -82,9 +82,6 @@ end @test codeunit("foo") == codeunit(SubString("fooαβγ",1,3)) == UInt8 -# 0.7.0-DEV.3972 -@test Compat.indexin([1, 2], [1, 0, 1]) == [1, nothing] - # 0.7.0-DEV.4585 @test isuppercase('A') @test !isuppercase('a') From ea5874f4f9d55d354e7c328c86056fac48287178 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 18:15:11 +0200 Subject: [PATCH 093/121] Drop compat code for `isuppercase` and friends from #516 --- README.md | 3 --- src/Compat.jl | 8 -------- test/old.jl | 8 ++++++++ test/runtests.jl | 8 -------- 4 files changed, 8 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 9b5701fb5..dc9cc5926 100644 --- a/README.md +++ b/README.md @@ -109,9 +109,6 @@ Currently, the `@compat` macro supports the following syntaxes: ## Renaming -* `isupper`, `islower`, `ucfirst` and `lcfirst` are now `isuppercase`, `islowercase`, - `uppercasefirst` and `lowercasefirst` ([#26442]). - * `Compat.split` and `Compat.rsplit` accept `keepempty` keyword argument if `splitter` is given as second argument ([#26634]) diff --git a/src/Compat.jl b/src/Compat.jl index e92b2d42d..8fa100eeb 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -76,14 +76,6 @@ end end end -if VERSION < v"0.7.0-DEV.4585" - export isuppercase, islowercase, uppercasefirst, lowercasefirst - const isuppercase = isupper - const islowercase = islower - const uppercasefirst = ucfirst - const lowercasefirst = lcfirst -end - if VERSION < v"0.7.0-DEV.4064" for f in (:mean, :median, :var, :varm, :std, :cov, :cor) @eval import .Statistics: $f # compatibility with old Compat versions diff --git a/test/old.jl b/test/old.jl index 62634fc74..96e3c5cd5 100644 --- a/test/old.jl +++ b/test/old.jl @@ -867,3 +867,11 @@ end # 0.7.0-DEV.3972 @test Compat.indexin([1, 2], [1, 0, 1]) == [1, nothing] + +# 0.7.0-DEV.4585 +@test isuppercase('A') +@test !isuppercase('a') +@test islowercase('a') +@test !islowercase('A') +@test uppercasefirst("qwerty") == "Qwerty" +@test lowercasefirst("Qwerty") == "qwerty" diff --git a/test/runtests.jl b/test/runtests.jl index 736bce3e9..19840353d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -82,14 +82,6 @@ end @test codeunit("foo") == codeunit(SubString("fooαβγ",1,3)) == UInt8 -# 0.7.0-DEV.4585 -@test isuppercase('A') -@test !isuppercase('a') -@test islowercase('a') -@test !islowercase('A') -@test uppercasefirst("qwerty") == "Qwerty" -@test lowercasefirst("Qwerty") == "qwerty" - # 0.7.0-DEV.4064 # some tests are behind a version check below because Julia gave # the wrong result between 0.7.0-DEV.3262 and 0.7.0-DEV.4646 From 49bb0ae7adc418fa68c2396e320cbd6d89d946cc Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 18:22:50 +0200 Subject: [PATCH 094/121] Drop compat code for `dims` and `init` kwargs from #518, #528, #590, #592, and #613 --- README.md | 10 --- src/Compat.jl | 73 ---------------------- test/old.jl | 156 +++++++++++++++++++++++++++++++++++++++++++++++ test/runtests.jl | 156 ----------------------------------------------- 4 files changed, 156 insertions(+), 239 deletions(-) diff --git a/README.md b/README.md index dc9cc5926..060a3b168 100644 --- a/README.md +++ b/README.md @@ -74,18 +74,8 @@ Currently, the `@compat` macro supports the following syntaxes: * `range` supporting `stop` as positional argument ([#28708]). -* `Compat.accumulate`, `Compat.accumulate!`, `Compat.all`, `Compat.any`, - `Compat.cumprod`, `Compat.cumprod!`, `Compat.cumsum`, `Compat.cumsum!`, - `Compat.findmax`, `Compat.findmin`, `Compat.mapreduce`, `Compat.maximum`, - `Compat.minimum`, `Compat.prod`, `Compat.reduce`, `Compat.sort`, - and `Compat.sum` with `dims` keyword argument ([#25989],[#26369]). - -* `Compat.mapreduce` and `Compat.reduce` with `init` keyword argument ([#27711]). - * `selectdim` to obtain a view of an array with a specified index for a specified dimension ([#26009]). -* `Compat.cat` with `dims` as keyword argument ([#27163]) - * Single-argument `permutedims(x)` for matrices and vectors ([#24839]). * `fetch` for `Task`s ([#25940]). diff --git a/src/Compat.jl b/src/Compat.jl index 8fa100eeb..3390f2c2a 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -76,79 +76,6 @@ end end end -if VERSION < v"0.7.0-DEV.4064" - for f in (:mean, :median, :var, :varm, :std, :cov, :cor) - @eval import .Statistics: $f # compatibility with old Compat versions - end - for f in (:cumsum, :cumprod, :sum, :prod, :maximum, :minimum, :all, :any) - @eval begin - $f(a::AbstractArray; dims=nothing) = - dims===nothing ? Base.$f(a) : Base.$f(a, dims) - end - end - for f in (:sum, :prod, :maximum, :minimum, :all, :any, :accumulate) - @eval begin - $f(f, a::AbstractArray; dims=nothing) = - dims===nothing ? Base.$f(f, a) : Base.$f(f, a, dims) - end - end - for f in (:findmax, :findmin) - @eval begin - $f(a::AbstractVector; dims=nothing) = - dims===nothing ? Base.$f(a) : Base.$f(a, dims) - function $f(a::AbstractArray; dims=nothing) - vs, inds = dims===nothing ? Base.$f(a) : Base.$f(a, dims) - cis = CartesianIndices(a) - return (vs, map(i -> cis[i], inds)) - end - end - end - @eval sort(a::AbstractArray; dims=nothing, kwargs...) = - dims===nothing ? Base.sort(a; kwargs...) : Base.sort(a, dims; kwargs...) - for f in (:cumsum!, :cumprod!) - @eval $f(out, a; dims=nothing) = - dims===nothing ? Base.$f(out, a) : Base.$f(out, a, dims) - end -end -if VERSION < v"0.7.0-DEV.4064" - mapreduce(f, op, a::AbstractArray; dims=nothing, init=nothing) = - init === nothing ? (dims===nothing ? Base.mapreduce(f, op, a) : Base.mapreducedim(f, op, a, dims)) : - (dims===nothing ? Base.mapreduce(f, op, init, a) : Base.mapreducedim(f, op, a, dims, init)) - reduce(op, a::AbstractArray; dims=nothing, init=nothing) = - init === nothing ? (dims===nothing ? Base.reduce(op, a) : Base.reducedim(op, a, dims)) : - (dims===nothing ? Base.reduce(op, init, a) : Base.reducedim(op, a, dims, init)) - accumulate!(op, out, a; dims=nothing) = - dims===nothing ? Base.accumulate!(op, out, a) : Base.accumulate!(op, out, a, dims) - # kept for compatibility with early adopters - mapreduce(f, op, v0, a::AbstractArray; dims=nothing) = - mapreduce(f, op, a, dims=dims, init=v0) - reduce(op, v0, a::AbstractArray; dims=nothing) = - reduce(op, a, dims=dims, init=v0) -elseif VERSION < v"0.7.0-beta.81" # julia#27711 - mapreduce(f, op, a::AbstractArray; dims=nothing, init=nothing) = - init === nothing ? (dims===nothing ? Base.mapreduce(f, op, a) : Base.mapreduce(f, op, a, dims=dims)) : - (dims===nothing ? Base.mapreduce(f, op, init, a) : Base.mapreduce(f, op, init, a, dims=dims)) - reduce(op, a::AbstractArray; dims=nothing, init=nothing) = - init === nothing ? (dims===nothing ? Base.reduce(op, a) : Base.reduce(op, a, dims=dims)) : - (dims===nothing ? Base.reduce(op, init, a) : Base.reduce(op, init, a, dims=dims)) -end -if VERSION < v"0.7.0-beta.81" # julia#27711 - mapreduce(f, op, itr; init=nothing) = - init === nothing ? Base.mapreduce(f, op, itr) : Base.mapreduce(f, op, init, itr) - reduce(op, itr; init=nothing) = - init === nothing ? Base.reduce(op, itr) : Base.reduce(op, init, itr) -end -if VERSION < v"0.7.0-DEV.4534" - reverse(a::AbstractArray; dims=nothing) = - dims===nothing ? Base.reverse(a) : Base.flipdim(a, dims) -end -if VERSION < v"0.7.0-DEV.4738" - Base.squeeze(A; dims=error("squeeze: keyword argument dims not assigned")) = squeeze(A, dims) -end -if VERSION < v"0.7.0-DEV.5165" # julia#27163 - cat(X...; dims = throw(UndefKeywordError("cat: keyword argument dims not assigned"))) = Base.cat(dims, X...) -end - if !isdefined(Base, :selectdim) # 0.7.0-DEV.3976 export selectdim @inline selectdim(A::AbstractArray, d::Integer, i) = _selectdim(A, d, i, Base.setindex(map(Base.Slice, axes(A)), i, d)) diff --git a/test/old.jl b/test/old.jl index 96e3c5cd5..daed1615c 100644 --- a/test/old.jl +++ b/test/old.jl @@ -875,3 +875,159 @@ end @test !islowercase('A') @test uppercasefirst("qwerty") == "Qwerty" @test lowercasefirst("Qwerty") == "qwerty" + +# 0.7.0-DEV.4064 +# some tests are behind a version check below because Julia gave +# the wrong result between 0.7.0-DEV.3262 and 0.7.0-DEV.4646 +# see https://github.com/JuliaLang/julia/issues/26488 +Issue26488 = VERSION < v"0.7.0-DEV.3262" || VERSION >= v"0.7.0-DEV.4646" +@test Compat.Statistics.mean([1 2; 3 4]) == 2.5 +@test Compat.Statistics.mean([1 2; 3 4], dims=1) == [2 3] +@test Compat.Statistics.mean([1 2; 3 4], dims=2) == hcat([1.5; 3.5]) +@test Compat.cumsum([1 2; 3 4], dims=1) == [1 2; 4 6] +@test Compat.cumsum([1 2; 3 4], dims=2) == [1 3; 3 7] +@test Compat.cumprod([1 2; 3 4], dims=1) == [1 2; 3 8] +@test Compat.cumprod([1 2; 3 4], dims=2) == [1 2; 3 12] +@test Compat.sum([1 2; 3 4]) == 10 +@test Compat.sum([1 2; 3 4], dims=1) == [4 6] +@test Compat.sum([1 2; 3 4], dims=2) == hcat([3; 7]) +@test Compat.sum(x -> x+1, [1 2; 3 4]) == 14 +Issue26488 && @test Compat.sum(x -> x+1, [1 2; 3 4], dims=1) == [6 8] +Issue26488 && @test Compat.sum(x -> x+1, [1 2; 3 4], dims=2) == hcat([5; 9]) +@test Compat.prod([1 2; 3 4]) == 24 +@test Compat.prod([1 2; 3 4], dims=1) == [3 8] +@test Compat.prod([1 2; 3 4], dims=2) == hcat([2; 12]) +@test Compat.prod(x -> x+1, [1 2; 3 4]) == 120 +Issue26488 && @test Compat.prod(x -> x+1, [1 2; 3 4], dims=1) == [8 15] +Issue26488 && @test Compat.prod(x -> x+1, [1 2; 3 4], dims=2) == hcat([6; 20]) +@test Compat.maximum([1 2; 3 4]) == 4 +@test Compat.maximum([1 2; 3 4], dims=1) == [3 4] +@test Compat.maximum([1 2; 3 4], dims=2) == hcat([2; 4]) +@test Compat.maximum(x -> x+1, [1 2; 3 4]) == 5 +@test Compat.maximum(x -> x+1, [1 2; 3 4], dims=1) == [4 5] +@test Compat.maximum(x -> x+1, [1 2; 3 4], dims=2) == hcat([3; 5]) +@test Compat.minimum([1 2; 3 4]) == 1 +@test Compat.minimum([1 2; 3 4], dims=1) == [1 2] +@test Compat.minimum([1 2; 3 4], dims=2) == hcat([1; 3]) +@test Compat.minimum(x -> x+1, [1 2; 3 4]) == 2 +@test Compat.minimum(x -> x+1, [1 2; 3 4], dims=1) == [2 3] +@test Compat.minimum(x -> x+1, [1 2; 3 4], dims=2) == hcat([2; 4]) +@test Compat.all([true false; true false]) == false +@test Compat.all([true false; true false], dims=1) == [true false] +@test Compat.all([true false; true false], dims=2) == hcat([false; false]) +@test Compat.all(isodd, [1 2; 3 4]) == false +@test Compat.all(isodd, [1 2; 3 4], dims=1) == [true false] +@test Compat.all(isodd, [1 2; 3 4], dims=2) == hcat([false; false]) +@test Compat.any([true false; true false]) == true +@test Compat.any([true false; true false], dims=1) == [true false] +@test Compat.any([true false; true false], dims=2) == hcat([true; true]) +@test Compat.any(isodd, [1 2; 3 4]) == true +@test Compat.any(isodd, [1 2; 3 4], dims=1) == [true false] +@test Compat.any(isodd, [1 2; 3 4], dims=2) == hcat([true; true]) +@test Compat.findmax([3, 2, 7, 4]) == (7, 3) +@test Compat.findmax([3, 2, 7, 4], dims=1) == ([7], [3]) +@test Compat.findmax([1 2; 3 4], dims=1) == ([3 4], [CartesianIndex(2, 1) CartesianIndex(2, 2)]) +@test Compat.findmax([1 2; 3 4]) == (4, CartesianIndex(2, 2)) +@test Compat.findmax([1 2; 3 4], dims=1) == ([3 4], [CartesianIndex(2, 1) CartesianIndex(2, 2)]) +@test Compat.findmax([1 2; 3 4], dims=2) == (hcat([2; 4]), hcat([CartesianIndex(1, 2); CartesianIndex(2, 2)])) +@test Compat.findmin([3, 2, 7, 4]) == (2, 2) +@test Compat.findmin([3, 2, 7, 4], dims=1) == ([2], [2]) +@test Compat.findmin([1 2; 3 4]) == (1, CartesianIndex(1, 1)) +@test Compat.findmin([1 2; 3 4], dims=1) == ([1 2], [CartesianIndex(1, 1) CartesianIndex(1, 2)]) +@test Compat.findmin([1 2; 3 4], dims=2) == (hcat([1; 3]), hcat([CartesianIndex(1, 1); CartesianIndex(2, 1)])) +if VERSION < v"0.7.0-DEV.5238" + # Test these functions if their counterparts are defined in Base. In the future, this + # will be dealt with in StatsBase + @test Compat.Statistics.varm([1 2; 3 4], -1) == 18 + @test Compat.Statistics.varm([1 2; 3 4], [-1 -2], dims=1) == [20 52] + @test Compat.Statistics.varm([1 2; 3 4], [-1, -2], dims=2) == hcat([13, 61]) + @test Compat.Statistics.var([1 2; 3 4]) == 5/3 + @test Compat.Statistics.var([1 2; 3 4], dims=1) == [2 2] + @test Compat.Statistics.var([1 2; 3 4], dims=2) == hcat([0.5, 0.5]) + @test Compat.Statistics.var([1 2; 3 4], corrected=false) == 1.25 + @test Compat.Statistics.var([1 2; 3 4], corrected=false, dims=1) == [1 1] + @test Compat.Statistics.var([1 2; 3 4], corrected=false, dims=2) == hcat([0.25, 0.25]) + @test Compat.Statistics.std([1 2; 3 4]) == sqrt(5/3) + @test Compat.Statistics.std([1 2; 3 4], dims=1) == [sqrt(2) sqrt(2)] + @test Compat.Statistics.std([1 2; 3 4], dims=2) == hcat([sqrt(0.5), sqrt(0.5)]) + @test Compat.Statistics.std([1 2; 3 4], corrected=false) == sqrt(1.25) + @test Compat.Statistics.std([1 2; 3 4], corrected=false, dims=1) == [sqrt(1) sqrt(1)] + @test Compat.Statistics.std([1 2; 3 4], corrected=false, dims=2) == hcat([sqrt(0.25), sqrt(0.25)]) + @test Compat.Statistics.cov([1 2; 3 4]) == [2 2; 2 2] + @test Compat.Statistics.cov([1 2; 3 4], dims=1) == [2 2; 2 2] + @test Compat.Statistics.cov([1 2; 3 4], dims=2) == [0.5 0.5; 0.5 0.5] + @test Compat.Statistics.cov([1 2; 3 4], [4; 5]) == hcat([1; 1]) + @test Compat.Statistics.cov([1 2; 3 4], [4; 5], dims=1) == hcat([1; 1]) + @test Compat.Statistics.cov([1 2; 3 4], [4; 5], dims=2) == hcat([0.5; 0.5]) + @test Compat.Statistics.cov([1 2; 3 4], [4; 5], corrected=false) == hcat([0.5; 0.5]) + @test Compat.Statistics.cov([1 2; 3 4], [4; 5], corrected=false, dims=1) == hcat([0.5; 0.5]) + @test Compat.Statistics.cov([1 2; 3 4], [4; 5], corrected=false, dims=2) == hcat([0.25; 0.25]) + @test Compat.Statistics.cor([1 2; 3 4]) ≈ [1 1; 1 1] + @test Compat.Statistics.cor([1 2; 3 4], dims=1) ≈ [1 1; 1 1] + @test Compat.Statistics.cor([1 2; 3 4], dims=2) ≈ [1 1; 1 1] + @test Compat.Statistics.cor([1 2; 3 4], [4; 5]) ≈ [1; 1] + @test Compat.Statistics.cor([1 2; 3 4], [4; 5], dims=1) ≈ [1; 1] + @test Compat.Statistics.cor([1 2; 3 4], [4; 5], dims=2) ≈ [1; 1] +end +@test Compat.Statistics.median([1 2; 3 4]) == 2.5 +@test Compat.Statistics.median([1 2; 3 4], dims=1) == [2 3] +@test Compat.Statistics.median([1 2; 3 4], dims=2) == hcat([1.5; 3.5]) +@test Compat.mapreduce(string, *, [1 2; 3 4]) == "1324" +Issue26488 && @test Compat.mapreduce(string, *, [1 2; 3 4], dims=1) == ["13" "24"] +Issue26488 && @test Compat.mapreduce(string, *, [1 2; 3 4], dims=2) == hcat(["12", "34"]) +@test Compat.mapreduce(string, *, [1 2; 3 4], init="z") == "z1324" +@test Compat.mapreduce(string, *, (1, 2, 3, 4), init="z") == "z1234" +@test Compat.mapreduce(string, *, [1 2; 3 4], dims=1, init="z") == ["z13" "z24"] +@test Compat.mapreduce(string, *, [1 2; 3 4], dims=2, init="z") == hcat(["z12", "z34"]) +@test Compat.reduce(*, [1 2; 3 4]) == 24 +@test Compat.reduce(*, [1 2; 3 4], dims=1) == [3 8] +@test Compat.reduce(*, [1 2; 3 4], dims=2) == hcat([2, 12]) +@test Compat.reduce(*, [1 2; 3 4], init=10) == 240 +@test Compat.reduce(*, (1, 2, 3, 4), init=10) == 240 +@test Compat.reduce(*, [1 2; 3 4], dims=1, init=10) == [30 80] +@test Compat.reduce(*, [1 2; 3 4], dims=2, init=10) == hcat([20, 120]) +@test Compat.sort([1, 2, 3, 4]) == [1, 2, 3, 4] +@test Compat.sort([1 2; 3 4], dims=1) == [1 2; 3 4] +@test Compat.sort([1 2; 3 4], dims=2) == [1 2; 3 4] +@test Compat.sort([1, 2, 3, 4], rev=true) == [4, 3, 2, 1] +@test Compat.sort([1 2; 3 4], rev=true, dims=1) == [3 4; 1 2] +@test Compat.sort([1 2; 3 4], rev=true, dims=2) == [2 1; 4 3] +@test Compat.accumulate(*, [1 2; 3 4], dims=1) == [1 2; 3 8] +@test Compat.accumulate(*, [1 2; 3 4], dims=2) == [1 2; 3 12] +@test Compat.cumsum([1 2; 3 4], dims=1) == [1 2; 4 6] +@test Compat.cumsum([1 2; 3 4], dims=2) == [1 3; 3 7] +@test Compat.cumprod([1 2; 3 4], dims=1) == [1 2; 3 8] +@test Compat.cumprod([1 2; 3 4], dims=2) == [1 2; 3 12] +let b = zeros(2,2) + Compat.accumulate!(*, b, [1 2; 3 4], dims=1) + @test b == [1 2; 3 8] + Compat.accumulate!(*, b, [1 2; 3 4], dims=2) + @test b == [1 2; 3 12] + Compat.cumsum!(b, [1 2; 3 4], dims=1) + @test b == [1 2; 4 6] + Compat.cumsum!(b, [1 2; 3 4], dims=2) + @test b == [1 3; 3 7] + Compat.cumprod!(b, [1 2; 3 4], dims=1) + @test b == [1 2; 3 8] + Compat.cumprod!(b, [1 2; 3 4], dims=2) + @test b == [1 2; 3 12] +end +@test Compat.reverse([1, 2, 3, 4]) == [4, 3, 2, 1] +@test Compat.reverse([1 2; 3 4], dims=1) == [3 4; 1 2] +@test Compat.reverse([1 2; 3 4], dims=2) == [2 1; 4 3] + +# 0.7.0-DEV.4738 +if VERSION < v"0.7.0-beta2.143" + @test squeeze([1 2], dims=1) == [1, 2] + @test_throws ArgumentError squeeze([1 2], dims=2) + @test_throws ArgumentError squeeze(hcat([1, 2]), dims=1) + @test squeeze(hcat([1, 2]), dims=2) == [1, 2] + @test_throws Exception squeeze([1,2]) +end + +# 0.7.0-DEV.5165 +@test Compat.cat([1, 2], [3, 4, 5], dims = 1) == [1, 2, 3, 4, 5] +@test Compat.cat([1, 2], [3, 4], dims = 2) == [1 3; 2 4] +if VERSION < v"0.7.0-DEV.5165" + @test_throws UndefKeywordError Compat.cat([1, 2], [3, 4]) +end diff --git a/test/runtests.jl b/test/runtests.jl index 19840353d..3e929fc1a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -82,162 +82,6 @@ end @test codeunit("foo") == codeunit(SubString("fooαβγ",1,3)) == UInt8 -# 0.7.0-DEV.4064 -# some tests are behind a version check below because Julia gave -# the wrong result between 0.7.0-DEV.3262 and 0.7.0-DEV.4646 -# see https://github.com/JuliaLang/julia/issues/26488 -Issue26488 = VERSION < v"0.7.0-DEV.3262" || VERSION >= v"0.7.0-DEV.4646" -@test Compat.Statistics.mean([1 2; 3 4]) == 2.5 -@test Compat.Statistics.mean([1 2; 3 4], dims=1) == [2 3] -@test Compat.Statistics.mean([1 2; 3 4], dims=2) == hcat([1.5; 3.5]) -@test Compat.cumsum([1 2; 3 4], dims=1) == [1 2; 4 6] -@test Compat.cumsum([1 2; 3 4], dims=2) == [1 3; 3 7] -@test Compat.cumprod([1 2; 3 4], dims=1) == [1 2; 3 8] -@test Compat.cumprod([1 2; 3 4], dims=2) == [1 2; 3 12] -@test Compat.sum([1 2; 3 4]) == 10 -@test Compat.sum([1 2; 3 4], dims=1) == [4 6] -@test Compat.sum([1 2; 3 4], dims=2) == hcat([3; 7]) -@test Compat.sum(x -> x+1, [1 2; 3 4]) == 14 -Issue26488 && @test Compat.sum(x -> x+1, [1 2; 3 4], dims=1) == [6 8] -Issue26488 && @test Compat.sum(x -> x+1, [1 2; 3 4], dims=2) == hcat([5; 9]) -@test Compat.prod([1 2; 3 4]) == 24 -@test Compat.prod([1 2; 3 4], dims=1) == [3 8] -@test Compat.prod([1 2; 3 4], dims=2) == hcat([2; 12]) -@test Compat.prod(x -> x+1, [1 2; 3 4]) == 120 -Issue26488 && @test Compat.prod(x -> x+1, [1 2; 3 4], dims=1) == [8 15] -Issue26488 && @test Compat.prod(x -> x+1, [1 2; 3 4], dims=2) == hcat([6; 20]) -@test Compat.maximum([1 2; 3 4]) == 4 -@test Compat.maximum([1 2; 3 4], dims=1) == [3 4] -@test Compat.maximum([1 2; 3 4], dims=2) == hcat([2; 4]) -@test Compat.maximum(x -> x+1, [1 2; 3 4]) == 5 -@test Compat.maximum(x -> x+1, [1 2; 3 4], dims=1) == [4 5] -@test Compat.maximum(x -> x+1, [1 2; 3 4], dims=2) == hcat([3; 5]) -@test Compat.minimum([1 2; 3 4]) == 1 -@test Compat.minimum([1 2; 3 4], dims=1) == [1 2] -@test Compat.minimum([1 2; 3 4], dims=2) == hcat([1; 3]) -@test Compat.minimum(x -> x+1, [1 2; 3 4]) == 2 -@test Compat.minimum(x -> x+1, [1 2; 3 4], dims=1) == [2 3] -@test Compat.minimum(x -> x+1, [1 2; 3 4], dims=2) == hcat([2; 4]) -@test Compat.all([true false; true false]) == false -@test Compat.all([true false; true false], dims=1) == [true false] -@test Compat.all([true false; true false], dims=2) == hcat([false; false]) -@test Compat.all(isodd, [1 2; 3 4]) == false -@test Compat.all(isodd, [1 2; 3 4], dims=1) == [true false] -@test Compat.all(isodd, [1 2; 3 4], dims=2) == hcat([false; false]) -@test Compat.any([true false; true false]) == true -@test Compat.any([true false; true false], dims=1) == [true false] -@test Compat.any([true false; true false], dims=2) == hcat([true; true]) -@test Compat.any(isodd, [1 2; 3 4]) == true -@test Compat.any(isodd, [1 2; 3 4], dims=1) == [true false] -@test Compat.any(isodd, [1 2; 3 4], dims=2) == hcat([true; true]) -@test Compat.findmax([3, 2, 7, 4]) == (7, 3) -@test Compat.findmax([3, 2, 7, 4], dims=1) == ([7], [3]) -@test Compat.findmax([1 2; 3 4], dims=1) == ([3 4], [CartesianIndex(2, 1) CartesianIndex(2, 2)]) -@test Compat.findmax([1 2; 3 4]) == (4, CartesianIndex(2, 2)) -@test Compat.findmax([1 2; 3 4], dims=1) == ([3 4], [CartesianIndex(2, 1) CartesianIndex(2, 2)]) -@test Compat.findmax([1 2; 3 4], dims=2) == (hcat([2; 4]), hcat([CartesianIndex(1, 2); CartesianIndex(2, 2)])) -@test Compat.findmin([3, 2, 7, 4]) == (2, 2) -@test Compat.findmin([3, 2, 7, 4], dims=1) == ([2], [2]) -@test Compat.findmin([1 2; 3 4]) == (1, CartesianIndex(1, 1)) -@test Compat.findmin([1 2; 3 4], dims=1) == ([1 2], [CartesianIndex(1, 1) CartesianIndex(1, 2)]) -@test Compat.findmin([1 2; 3 4], dims=2) == (hcat([1; 3]), hcat([CartesianIndex(1, 1); CartesianIndex(2, 1)])) -if VERSION < v"0.7.0-DEV.5238" - # Test these functions if their counterparts are defined in Base. In the future, this - # will be dealt with in StatsBase - @test Compat.Statistics.varm([1 2; 3 4], -1) == 18 - @test Compat.Statistics.varm([1 2; 3 4], [-1 -2], dims=1) == [20 52] - @test Compat.Statistics.varm([1 2; 3 4], [-1, -2], dims=2) == hcat([13, 61]) - @test Compat.Statistics.var([1 2; 3 4]) == 5/3 - @test Compat.Statistics.var([1 2; 3 4], dims=1) == [2 2] - @test Compat.Statistics.var([1 2; 3 4], dims=2) == hcat([0.5, 0.5]) - @test Compat.Statistics.var([1 2; 3 4], corrected=false) == 1.25 - @test Compat.Statistics.var([1 2; 3 4], corrected=false, dims=1) == [1 1] - @test Compat.Statistics.var([1 2; 3 4], corrected=false, dims=2) == hcat([0.25, 0.25]) - @test Compat.Statistics.std([1 2; 3 4]) == sqrt(5/3) - @test Compat.Statistics.std([1 2; 3 4], dims=1) == [sqrt(2) sqrt(2)] - @test Compat.Statistics.std([1 2; 3 4], dims=2) == hcat([sqrt(0.5), sqrt(0.5)]) - @test Compat.Statistics.std([1 2; 3 4], corrected=false) == sqrt(1.25) - @test Compat.Statistics.std([1 2; 3 4], corrected=false, dims=1) == [sqrt(1) sqrt(1)] - @test Compat.Statistics.std([1 2; 3 4], corrected=false, dims=2) == hcat([sqrt(0.25), sqrt(0.25)]) - @test Compat.Statistics.cov([1 2; 3 4]) == [2 2; 2 2] - @test Compat.Statistics.cov([1 2; 3 4], dims=1) == [2 2; 2 2] - @test Compat.Statistics.cov([1 2; 3 4], dims=2) == [0.5 0.5; 0.5 0.5] - @test Compat.Statistics.cov([1 2; 3 4], [4; 5]) == hcat([1; 1]) - @test Compat.Statistics.cov([1 2; 3 4], [4; 5], dims=1) == hcat([1; 1]) - @test Compat.Statistics.cov([1 2; 3 4], [4; 5], dims=2) == hcat([0.5; 0.5]) - @test Compat.Statistics.cov([1 2; 3 4], [4; 5], corrected=false) == hcat([0.5; 0.5]) - @test Compat.Statistics.cov([1 2; 3 4], [4; 5], corrected=false, dims=1) == hcat([0.5; 0.5]) - @test Compat.Statistics.cov([1 2; 3 4], [4; 5], corrected=false, dims=2) == hcat([0.25; 0.25]) - @test Compat.Statistics.cor([1 2; 3 4]) ≈ [1 1; 1 1] - @test Compat.Statistics.cor([1 2; 3 4], dims=1) ≈ [1 1; 1 1] - @test Compat.Statistics.cor([1 2; 3 4], dims=2) ≈ [1 1; 1 1] - @test Compat.Statistics.cor([1 2; 3 4], [4; 5]) ≈ [1; 1] - @test Compat.Statistics.cor([1 2; 3 4], [4; 5], dims=1) ≈ [1; 1] - @test Compat.Statistics.cor([1 2; 3 4], [4; 5], dims=2) ≈ [1; 1] -end -@test Compat.Statistics.median([1 2; 3 4]) == 2.5 -@test Compat.Statistics.median([1 2; 3 4], dims=1) == [2 3] -@test Compat.Statistics.median([1 2; 3 4], dims=2) == hcat([1.5; 3.5]) -@test Compat.mapreduce(string, *, [1 2; 3 4]) == "1324" -Issue26488 && @test Compat.mapreduce(string, *, [1 2; 3 4], dims=1) == ["13" "24"] -Issue26488 && @test Compat.mapreduce(string, *, [1 2; 3 4], dims=2) == hcat(["12", "34"]) -@test Compat.mapreduce(string, *, [1 2; 3 4], init="z") == "z1324" -@test Compat.mapreduce(string, *, (1, 2, 3, 4), init="z") == "z1234" -@test Compat.mapreduce(string, *, [1 2; 3 4], dims=1, init="z") == ["z13" "z24"] -@test Compat.mapreduce(string, *, [1 2; 3 4], dims=2, init="z") == hcat(["z12", "z34"]) -@test Compat.reduce(*, [1 2; 3 4]) == 24 -@test Compat.reduce(*, [1 2; 3 4], dims=1) == [3 8] -@test Compat.reduce(*, [1 2; 3 4], dims=2) == hcat([2, 12]) -@test Compat.reduce(*, [1 2; 3 4], init=10) == 240 -@test Compat.reduce(*, (1, 2, 3, 4), init=10) == 240 -@test Compat.reduce(*, [1 2; 3 4], dims=1, init=10) == [30 80] -@test Compat.reduce(*, [1 2; 3 4], dims=2, init=10) == hcat([20, 120]) -@test Compat.sort([1, 2, 3, 4]) == [1, 2, 3, 4] -@test Compat.sort([1 2; 3 4], dims=1) == [1 2; 3 4] -@test Compat.sort([1 2; 3 4], dims=2) == [1 2; 3 4] -@test Compat.sort([1, 2, 3, 4], rev=true) == [4, 3, 2, 1] -@test Compat.sort([1 2; 3 4], rev=true, dims=1) == [3 4; 1 2] -@test Compat.sort([1 2; 3 4], rev=true, dims=2) == [2 1; 4 3] -@test Compat.accumulate(*, [1 2; 3 4], dims=1) == [1 2; 3 8] -@test Compat.accumulate(*, [1 2; 3 4], dims=2) == [1 2; 3 12] -@test Compat.cumsum([1 2; 3 4], dims=1) == [1 2; 4 6] -@test Compat.cumsum([1 2; 3 4], dims=2) == [1 3; 3 7] -@test Compat.cumprod([1 2; 3 4], dims=1) == [1 2; 3 8] -@test Compat.cumprod([1 2; 3 4], dims=2) == [1 2; 3 12] -let b = zeros(2,2) - Compat.accumulate!(*, b, [1 2; 3 4], dims=1) - @test b == [1 2; 3 8] - Compat.accumulate!(*, b, [1 2; 3 4], dims=2) - @test b == [1 2; 3 12] - Compat.cumsum!(b, [1 2; 3 4], dims=1) - @test b == [1 2; 4 6] - Compat.cumsum!(b, [1 2; 3 4], dims=2) - @test b == [1 3; 3 7] - Compat.cumprod!(b, [1 2; 3 4], dims=1) - @test b == [1 2; 3 8] - Compat.cumprod!(b, [1 2; 3 4], dims=2) - @test b == [1 2; 3 12] -end -@test Compat.reverse([1, 2, 3, 4]) == [4, 3, 2, 1] -@test Compat.reverse([1 2; 3 4], dims=1) == [3 4; 1 2] -@test Compat.reverse([1 2; 3 4], dims=2) == [2 1; 4 3] - -# 0.7.0-DEV.4738 -if VERSION < v"0.7.0-beta2.143" - @test squeeze([1 2], dims=1) == [1, 2] - @test_throws ArgumentError squeeze([1 2], dims=2) - @test_throws ArgumentError squeeze(hcat([1, 2]), dims=1) - @test squeeze(hcat([1, 2]), dims=2) == [1, 2] - @test_throws Exception squeeze([1,2]) -end - -# 0.7.0-DEV.5165 -@test Compat.cat([1, 2], [3, 4, 5], dims = 1) == [1, 2, 3, 4, 5] -@test Compat.cat([1, 2], [3, 4], dims = 2) == [1 3; 2 4] -if VERSION < v"0.7.0-DEV.5165" - @test_throws UndefKeywordError Compat.cat([1, 2], [3, 4]) -end - # 0.7.0-DEV.3976 let A = rand(5,5) @test selectdim(A, 1, 3) == A[3, :] From c9c40edbe49c484c50a516123aab49f1a62a2082 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 18:27:55 +0200 Subject: [PATCH 095/121] Drop compat code for `selectdim` from #522 and #531 --- README.md | 2 -- src/Compat.jl | 11 ----------- test/old.jl | 14 ++++++++++++++ test/runtests.jl | 17 ----------------- 4 files changed, 14 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 060a3b168..85eb205ac 100644 --- a/README.md +++ b/README.md @@ -74,8 +74,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `range` supporting `stop` as positional argument ([#28708]). -* `selectdim` to obtain a view of an array with a specified index for a specified dimension ([#26009]). - * Single-argument `permutedims(x)` for matrices and vectors ([#24839]). * `fetch` for `Task`s ([#25940]). diff --git a/src/Compat.jl b/src/Compat.jl index 3390f2c2a..0c0943547 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -76,17 +76,6 @@ end end end -if !isdefined(Base, :selectdim) # 0.7.0-DEV.3976 - export selectdim - @inline selectdim(A::AbstractArray, d::Integer, i) = _selectdim(A, d, i, Base.setindex(map(Base.Slice, axes(A)), i, d)) - @noinline function _selectdim(A, d, i, idxs) - d >= 1 || throw(ArgumentError("dimension must be ≥ 1")) - nd = ndims(A) - d > nd && (i == 1 || throw(BoundsError(A, (ntuple(k->Colon(),d-1)..., i)))) - return view(A, idxs...) - end -end - if VERSION < v"0.7.0-DEV.3977" #26039 Base.repeat(A::AbstractArray, counts::Integer...) = Base.repeat(A, outer = counts) Base.repeat(a::AbstractVecOrMat, m::Integer, n::Integer=1) = Base.repmat(a, m, n) diff --git a/test/old.jl b/test/old.jl index daed1615c..ca356cd7f 100644 --- a/test/old.jl +++ b/test/old.jl @@ -1031,3 +1031,17 @@ end if VERSION < v"0.7.0-DEV.5165" @test_throws UndefKeywordError Compat.cat([1, 2], [3, 4]) end + +# 0.7.0-DEV.3976 +let A = rand(5,5) + @test selectdim(A, 1, 3) == A[3, :] + @test selectdim(A, 1, 1:3) == A[1:3, :] + @test selectdim(A, 2, 3) == A[:, 3] + @test selectdim(A, 2, 1:3) == A[:, 1:3] + selectdim(A, 1, 3)[3] = 42 + @test A[3,3] == 42 + B = rand(4, 3, 2) + @test IndexStyle(selectdim(B, 1, 1)) == IndexStyle(view(B, 1, :, :)) == IndexLinear() + @test IndexStyle(selectdim(B, 2, 1)) == IndexStyle(view(B, :, 1, :)) == IndexCartesian() + @test IndexStyle(selectdim(B, 3, 1)) == IndexStyle(view(B, :, :, 1)) == IndexLinear() +end diff --git a/test/runtests.jl b/test/runtests.jl index 3e929fc1a..bbe0750ab 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -82,23 +82,6 @@ end @test codeunit("foo") == codeunit(SubString("fooαβγ",1,3)) == UInt8 -# 0.7.0-DEV.3976 -let A = rand(5,5) - @test selectdim(A, 1, 3) == A[3, :] - @test selectdim(A, 1, 1:3) == A[1:3, :] - @test selectdim(A, 2, 3) == A[:, 3] - @test selectdim(A, 2, 1:3) == A[:, 1:3] - selectdim(A, 1, 3)[3] = 42 - @test A[3,3] == 42 - if VERSION < v"0.7.0-DEV.3976" || VERSION >= v"0.7.0-DEV.4739" - # in the omitted version range, Julia's selectdim always gives IndexCartesian() - B = rand(4, 3, 2) - @test IndexStyle(selectdim(B, 1, 1)) == IndexStyle(view(B, 1, :, :)) == IndexLinear() - @test IndexStyle(selectdim(B, 2, 1)) == IndexStyle(view(B, :, 1, :)) == IndexCartesian() - @test IndexStyle(selectdim(B, 3, 1)) == IndexStyle(view(B, :, :, 1)) == IndexLinear() - end -end - # 0.7.0-DEV.843 / 0.7.0-DEV.2337 let A = [1 2; 1 2; 1 2] if VERSION < v"0.7.0-DEV.5211" From 1f9a3f39679fc05006183f6f7923c429f5fc62ce Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 18:29:39 +0200 Subject: [PATCH 096/121] Drop compat code for `repeat` from #625 --- README.md | 2 -- src/Compat.jl | 6 ------ test/old.jl | 8 ++++++++ test/runtests.jl | 8 -------- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 85eb205ac..2076fac73 100644 --- a/README.md +++ b/README.md @@ -114,8 +114,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `squeeze` is now `dropdims` ([#28303], [#26660]). -* `repmat` is now `repeat` ([#26039]) - ## New macros ## Other changes diff --git a/src/Compat.jl b/src/Compat.jl index 0c0943547..265def42b 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -76,12 +76,6 @@ end end end -if VERSION < v"0.7.0-DEV.3977" #26039 - Base.repeat(A::AbstractArray, counts::Integer...) = Base.repeat(A, outer = counts) - Base.repeat(a::AbstractVecOrMat, m::Integer, n::Integer=1) = Base.repmat(a, m, n) - Base.repeat(a::AbstractVector, m::Integer) = Base.repmat(a, m) -end - if VERSION < v"0.7.0-DEV.2337" # qr doesn't take the full keyword anymore since 0.7.0-DEV.5211; we still support it # here to avoid unneccesary breakage diff --git a/test/old.jl b/test/old.jl index ca356cd7f..bcd6a7448 100644 --- a/test/old.jl +++ b/test/old.jl @@ -1045,3 +1045,11 @@ let A = rand(5,5) @test IndexStyle(selectdim(B, 2, 1)) == IndexStyle(view(B, :, 1, :)) == IndexCartesian() @test IndexStyle(selectdim(B, 3, 1)) == IndexStyle(view(B, :, :, 1)) == IndexLinear() end + +@test repeat([1, 2], 3) == [1, 2, 1, 2, 1, 2] +@test repeat(1:4, 2) == [1, 2, 3, 4, 1, 2, 3, 4] +@test repeat([1 2; 3 4], 2, 3) == [1 2 1 2 1 2 + 3 4 3 4 3 4 + 1 2 1 2 1 2 + 3 4 3 4 3 4] +@test repeat([1, 2], 1, 2, 3) == [x for x in 1:2, y in 1:2, z in 1:3] diff --git a/test/runtests.jl b/test/runtests.jl index bbe0750ab..c4e973a5d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -346,14 +346,6 @@ if VERSION < v"0.7.0-beta2.143" end end -@test repeat([1, 2], 3) == [1, 2, 1, 2, 1, 2] -@test repeat(1:4, 2) == [1, 2, 3, 4, 1, 2, 3, 4] -@test repeat([1 2; 3 4], 2, 3) == [1 2 1 2 1 2 - 3 4 3 4 3 4 - 1 2 1 2 1 2 - 3 4 3 4 3 4] -@test repeat([1, 2], 1, 2, 3) == [x for x in 1:2, y in 1:2, z in 1:3] - # Support for positional `stop` @test Compat.range(0, 5, length = 6) == 0.0:1.0:5.0 @test Compat.range(0, 10, step = 2) == 0:2:10 From 430e42d04b74abcfc496b52e260e119e36a14ef4 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 18:33:38 +0200 Subject: [PATCH 097/121] Mark `Compat.qr` from #534 for deprecation --- README.md | 2 -- src/Compat.jl | 15 +-------------- test/old.jl | 10 ++++++++++ test/runtests.jl | 34 ---------------------------------- 4 files changed, 11 insertions(+), 50 deletions(-) diff --git a/README.md b/README.md index 2076fac73..0ed307015 100644 --- a/README.md +++ b/README.md @@ -78,8 +78,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `fetch` for `Task`s ([#25940]). -* `Compat.qr` takes `pivot` as a `Val` _instance_ ([#22475]). - * `Compat.rmul!` provides a subset of the functionality of `LinearAlgebra.rmul!` for use with Julia 0.6 ([#25701], [#25812]). diff --git a/src/Compat.jl b/src/Compat.jl index 265def42b..0cc92ab23 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -51,6 +51,7 @@ import Pkg import InteractiveUtils import LibGit2 import UUIDs +using LinearAlgebra: qr include("compatmacro.jl") @@ -76,20 +77,6 @@ end end end -if VERSION < v"0.7.0-DEV.2337" - # qr doesn't take the full keyword anymore since 0.7.0-DEV.5211; we still support it - # here to avoid unneccesary breakage - if VERSION < v"0.7.0-DEV.843" - qr(A::Union{Number,AbstractMatrix}, pivot::Union{Val{false},Val{true}}=Val(false); full=false) = - Base.qr(A, typeof(pivot), thin=!full) - else - qr(A::Union{Number,AbstractMatrix}, pivot::Union{Val{false},Val{true}}=Val(false); full=false) = - Base.qr(A, pivot, thin=!full) - end -else - using LinearAlgebra: qr -end - # rmul! (NOTE: Purposefully not exported) if VERSION < v"0.7.0-DEV.3563" # scale! not deprecated if VERSION >= v"0.7.0-DEV.3449" # LinearAlgebra in the stdlib diff --git a/test/old.jl b/test/old.jl index bcd6a7448..4590045db 100644 --- a/test/old.jl +++ b/test/old.jl @@ -232,6 +232,16 @@ module TestUUIDs @test uuid4() isa UUID end +# 0.7.0-DEV.843 / 0.7.0-DEV.2337 +let A = [1 2; 1 2; 1 2] + f = Compat.qr(A, Val(false)) + @test size(f.Q) == (3, 3) + @test f.Q * [f.R; [0 0]] ≈ A + f = Compat.qr(A, Val(true)) + @test size(f.Q) == (3, 3) + @test f.Q * [f.R; [0 0]] ≈ A[:,f.p] +end + # tests of removed functionality (i.e. justs tests Base) diff --git a/test/runtests.jl b/test/runtests.jl index c4e973a5d..4912a57b0 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -82,40 +82,6 @@ end @test codeunit("foo") == codeunit(SubString("fooαβγ",1,3)) == UInt8 -# 0.7.0-DEV.843 / 0.7.0-DEV.2337 -let A = [1 2; 1 2; 1 2] - if VERSION < v"0.7.0-DEV.5211" - # the full keyword was only temporarily available in Base, so these methods don't - # work on 0.7 anymore, but we test them for the time being to avoid accidentally - # breaking anyone's code - f = Compat.qr(A, Val(false), full=false) - @test f == Compat.qr(A, Val(false)) - @test length(f) == 2 - @test size(f[1]) == (3, 2) - @test f[1] * f[2] ≈ A - f = Compat.qr(A, Val(false), full=true) - @test length(f) == 2 - @test size(f[1]) == (3, 3) - @test f[1] * [f[2]; [0 0]] ≈ A - f = Compat.qr(A, Val(true), full=false) - @test f == Compat.qr(A, Val(true)) - @test length(f) == 3 - @test size(f[1]) == (3, 2) - @test f[1] * f[2] ≈ A[:,f[3]] - f = Compat.qr(A, Val(true), full=true) - @test length(f) == 3 - @test size(f[1]) == (3, 3) - @test f[1] * [f[2]; [0 0]] ≈ A[:,f[3]] - else - f = Compat.qr(A, Val(false)) - @test size(f.Q) == (3, 3) - @test f.Q * [f.R; [0 0]] ≈ A - f = Compat.qr(A, Val(true)) - @test size(f.Q) == (3, 3) - @test f.Q * [f.R; [0 0]] ≈ A[:,f.p] - end -end - let A = [1 2; 3 4] @test Compat.rmul!(A, 2) == [2 4; 6 8] @test Compat.rmul!(A, Diagonal([1, 2])) == [2 8; 6 16] From 2c001f03f90ecab5cf3429ca9dde35fe38c85dc8 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 18:39:27 +0200 Subject: [PATCH 098/121] Mark `Compat.rmul!` from #546 for deprecation --- README.md | 3 --- src/Compat.jl | 26 +------------------------- test/old.jl | 8 ++++++++ test/runtests.jl | 8 -------- 4 files changed, 9 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 0ed307015..d07f64f86 100644 --- a/README.md +++ b/README.md @@ -78,9 +78,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `fetch` for `Task`s ([#25940]). -* `Compat.rmul!` provides a subset of the functionality of `LinearAlgebra.rmul!` for - use with Julia 0.6 ([#25701], [#25812]). - * `isbits(t::Type)` is now `isbitstype(t)` ([#26850]). * `something` to get the first argument different from `nothing`, unwrapping those diff --git a/src/Compat.jl b/src/Compat.jl index 0cc92ab23..4102e421b 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -52,6 +52,7 @@ import InteractiveUtils import LibGit2 import UUIDs using LinearAlgebra: qr +using LinearAlgebra: rmul! include("compatmacro.jl") @@ -77,31 +78,6 @@ end end end -# rmul! (NOTE: Purposefully not exported) -if VERSION < v"0.7.0-DEV.3563" # scale! not deprecated - if VERSION >= v"0.7.0-DEV.3449" # LinearAlgebra in the stdlib - using LinearAlgebra: UnitUpperTriangular, UnitLowerTriangular, scale! - else - using Base.LinAlg: UnitUpperTriangular, UnitLowerTriangular, scale! - end - const Triangle = Union{UpperTriangular, UnitUpperTriangular, - LowerTriangular, UnitLowerTriangular} - if VERSION < v"0.7.0-DEV.3204" # A_mul_B! not deprecated - rmul!(A::AbstractMatrix, B::Triangle) = A_mul_B!(A, A, B) - else - rmul!(A::AbstractMatrix, B::Triangle) = mul!(A, A, B) - end - rmul!(A::AbstractArray, s::Number) = scale!(A, s) - rmul!(A::AbstractMatrix, D::Diagonal) = scale!(A, D.diag) - rmul!(A::Diagonal, B::Diagonal) = Diagonal(A.diag .*= B.diag) - rmul!(A::Triangle, B::Diagonal) = typeof(A)(rmul!(A.data, B)) -elseif v"0.7.0-DEV.3563" <= VERSION < v"0.7.0-DEV.3665" # scale! -> mul1! - using LinearAlgebra: mul1! - const rmul! = mul1! -elseif VERSION >= v"0.7.0-DEV.3665" # mul1! -> rmul! - using LinearAlgebra: rmul! -end - @static if VERSION < v"0.7.0-DEV.3936" Base.fetch(t::Task) = wait(t) end diff --git a/test/old.jl b/test/old.jl index 4590045db..571821930 100644 --- a/test/old.jl +++ b/test/old.jl @@ -242,6 +242,14 @@ let A = [1 2; 1 2; 1 2] @test f.Q * [f.R; [0 0]] ≈ A[:,f.p] end +let A = [1 2; 3 4] + @test Compat.rmul!(A, 2) == [2 4; 6 8] + @test Compat.rmul!(A, Diagonal([1, 2])) == [2 8; 6 16] + @test Compat.rmul!(A, UpperTriangular([2 2; 3 3])) == [4 28; 12 60] + @test Compat.rmul!(LowerTriangular(A), Diagonal([1, 2])) == LowerTriangular([4 0; 12 120]) + @test Compat.rmul!(Diagonal(A), Diagonal([2, 1])) == Diagonal([8, 120]) +end + # tests of removed functionality (i.e. justs tests Base) diff --git a/test/runtests.jl b/test/runtests.jl index 4912a57b0..8efd2e1eb 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -82,14 +82,6 @@ end @test codeunit("foo") == codeunit(SubString("fooαβγ",1,3)) == UInt8 -let A = [1 2; 3 4] - @test Compat.rmul!(A, 2) == [2 4; 6 8] - @test Compat.rmul!(A, Diagonal([1, 2])) == [2 8; 6 16] - @test Compat.rmul!(A, UpperTriangular([2 2; 3 3])) == [4 28; 12 60] - @test Compat.rmul!(LowerTriangular(A), Diagonal([1, 2])) == LowerTriangular([4 0; 12 120]) - @test Compat.rmul!(Diagonal(A), Diagonal([2, 1])) == Diagonal([8, 120]) -end - # 0.7.0-DEV.3936 @test let ct = current_task(), t = @task true schedule(ct) From d613e8e9c8965e7376e2bed6378a2bb62125b1a5 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 18:40:59 +0200 Subject: [PATCH 099/121] Drop compat code for `fetch(::Task)` from #549 --- README.md | 2 -- src/Compat.jl | 4 ---- test/old.jl | 7 +++++++ test/runtests.jl | 7 ------- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index d07f64f86..6d3337906 100644 --- a/README.md +++ b/README.md @@ -76,8 +76,6 @@ Currently, the `@compat` macro supports the following syntaxes: * Single-argument `permutedims(x)` for matrices and vectors ([#24839]). -* `fetch` for `Task`s ([#25940]). - * `isbits(t::Type)` is now `isbitstype(t)` ([#26850]). * `something` to get the first argument different from `nothing`, unwrapping those diff --git a/src/Compat.jl b/src/Compat.jl index 4102e421b..80e41926c 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -78,10 +78,6 @@ end end end -@static if VERSION < v"0.7.0-DEV.3936" - Base.fetch(t::Task) = wait(t) -end - # https://github.com/JuliaLang/julia/pull/27077 @static if VERSION < v"0.7.0-DEV.5087" export isletter diff --git a/test/old.jl b/test/old.jl index 571821930..fb8ce57ef 100644 --- a/test/old.jl +++ b/test/old.jl @@ -1071,3 +1071,10 @@ end 1 2 1 2 1 2 3 4 3 4 3 4] @test repeat([1, 2], 1, 2, 3) == [x for x in 1:2, y in 1:2, z in 1:3] + +# 0.7.0-DEV.3936 +@test let ct = current_task(), t = @task true + schedule(ct) + yieldto(t) + fetch(t) +end diff --git a/test/runtests.jl b/test/runtests.jl index 8efd2e1eb..a0765ae8b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -82,13 +82,6 @@ end @test codeunit("foo") == codeunit(SubString("fooαβγ",1,3)) == UInt8 -# 0.7.0-DEV.3936 -@test let ct = current_task(), t = @task true - schedule(ct) - yieldto(t) - fetch(t) -end - # 0.7.0-DEV.5087 @test isletter('a') @test isletter('β') From 84299d3dc1eeaf7a5a4d2e9d76fb34e160394dec Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 18:42:18 +0200 Subject: [PATCH 100/121] Drop compat code for `isletter` from #542 --- README.md | 2 -- src/Compat.jl | 6 ------ test/old.jl | 5 +++++ test/runtests.jl | 5 ----- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 6d3337906..a0d674f4a 100644 --- a/README.md +++ b/README.md @@ -93,8 +93,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `Compat.split` and `Compat.rsplit` accept `keepempty` keyword argument if `splitter` is given as second argument ([#26634]) -* `isalpha` is now `isletter` ([#27077]). - * `cfunction` is now `@cfunction` ([#26486]). * `vecnorm` and `vecdot` are now `Compat.norm` and `Compat.dot`, respectively, while the diff --git a/src/Compat.jl b/src/Compat.jl index 80e41926c..10dbaff0d 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -78,12 +78,6 @@ end end end -# https://github.com/JuliaLang/julia/pull/27077 -@static if VERSION < v"0.7.0-DEV.5087" - export isletter - const isletter = isalpha -end - # https://github.com/JuliaLang/julia/pull/26850 if !isdefined(Base, :isbitstype) # 0.7.0-DEV.4905 export isbitstype diff --git a/test/old.jl b/test/old.jl index fb8ce57ef..3278f69ad 100644 --- a/test/old.jl +++ b/test/old.jl @@ -1078,3 +1078,8 @@ end yieldto(t) fetch(t) end + +# 0.7.0-DEV.5087 +@test isletter('a') +@test isletter('β') +@test !isletter('3') diff --git a/test/runtests.jl b/test/runtests.jl index a0765ae8b..3cea59941 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -82,11 +82,6 @@ end @test codeunit("foo") == codeunit(SubString("fooαβγ",1,3)) == UInt8 -# 0.7.0-DEV.5087 -@test isletter('a') -@test isletter('β') -@test !isletter('3') - # 0.7.0-DEV.4905 @test isbitstype(Int) @test !isbitstype(Vector{Int}) From e6ad117d542e2f11a44235a070ebff01019efbd1 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 18:44:58 +0200 Subject: [PATCH 101/121] Drop compat code for `isbitstype` from #560 --- README.md | 2 -- src/Compat.jl | 6 ------ test/old.jl | 4 ++++ test/runtests.jl | 4 ---- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index a0d674f4a..f3fa857dd 100644 --- a/README.md +++ b/README.md @@ -76,8 +76,6 @@ Currently, the `@compat` macro supports the following syntaxes: * Single-argument `permutedims(x)` for matrices and vectors ([#24839]). -* `isbits(t::Type)` is now `isbitstype(t)` ([#26850]). - * `something` to get the first argument different from `nothing`, unwrapping those of the `Some` type ([#27258]). diff --git a/src/Compat.jl b/src/Compat.jl index 10dbaff0d..4db7e5b1a 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -78,12 +78,6 @@ end end end -# https://github.com/JuliaLang/julia/pull/26850 -if !isdefined(Base, :isbitstype) # 0.7.0-DEV.4905 - export isbitstype - isbitstype(::Type{T}) where {T} = isbits(T) -end - # 0.7.0-DEV.4762 @static if !isdefined(Base, Symbol("@cfunction")) macro cfunction(f, rt, tup) diff --git a/test/old.jl b/test/old.jl index 3278f69ad..42a0667f2 100644 --- a/test/old.jl +++ b/test/old.jl @@ -1083,3 +1083,7 @@ end @test isletter('a') @test isletter('β') @test !isletter('3') + +# 0.7.0-DEV.4905 +@test isbitstype(Int) +@test !isbitstype(Vector{Int}) diff --git a/test/runtests.jl b/test/runtests.jl index 3cea59941..1f4f7dc67 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -82,10 +82,6 @@ end @test codeunit("foo") == codeunit(SubString("fooαβγ",1,3)) == UInt8 -# 0.7.0-DEV.4905 -@test isbitstype(Int) -@test !isbitstype(Vector{Int}) - # 0.7.0-DEV.4762 let ptr = @cfunction(+, Int, (Int, Int)) @test ptr isa Ptr{Cvoid} From 4f706a7c107b67ac80967e70772ce48751eda439 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 19:08:01 +0200 Subject: [PATCH 102/121] Drop compat code for `at-cfunction` from #553 and #566 --- README.md | 2 -- src/Compat.jl | 8 -------- test/old.jl | 15 +++++++++++++++ test/runtests.jl | 15 --------------- 4 files changed, 15 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index f3fa857dd..d16daafa7 100644 --- a/README.md +++ b/README.md @@ -91,8 +91,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `Compat.split` and `Compat.rsplit` accept `keepempty` keyword argument if `splitter` is given as second argument ([#26634]) -* `cfunction` is now `@cfunction` ([#26486]). - * `vecnorm` and `vecdot` are now `Compat.norm` and `Compat.dot`, respectively, while the old `norm(A::AbstractMatrix, p=2)` is now `Compat.opnorm` ([#27401]). `import Compat: ⋅` to get `Compat.dot` as the binary operator `⋅`. diff --git a/src/Compat.jl b/src/Compat.jl index 4db7e5b1a..61be14dd6 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -78,14 +78,6 @@ end end end -# 0.7.0-DEV.4762 -@static if !isdefined(Base, Symbol("@cfunction")) - macro cfunction(f, rt, tup) - :(Base.cfunction($(esc(f)), $(esc(rt)), Tuple{$(esc(tup))...})) - end - export @cfunction -end - if VERSION < v"0.7.0-DEV.2920" # julia#24999 Base.length(s::AbstractString, i::Integer, j::Integer) = length(s, Int(i), Int(j)) function Base.length(s::AbstractString, i::Int, j::Int) diff --git a/test/old.jl b/test/old.jl index 42a0667f2..584c797a0 100644 --- a/test/old.jl +++ b/test/old.jl @@ -1087,3 +1087,18 @@ end # 0.7.0-DEV.4905 @test isbitstype(Int) @test !isbitstype(Vector{Int}) + +# 0.7.0-DEV.4762 +let ptr = @cfunction(+, Int, (Int, Int)) + @test ptr isa Ptr{Cvoid} + @test ptr != C_NULL + @test ccall(ptr, Int, (Int, Int), 2, 3) == 5 +end +# issue #565 +issue565(x) = x + 1 +const Issue565 = Int +let bar() = @cfunction(issue565, Issue565, (Issue565,)), ptr = bar() + @test ptr isa Ptr{Cvoid} + @test ptr != C_NULL + @test ccall(ptr, Int, (Int,), 2) === 3 +end diff --git a/test/runtests.jl b/test/runtests.jl index 1f4f7dc67..6b254fe27 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.4762 -let ptr = @cfunction(+, Int, (Int, Int)) - @test ptr isa Ptr{Cvoid} - @test ptr != C_NULL - @test ccall(ptr, Int, (Int, Int), 2, 3) == 5 -end -# issue #565 -issue565(x) = x + 1 -const Issue565 = Int -let bar() = @cfunction(issue565, Issue565, (Issue565,)), ptr = bar() - @test ptr isa Ptr{Cvoid} - @test ptr != C_NULL - @test ccall(ptr, Int, (Int,), 2) === 3 -end - # 0.7.0-DEV.5278 @test something(nothing, 1) === 1 @test something(Some(2)) === 2 From 4b8279d085536f0e3e03f1c7f154d7e33302e126 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 19:12:12 +0200 Subject: [PATCH 103/121] Drop compat code for `codeunit` and `thisind` and friends from #573 --- README.md | 6 --- src/Compat.jl | 54 -------------------------- test/old.jl | 99 ++++++++++++++++++++++++++++++++++++++++++++++++ test/runtests.jl | 99 ------------------------------------------------ 4 files changed, 99 insertions(+), 159 deletions(-) diff --git a/README.md b/README.md index d16daafa7..378cd7b14 100644 --- a/README.md +++ b/README.md @@ -66,12 +66,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `@compat finalizer(func, obj)` with the finalizer to run as the first argument and the object to be finalized as the second ([#24605]). -* `codeunit(s)` returns the type of the code units of `s` ([#24999]). - -* `thisind(s, i)` returns the character index for codeunit `i` ([#24414]). - -* 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. - * `range` supporting `stop` as positional argument ([#28708]). * Single-argument `permutedims(x)` for matrices and vectors ([#24839]). diff --git a/src/Compat.jl b/src/Compat.jl index 61be14dd6..b674c38d0 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -78,60 +78,6 @@ end end end -if VERSION < v"0.7.0-DEV.2920" # julia#24999 - Base.length(s::AbstractString, i::Integer, j::Integer) = length(s, Int(i), Int(j)) - function Base.length(s::AbstractString, i::Int, j::Int) - @boundscheck begin - 0 < i ≤ ncodeunits(s)+1 || throw(BoundsError(s, i)) - 0 ≤ j < ncodeunits(s)+1 || throw(BoundsError(s, j)) - end - n = 0 - for k = i:j - @inbounds n += isvalid(s, k) - end - return n - end - Base.codeunit(s::String) = UInt8 - Base.codeunit(s::SubString) = codeunit(s.string) -end -if !isdefined(Base, :thisind) # #24414 - thisind(s::AbstractString, i::Integer) = thisind(s, Int(i)) - function thisind(s::AbstractString, i::Int) - z = ncodeunits(s) + 1 - i == z && return i - @boundscheck 0 ≤ i ≤ z || throw(BoundsError(s, i)) - @inbounds while 1 < i && !isvalid(s, i) - i -= 1 - end - return i - end - export thisind -end -if VERSION < v"0.7.0-DEV.2019" # julia#23805 - Base.prevind(s::AbstractString, i::Integer, n::Integer) = prevind(s, Int(i), Int(n)) - Base.nextind(s::AbstractString, i::Integer, n::Integer) = nextind(s, Int(i), Int(n)) - function Base.nextind(s::AbstractString, i::Int, n::Int) - n < 0 && throw(ArgumentError("n cannot be negative: $n")) - z = ncodeunits(s) - @boundscheck 0 ≤ i ≤ z || throw(BoundsError(s, i)) - n == 0 && return thisind(s, i) == i ? i : throw(BoundsError(s, i)) - while n > 0 && i < z - @inbounds n -= isvalid(s, i += 1) - end - return i + n - end - function Base.prevind(s::AbstractString, i::Int, n::Int) - n < 0 && throw(ArgumentError("n cannot be negative: $n")) - z = ncodeunits(s) + 1 - @boundscheck 0 < i ≤ z || throw(BoundsError(s, i)) - n == 0 && return thisind(s, i) == i ? i : throw(BoundsError(s, i)) - while n > 0 && 1 < i - @inbounds n -= isvalid(s, i -= 1) - end - return i - n - end -end - if VERSION < v"0.7.0-DEV.5278" something() = throw(ArgumentError("No value arguments present")) something(x::Nothing, y...) = something(y...) diff --git a/test/old.jl b/test/old.jl index 584c797a0..ecdb2511a 100644 --- a/test/old.jl +++ b/test/old.jl @@ -1102,3 +1102,102 @@ let bar() = @cfunction(issue565, Issue565, (Issue565,)), ptr = bar() @test ptr != C_NULL @test ccall(ptr, Int, (Int,), 2) === 3 end + +@test codeunit("foo") == codeunit(SubString("fooαβγ",1,3)) == UInt8 + +# julia#24999 +let s = "∀α>β:α+" + @test [length(s,i,j) for i=1:ncodeunits(s)+1, j=0:ncodeunits(s)] == + [0 1 1 1 2 2 3 4 4 5 6 6 7; 0 0 0 0 1 1 2 3 3 4 5 5 6; 0 0 0 0 1 1 2 3 3 4 5 5 6; 0 0 0 0 1 1 2 3 3 4 5 5 6; 0 0 0 0 0 0 1 2 2 3 4 4 5; 0 0 0 0 0 0 1 2 2 3 4 4 5; 0 0 0 0 0 0 0 1 1 2 3 3 4; 0 0 0 0 0 0 0 0 0 1 2 2 3; 0 0 0 0 0 0 0 0 0 1 2 2 3; 0 0 0 0 0 0 0 0 0 0 1 1 2; 0 0 0 0 0 0 0 0 0 0 0 0 1; 0 0 0 0 0 0 0 0 0 0 0 0 1; 0 0 0 0 0 0 0 0 0 0 0 0 0] +end +@test_throws BoundsError length("hello", 1, -1) +@test_throws BoundsError length("hellø", 1, -1) +@test_throws BoundsError length("hello", 1, 10) +@test_throws BoundsError length("hellø", 1, 10) == 9 +@test_throws BoundsError prevind("hello", 0, 1) +@test_throws BoundsError prevind("hellø", 0, 1) +@test nextind("hello", 0, 10) == 10 +# julia#24414 +let strs = Any["∀α>β:α+1>β", SubString("123∀α>β:α+1>β123", 4, 18)] + for s in strs + @test_throws BoundsError thisind(s, -2) + @test_throws BoundsError thisind(s, -1) + @test thisind(s, 0) == 0 + @test thisind(s, 1) == 1 + @test thisind(s, 2) == 1 + @test thisind(s, 3) == 1 + @test thisind(s, 4) == 4 + @test thisind(s, 5) == 4 + @test thisind(s, 6) == 6 + @test thisind(s, 15) == 15 + @test thisind(s, 16) == 15 + @test thisind(s, 17) == 17 + @test_throws BoundsError thisind(s, 18) + @test_throws BoundsError thisind(s, 19) + end +end +let strs = Any["", SubString("123", 2, 1)] + for s in strs + @test_throws BoundsError thisind(s, -1) + @test thisind(s, 0) == 0 + @test thisind(s, 1) == 1 + @test_throws BoundsError thisind(s, 2) + end +end +# prevind and nextind, julia#23805 +let s = "∀α>β:α+1>β" + @test_throws BoundsError prevind(s, 0, 0) + @test_throws BoundsError prevind(s, 0, 1) + @test prevind(s, 1, 1) == 0 + @test prevind(s, 1, 0) == 1 + @test prevind(s, 2, 1) == 1 + @test prevind(s, 4, 1) == 1 + @test prevind(s, 5, 1) == 4 + @test prevind(s, 5, 2) == 1 + @test prevind(s, 5, 3) == 0 + @test prevind(s, 15, 1) == 14 + @test prevind(s, 15, 2) == 13 + @test prevind(s, 15, 3) == 12 + @test prevind(s, 15, 4) == 10 + @test prevind(s, 15, 10) == 0 + @test prevind(s, 15, 9) == 1 + @test prevind(s, 16, 1) == 15 + @test prevind(s, 16, 2) == 14 + @test prevind(s, 17, 1) == 15 + @test prevind(s, 17, 2) == 14 + @test_throws BoundsError prevind(s, 18, 0) + @test_throws BoundsError prevind(s, 18, 1) + @test_throws BoundsError nextind(s, -1, 0) + @test_throws BoundsError nextind(s, -1, 1) + @test nextind(s, 0, 2) == 4 + @test nextind(s, 0, 20) == 26 + @test nextind(s, 0, 10) == 15 + @test nextind(s, 1, 1) == 4 + @test nextind(s, 1, 2) == 6 + @test nextind(s, 1, 9) == 15 + @test nextind(s, 1, 10) == 17 + @test nextind(s, 2, 1) == 4 + @test nextind(s, 3, 1) == 4 + @test nextind(s, 4, 1) == 6 + @test nextind(s, 14, 1) == 15 + @test nextind(s, 15, 1) == 17 + @test nextind(s, 15, 2) == 18 + @test nextind(s, 16, 1) == 17 + @test nextind(s, 16, 2) == 18 + @test nextind(s, 16, 3) == 19 + @test_throws BoundsError nextind(s, 17, 0) + @test_throws BoundsError nextind(s, 17, 1) + for k in 0:ncodeunits(s)+1 + n = p = k + for j in 1:40 + if 1 ≤ p + p = prevind(s, p) + @test prevind(s, k, j) == p + end + if n ≤ ncodeunits(s) + n = nextind(s, n) + @test nextind(s, k, j) == n + end + end + end +end diff --git a/test/runtests.jl b/test/runtests.jl index 6b254fe27..7ea0402a6 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -80,111 +80,12 @@ let A = [1] @test x == 1 end -@test codeunit("foo") == codeunit(SubString("fooαβγ",1,3)) == UInt8 - # 0.7.0-DEV.5278 @test something(nothing, 1) === 1 @test something(Some(2)) === 2 @test something(Some(2), 1) === 2 @test something(nothing, Some(1)) === 1 -# julia#24999 -let s = "∀α>β:α+" - @test [length(s,i,j) for i=1:ncodeunits(s)+1, j=0:ncodeunits(s)] == - [0 1 1 1 2 2 3 4 4 5 6 6 7; 0 0 0 0 1 1 2 3 3 4 5 5 6; 0 0 0 0 1 1 2 3 3 4 5 5 6; 0 0 0 0 1 1 2 3 3 4 5 5 6; 0 0 0 0 0 0 1 2 2 3 4 4 5; 0 0 0 0 0 0 1 2 2 3 4 4 5; 0 0 0 0 0 0 0 1 1 2 3 3 4; 0 0 0 0 0 0 0 0 0 1 2 2 3; 0 0 0 0 0 0 0 0 0 1 2 2 3; 0 0 0 0 0 0 0 0 0 0 1 1 2; 0 0 0 0 0 0 0 0 0 0 0 0 1; 0 0 0 0 0 0 0 0 0 0 0 0 1; 0 0 0 0 0 0 0 0 0 0 0 0 0] -end -@test_throws BoundsError length("hello", 1, -1) -@test_throws BoundsError length("hellø", 1, -1) -@test_throws BoundsError length("hello", 1, 10) -@test_throws BoundsError length("hellø", 1, 10) == 9 -@test_throws BoundsError prevind("hello", 0, 1) -@test_throws BoundsError prevind("hellø", 0, 1) -@test nextind("hello", 0, 10) == 10 -# julia#24414 -let strs = Any["∀α>β:α+1>β", SubString("123∀α>β:α+1>β123", 4, 18)] - for s in strs - @test_throws BoundsError thisind(s, -2) - @test_throws BoundsError thisind(s, -1) - @test thisind(s, 0) == 0 - @test thisind(s, 1) == 1 - @test thisind(s, 2) == 1 - @test thisind(s, 3) == 1 - @test thisind(s, 4) == 4 - @test thisind(s, 5) == 4 - @test thisind(s, 6) == 6 - @test thisind(s, 15) == 15 - @test thisind(s, 16) == 15 - @test thisind(s, 17) == 17 - @test_throws BoundsError thisind(s, 18) - @test_throws BoundsError thisind(s, 19) - end -end -let strs = Any["", SubString("123", 2, 1)] - for s in strs - @test_throws BoundsError thisind(s, -1) - @test thisind(s, 0) == 0 - @test thisind(s, 1) == 1 - @test_throws BoundsError thisind(s, 2) - end -end -# prevind and nextind, julia#23805 -let s = "∀α>β:α+1>β" - @test_throws BoundsError prevind(s, 0, 0) - @test_throws BoundsError prevind(s, 0, 1) - @test prevind(s, 1, 1) == 0 - @test prevind(s, 1, 0) == 1 - @test prevind(s, 2, 1) == 1 - @test prevind(s, 4, 1) == 1 - @test prevind(s, 5, 1) == 4 - @test prevind(s, 5, 2) == 1 - @test prevind(s, 5, 3) == 0 - @test prevind(s, 15, 1) == 14 - @test prevind(s, 15, 2) == 13 - @test prevind(s, 15, 3) == 12 - @test prevind(s, 15, 4) == 10 - @test prevind(s, 15, 10) == 0 - @test prevind(s, 15, 9) == 1 - @test prevind(s, 16, 1) == 15 - @test prevind(s, 16, 2) == 14 - @test prevind(s, 17, 1) == 15 - @test prevind(s, 17, 2) == 14 - @test_throws BoundsError prevind(s, 18, 0) - @test_throws BoundsError prevind(s, 18, 1) - @test_throws BoundsError nextind(s, -1, 0) - @test_throws BoundsError nextind(s, -1, 1) - @test nextind(s, 0, 2) == 4 - @test nextind(s, 0, 20) == 26 - @test nextind(s, 0, 10) == 15 - @test nextind(s, 1, 1) == 4 - @test nextind(s, 1, 2) == 6 - @test nextind(s, 1, 9) == 15 - @test nextind(s, 1, 10) == 17 - @test nextind(s, 2, 1) == 4 - @test nextind(s, 3, 1) == 4 - @test nextind(s, 4, 1) == 6 - @test nextind(s, 14, 1) == 15 - @test nextind(s, 15, 1) == 17 - @test nextind(s, 15, 2) == 18 - @test nextind(s, 16, 1) == 17 - @test nextind(s, 16, 2) == 18 - @test nextind(s, 16, 3) == 19 - @test_throws BoundsError nextind(s, 17, 0) - @test_throws BoundsError nextind(s, 17, 1) - for k in 0:ncodeunits(s)+1 - n = p = k - for j in 1:40 - if 1 ≤ p - p = prevind(s, p) - @test prevind(s, k, j) == p - end - if n ≤ ncodeunits(s) - n = nextind(s, n) - @test nextind(s, k, j) == n - end - end - end -end - # julia#24839 @test permutedims([1 2; 3 4]) == [1 3; 2 4] @test permutedims([1,2,3]) == [1 2 3] From 2470ca4304d7e30b46ae57e80a1ee44bd2964531 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 19:13:42 +0200 Subject: [PATCH 104/121] Drop compat code for `something` from #562 --- README.md | 3 --- src/Compat.jl | 8 -------- test/old.jl | 6 ++++++ test/runtests.jl | 6 ------ 4 files changed, 6 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 378cd7b14..1ecc80774 100644 --- a/README.md +++ b/README.md @@ -70,9 +70,6 @@ Currently, the `@compat` macro supports the following syntaxes: * Single-argument `permutedims(x)` for matrices and vectors ([#24839]). -* `something` to get the first argument different from `nothing`, unwrapping those - of the `Some` type ([#27258]). - * `mapslices` with `dims` keyword argument ([#27828]). * `hasproperty` and `hasfield` ([#28850]). diff --git a/src/Compat.jl b/src/Compat.jl index b674c38d0..bd12ec1e2 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -78,14 +78,6 @@ end end end -if VERSION < v"0.7.0-DEV.5278" - something() = throw(ArgumentError("No value arguments present")) - something(x::Nothing, y...) = something(y...) - something(x::Some, y...) = x.value - something(x::Any, y...) = x - export something -end - if !isdefined(LinearAlgebra, :opnorm) # julia#27401 opnorm(A::AbstractMatrix, p::Real=2) = LinearAlgebra.norm(A, p) const norm = LinearAlgebra.vecnorm diff --git a/test/old.jl b/test/old.jl index ecdb2511a..6a2992895 100644 --- a/test/old.jl +++ b/test/old.jl @@ -1201,3 +1201,9 @@ let s = "∀α>β:α+1>β" end end end + +# 0.7.0-DEV.5278 +@test something(nothing, 1) === 1 +@test something(Some(2)) === 2 +@test something(Some(2), 1) === 2 +@test something(nothing, Some(1)) === 1 diff --git a/test/runtests.jl b/test/runtests.jl index 7ea0402a6..adf8522c7 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -80,12 +80,6 @@ let A = [1] @test x == 1 end -# 0.7.0-DEV.5278 -@test something(nothing, 1) === 1 -@test something(Some(2)) === 2 -@test something(Some(2), 1) === 2 -@test something(nothing, Some(1)) === 1 - # julia#24839 @test permutedims([1 2; 3 4]) == [1 3; 2 4] @test permutedims([1,2,3]) == [1 2 3] From b56b9234e9044fad59c65de1627c07dc62330528 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 19:19:24 +0200 Subject: [PATCH 105/121] Mark `Compat.norm` abd friends from #577 for deprecation --- README.md | 4 ---- src/Compat.jl | 15 ++++----------- test/old.jl | 8 ++++++++ test/runtests.jl | 8 -------- 4 files changed, 12 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 1ecc80774..75c3bdf95 100644 --- a/README.md +++ b/README.md @@ -82,10 +82,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `Compat.split` and `Compat.rsplit` accept `keepempty` keyword argument if `splitter` is given as second argument ([#26634]) -* `vecnorm` and `vecdot` are now `Compat.norm` and `Compat.dot`, respectively, while the - old `norm(A::AbstractMatrix, p=2)` is now `Compat.opnorm` ([#27401]). `import Compat: ⋅` - to get `Compat.dot` as the binary operator `⋅`. - * `atan2` is now a 2-argument method of `atan` ([#27253]). * `realmin` and `realmax` are now `floatmin` and `floatmax` ([#28302]) diff --git a/src/Compat.jl b/src/Compat.jl index bd12ec1e2..5e28e6cb2 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -53,6 +53,10 @@ import LibGit2 import UUIDs using LinearAlgebra: qr using LinearAlgebra: rmul! +const opnorm = LinearAlgebra.opnorm +const norm = LinearAlgebra.norm +const dot = LinearAlgebra.dot +const ⋅ = dot include("compatmacro.jl") @@ -78,17 +82,6 @@ end end end -if !isdefined(LinearAlgebra, :opnorm) # julia#27401 - opnorm(A::AbstractMatrix, p::Real=2) = LinearAlgebra.norm(A, p) - const norm = LinearAlgebra.vecnorm - const dot = LinearAlgebra.vecdot -else - const opnorm = LinearAlgebra.opnorm - const norm = LinearAlgebra.norm - const dot = LinearAlgebra.dot -end -const ⋅ = dot - if VERSION < v"0.7.0-DEV.2956" # julia#24839 Base.permutedims(A::AbstractMatrix) = permutedims(A, (2,1)) Base.permutedims(v::AbstractVector) = reshape(v, (1, length(v))) diff --git a/test/old.jl b/test/old.jl index 6a2992895..da97bf8b8 100644 --- a/test/old.jl +++ b/test/old.jl @@ -250,6 +250,14 @@ let A = [1 2; 3 4] @test Compat.rmul!(Diagonal(A), Diagonal([2, 1])) == Diagonal([8, 120]) end +# julia#27401 +import Compat: ⋅ +@test Compat.opnorm([1 2;3 4]) ≈ 5.464985704219043 +@test Compat.opnorm([1 2;3 4], 1) ≈ 6 +@test Compat.norm([1 2;3 4]) ≈ 5.477225575051661 +@test Compat.norm([1 2;3 4], 1) ≈ 10 +@test Compat.dot([1 2;3 4], [5 6;7 8]) == [1 2;3 4] ⋅ [5 6;7 8] ≈ 70 + # tests of removed functionality (i.e. justs tests Base) diff --git a/test/runtests.jl b/test/runtests.jl index adf8522c7..31ba3d835 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -84,14 +84,6 @@ end @test permutedims([1 2; 3 4]) == [1 3; 2 4] @test permutedims([1,2,3]) == [1 2 3] -# julia#27401 -import Compat: ⋅ -@test Compat.opnorm([1 2;3 4]) ≈ 5.464985704219043 -@test Compat.opnorm([1 2;3 4], 1) ≈ 6 -@test Compat.norm([1 2;3 4]) ≈ 5.477225575051661 -@test Compat.norm([1 2;3 4], 1) ≈ 10 -@test Compat.dot([1 2;3 4], [5 6;7 8]) == [1 2;3 4] ⋅ [5 6;7 8] ≈ 70 - # 0.7.0-alpha.44 @test atan(1, 2) == atan(0.5) @test atan(1.0, 2.0) == atan(0.5) From 77023ea5cbfb5a3609528c779a4d2c24eab9842b Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 19:20:51 +0200 Subject: [PATCH 106/121] Drop compat code for `permutedims` from #582 --- README.md | 2 -- src/Compat.jl | 5 ----- test/old.jl | 4 ++++ test/runtests.jl | 4 ---- 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 75c3bdf95..493e1bde6 100644 --- a/README.md +++ b/README.md @@ -68,8 +68,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `range` supporting `stop` as positional argument ([#28708]). -* Single-argument `permutedims(x)` for matrices and vectors ([#24839]). - * `mapslices` with `dims` keyword argument ([#27828]). * `hasproperty` and `hasfield` ([#28850]). diff --git a/src/Compat.jl b/src/Compat.jl index 5e28e6cb2..582c8ed5b 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -82,11 +82,6 @@ end end end -if VERSION < v"0.7.0-DEV.2956" # julia#24839 - Base.permutedims(A::AbstractMatrix) = permutedims(A, (2,1)) - Base.permutedims(v::AbstractVector) = reshape(v, (1, length(v))) -end - # https://github.com/JuliaLang/julia/pull/27253 @static if VERSION < v"0.7.0-alpha.44" Base.atan(x::Real, y::Real) = atan2(x, y) diff --git a/test/old.jl b/test/old.jl index da97bf8b8..3e9934ef1 100644 --- a/test/old.jl +++ b/test/old.jl @@ -1215,3 +1215,7 @@ end @test something(Some(2)) === 2 @test something(Some(2), 1) === 2 @test something(nothing, Some(1)) === 1 + +# julia#24839 +@test permutedims([1 2; 3 4]) == [1 3; 2 4] +@test permutedims([1,2,3]) == [1 2 3] diff --git a/test/runtests.jl b/test/runtests.jl index 31ba3d835..c7d6b7e9c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -80,10 +80,6 @@ let A = [1] @test x == 1 end -# julia#24839 -@test permutedims([1 2; 3 4]) == [1 3; 2 4] -@test permutedims([1,2,3]) == [1 2 3] - # 0.7.0-alpha.44 @test atan(1, 2) == atan(0.5) @test atan(1.0, 2.0) == atan(0.5) From d2367e9cbb6216ad4954d32fccf549181dd44706 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 19:22:09 +0200 Subject: [PATCH 107/121] Drop compat code for `atan` from #574 --- README.md | 2 -- src/Compat.jl | 5 ----- test/old.jl | 6 ++++++ test/runtests.jl | 6 ------ 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 493e1bde6..3eddd521a 100644 --- a/README.md +++ b/README.md @@ -80,8 +80,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `Compat.split` and `Compat.rsplit` accept `keepempty` keyword argument if `splitter` is given as second argument ([#26634]) -* `atan2` is now a 2-argument method of `atan` ([#27253]). - * `realmin` and `realmax` are now `floatmin` and `floatmax` ([#28302]) * `squeeze` is now `dropdims` ([#28303], [#26660]). diff --git a/src/Compat.jl b/src/Compat.jl index 582c8ed5b..4a4393c45 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -82,11 +82,6 @@ end end end -# https://github.com/JuliaLang/julia/pull/27253 -@static if VERSION < v"0.7.0-alpha.44" - Base.atan(x::Real, y::Real) = atan2(x, y) -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) = diff --git a/test/old.jl b/test/old.jl index 3e9934ef1..6f22334ec 100644 --- a/test/old.jl +++ b/test/old.jl @@ -1219,3 +1219,9 @@ end # julia#24839 @test permutedims([1 2; 3 4]) == [1 3; 2 4] @test permutedims([1,2,3]) == [1 2 3] + +# 0.7.0-alpha.44 +@test atan(1, 2) == atan(0.5) +@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") - π diff --git a/test/runtests.jl b/test/runtests.jl index c7d6b7e9c..f1bd0871d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -80,12 +80,6 @@ let A = [1] @test x == 1 end -# 0.7.0-alpha.44 -@test atan(1, 2) == atan(0.5) -@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) == [] From 9de49e69cde7bb36bb8986ea2886a0fa939258d8 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 19:24:14 +0200 Subject: [PATCH 108/121] Drop compat code for `split` and `rsplit` from #572 --- README.md | 3 --- src/Compat.jl | 8 -------- test/old.jl | 29 +++++++++++++++++++++++++++++ test/runtests.jl | 29 ----------------------------- 4 files changed, 29 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 3eddd521a..22547428d 100644 --- a/README.md +++ b/README.md @@ -77,9 +77,6 @@ Currently, the `@compat` macro supports the following syntaxes: ## Renaming -* `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]). diff --git a/src/Compat.jl b/src/Compat.jl index 4a4393c45..addd90f3b 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -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")) = diff --git a/test/old.jl b/test/old.jl index 6f22334ec..6962c12bb 100644 --- a/test/old.jl +++ b/test/old.jl @@ -1225,3 +1225,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 diff --git a/test/runtests.jl b/test/runtests.jl index f1bd0871d..5cd45f19f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -80,35 +80,6 @@ let A = [1] @test x == 1 end -# 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 From 0388309c3470cf2f1532b37549f539a976ca10fd Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 19:25:29 +0200 Subject: [PATCH 109/121] Drop compat code for `mapslices` from #588 --- README.md | 2 -- src/Compat.jl | 6 ------ test/old.jl | 10 ++++++++++ test/runtests.jl | 10 ---------- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 22547428d..78d3ded4f 100644 --- a/README.md +++ b/README.md @@ -68,8 +68,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `range` supporting `stop` as positional argument ([#28708]). -* `mapslices` with `dims` keyword argument ([#27828]). - * `hasproperty` and `hasfield` ([#28850]). `hasproperty` is defined only for Julia 0.7 or later. diff --git a/src/Compat.jl b/src/Compat.jl index addd90f3b..3d27c829c 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -82,12 +82,6 @@ end end 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")) = - mapslices(f, A, dims) -end - # https://github.com/JuliaLang/julia/pull/28302 if VERSION < v"0.7.0-beta2.169" const floatmin = realmin diff --git a/test/old.jl b/test/old.jl index 6962c12bb..af3edd6fd 100644 --- a/test/old.jl +++ b/test/old.jl @@ -1254,3 +1254,13 @@ let @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 + +# 0.7.0-beta.73 +let a = rand(5,5) + s = mapslices(sort, a, dims=[1]) + S = mapslices(sort, a, dims=[2]) + for i = 1:5 + @test s[:,i] == sort(a[:,i]) + @test vec(S[i,:]) == sort(vec(a[i,:])) + end +end diff --git a/test/runtests.jl b/test/runtests.jl index 5cd45f19f..cf416b7c1 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -98,16 +98,6 @@ let @test_throws UndefKeywordError func5(x=2) end -# 0.7.0-beta.73 -let a = rand(5,5) - s = mapslices(sort, a, dims=[1]) - S = mapslices(sort, a, dims=[2]) - for i = 1:5 - @test s[:,i] == sort(a[:,i]) - @test vec(S[i,:]) == sort(vec(a[i,:])) - end -end - # 0.7.0-beta2.169 @test floatmin(Float16) == @eval $(Core.Intrinsics.bitcast(Float16, 0x0400)) @test floatmax(Float32) == @eval $(Core.Intrinsics.bitcast(Float32, 0x7f7fffff)) From f886239dfb7f3fa6d0aa17ae8e7fd6d525b27528 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 19:27:01 +0200 Subject: [PATCH 110/121] Drop compat code for `floatmin` and `floatmax` from #607 --- README.md | 2 -- src/Compat.jl | 7 ------- test/old.jl | 5 +++++ test/runtests.jl | 5 ----- 4 files changed, 5 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 78d3ded4f..c8ace34ca 100644 --- a/README.md +++ b/README.md @@ -75,8 +75,6 @@ Currently, the `@compat` macro supports the following syntaxes: ## Renaming -* `realmin` and `realmax` are now `floatmin` and `floatmax` ([#28302]) - * `squeeze` is now `dropdims` ([#28303], [#26660]). ## New macros diff --git a/src/Compat.jl b/src/Compat.jl index 3d27c829c..ec6bf1596 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -82,13 +82,6 @@ end end end -# https://github.com/JuliaLang/julia/pull/28302 -if VERSION < v"0.7.0-beta2.169" - const floatmin = realmin - const floatmax = realmax - export floatmin, floatmax -end - # https://github.com/JuliaLang/julia/pull/28303 if VERSION < v"0.7.0-beta2.143" export dropdims diff --git a/test/old.jl b/test/old.jl index af3edd6fd..80ee36f1b 100644 --- a/test/old.jl +++ b/test/old.jl @@ -1264,3 +1264,8 @@ let a = rand(5,5) @test vec(S[i,:]) == sort(vec(a[i,:])) end end + +# 0.7.0-beta2.169 +@test floatmin(Float16) == @eval $(Core.Intrinsics.bitcast(Float16, 0x0400)) +@test floatmax(Float32) == @eval $(Core.Intrinsics.bitcast(Float32, 0x7f7fffff)) +@test floatmin(zero(Float64)) == floatmin(Float64) diff --git a/test/runtests.jl b/test/runtests.jl index cf416b7c1..3b55ed3fc 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -98,11 +98,6 @@ let @test_throws UndefKeywordError func5(x=2) end -# 0.7.0-beta2.169 -@test floatmin(Float16) == @eval $(Core.Intrinsics.bitcast(Float16, 0x0400)) -@test floatmax(Float32) == @eval $(Core.Intrinsics.bitcast(Float32, 0x7f7fffff)) -@test floatmin(zero(Float64)) == floatmin(Float64) - # 0.7.0-beta2.143 if VERSION < v"0.7.0-beta2.143" let a = reshape(Vector(1:4),(2,2,1,1)), b = reshape(Vector(1:4), (2,2,1)) From 532c69880be8a3f27e2007f39381b9e927469458 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 19:29:09 +0200 Subject: [PATCH 111/121] Drop compat code for `dropdims` from #618 --- README.md | 2 -- src/Compat.jl | 19 ------------------- test/old.jl | 8 ++++++++ test/runtests.jl | 8 -------- 4 files changed, 8 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index c8ace34ca..7781ffa45 100644 --- a/README.md +++ b/README.md @@ -75,8 +75,6 @@ Currently, the `@compat` macro supports the following syntaxes: ## Renaming -* `squeeze` is now `dropdims` ([#28303], [#26660]). - ## New macros ## Other changes diff --git a/src/Compat.jl b/src/Compat.jl index ec6bf1596..95961b7bd 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -82,25 +82,6 @@ end end end -# https://github.com/JuliaLang/julia/pull/28303 -if VERSION < v"0.7.0-beta2.143" - export dropdims - # https://github.com/JuliaLang/julia/pull/26660 - if VERSION >= v"0.7.0-DEV.4738" - dropdims( - X; - dims = throw( - UndefKeywordError("dropdims: keyword argument dims not assigned")) - ) = squeeze(X, dims = dims) - else - dropdims( - X; - dims = throw( - UndefKeywordError("dropdims: keyword argument dims not assigned")) - ) = squeeze(X, dims) - end -end - function rangedepwarn(;step=nothing, length=nothing, kwargs...) if step===nothing && length===nothing Base.depwarn("`range(start, stop)` (with neither `length` nor `step` given) is deprecated, use `range(start, stop=stop)` instead.", :range) diff --git a/test/old.jl b/test/old.jl index 80ee36f1b..771f941c0 100644 --- a/test/old.jl +++ b/test/old.jl @@ -1269,3 +1269,11 @@ end @test floatmin(Float16) == @eval $(Core.Intrinsics.bitcast(Float16, 0x0400)) @test floatmax(Float32) == @eval $(Core.Intrinsics.bitcast(Float32, 0x7f7fffff)) @test floatmin(zero(Float64)) == floatmin(Float64) + +# 0.7.0-beta2.143 +if VERSION < v"0.7.0-beta2.143" + let a = reshape(Vector(1:4),(2,2,1,1)), b = reshape(Vector(1:4), (2,2,1)) + @test dropdims(a; dims=3) == b + @test_throws UndefKeywordError dropdims(a) + end +end diff --git a/test/runtests.jl b/test/runtests.jl index 3b55ed3fc..2ca3cc0d3 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -98,14 +98,6 @@ let @test_throws UndefKeywordError func5(x=2) end -# 0.7.0-beta2.143 -if VERSION < v"0.7.0-beta2.143" - let a = reshape(Vector(1:4),(2,2,1,1)), b = reshape(Vector(1:4), (2,2,1)) - @test dropdims(a; dims=3) == b - @test_throws UndefKeywordError dropdims(a) - end -end - # Support for positional `stop` @test Compat.range(0, 5, length = 6) == 0.0:1.0:5.0 @test Compat.range(0, 10, step = 2) == 0:2:10 From 072b0f7c3c2bcdd6b7b2ed82f49721d8276f3d47 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 19:58:58 +0200 Subject: [PATCH 112/121] Drop compat code for required keyword arguments from #586 --- README.md | 2 -- src/compatmacro.jl | 18 ------------------ test/old.jl | 18 ++++++++++++++++++ test/runtests.jl | 18 ------------------ 4 files changed, 18 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 7781ffa45..53c47bf9b 100644 --- a/README.md +++ b/README.md @@ -48,8 +48,6 @@ Currently, the `@compat` macro supports the following syntaxes: `CartesianRange` now has two type parameters, so using them as fields in other `struct`s requires manual intervention. -* Required keyword arguments ([#25830]). For example, `@compat foo(; x, y)` makes `x` and `y` required keyword arguments: when calling `foo`, an error is thrown if `x` or `y` is not explicitly provided. - ## Module Aliases ## New functions, macros, and methods diff --git a/src/compatmacro.jl b/src/compatmacro.jl index 09234c613..97a78771b 100644 --- a/src/compatmacro.jl +++ b/src/compatmacro.jl @@ -4,27 +4,9 @@ using Base.Meta export @compat -if !isdefined(Base, :UndefKeywordError) - struct UndefKeywordError <: Exception - kw - end - Base.showerror(io::IO, e::UndefKeywordError) = print(io, "UndefKeywordError: keyword argument $(e.kw) not assigned") - export UndefKeywordError -end - -"Convert a functions symbol argument to the corresponding required keyword argument." -function symbol2kw(sym::Symbol) - Expr(:kw, sym, Expr(:call, throw, UndefKeywordError(sym))) -end -symbol2kw(arg) = arg - function _compat(ex::Expr) if ex.head === :call f = ex.args[1] - if !isdefined(Base, :UndefKeywordError) && length(ex.args) > 1 && isexpr(ex.args[2], :parameters) - params = ex.args[2] - params.args = map(symbol2kw, params.args) - end elseif ex.head === :quote && isa(ex.args[1], Symbol) # Passthrough return ex diff --git a/test/old.jl b/test/old.jl index 771f941c0..a91c7e63a 100644 --- a/test/old.jl +++ b/test/old.jl @@ -1277,3 +1277,21 @@ if VERSION < v"0.7.0-beta2.143" @test_throws UndefKeywordError dropdims(a) end end + +let + # test required keyword arguments + @compat func1() = 1 + @test func1() == 1 # using the function works + @compat func2(x) = x + @test func2(3) == 3 # using the function works + @compat func3(;y) = y + @test func3(y=2) == 2 # using the function works + @test_throws UndefKeywordError func3() + @compat func4(x; z) = x*z + @test func4(2,z=3) == 6 # using the function works + @test_throws UndefKeywordError func4(2) + @compat func5(;x=1, y) = x*y + @test func5(y=3) == 3 + @test func5(y=3, x=2) == 6 + @test_throws UndefKeywordError func5(x=2) +end diff --git a/test/runtests.jl b/test/runtests.jl index 2ca3cc0d3..d42344f60 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -80,24 +80,6 @@ let A = [1] @test x == 1 end -let - # test required keyword arguments - @compat func1() = 1 - @test func1() == 1 # using the function works - @compat func2(x) = x - @test func2(3) == 3 # using the function works - @compat func3(;y) = y - @test func3(y=2) == 2 # using the function works - @test_throws UndefKeywordError func3() - @compat func4(x; z) = x*z - @test func4(2,z=3) == 6 # using the function works - @test_throws UndefKeywordError func4(2) - @compat func5(;x=1, y) = x*y - @test func5(y=3) == 3 - @test func5(y=3, x=2) == 6 - @test_throws UndefKeywordError func5(x=2) -end - # Support for positional `stop` @test Compat.range(0, 5, length = 6) == 0.0:1.0:5.0 @test Compat.range(0, 10, step = 2) == 0:2:10 From c0239a3bd176e8424bc07ee2b364ca93e2c85e0a Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 20:24:26 +0200 Subject: [PATCH 113/121] Drop compat code for `CartesianRange` in `at-compat` from #377 --- README.md | 5 ----- src/compatmacro.jl | 8 -------- test/old.jl | 6 ++++++ test/runtests.jl | 14 -------------- 4 files changed, 6 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 53c47bf9b..2b28733e4 100644 --- a/README.md +++ b/README.md @@ -43,11 +43,6 @@ Please check the list below for the specific syntax you need. Currently, the `@compat` macro supports the following syntaxes: -* `@compat foo(::CartesianRange{N})` to replace the former - `foo(::CartesianRange{CartesianIndex{N}})` ([#20974]). Note that - `CartesianRange` now has two type parameters, so using them as - fields in other `struct`s requires manual intervention. - ## Module Aliases ## New functions, macros, and methods diff --git a/src/compatmacro.jl b/src/compatmacro.jl index 97a78771b..28714935d 100644 --- a/src/compatmacro.jl +++ b/src/compatmacro.jl @@ -11,14 +11,6 @@ function _compat(ex::Expr) # Passthrough return ex end - if VERSION < v"0.7.0-DEV.880" - if ex.head == :curly && ex.args[1] == :CartesianRange && length(ex.args) >= 2 - a = ex.args[2] - if a != :CartesianIndex && !(isa(a, Expr) && a.head == :curly && a.args[1] == :CartesianIndex) - return Expr(:curly, :CartesianRange, Expr(:curly, :CartesianIndex, ex.args[2])) - end - end - end if VERSION < v"0.7.0-DEV.2562" if ex.head == :call && ex.args[1] == :finalizer ex.args[2], ex.args[3] = ex.args[3], ex.args[2] diff --git a/test/old.jl b/test/old.jl index a91c7e63a..6df6d0a95 100644 --- a/test/old.jl +++ b/test/old.jl @@ -1295,3 +1295,9 @@ let @test func5(y=3, x=2) == 6 @test_throws UndefKeywordError func5(x=2) end + +let + @compat cr(::CartesianIndices{2}) = 2 + @test cr(CartesianIndices((5, 3))) == 2 + @test_throws MethodError cr(CartesianIndices((5, 3, 2))) +end diff --git a/test/runtests.jl b/test/runtests.jl index d42344f60..0bcac8e69 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -55,20 +55,6 @@ for x in (3.1, -17, 3//4, big(111.1), Inf) @test minmax(x) == (x, x) end -let - @compat cr(::CartesianIndices{2}) = 2 - @test cr(CartesianIndices((5, 3))) == 2 - @test_throws MethodError cr(CartesianIndices((5, 3, 2))) -end -if VERSION < v"0.7.0-DEV.880" - # ensure we don't bork any non-updated expressions - let - @compat cr(::CartesianRange{CartesianIndex{2}}) = 2 - @test cr(CartesianRange((5, 3))) == 2 - @test_throws MethodError cr(CartesianRange((5, 3, 2))) - end -end - # 0.7 let A = [1] local x = 0 From 831f7e023c2a614f671c512c40c4cf48749816a3 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 20:27:20 +0200 Subject: [PATCH 114/121] Drop compat code for `finalizer` from #416 --- README.md | 3 --- src/compatmacro.jl | 5 ----- test/old.jl | 11 +++++++++++ test/runtests.jl | 11 ----------- 4 files changed, 11 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 2b28733e4..5d0a79816 100644 --- a/README.md +++ b/README.md @@ -56,9 +56,6 @@ Currently, the `@compat` macro supports the following syntaxes: * `isnothing` for testing if a variable is equal to `nothing` ([#29674]). -* `@compat finalizer(func, obj)` with the finalizer to run as the first argument and the object to be finalized - as the second ([#24605]). - * `range` supporting `stop` as positional argument ([#28708]). * `hasproperty` and `hasfield` ([#28850]). diff --git a/src/compatmacro.jl b/src/compatmacro.jl index 28714935d..b8167a7bf 100644 --- a/src/compatmacro.jl +++ b/src/compatmacro.jl @@ -11,11 +11,6 @@ function _compat(ex::Expr) # Passthrough return ex end - if VERSION < v"0.7.0-DEV.2562" - if ex.head == :call && ex.args[1] == :finalizer - ex.args[2], ex.args[3] = ex.args[3], ex.args[2] - end - end return Expr(ex.head, map(_compat, ex.args)...) end diff --git a/test/old.jl b/test/old.jl index 6df6d0a95..dab17180e 100644 --- a/test/old.jl +++ b/test/old.jl @@ -1301,3 +1301,14 @@ let @test cr(CartesianIndices((5, 3))) == 2 @test_throws MethodError cr(CartesianIndices((5, 3, 2))) end + +# 0.7 +let A = [1] + local x = 0 + @compat finalizer(a->(x+=1), A) + finalize(A) + @test x == 1 + A = 0 + GC.gc(); GC.gc() + @test x == 1 +end diff --git a/test/runtests.jl b/test/runtests.jl index 0bcac8e69..8c2e62d12 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -55,17 +55,6 @@ for x in (3.1, -17, 3//4, big(111.1), Inf) @test minmax(x) == (x, x) end -# 0.7 -let A = [1] - local x = 0 - @compat finalizer(a->(x+=1), A) - finalize(A) - @test x == 1 - A = 0 - GC.gc(); GC.gc() - @test x == 1 -end - # Support for positional `stop` @test Compat.range(0, 5, length = 6) == 0.0:1.0:5.0 @test Compat.range(0, 10, step = 2) == 0:2:10 From bc6bd70f78388f7a596ddc5a36ee6964b336910b Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 20:37:48 +0200 Subject: [PATCH 115/121] Remove obsolete README entry, missed in #385 --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 5d0a79816..fa2fe1338 100644 --- a/README.md +++ b/README.md @@ -69,8 +69,6 @@ Currently, the `@compat` macro supports the following syntaxes: ## Other changes -* On versions of Julia that do not contain a Base.Threads module, Compat defines a Threads module containing a no-op `@threads` macro. - ## New types ## Developer tips From 3b0afb90a96e3122a29f7cc6191f733cbf45c2b3 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 20:55:40 +0200 Subject: [PATCH 116/121] Remove long obsolete tests (missed in #372) --- test/runtests.jl | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 8c2e62d12..35ddf4fdd 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -7,16 +7,6 @@ using Compat.SparseArrays const struct_sym = VERSION < v"0.7.0-DEV.1263" ? :type : :struct -let s = "Koala test: 🐨" - @test transcode(UInt16, s) == UInt16[75,111,97,108,97,32,116,101,115,116,58,32,55357,56360] - @test transcode(UInt32, s) == UInt32[75,111,97,108,97,32,116,101,115,116,58,32,128040] - for T in (UInt8,UInt16,UInt32,Cwchar_t) - @test transcode(Compat.String, transcode(T, s)) == s - @test transcode(UInt8, transcode(T, s)) == codeunits(s) - @test transcode(T, s) == transcode(T, codeunits(s)) == transcode(T, transcode(T, s)) - end -end - # julia#29679 @test !isnothing(1) @test isnothing(nothing) @@ -38,23 +28,6 @@ if VERSION >= v"0.7" end end -let - x = view(1:10, 2:4) - D = Diagonal(x) - @test D[1,1] == 2 - @test D[3,3] == 4 - A = view(rand(5,5), 1:3, 1:3) - @test D*A == Diagonal(copy(x)) * copy(A) - @test A*D == copy(A) * Diagonal(copy(x)) -end - -# julia#13998 -for x in (3.1, -17, 3//4, big(111.1), Inf) - local x - @test min(x) == max(x) == x - @test minmax(x) == (x, x) -end - # Support for positional `stop` @test Compat.range(0, 5, length = 6) == 0.0:1.0:5.0 @test Compat.range(0, 10, step = 2) == 0:2:10 From f64e5161620a484a544ddb8f901bbe8639fbf58d Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 21:06:47 +0200 Subject: [PATCH 117/121] Remove obsolete `VERSION` conditionals And some minor clean-up. --- src/Compat.jl | 16 ++---- src/compatmacro.jl | 5 +- src/deprecated.jl | 61 +++++--------------- test/old.jl | 4 ++ test/runtests.jl | 140 ++++++++++++++++++++------------------------- 5 files changed, 88 insertions(+), 138 deletions(-) diff --git a/src/Compat.jl b/src/Compat.jl index 95961b7bd..fcbd31f85 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -1,5 +1,3 @@ -VERSION < v"0.7.0-beta2.199" && __precompile__() - module Compat # to be deprecated @@ -69,7 +67,7 @@ if VERSION < v"1.1.0-DEV.472" end # https://github.com/JuliaLang/julia/pull/29749 -@static if v"0.7" <= VERSION < v"1.1.0-DEV.792" +@static if VERSION < v"1.1.0-DEV.792" export eachrow, eachcol, eachslice eachrow(A::AbstractVecOrMat) = (view(A, i, :) for i in axes(A, 1)) eachcol(A::AbstractVecOrMat) = (view(A, :, i) for i in axes(A, 2)) @@ -100,20 +98,18 @@ if VERSION < v"1.2.0-DEV.272" Base.@pure hasfield(::Type{T}, name::Symbol) where T = Base.fieldindex(T, name, false) > 0 export hasfield - if VERSION >= v"0.7-DEV.5136" - hasproperty(x, s::Symbol) = s in propertynames(x) - export hasproperty - end + hasproperty(x, s::Symbol) = s in propertynames(x) + export hasproperty end # https://github.com/JuliaLang/julia/pull/29259 -if v"0.7.0" <= VERSION < v"1.1.0-DEV.594" +if VERSION < v"1.1.0-DEV.594" Base.merge(a::NamedTuple, b::NamedTuple, cs::NamedTuple...) = merge(merge(a, b), cs...) Base.merge(a::NamedTuple) = a end # https://github.com/JuliaLang/julia/pull/33129 -if v"0.7.0" <= VERSION < v"1.4.0-DEV.142" +if VERSION < v"1.4.0-DEV.142" export only Base.@propagate_inbounds function only(x) @@ -144,7 +140,7 @@ if v"0.7.0" <= VERSION < v"1.4.0-DEV.142" end # https://github.com/JuliaLang/julia/pull/32628 -if v"0.7.0" <= VERSION < v"1.3.0-alpha.8" +if VERSION < v"1.3.0-alpha.8" Base.mod(i::Integer, r::Base.OneTo) = mod1(i, last(r)) Base.mod(i::Integer, r::AbstractUnitRange{<:Integer}) = mod(i-first(r), length(r)) + first(r) end diff --git a/src/compatmacro.jl b/src/compatmacro.jl index b8167a7bf..0d44b6bc6 100644 --- a/src/compatmacro.jl +++ b/src/compatmacro.jl @@ -1,13 +1,10 @@ # The @compat macro is used to implement compatibility rules that require # syntax rewriting rather than simply new function/constant/module definitions. -using Base.Meta export @compat function _compat(ex::Expr) - if ex.head === :call - f = ex.args[1] - elseif ex.head === :quote && isa(ex.args[1], Symbol) + if ex.head === :quote && isa(ex.args[1], Symbol) # Passthrough return ex end diff --git a/src/deprecated.jl b/src/deprecated.jl index e0d937245..5a437eba6 100644 --- a/src/deprecated.jl +++ b/src/deprecated.jl @@ -8,52 +8,21 @@ Base.@deprecate_binding StringVector Base.StringVector false # of the deprecated vectorized function have migrated. # These macros should be dropped when the support for `0.6` is dropped from `Compat`. # Modified based on the version copied from 0.6 Base. -if VERSION < v"0.7.0-DEV.1211" - macro dep_vectorize_1arg(S, f) - S = esc(S) - f = esc(f) - T = esc(:T) - x = esc(:x) - AbsArr = esc(:AbstractArray) - Base.depwarn("Implicit vectorized function is deprecated in favor of compact broadcast syntax.", - Symbol("@dep_vectorize_1arg")) - :(@deprecate $f{$T<:$S}($x::$AbsArr{$T}) @compat($f.($x))) - end - - macro dep_vectorize_2arg(S, f) - S = esc(S) - f = esc(f) - T1 = esc(:T1) - T2 = esc(:T2) - x = esc(:x) - y = esc(:y) - AbsArr = esc(:AbstractArray) - Base.depwarn("Implicit vectorized function is deprecated in favor of compact broadcast syntax.", - Symbol("@dep_vectorize_2arg")) - quote - @deprecate $f{$T1<:$S}($x::$S, $y::$AbsArr{$T1}) @compat($f.($x,$y)) - @deprecate $f{$T1<:$S}($x::$AbsArr{$T1}, $y::$S) @compat($f.($x,$y)) - @deprecate $f{$T1<:$S,$T2<:$S}($x::$AbsArr{$T1}, $y::$AbsArr{$T2}) @compat($f.($x,$y)) - end - end -else - macro dep_vectorize_1arg(S, f) - AbstractArray = GlobalRef(Base, :AbstractArray) - Base.depwarn("Implicit vectorized function is deprecated in favor of compact broadcast syntax.", - Symbol("@dep_vectorize_1arg")) - return esc(:(@deprecate $f(x::$AbstractArray{T}) where {T<:$S} $f.(x))) - end - - macro dep_vectorize_2arg(S, f) - AbstractArray = GlobalRef(Base, :AbstractArray) - Base.depwarn("Implicit vectorized function is deprecated in favor of compact broadcast syntax.", - Symbol("@dep_vectorize_2arg")) - return esc(quote - @deprecate $f(x::$S, y::$AbstractArray{T1}) where {T1<:$S} $f.(x, y) - @deprecate $f(x::$AbstractArray{T1}, y::$S) where {T1<:$S} $f.(x, y) - @deprecate $f(x::$AbstractArray{T1}, y::$AbstractArray{T2}) where {T1<:$S, T2<:$S} $f.(x, y) - end) - end +macro dep_vectorize_1arg(S, f) + AbstractArray = GlobalRef(Base, :AbstractArray) + Base.depwarn("Implicit vectorized function is deprecated in favor of compact broadcast syntax.", + Symbol("@dep_vectorize_1arg")) + return esc(:(@deprecate $f(x::$AbstractArray{T}) where {T<:$S} $f.(x))) +end +macro dep_vectorize_2arg(S, f) + AbstractArray = GlobalRef(Base, :AbstractArray) + Base.depwarn("Implicit vectorized function is deprecated in favor of compact broadcast syntax.", + Symbol("@dep_vectorize_2arg")) + return esc(quote + @deprecate $f(x::$S, y::$AbstractArray{T1}) where {T1<:$S} $f.(x, y) + @deprecate $f(x::$AbstractArray{T1}, y::$S) where {T1<:$S} $f.(x, y) + @deprecate $f(x::$AbstractArray{T1}, y::$AbstractArray{T2}) where {T1<:$S, T2<:$S} $f.(x, y) + end) end # compatibility with https://github.com/JuliaLang/julia/pull/26156 diff --git a/test/old.jl b/test/old.jl index dab17180e..9357258b1 100644 --- a/test/old.jl +++ b/test/old.jl @@ -1,5 +1,7 @@ # tests of functionality to be deprecated +using Compat.LinearAlgebra + # 0.7.0-DEV.3666 module TestSockets using Compat @@ -261,6 +263,8 @@ import Compat: ⋅ # tests of removed functionality (i.e. justs tests Base) +using Compat.SparseArrays + # 25959 @test all(x -> isa(x, IO), (devnull, stdin, stdout, stderr)) @static if !isdefined(Base, :devnull) diff --git a/test/runtests.jl b/test/runtests.jl index 35ddf4fdd..095c3c741 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,31 +1,25 @@ using Compat -using Compat.Test -using Compat.LinearAlgebra -using Compat.SparseArrays +using Test @test isempty(detect_ambiguities(Base, Core, Compat)) -const struct_sym = VERSION < v"0.7.0-DEV.1263" ? :type : :struct - # julia#29679 @test !isnothing(1) @test isnothing(nothing) # https://github.com/JuliaLang/julia/pull/29749 -if VERSION >= v"0.7" - @testset "row/column/slice iterators" begin - # Simple ones - M = [1 2 3; 4 5 6; 7 8 9] - @test collect(eachrow(M)) == collect(eachslice(M, dims = 1)) == [[1, 2, 3], [4, 5, 6], [7, 8, 9]] - @test collect(eachcol(M)) == collect(eachslice(M, dims = 2)) == [[1, 4, 7], [2, 5, 8], [3, 6, 9]] - @test_throws DimensionMismatch eachslice(M, dims = 4) - - # Higher-dimensional case - M = reshape([(1:16)...], 2, 2, 2, 2) - @test_throws MethodError collect(eachrow(M)) - @test_throws MethodError collect(eachcol(M)) - @test collect(eachslice(M, dims = 1))[1][:, :, 1] == [1 5; 3 7] - end +@testset "row/column/slice iterators" begin + # Simple ones + M = [1 2 3; 4 5 6; 7 8 9] + @test collect(eachrow(M)) == collect(eachslice(M, dims = 1)) == [[1, 2, 3], [4, 5, 6], [7, 8, 9]] + @test collect(eachcol(M)) == collect(eachslice(M, dims = 2)) == [[1, 4, 7], [2, 5, 8], [3, 6, 9]] + @test_throws DimensionMismatch eachslice(M, dims = 4) + + # Higher-dimensional case + M = reshape([(1:16)...], 2, 2, 2, 2) + @test_throws MethodError collect(eachrow(M)) + @test_throws MethodError collect(eachcol(M)) + @test collect(eachslice(M, dims = 1))[1][:, :, 1] == [1 5; 3 7] end # Support for positional `stop` @@ -40,69 +34,59 @@ end tlayout = TLayout(5,7,11) @test hasfield(TLayout, :y) @test !hasfield(TLayout, :a) -if VERSION >= v"0.7-" - @test hasproperty(tlayout, :x) - @test !hasproperty(tlayout, :p) -end - -@static if VERSION >= v"0.7.0" - @test merge((a=1,b=1)) == (a=1,b=1) - @test merge((a=1,), (b=2,), (c=3,)) == (a=1,b=2,c=3) -end - -@static if VERSION >= v"0.7.0" - @testset "only" begin - @test only([3]) === 3 - @test_throws ArgumentError only([]) - @test_throws ArgumentError only([3, 2]) - - @test @inferred(only((3,))) === 3 - @test_throws ArgumentError only(()) - @test_throws ArgumentError only((3, 2)) - - @test only(Dict(1=>3)) === (1=>3) - @test_throws ArgumentError only(Dict{Int,Int}()) - @test_throws ArgumentError only(Dict(1=>3, 2=>2)) - - @test only(Set([3])) === 3 - @test_throws ArgumentError only(Set(Int[])) - @test_throws ArgumentError only(Set([3,2])) - - @test @inferred(only((;a=1))) === 1 - @test_throws ArgumentError only(NamedTuple()) - @test_throws ArgumentError only((a=3, b=2.0)) - - @test @inferred(only(1)) === 1 - @test @inferred(only('a')) === 'a' - if VERSION >= v"1.0" - @test @inferred(only(Ref([1, 2]))) == [1, 2] # Fails on v0.7, depwarn "`Ref(x::AbstractArray)` is deprecated, use `Ref(x, 1)` instead." - end - @test_throws ArgumentError only(Pair(10, 20)) - - @test only(1 for ii in 1:1) === 1 - @test only(1 for ii in 1:10 if ii < 2) === 1 - @test_throws ArgumentError only(1 for ii in 1:10) - @test_throws ArgumentError only(1 for ii in 1:10 if ii > 2) - @test_throws ArgumentError only(1 for ii in 1:10 if ii > 200) - end +@test hasproperty(tlayout, :x) +@test !hasproperty(tlayout, :p) + +@test merge((a=1,b=1)) == (a=1,b=1) +@test merge((a=1,), (b=2,), (c=3,)) == (a=1,b=2,c=3) + +@testset "only" begin + @test only([3]) === 3 + @test_throws ArgumentError only([]) + @test_throws ArgumentError only([3, 2]) + + @test @inferred(only((3,))) === 3 + @test_throws ArgumentError only(()) + @test_throws ArgumentError only((3, 2)) + + @test only(Dict(1=>3)) === (1=>3) + @test_throws ArgumentError only(Dict{Int,Int}()) + @test_throws ArgumentError only(Dict(1=>3, 2=>2)) + + @test only(Set([3])) === 3 + @test_throws ArgumentError only(Set(Int[])) + @test_throws ArgumentError only(Set([3,2])) + + @test @inferred(only((;a=1))) === 1 + @test_throws ArgumentError only(NamedTuple()) + @test_throws ArgumentError only((a=3, b=2.0)) + + @test @inferred(only(1)) === 1 + @test @inferred(only('a')) === 'a' + @test @inferred(only(Ref([1, 2]))) == [1, 2] + @test_throws ArgumentError only(Pair(10, 20)) + + @test only(1 for ii in 1:1) === 1 + @test only(1 for ii in 1:10 if ii < 2) === 1 + @test_throws ArgumentError only(1 for ii in 1:10) + @test_throws ArgumentError only(1 for ii in 1:10 if ii > 2) + @test_throws ArgumentError only(1 for ii in 1:10 if ii > 200) end # https://github.com/JuliaLang/julia/pull/32628 -if VERSION >= v"0.7" - @testset "mod with ranges" begin - for n in -10:10 - @test mod(n, 0:4) == mod(n, 5) - @test mod(n, 1:5) == mod1(n, 5) - @test mod(n, 2:6) == 2 + mod(n-2, 5) - @test mod(n, Base.OneTo(5)) == mod1(n, 5) - end - @test mod(Int32(3), 1:5) == 3 - @test mod(big(typemax(Int))+99, 0:4) == mod(big(typemax(Int))+99, 5) - @test_throws MethodError mod(3.141, 1:5) - @test_throws MethodError mod(3, UnitRange(1.0,5.0)) - @test_throws MethodError mod(3, 1:2:7) - @test_throws DivideError mod(3, 1:0) +@testset "mod with ranges" begin + for n in -10:10 + @test mod(n, 0:4) == mod(n, 5) + @test mod(n, 1:5) == mod1(n, 5) + @test mod(n, 2:6) == 2 + mod(n-2, 5) + @test mod(n, Base.OneTo(5)) == mod1(n, 5) end + @test mod(Int32(3), 1:5) == 3 + @test mod(big(typemax(Int))+99, 0:4) == mod(big(typemax(Int))+99, 5) + @test_throws MethodError mod(3.141, 1:5) + @test_throws MethodError mod(3, UnitRange(1.0,5.0)) + @test_throws MethodError mod(3, 1:2:7) + @test_throws DivideError mod(3, 1:0) end include("old.jl") From 64d951dab03a5fafac7a7b9792c2f84ca890add6 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 21:09:04 +0200 Subject: [PATCH 118/121] Update link list in README --- README.md | 129 +----------------------------------------------------- 1 file changed, 1 insertion(+), 128 deletions(-) diff --git a/README.md b/README.md index fa2fe1338..0b1a801d4 100644 --- a/README.md +++ b/README.md @@ -120,137 +120,10 @@ includes this fix. Find the minimum version from there. * Now specify the correct minimum version for Compat in your REQUIRE file by `Compat ` -[#20005]: https://github.com/JuliaLang/julia/issues/20005 -[#20974]: https://github.com/JuliaLang/julia/issues/20974 -[#21197]: https://github.com/JuliaLang/julia/issues/21197 -[#21709]: https://github.com/JuliaLang/julia/issues/21709 -[#22064]: https://github.com/JuliaLang/julia/issues/22064 -[#22182]: https://github.com/JuliaLang/julia/issues/22182 -[#22350]: https://github.com/JuliaLang/julia/issues/22350 -[#22435]: https://github.com/JuliaLang/julia/issues/22435 -[#22475]: https://github.com/JuliaLang/julia/issues/22475 -[#22512]: https://github.com/JuliaLang/julia/issues/22512 -[#22629]: https://github.com/JuliaLang/julia/issues/22629 -[#22646]: https://github.com/JuliaLang/julia/issues/22646 -[#22666]: https://github.com/JuliaLang/julia/issues/22666 -[#22751]: https://github.com/JuliaLang/julia/issues/22751 -[#22761]: https://github.com/JuliaLang/julia/issues/22761 -[#22864]: https://github.com/JuliaLang/julia/issues/22864 -[#22907]: https://github.com/JuliaLang/julia/issues/22907 -[#23051]: https://github.com/JuliaLang/julia/issues/23051 -[#23235]: https://github.com/JuliaLang/julia/issues/23235 -[#23271]: https://github.com/JuliaLang/julia/issues/23271 -[#23412]: https://github.com/JuliaLang/julia/issues/23412 -[#23427]: https://github.com/JuliaLang/julia/issues/23427 -[#23570]: https://github.com/JuliaLang/julia/issues/23570 -[#23642]: https://github.com/JuliaLang/julia/issues/23642 -[#23666]: https://github.com/JuliaLang/julia/issues/23666 -[#23667]: https://github.com/JuliaLang/julia/issues/23667 -[#23757]: https://github.com/JuliaLang/julia/issues/23757 -[#23805]: https://github.com/JuliaLang/julia/issues/23805 -[#23931]: https://github.com/JuliaLang/julia/issues/23931 -[#24047]: https://github.com/JuliaLang/julia/issues/24047 -[#24182]: https://github.com/JuliaLang/julia/issues/24182 -[#24282]: https://github.com/JuliaLang/julia/issues/24282 -[#24361]: https://github.com/JuliaLang/julia/issues/24361 -[#24372]: https://github.com/JuliaLang/julia/issues/24372 -[#24414]: https://github.com/JuliaLang/julia/issues/24414 -[#24443]: https://github.com/JuliaLang/julia/issues/24443 -[#24459]: https://github.com/JuliaLang/julia/issues/24459 -[#24490]: https://github.com/JuliaLang/julia/issues/24490 -[#24605]: https://github.com/JuliaLang/julia/issues/24605 -[#24647]: https://github.com/JuliaLang/julia/issues/24647 -[#24652]: https://github.com/JuliaLang/julia/issues/24652 -[#24657]: https://github.com/JuliaLang/julia/issues/24657 -[#24673]: https://github.com/JuliaLang/julia/issues/24673 -[#24785]: https://github.com/JuliaLang/julia/issues/24785 -[#24808]: https://github.com/JuliaLang/julia/issues/24808 -[#24831]: https://github.com/JuliaLang/julia/issues/24831 -[#24839]: https://github.com/JuliaLang/julia/issues/24839 -[#24874]: https://github.com/JuliaLang/julia/issues/24874 -[#24999]: https://github.com/JuliaLang/julia/issues/24999 -[#25012]: https://github.com/JuliaLang/julia/issues/25012 -[#25021]: https://github.com/JuliaLang/julia/issues/25021 -[#25056]: https://github.com/JuliaLang/julia/issues/25056 -[#25057]: https://github.com/JuliaLang/julia/issues/25057 -[#25100]: https://github.com/JuliaLang/julia/issues/25100 -[#25102]: https://github.com/JuliaLang/julia/issues/25102 -[#25113]: https://github.com/JuliaLang/julia/issues/25113 -[#25162]: https://github.com/JuliaLang/julia/issues/25162 -[#25165]: https://github.com/JuliaLang/julia/issues/25165 -[#25168]: https://github.com/JuliaLang/julia/issues/25168 -[#25227]: https://github.com/JuliaLang/julia/issues/25227 -[#25241]: https://github.com/JuliaLang/julia/issues/25241 -[#25249]: https://github.com/JuliaLang/julia/issues/25249 -[#25402]: https://github.com/JuliaLang/julia/issues/25402 -[#25458]: https://github.com/JuliaLang/julia/issues/25458 -[#25459]: https://github.com/JuliaLang/julia/issues/25459 -[#25479]: https://github.com/JuliaLang/julia/issues/25479 -[#25496]: https://github.com/JuliaLang/julia/issues/25496 -[#25522]: https://github.com/JuliaLang/julia/issues/25522 -[#25544]: https://github.com/JuliaLang/julia/issues/25544 -[#25545]: https://github.com/JuliaLang/julia/issues/25545 -[#25571]: https://github.com/JuliaLang/julia/issues/25571 -[#25615]: https://github.com/JuliaLang/julia/issues/25615 -[#25616]: https://github.com/JuliaLang/julia/issues/25616 -[#25622]: https://github.com/JuliaLang/julia/issues/25622 -[#25628]: https://github.com/JuliaLang/julia/issues/25628 -[#25629]: https://github.com/JuliaLang/julia/issues/25629 -[#25634]: https://github.com/JuliaLang/julia/issues/25634 -[#25646]: https://github.com/JuliaLang/julia/issues/25646 -[#25647]: https://github.com/JuliaLang/julia/issues/25647 -[#25654]: https://github.com/JuliaLang/julia/issues/25654 -[#25662]: https://github.com/JuliaLang/julia/issues/25662 -[#25701]: https://github.com/JuliaLang/julia/issues/25701 -[#25705]: https://github.com/JuliaLang/julia/issues/25705 -[#25706]: https://github.com/JuliaLang/julia/issues/25706 -[#25738]: https://github.com/JuliaLang/julia/issues/25738 -[#25780]: https://github.com/JuliaLang/julia/issues/25780 -[#25812]: https://github.com/JuliaLang/julia/issues/25812 -[#25819]: https://github.com/JuliaLang/julia/issues/25819 -[#25830]: https://github.com/JuliaLang/julia/issues/25830 -[#25873]: https://github.com/JuliaLang/julia/issues/25873 -[#25896]: https://github.com/JuliaLang/julia/issues/25896 -[#25935]: https://github.com/JuliaLang/julia/issues/25935 -[#25940]: https://github.com/JuliaLang/julia/issues/25940 -[#25959]: https://github.com/JuliaLang/julia/issues/25959 -[#25989]: https://github.com/JuliaLang/julia/issues/25989 -[#25990]: https://github.com/JuliaLang/julia/issues/25990 -[#25998]: https://github.com/JuliaLang/julia/issues/25998 -[#26009]: https://github.com/JuliaLang/julia/issues/26009 -[#26039]: https://github.com/JuliaLang/julia/issues/26039 -[#26069]: https://github.com/JuliaLang/julia/issues/26069 -[#26089]: https://github.com/JuliaLang/julia/issues/26089 -[#26149]: https://github.com/JuliaLang/julia/issues/26149 -[#26156]: https://github.com/JuliaLang/julia/issues/26156 -[#26283]: https://github.com/JuliaLang/julia/issues/26283 -[#26316]: https://github.com/JuliaLang/julia/issues/26316 -[#26365]: https://github.com/JuliaLang/julia/issues/26365 -[#26369]: https://github.com/JuliaLang/julia/issues/26369 -[#26436]: https://github.com/JuliaLang/julia/issues/26436 -[#26442]: https://github.com/JuliaLang/julia/issues/26442 -[#26486]: https://github.com/JuliaLang/julia/issues/26486 -[#26559]: https://github.com/JuliaLang/julia/issues/26559 -[#26634]: https://github.com/JuliaLang/julia/issues/26634 -[#26660]: https://github.com/JuliaLang/julia/issues/26660 -[#26670]: https://github.com/JuliaLang/julia/issues/26670 -[#26850]: https://github.com/JuliaLang/julia/issues/26850 -[#27077]: https://github.com/JuliaLang/julia/issues/27077 -[#27163]: https://github.com/JuliaLang/julia/issues/27163 -[#27253]: https://github.com/JuliaLang/julia/issues/27253 -[#27258]: https://github.com/JuliaLang/julia/issues/27258 -[#27298]: https://github.com/JuliaLang/julia/issues/27298 -[#27401]: https://github.com/JuliaLang/julia/issues/27401 -[#27711]: https://github.com/JuliaLang/julia/issues/27711 -[#27828]: https://github.com/JuliaLang/julia/issues/27828 -[#27834]: https://github.com/JuliaLang/julia/issues/27834 -[#28295]: https://github.com/JuliaLang/julia/issues/28295 -[#28302]: https://github.com/JuliaLang/julia/issues/28302 -[#28303]: https://github.com/JuliaLang/julia/issues/28303 [#28708]: https://github.com/JuliaLang/julia/issues/28708 [#28850]: https://github.com/JuliaLang/julia/issues/28850 [#29259]: https://github.com/JuliaLang/julia/issues/29259 [#29674]: https://github.com/JuliaLang/julia/issues/29674 [#29749]: https://github.com/JuliaLang/julia/issues/29749 -[#33129]: https://github.com/JuliaLang/julia/issues/33129 [#32628]: https://github.com/JuliaLang/julia/issues/32628 +[#33129]: https://github.com/JuliaLang/julia/issues/33129 From 2c55180afc67f5c2e6b4bfc0ecf576a5d6e7a664 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 21:14:34 +0200 Subject: [PATCH 119/121] Remove old deprecations --- src/Compat.jl | 6 ++--- src/deprecated.jl | 59 ----------------------------------------------- test/runtests.jl | 5 ++-- 3 files changed, 6 insertions(+), 64 deletions(-) diff --git a/src/Compat.jl b/src/Compat.jl index fcbd31f85..c9180f507 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -80,15 +80,15 @@ end end end -function rangedepwarn(;step=nothing, length=nothing, kwargs...) +function rangeargcheck(;step=nothing, length=nothing, kwargs...) if step===nothing && length===nothing - Base.depwarn("`range(start, stop)` (with neither `length` nor `step` given) is deprecated, use `range(start, stop=stop)` instead.", :range) + throw(ArgumentError("At least one of `length` or `step` must be specified")) end end if VERSION < v"1.1.0-DEV.506" function Base.range(start, stop; kwargs...) - rangedepwarn(;kwargs...) + rangeargcheck(;kwargs...) range(start; stop=stop, kwargs...) end end diff --git a/src/deprecated.jl b/src/deprecated.jl index 5a437eba6..e69de29bb 100644 --- a/src/deprecated.jl +++ b/src/deprecated.jl @@ -1,59 +0,0 @@ -Base.@deprecate_binding StringVector Base.StringVector false - -# PR #17302 -# Provide a non-deprecated version of `@vectorize_(1|2)arg` macro which defines -# deprecated version of the function so that the depwarns can be fixed without -# breaking users. -# Packages are expected to use this to maintain the old API until all users -# of the deprecated vectorized function have migrated. -# These macros should be dropped when the support for `0.6` is dropped from `Compat`. -# Modified based on the version copied from 0.6 Base. -macro dep_vectorize_1arg(S, f) - AbstractArray = GlobalRef(Base, :AbstractArray) - Base.depwarn("Implicit vectorized function is deprecated in favor of compact broadcast syntax.", - Symbol("@dep_vectorize_1arg")) - return esc(:(@deprecate $f(x::$AbstractArray{T}) where {T<:$S} $f.(x))) -end -macro dep_vectorize_2arg(S, f) - AbstractArray = GlobalRef(Base, :AbstractArray) - Base.depwarn("Implicit vectorized function is deprecated in favor of compact broadcast syntax.", - Symbol("@dep_vectorize_2arg")) - return esc(quote - @deprecate $f(x::$S, y::$AbstractArray{T1}) where {T1<:$S} $f.(x, y) - @deprecate $f(x::$AbstractArray{T1}, y::$S) where {T1<:$S} $f.(x, y) - @deprecate $f(x::$AbstractArray{T1}, y::$AbstractArray{T2}) where {T1<:$S, T2<:$S} $f.(x, y) - end) -end - -# compatibility with https://github.com/JuliaLang/julia/pull/26156 -Base.@deprecate trunc(x, digits; base = 10) Compat.trunc(x, digits = digits, base = base) false -Base.@deprecate floor(x, digits; base = 10) Compat.floor(x, digits = digits, base = base) false -Base.@deprecate ceil(x, digits; base = 10) Compat.ceil(x, digits = digits, base = base) false -Base.@deprecate round(x, digits; base = 10) Compat.round(x, digits = digits, base = base) false -Base.@deprecate signif(x, digits; base = 10) Compat.round(x, sigdigits = digits, base = base) false -# standard methods from Base; can be removed (so that Compat just inherits the functions -# from Base) once above deprecations are removed -trunc(x; digits = 0, base = 10) = Base.trunc(x, digits = digits, base = base) -floor(x; digits = 0, base = 10) = Base.floor(x, digits = digits, base = base) -ceil(x; digits = 0, base = 10) = Base.ceil(x, digits = digits, base = base) -round(x; digits = nothing, sigdigits = nothing, base = 10) = Base.round(x, digits = digits, sigdigits = sigdigits, base = base) - -if VERSION >= v"1.1.0-DEV.506" - # deprecation of range(start, stop) for earlier versions is done in Compat.jl - # This method is restricted to Number, since we don't - # want to overwrite the (::Any, ::Any) method in Base. - function Base.range(start::Number, stop::Number; kwargs...) - rangedepwarn(;kwargs...) - range(start; stop=stop, kwargs...) - end -end - -# this was defined for use with Julia versions prior to 0.5 -# (see https://github.com/JuliaLang/Compat.jl/pull/316) -macro dotcompat(x) - Base.depwarn("`@dotcompat x` is deprecated, use `@compat @. x` instead.", Symbol("@dotcompat")) - esc(:(Compat.@compat @. $x)) -end -export @dotcompat - -# Compat.Random.uuid1, uuid4, uuid_version are deprecated in Compat.jl diff --git a/test/runtests.jl b/test/runtests.jl index 095c3c741..fead53828 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -23,8 +23,9 @@ using Test end # Support for positional `stop` -@test Compat.range(0, 5, length = 6) == 0.0:1.0:5.0 -@test Compat.range(0, 10, step = 2) == 0:2:10 +@test range(0, 5, length = 6) == 0.0:1.0:5.0 +@test range(0, 10, step = 2) == 0:2:10 +@test_throws ArgumentError range(0, 10) mutable struct TLayout x::Int8 From 1f88d61094f88f3d13f9682f3fc5f8332ed8c052 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 21:58:27 +0200 Subject: [PATCH 120/121] Deprecate obsolete bindings --- src/Compat.jl | 57 ----------------------------------------------- src/deprecated.jl | 36 ++++++++++++++++++++++++++++++ test/old.jl | 2 +- 3 files changed, 37 insertions(+), 58 deletions(-) diff --git a/src/Compat.jl b/src/Compat.jl index c9180f507..e9d2d2fb6 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -1,62 +1,5 @@ module Compat -# to be deprecated -import Sockets -module TypeUtils - using Base: parameter_upper_bound, typename - using Compat: isabstracttype - const isabstract = isabstracttype - export isabstract, parameter_upper_bound, typename -end # module TypeUtils -import Base.invokelatest -const macros_have_sourceloc = true -module Sys - const KERNEL = Base.Sys.KERNEL - import Base.Sys: isapple, isbsd, islinux, isunix, iswindows - import Base.Sys: which, isexecutable - BINDIR = Base.Sys.BINDIR -end -import Base.MathConstants -import Test, SharedArrays, Mmap, DelimitedFiles -import Dates -import Libdl -const AbstractDateTime = Compat.Dates.AbstractDateTime -import Printf -import LinearAlgebra -import SparseArrays -import Random -import Markdown -import REPL -import Serialization -import Statistics -import Base: Fix2 -import Base64 -const tr = LinearAlgebra.tr -module Unicode - export graphemes, textwidth, isvalid, - islower, isupper, isalpha, isdigit, isxdigit, isnumeric, isalnum, - iscntrl, ispunct, isspace, isprint, isgraph, - lowercase, uppercase, titlecase, lcfirst, ucfirst - using Unicode - import Unicode: isassigned, normalize # not exported from Unicode module due to conflicts -end -import Base: notnothing -const IteratorSize = Base.IteratorSize -const IteratorEltype = Base.IteratorEltype -enable_debug(x::Bool) = x -import Distributed -import Pkg -import InteractiveUtils -import LibGit2 -import UUIDs -using LinearAlgebra: qr -using LinearAlgebra: rmul! -const opnorm = LinearAlgebra.opnorm -const norm = LinearAlgebra.norm -const dot = LinearAlgebra.dot -const ⋅ = dot - - include("compatmacro.jl") # https://github.com/JuliaLang/julia/pull/29679 diff --git a/src/deprecated.jl b/src/deprecated.jl index e69de29bb..3d1e29ebc 100644 --- a/src/deprecated.jl +++ b/src/deprecated.jl @@ -0,0 +1,36 @@ +import Dates, LinearAlgebra +Base.@deprecate_binding invokelatest Base.invokelatest false +Base.@deprecate_binding MathConstants Base.MathConstants false +Base.@deprecate_binding Fix2 Base.Fix2 false +Base.@deprecate_binding Sys Base.Sys false +Base.@deprecate_binding AbstractDateTime Dates.AbstractDateTime false +Base.@deprecate_binding tr LinearAlgebra.tr false +Base.@deprecate_binding IteratorSize Base.IteratorSize false +Base.@deprecate_binding IteratorEltype Base.IteratorEltype false +Base.@deprecate_binding opnorm LinearAlgebra.opnorm false +Base.@deprecate_binding norm LinearAlgebra.norm false +Base.@deprecate_binding dot LinearAlgebra.dot false +Base.@deprecate_binding (⋅) LinearAlgebra.dot false +Base.@deprecate_binding notnothing Base.notnothing false +Base.@deprecate_binding qr LinearAlgebra.qr false +Base.@deprecate_binding rmul! LinearAlgebra.rmul! false + +for stdlib in [:Base64, :Dates, :DelimitedFiles, :Distributed, :InteractiveUtils, :Libdl, + :LibGit2, :LinearAlgebra, :Markdown, :Mmap, :Pkg, :Printf, :Random, :REPL, + :Serialization, :SharedArrays, :Sockets, :SparseArrays, :Statistics, :Test, :Unicode, + :UUIDs] + @eval begin + import $stdlib + Base.@deprecate_binding $stdlib $stdlib false + end +end + +Base.@deprecate_binding macros_have_sourceloc true false +Base.@deprecate enable_debug(x::Bool) x false + +module TypeUtils + Base.@deprecate_binding isabstract isabstracttype + Base.@deprecate_binding typename Base.typename + Base.@deprecate_binding parameter_upper_bound Base.parameter_upper_bound +end # module TypeUtils +Base.@deprecate_binding TypeUtils TypeUtils false ", call the respective Base functions directly" diff --git a/test/old.jl b/test/old.jl index 9357258b1..2bfb704e3 100644 --- a/test/old.jl +++ b/test/old.jl @@ -725,7 +725,7 @@ end @test argmin((1.0, -3, 0.f0)) == 2 # 0.7.0-DEV.3460 -@test parentmodule(Compat.Sys) == Compat +@test parentmodule(Base.Sys) == Base @test parentmodule(sin) == Base @test parentmodule(sin, Tuple{Int}) == Base.Math @test parentmodule(Int) == Core From 45bd43d08ce5a8d546b4a21de83b4ea2ea236c4f Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 22:02:21 +0200 Subject: [PATCH 121/121] Remove obsolete tests --- test/old.jl | 1318 ---------------------------------------------- test/runtests.jl | 2 - 2 files changed, 1320 deletions(-) delete mode 100644 test/old.jl diff --git a/test/old.jl b/test/old.jl deleted file mode 100644 index 2bfb704e3..000000000 --- a/test/old.jl +++ /dev/null @@ -1,1318 +0,0 @@ -# tests of functionality to be deprecated - -using Compat.LinearAlgebra - -# 0.7.0-DEV.3666 -module TestSockets - using Compat - using Compat.Sockets - using Compat.Test - - @test isdefined(@__MODULE__, :UDPSocket) - @test isdefined(@__MODULE__, :connect) - @test isdefined(@__MODULE__, :listen) - @test isdefined(@__MODULE__, :recv) - - @test ip"127.0.0.1".host == UInt32(2130706433) -end - -# julia#20006 -abstract type AbstractFoo20006 end -struct ConcreteFoo20006{T<:Int} <: AbstractFoo20006 end -struct ConcreteFoo20006N{T<:Int,N} <: AbstractFoo20006 end -@compat ConcreteFoo200061{T<:Int} = ConcreteFoo20006N{T,1} -@test Compat.TypeUtils.isabstract(AbstractFoo20006) -@test !Compat.TypeUtils.isabstract(ConcreteFoo20006) -@test !Compat.TypeUtils.isabstract(ConcreteFoo20006N) -@test !Compat.TypeUtils.isabstract(ConcreteFoo200061) -@test !Compat.TypeUtils.isabstract(StridedArray) -@test Compat.TypeUtils.parameter_upper_bound(ConcreteFoo20006, 1) == Int -@test isa(Compat.TypeUtils.typename(Array), Core.TypeName) - -# invokelatest with keywords -pr22646(x; y=0) = 1 -let foo() = begin - eval(:(pr22646(x::Int; y=0) = 2)) - return Compat.invokelatest(pr22646, 0, y=1) - end - @test foo() == 2 -end - -for os in [:apple, :bsd, :linux, :unix, :windows] - from_base = if VERSION >= v"0.7.0-DEV.914" - Expr(:., Expr(:., :Base, Base.Meta.quot(:Sys)), Base.Meta.quot(Symbol("is", os))) - else - Expr(:., :Base, Base.Meta.quot(Symbol("is_", os))) - end - @eval @test Compat.Sys.$(Symbol("is", os))() == $from_base() -end - -# 0.7.0-DEV.3073 -@test Compat.Sys.BINDIR == Sys.BINDIR - -# 0.7.0-DEV.5171 -let sep = Compat.Sys.iswindows() ? ';' : ':' - withenv("PATH" => string(Compat.Sys.BINDIR, sep, get(ENV, "PATH", ""))) do - jl = joinpath(Compat.Sys.BINDIR, "julia") * (Compat.Sys.iswindows() ? ".exe" : "") - @test Compat.Sys.which("julia") == realpath(jl) - @test Compat.Sys.isexecutable(jl) - @test Compat.Sys.which("reallyseriouslynotathingyoushouldhave") === nothing - end -end - -# 0.7 -module TestMathConstants -using Compat.MathConstants -end -for name in [:π, :pi, :ℯ, :e, :γ, :eulergamma, :catalan, :φ, :golden] - @test isdefined(TestMathConstants, name) && !Base.isdeprecated(TestMathConstants, name) - @test isdefined(Compat.MathConstants, name) && !Base.isdeprecated(Compat.MathConstants, name) -end -module TestMathConstants2 -using Compat -end -@test isdefined(TestMathConstants2, :ℯ) && !Base.isdeprecated(TestMathConstants, :ℯ) - -# 0.7 -module Test23876 - using Compat - using Compat.Test - import Compat.DelimitedFiles - using Compat.Mmap, Compat.SharedArrays - using Compat.Distributed - @test isdefined(@__MODULE__, :DelimitedFiles) - @test isdefined(SharedArrays, :SharedArray) - @test isdefined(@__MODULE__, :SharedArray) - @test isdefined(@__MODULE__, :procs) - @test isdefined(@__MODULE__, :remote_do) - @test isdefined(Mmap, :mmap) -end - -# 0.7 -module Test24459 - using Compat - using Compat.Test - using Compat.Dates - @test isdefined(@__MODULE__, :Dates) -end - -# 0.7.0-DEV.3382 -module TestLibdl - using Compat - using Compat.Libdl - using Compat.Test - @test isdefined(@__MODULE__, :Libdl) -end - -# 0.7.0-DEV.3216 -@test Compat.AbstractDateTime === (isdefined(Compat.Dates, :AbstractDateTime) ? Compat.Dates.AbstractDateTime : Compat.Dates.TimeType) -@test Compat.AbstractDateTime <: Compat.Dates.TimeType -@test Compat.Dates.DateTime <: Compat.AbstractDateTime - -# 0.7 -module Test25056 - using Compat - using Compat.Test - using Compat.Printf - @test isdefined(@__MODULE__, :Printf) - @test isdefined(@__MODULE__, Symbol("@printf")) - @test isdefined(@__MODULE__, Symbol("@sprintf")) -end - -# 0.7.0-DEV.3449 -let A = [2.0 1.0; 1.0 3.0], b = [2.0, 3.0] - @test diag(A) == b -end - -# 0.7.0-DEV.3406 -using Compat.Random -@test rand(MersenneTwister(1234)) == 0.5908446386657102 - -# 0.7.0-beta2.171 -Random.seed!(1) -rng = MersenneTwister(0) -Random.seed!(rng, 1) -@test rand(rng) ≈ 0.23603334566204692 -@test 0 < rand(Random.GLOBAL_RNG, Random.RangeGenerator(1:3)) < 4 - -# 0.7.0-DEV.3589 -import Compat.Markdown -@test isa(Markdown.parse("foo"), Markdown.MD) - -# 0.7.0-DEV.3500 -module TestREPL - using Compat - using Compat.REPL - using Compat.Test - @test isdefined(@__MODULE__, :REPL) -end - -# 0.7.0-DEV.3476 -module TestSerialization - using Compat - using Compat.Serialization - using Compat.Test - @test isdefined(@__MODULE__, :Serialization) - @test isdefined(@__MODULE__, :serialize) - @test isdefined(@__MODULE__, :deserialize) - if VERSION < v"1.0.0-DEV.44" - @test isdefined(@__MODULE__, :SerializationState) - end -end - -# 0.7.0-DEV.2338 -module Test24361 - using Compat - using Compat.Test - @test String(Compat.Base64.base64decode("SGVsbG8h")) == "Hello!" -end - -# julia#26365 -@test Compat.tr([1 2; 3 5]) == 6 - -# 0.7.0-DEV.2915 -module Test25021 - using Compat - using Compat.Test - using Compat.Unicode - @test isdefined(@__MODULE__, :Unicode) - - @test !isnumeric('a') - @test isnumeric('1') - @test titlecase("firstname lastname") == "Firstname Lastname" - @test Compat.Unicode.isassigned('柒') && !Compat.Unicode.isassigned(0xfffe) - @test Compat.Unicode.normalize("\U1e9b\U0323", :NFKC) == "\U1e69" - @test Compat.Unicode.normalize("\t\r", stripcc=true) == " " -end - -# 0.7.0-DEV.3017 -@test Compat.notnothing(1) == 1 -@test_throws ArgumentError Compat.notnothing(nothing) - -# 0.7.0-DEV.3309 -let v = [1, 2, 3] - @test Compat.IteratorSize(v) isa Base.HasShape - @test Compat.IteratorEltype(v) == Base.HasEltype() -end - -module TestPkg - using Compat - using Compat.Pkg - using Compat.Test - @test isdefined(@__MODULE__, :Pkg) - @test isdefined(Compat.Pkg, :add) -end - -module TestInteractiveUtils - using Compat - using Compat.InteractiveUtils - using Compat.Test - @test isdefined(@__MODULE__, :InteractiveUtils) - @test isdefined(@__MODULE__, :varinfo) -end - -module TestLibGit2 - using Compat - using Compat.LibGit2 - using Compat.Test - @test isdefined(@__MODULE__, :LibGit2) - @test isdefined(@__MODULE__, :GitRepo) -end - -# 0.7.0-DEV.3666 -module TestUUIDs - using Compat - using Compat.UUIDs - using Compat.Test - @test isdefined(@__MODULE__, :uuid1) - @test isdefined(@__MODULE__, :uuid4) - @test isdefined(@__MODULE__, :uuid_version) - - @test uuid_version(uuid1()) == 1 - @test uuid_version(uuid4()) == 4 - @test uuid1() isa UUID - @test uuid4() isa UUID -end - -# 0.7.0-DEV.843 / 0.7.0-DEV.2337 -let A = [1 2; 1 2; 1 2] - f = Compat.qr(A, Val(false)) - @test size(f.Q) == (3, 3) - @test f.Q * [f.R; [0 0]] ≈ A - f = Compat.qr(A, Val(true)) - @test size(f.Q) == (3, 3) - @test f.Q * [f.R; [0 0]] ≈ A[:,f.p] -end - -let A = [1 2; 3 4] - @test Compat.rmul!(A, 2) == [2 4; 6 8] - @test Compat.rmul!(A, Diagonal([1, 2])) == [2 8; 6 16] - @test Compat.rmul!(A, UpperTriangular([2 2; 3 3])) == [4 28; 12 60] - @test Compat.rmul!(LowerTriangular(A), Diagonal([1, 2])) == LowerTriangular([4 0; 12 120]) - @test Compat.rmul!(Diagonal(A), Diagonal([2, 1])) == Diagonal([8, 120]) -end - -# julia#27401 -import Compat: ⋅ -@test Compat.opnorm([1 2;3 4]) ≈ 5.464985704219043 -@test Compat.opnorm([1 2;3 4], 1) ≈ 6 -@test Compat.norm([1 2;3 4]) ≈ 5.477225575051661 -@test Compat.norm([1 2;3 4], 1) ≈ 10 -@test Compat.dot([1 2;3 4], [5 6;7 8]) == [1 2;3 4] ⋅ [5 6;7 8] ≈ 70 - - -# tests of removed functionality (i.e. justs tests Base) - -using Compat.SparseArrays - -# 25959 -@test all(x -> isa(x, IO), (devnull, stdin, stdout, stderr)) -@static if !isdefined(Base, :devnull) - @test stdin === STDIN - @test stdout === STDOUT - @test stderr === STDERR -end - -# @nospecialize -# 0.7 -no_specialize(@nospecialize(x)) = sin(1) -no_specialize(@nospecialize(x::Integer)) = sin(2) -@test no_specialize(1.0) == sin(1) -@test no_specialize(1) == sin(2) -no_specialize_kw1(@nospecialize(x=0)) = sin(1) -no_specialize_kw1(@nospecialize(x::Integer)) = sin(2) -@test no_specialize_kw1(1.0) == sin(1) -@test no_specialize_kw1(1) == sin(2) -@test no_specialize_kw1() == sin(2) -no_specialize_kw2(@nospecialize(x)) = sin(1) -no_specialize_kw2(@nospecialize(x::Integer=0)) = sin(2) -@test no_specialize_kw2(1.0) == sin(1) -@test no_specialize_kw2(1) == sin(2) -@test no_specialize_kw2() == sin(2) - -# PR 22064 -module Test22064 -using Compat -using Compat.Test -@test (@__MODULE__) === Test22064 -end - -@test isabstracttype(AbstractFoo20006) -@test !isabstracttype(ConcreteFoo20006) -@test !isabstracttype(ConcreteFoo20006N) -@test !isabstracttype(ConcreteFoo200061) -@test !isabstracttype(StridedArray) -# 0.7 -@test isconcretetype(Int) - -# PR 20203 -@test Compat.readline(IOBuffer("Hello, World!\n")) == "Hello, World!" -@test Compat.readline(IOBuffer("x\n"), keep=false) == "x" -@test Compat.readline(IOBuffer("x\n"), keep=true) == "x\n" -@test collect(Compat.eachline(IOBuffer("x\ny"))) == ["x", "y"] -@test collect(Compat.eachline(IOBuffer("x\ny"), keep=false)) == ["x", "y"] -@test collect(Compat.eachline(IOBuffer("x\ny"), keep=true)) == ["x\n", "y"] - -# PR 25646 -for (t, s, m, kept) in [ - ("a", "ab", "a", "a"), - ("b", "ab", "b", "b"), - ("α", "αγ", "α", "α"), - ("ab", "abc", "ab", "ab"), - ("bc", "abc", "bc", "bc"), - ("αβ", "αβγ", "αβ", "αβ"), - ("aaabc", "ab", "aa", "aaab"), - ("aaabc", "ac", "aaabc", "aaabc"), - ("aaabc", "aab", "a", "aaab"), - ("aaabc", "aac", "aaabc", "aaabc"), - ("αααβγ", "αβ", "αα", "αααβ"), - ("αααβγ", "ααβ", "α", "αααβ"), - ("αααβγ", "αγ", "αααβγ", "αααβγ"), - ("barbarbarians", "barbarian", "bar", "barbarbarian"), - ("abcaabcaabcxl", "abcaabcx", "abca", "abcaabcaabcx"), - ("abbaabbaabbabbaax", "abbaabbabbaax", "abba", "abbaabbaabbabbaax"), - ("abbaabbabbaabbaabbabbaax", "abbaabbabbaax", "abbaabbabba", "abbaabbabbaabbaabbabbaax"), - ] - local t, s, m, kept - @test Compat.readuntil(IOBuffer(t), s) == m - @test Compat.readuntil(IOBuffer(t), s, keep=true) == kept - @test Compat.readuntil(IOBuffer(t), SubString(s, firstindex(s))) == m - @test Compat.readuntil(IOBuffer(t), SubString(s, firstindex(s)), keep=true) == kept - @test Compat.readuntil(IOBuffer(t), GenericString(s)) == m - @test Compat.readuntil(IOBuffer(t), GenericString(s), keep=true) == kept - @test Compat.readuntil(IOBuffer(t), Vector{UInt8}(codeunits(s))) == Vector{UInt8}(codeunits(m)) - @test Compat.readuntil(IOBuffer(t), Vector{UInt8}(codeunits(s)), keep=true) == Vector{UInt8}(codeunits(kept)) - @test Compat.readuntil(IOBuffer(t), collect(s)::Vector{Char}) == Vector{Char}(m) - @test Compat.readuntil(IOBuffer(t), collect(s)::Vector{Char}, keep=true) == Vector{Char}(kept) -end - -# PR #21197 -let c = `ls -l "foo bar"` - @test collect(c) == ["ls", "-l", "foo bar"] - @test first(c) == "ls" == c[1] - @test last(c) == "foo bar" == c[3] == c[end] - @test c[1:2] == ["ls", "-l"] - @test eltype(c) == String - @test length(c) == 3 - @test eachindex(c) == 1:3 -end - -# Val(x) -# 0.7 -begin - local firstlast - firstlast(::Val{true}) = "First" - firstlast(::Val{false}) = "Last" - - @test firstlast(Val(true)) == "First" - @test firstlast(Val(false)) == "Last" -end - -# Reshape to a given number of dimensions using Val(N) -# 0.7 -let - for A in (rand(Float64, ()), rand(2), rand(2,3), rand(2,3,5), rand(2,3,5,7)), N in (1,2,3,4,5,6) - B = @inferred reshape(A, Val(N)) - @test ndims(B) == N - if N < ndims(A) - new_sz = (size(A)[1:N-1]..., prod(size(A)[N:end])) - elseif N == ndims(A) - new_sz = size(A) - else - new_sz = (size(A)..., ntuple(x->1, N-ndims(A))...) - end - @test size(B) == new_sz - @test B == reshape(A, new_sz) - end -end - -# ntuple with Val(N) -# 0.7 -@test @inferred(ntuple(x->1, Val(3))) == (1,1,1) -@test @inferred(ntuple(x->x, Val(0))) == () -@test @inferred(ntuple(x->x, Val(5))) == (1,2,3,4,5) - -# PR 22629 -@test logdet(0.5) == log(det(0.5)) - -# 0.7.0-DEV.3155 -let coolvec = [1,2,3] - @test pushfirst!(coolvec, 0) == [0,1,2,3] - @test popfirst!(coolvec) == 0 -end - -# PR 22350 -struct TestType - a::Int - b -end -@test fieldcount(TestType) == 2 -@test fieldcount(Int) == 0 - -# 0.7 -@test read(IOBuffer("aaaa"), String) == "aaaa" -@test occursin("read(@__FILE__, String)", read(@__FILE__, String)) -let cmd = `$(Base.julia_cmd()) --startup-file=no -e "println(:aaaa)"` - @test read(cmd, String) == "aaaa\n" - @test read(pipeline(cmd, stderr=devnull), String) == "aaaa\n" -end - -# PR 20005 -@test_throws InexactError throw(InexactError(:func, Int, 3.2)) - -# PR 22751 -@test_throws DomainError throw(DomainError(-2)) -@test_throws DomainError throw(DomainError(-2, "negative")) - -# PR 22761 -@test_throws OverflowError throw(OverflowError("overflow")) - -# 0.7 -let M = [1 + 2im 3 + 4im; 5 + 6im 7 + 8im], - M2 = adjoint(copy(M)), - Mc = [1 - 2im 5 - 6im; 3 - 4im 7 - 8im] - - @test adjoint(M) == Mc - M2 .= 0 - adjoint!(M2, M) - @test M2 == Mc -end - -# 0.7 -@test partialsort([3,6,30,1,9], 2, rev=true) == 9 -@test partialsort([3,6,30,1,9], 2, by=x->1/x) == 9 -@test partialsortperm([3,6,30,1,9], 2, rev=true) == 5 -@test partialsortperm([3,6,30,1,9], 2, by=x->1/x) == 5 - -# PR 22907 -using Compat: pairs - -# keys, values, pairs -for A in (rand(2), rand(2,3)) - local A - for (i, v) in pairs(A) - @test A[i] == v - end - @test collect(values(A)) == collect(A) -end - -let A = Dict(:foo=>1, :bar=>3) - for (k, v) in pairs(A) - @test A[k] == v - end - @test sort!(collect(pairs(A))) == sort!(collect(A)) -end - -let - A14 = [11 13; 12 14] - R = CartesianIndices(Compat.axes(A14)) - @test vec([a for (a,b) in pairs(IndexLinear(), A14)]) == [1,2,3,4] - @test vec([a for (a,b) in pairs(IndexCartesian(), A14)]) == vec(collect(R)) - @test vec([b for (a,b) in pairs(IndexLinear(), A14)]) == [11,12,13,14] - @test vec([b for (a,b) in pairs(IndexCartesian(), A14)]) == [11,12,13,14] -end - -# 0.7 -@test isa(1:2, AbstractRange) - -# 0.7 -@test isa(Base.rtoldefault(1.0, 2.0, 0), Float64) -@test isa(Base.rtoldefault(Float64, 2.0, 0), Float64) -@test isa(Base.rtoldefault(1.0, Float64, 0), Float64) -@test isa(Base.rtoldefault(Float64, Float64, 0), Float64) -@test Base.rtoldefault(Float64, Float64, 1.0) === 0.0 - -# 0.7.0-DEV.2402 - -x = Compat.Dates.Second(172799) -@test floor(x, Compat.Dates.Week) == Compat.Dates.Week(0) -@test floor(x, Compat.Dates.Day) == Compat.Dates.Day(1) -@test floor(x, Compat.Dates.Hour) == Compat.Dates.Hour(47) -@test floor(x, Compat.Dates.Minute) == Compat.Dates.Minute(2879) -@test floor(x, Compat.Dates.Second) == Compat.Dates.Second(172799) -@test floor(x, Compat.Dates.Millisecond) == Compat.Dates.Millisecond(172799000) -@test ceil(x, Compat.Dates.Week) == Compat.Dates.Week(1) -@test ceil(x, Compat.Dates.Day) == Compat.Dates.Day(2) -@test ceil(x, Compat.Dates.Hour) == Compat.Dates.Hour(48) -@test ceil(x, Compat.Dates.Minute) == Compat.Dates.Minute(2880) -@test ceil(x, Compat.Dates.Second) == Compat.Dates.Second(172799) -@test ceil(x, Compat.Dates.Millisecond) == Compat.Dates.Millisecond(172799000) -@test round(x, Compat.Dates.Week) == Compat.Dates.Week(0) -@test round(x, Compat.Dates.Day) == Compat.Dates.Day(2) -@test round(x, Compat.Dates.Hour) == Compat.Dates.Hour(48) -@test round(x, Compat.Dates.Minute) == Compat.Dates.Minute(2880) -@test round(x, Compat.Dates.Second) == Compat.Dates.Second(172799) -@test round(x, Compat.Dates.Millisecond) == Compat.Dates.Millisecond(172799000) - -x = Compat.Dates.Nanosecond(2000999999) -@test floor(x, Compat.Dates.Second) == Compat.Dates.Second(2) -@test floor(x, Compat.Dates.Millisecond) == Compat.Dates.Millisecond(2000) -@test floor(x, Compat.Dates.Microsecond) == Compat.Dates.Microsecond(2000999) -@test floor(x, Compat.Dates.Nanosecond) == x -@test ceil(x, Compat.Dates.Second) == Compat.Dates.Second(3) -@test ceil(x, Compat.Dates.Millisecond) == Compat.Dates.Millisecond(2001) -@test ceil(x, Compat.Dates.Microsecond) == Compat.Dates.Microsecond(2001000) -@test ceil(x, Compat.Dates.Nanosecond) == x -@test round(x, Compat.Dates.Second) == Compat.Dates.Second(2) -@test round(x, Compat.Dates.Millisecond) == Compat.Dates.Millisecond(2001) -@test round(x, Compat.Dates.Microsecond) == Compat.Dates.Microsecond(2001000) -@test round(x, Compat.Dates.Nanosecond) == x - - -for x in [Compat.Dates.Week(3), Compat.Dates.Day(14), Compat.Dates.Second(604800)] - local x - for p in [Compat.Dates.Week, Compat.Dates.Day, Compat.Dates.Hour, Compat.Dates.Second, Compat.Dates.Millisecond, Compat.Dates.Microsecond, Compat.Dates.Nanosecond] - local p - @test floor(x, p) == p(x) - @test ceil(x, p) == p(x) - end -end - -x = Compat.Dates.Hour(36) -@test round(x, Compat.Dates.Day, RoundNearestTiesUp) == Compat.Dates.Day(2) -@test round(x, Compat.Dates.Day, RoundUp) == Compat.Dates.Day(2) -@test round(x, Compat.Dates.Day, RoundDown) == Compat.Dates.Day(1) -@test_throws DomainError round(x, Compat.Dates.Day, RoundNearest) -@test_throws DomainError round(x, Compat.Dates.Day, RoundNearestTiesAway) -@test_throws DomainError round(x, Compat.Dates.Day, RoundToZero) -@test round(x, Compat.Dates.Day) == round(x, Compat.Dates.Day, RoundNearestTiesUp) - -x = Compat.Dates.Hour(86399) -for p in [Compat.Dates.Week, Compat.Dates.Day, Compat.Dates.Hour, Compat.Dates.Second, Compat.Dates.Millisecond, Compat.Dates.Microsecond, Compat.Dates.Nanosecond] - local p - for v in [-1, 0] - @test_throws DomainError floor(x, p(v)) - @test_throws DomainError ceil(x, p(v)) - @test_throws DomainError round(x, p(v)) - end -end -for p in [Compat.Dates.Year, Compat.Dates.Month] - local p - for v in [-1, 0, 1] - @test_throws MethodError floor(x, p(v)) - @test_throws MethodError ceil(x, p(v)) - @test_throws DomainError round(x, p(v)) - end -end - -# 0.7 - -let a = [0,1,2,3,0,1,2,3] - # curried isequal - @test findfirst(isequal(3), [1,2,4,1,2,3,4]) == 6 - @test findfirst(!isequal(1), [1,2,4,1,2,3,4]) == 2 - @test findnext(isequal(1), a, 4) == 6 - # @test findnext(isequal(5), a, 4) == 0 - @test findlast(isequal(3), [1,2,4,1,2,3,4]) == 6 - @test findprev(isequal(1), a, 4) == 2 - @test findprev(isequal(1), a, 8) == 6 - if VERSION < v"0.7.0-DEV.4592" - # test that equalto work on 0.6 - @test findfirst(equalto(3), [1,2,4,1,2,3,4]) == 6 - @test findfirst(!equalto(1), [1,2,4,1,2,3,4]) == 2 - end - # curried == - @test findfirst(==(3), [1,2,4,1,2,3,4]) == 6 - @test findfirst(!(==(1)), [1,2,4,1,2,3,4]) == 2 - @test findnext(==(1), a, 4) == 6 - @test findlast(==(3), [1,2,4,1,2,3,4]) == 6 - @test findprev(==(1), a, 4) == 2 - @test findprev(==(1), a, 8) == 6 -end - -# 0.7.0-DEV.4639 -@test occursin(r"World", "Hello, World!") -@test occursin(r"World", "Hello, World!", offset = 4) -@test occursin("World", "Hello, World!") -# 0.7.0-DEV.912 -@test occursin('W', "Hello, World!") - -# 0.7 -@test 'a'*"b" == "a"*'b' == 'a'*'b' == "ab" - -# 0.7 -@test 1 in BitSet(1:10) - -# 0.7 -@test diagm(0 => ones(2), -1 => ones(2)) == [1.0 0.0 0.0; 1.0 1.0 0.0; 0.0 1.0 0.0] -@test diagm(0 => ones(2), 1 => ones(2)) == [1.0 1.0 0.0; 0.0 1.0 1.0; 0.0 0.0 0.0] -@test spdiagm(0 => ones(2), -1 => ones(2)) == [1.0 0.0 0.0; 1.0 1.0 0.0; 0.0 1.0 0.0] -@test spdiagm(0 => ones(2), 1 => ones(2)) == [1.0 1.0 0.0; 0.0 1.0 1.0; 0.0 0.0 0.0] - -# 0.7 -let a = [1 0 0; 0 1 0; 0 0 1] - @test Matrix{Int}(I, 3, 3)::Matrix{Int} == a - @test Matrix{Float64}(I, (3, 2))::Matrix{Float64} == a[:,1:2] - @test Array{Int}(I, (3, 3))::Matrix{Int} == a - @test Array{Float64}(I, 3, 2)::Matrix{Float64} == a[:,1:2] - @test SparseMatrixCSC{Int}(I, 3, 3)::SparseMatrixCSC{Int,Int} == a - @test SparseMatrixCSC{Float64}(I, (3, 2))::SparseMatrixCSC{Float64,Int} == a[:,1:2] - @test SparseMatrixCSC{Bool,Int16}(I, (3, 3))::SparseMatrixCSC{Bool,Int16} == a - @test SparseMatrixCSC{ComplexF64,Int8}(I, 3, 2)::SparseMatrixCSC{ComplexF64,Int8} == a[:,1:2] - - @test Matrix(2I, 3, 3)::Matrix{Int} == Matrix(2I, (3, 3))::Matrix{Int} == 2a - @test Matrix(2.0I, 3, 3)::Matrix{Float64} == Matrix(2.0I, (3, 3))::Matrix{Float64} == 2a -end - -# 0.7.0-DEV.1472 -@test get(IOContext(IOBuffer(), :arg1=>true, :arg2=>true, :arg3=>true), :arg3, false) -@test get(IOContext(IOBuffer(), :arg1=>true, :arg2=>true), :arg2, false) - -# 0.7.0-DEV.2581, 0.7.0-DEV.4527 -@test isa(Vector(undef, 2), Vector{Any}) -@test isa(Vector{Float64}(undef, 2), Vector{Float64}) -@test isa(Matrix(undef, 2, 2), Matrix{Any}) -@test isa(Matrix{Float64}(undef, 2, 2), Matrix{Float64}) -@test isa(Array{Float64}(undef, 2, 2), Matrix{Float64}) -@test isa(Array{Float64,3}(undef, 2, 2, 2), Array{Float64,3}) - -# 0.7.0-DEV.2687, 0.7.0-DEV.4527 -@test isa(BitVector(undef, 2), BitVector) -@test isa(BitArray(undef, 2, 2), BitMatrix) - -# 0.7.0-DEV.1499 -let key = "TEST_23412" - @test !haskey(ENV, key) - @test get(() -> "default", ENV, key) == "default" -end - -# 0.7.0-DEV.2919 -@test ComplexF16 === Complex{Float16} -@test ComplexF32 === Complex{Float32} -@test ComplexF64 === Complex{Float64} - -# 0.7.0-DEV.1930 -@test textwidth("A") == 1 -@test textwidth('A') == 1 - -# 0.7.0-DEV.3393 -@test !isnumeric('a') -@test isnumeric('1') - -# 0.7.0-DEV.2951 -@test AbstractDict === (isdefined(Base, :AbstractDict) ? Base.AbstractDict : Base.Associative) - -# 0.7.0-DEV.2978 -@test Compat.axes === (isdefined(Base, :axes) ? Base.axes : Base.indices) -@test Compat.axes(1) == () -@test Compat.axes(1,1) == 1:1 - -# 0.7.0-DEV.3137 -@test Nothing === (isdefined(Base, :Nothing) ? Base.Nothing : Base.Void) -@test Nothing === Cvoid - -# 0.7.0-DEV.3017 -@test isa(Some(1), Some{Int}) -@test convert(Some{Float64}, Some(1)) == Some(1.0) -@test convert(Nothing, nothing) == nothing -@test_throws MethodError convert(Nothing, 1) -@test Some(nothing) != nothing - -# 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" - -# 0.7.0-DEV.3057 -let A = [0, 0, 0], B = [1, 2, 3] - @test copyto!(A, B) === A == B -end -let A = [0, 0, 0], B = [1, 2, 3] - @test unsafe_copyto!(A, 2, B, 1, 1) === A == [0, 1, 0] -end - -# 0.7.0-DEV.3025 -let c = CartesianIndices((1:3, 1:2)), l = LinearIndices((1:3, 1:2)) - @test LinearIndices(c) == collect(l) - @test CartesianIndices(l) == collect(c) - @test first(c) == CartesianIndex(1, 1) - @test CartesianIndex(1, 1) in c - @test first(l) == 1 - @test size(c) == size(l) == (3, 2) - @test c == collect(c) == [CartesianIndex(1, 1) CartesianIndex(1, 2) - CartesianIndex(2, 1) CartesianIndex(2, 2) - CartesianIndex(3, 1) CartesianIndex(3, 2)] - @test l == collect(l) == reshape(1:6, 3, 2) - @test c[1:6] == vec(c) - @test l[1:6] == vec(l) - # TODO the following test fails on current Julia master (since 0.7.0-DEV.4742), and - # it's not clear yet whether it should work or not. See - # https://github.com/JuliaLang/julia/pull/26682#issuecomment-379762632 and the - # discussion following it - #@test l == l[c] == map(i -> l[i], c) - @test l[vec(c)] == collect(1:6) - @test CartesianIndex(1, 1) in CartesianIndices((3, 4)) -end - -# Issue #523 -@test length(Compat.CartesianIndices((1:1,))) == 1 -@test length(Compat.CartesianIndices((1:2,))) == 2 -@test length(Compat.CartesianIndices((1:2, -1:1))) == 6 - -# 0.7.0-DEV.3415 -@test findall(x -> x==1, [1, 2, 3, 2, 1]) == [1, 5] - -# 0.7.0-DEV.3516 -@test argmax([10,12,9,11]) == 2 -@test argmax([10 12; 9 11]) == CartesianIndex(1, 2) -@test argmax(Dict(:z=>10, :y=>12, :x=>9, :w=>11)) == :y -@test argmax((-5, 6, 10)) == 3 -@test argmin([10,12,9,11]) == 3 -@test argmin([10 12; 9 11]) == CartesianIndex(2, 1) -@test argmin(Dict(:z=>10, :y=>12, :x=>9, :w=>11)) == :x -@test argmin((1.0, -3, 0.f0)) == 2 - -# 0.7.0-DEV.3460 -@test parentmodule(Base.Sys) == Base -@test parentmodule(sin) == Base -@test parentmodule(sin, Tuple{Int}) == Base.Math -@test parentmodule(Int) == Core -@test parentmodule(Array) == Core - -@test codeunits("foo") == [0x66,0x6f,0x6f] == codeunits(SubString("fooαβγ",1,3)) -@test ncodeunits("αβγ") == 6 == ncodeunits(SubString("fooαβγ",4,8)) - -# 0.7.0-DEV.3539 -@test nameof(Compat.Sys) == :Sys -@test nameof(sin) == :sin -@test nameof(Float64) == :Float64 -@test nameof(Array) == :Array - -# 0.7.0-DEV.3469 -@test GC.enable(true) -@test GC.enable(false) -@test !GC.enable(false) -@test !GC.enable(true) -@test GC.enable(true) - -@test eltype(Base.Multimedia.displays) <: AbstractDisplay - -# 0.7.0-DEV.3481 -let b = IOBuffer() - write(b, "hi") - @test bytesavailable(b) == 0 -end - -# 0.7.0-DEV.3583 -@test lastindex(zeros(4)) == 4 -@test lastindex(zeros(4,4)) == 16 -@test all(x -> firstindex(x) == 1, ([1, 2], [1 2; 3 4], 'a', 1, 1=>2, `foo`, "foo", (1, 2))) - -# 0.7.0-DEV.3585 -let buf = IOBuffer() - if VERSION < v"0.7.0-DEV.3077" - col = Base.have_color - eval(Base, :(have_color = true)) - printstyled(buf, "foo", color=:red) - eval(Base, :(have_color = $col)) - else - printstyled(IOContext(buf, :color=>true), "foo", color=:red) - end - @test startswith(String(take!(buf)), Base.text_colors[:red]) -end - -# 0.7.0-DEV.3455 -@test hasmethod(sin, Tuple{Float64}) -let x = y = 1 - @test objectid(x) == objectid(y) -end - -# 0.7.0-DEV.3415 -for (f1, f2, i) in ((Compat.findfirst, Compat.findnext, 1), - (Compat.findlast, Compat.findprev, 2)) - # Generic methods - @test f1(isequal(0), [1, 0]) == f2(isequal(0), [1, 0], i) == 2 - @test f1(isequal(9), [1, 0]) == f2(isequal(9), [1, 0], i) == nothing - @test f1(in([0, 2]), [1, 0]) == f2(in([0, 2]), [1, 0], i) == 2 - @test f1(in([0, 2]), [1, 9]) == f2(in([0, 2]), [1, 9], i) == nothing - @test f1([true, false]) == f2([true, false], i) == 1 - @test f1([false, false]) == f2([false, false], i) == nothing - - # Specific methods - @test f2(isequal('a'), "ba", i) == f1(isequal('a'), "ba") == 2 - for S in (Int8, UInt8), T in (Int8, UInt8) - # Bug in Julia 0.6 - @test f2(isequal(S(1)), T[0, 1], i) == f1(isequal(S(1)), T[0, 1]) == 2 - @test f2(isequal(S(9)), T[0, 1], i) == f1(isequal(S(9)), T[0, 1]) == nothing - end - for chars in (['a', 'z'], Set(['a', 'z']), ('a', 'z')) - @test f2(in(chars), "ba", i) == f1(in(chars), "ba") == 2 - @test f2(in(chars), "bx", i) == f1(in(chars), "bx") == nothing - end -end -@test findnext("a", "ba", 1) == findfirst("a", "ba") == 2:2 -@test findnext("z", "ba", 1) == findfirst("z", "ba") == nothing -@test findprev("a", "ba", 2) == findlast("a", "ba") == 2:2 -@test findprev("z", "ba", 2) == findlast("z", "ba") == nothing -@test Compat.findnext("a", "ba", 1) == Compat.findfirst("a", "ba") == 2:2 -@test Compat.findnext("z", "ba", 1) == Compat.findfirst("z", "ba") == nothing -@test Compat.findprev("a", "ba", 2) == Compat.findlast("a", "ba") == 2:2 -@test Compat.findprev("z", "ba", 2) == Compat.findlast("z", "ba") == nothing - -@test findnext(r"a", "ba", 1) == findfirst(r"a", "ba") == 2:2 -@test findnext(r"z", "ba", 1) == findfirst(r"z", "ba") == nothing -@test Compat.findnext(r"a", "ba", 1) == Compat.findfirst(r"a", "ba") == 2:2 -@test Compat.findnext(r"z", "ba", 1) == Compat.findfirst(r"z", "ba") == nothing - -@test findall([true, false, true]) == [1, 3] -@test findall(in([1, 2]), [1]) == [1] - -@test repr("text/plain", "string") == "\"string\"" #25990 -@test showable("text/plain", 3.14159) #26089 - -# 0.7.0-DEV.3526 -module TestNames - export foo - function bar end -end -@test :foo in Compat.names(TestNames) -@test :bar in Compat.names(TestNames, all=true) - -# 0.7.0-DEV.4804 -@test Compat.trunc(pi) == 3.0 -@test Compat.floor(pi) == 3.0 -@test Compat.ceil(pi) == 4.0 -@test Compat.round(pi) == 3.0 -@test Compat.trunc(pi, digits = 3) == 3.141 -@test Compat.floor(pi, digits = 3) == 3.141 -@test Compat.ceil(pi, digits = 3) == 3.142 -@test Compat.round(pi, digits = 3) == 3.142 -@test Compat.round(pi, sigdigits = 5) == 3.1416 -@test Compat.trunc(pi, base = 2) == 3.0 -@test Compat.floor(pi, base = 2) == 3.0 -@test Compat.ceil(pi, base = 2) == 4.0 -@test Compat.round(pi, base = 2) == 3.0 -@test Compat.trunc(pi, digits = 3, base = 2) == 3.125 -@test Compat.floor(pi, digits = 3, base = 2) == 3.125 -@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 - -# 0.7.0-DEV.3986 -@test_throws ArgumentError Compat.range(1) -@test_throws ArgumentError Compat.range(nothing) -@test_throws ArgumentError Compat.range(1, step=1) -@test_throws ArgumentError Compat.range(1, step=1, stop=4, length=3) -@test Compat.range(2, step=2, stop=8) == 2:2:8 -@test Compat.range(2, stop=8) == 2:8 -@test Compat.range(2, step=2, length=8) == 2:2:16 -@test Compat.range(1.0, stop=2.0, length=3) == 1.0:0.5:2.0 - -# 0.7.0-DEV.3995 -mktempdir(@__DIR__) do dir - src = joinpath(dir, "src.jl") - touch(src) - dest = joinpath(dir, "dest.jl") - touch(dest) - open(src, "w") do f - write(f, "Hello, world!") - end - Compat.cp(src, dest, force = true) - open(dest, "r") do f - @test read(f, String) == "Hello, world!" - end - Compat.mv(src, dest, force = true) - open(dest, "r") do f - @test read(f, String) == "Hello, world!" - end - @test readdir(dir) == ["dest.jl"] -end - -# 0.7.0-DEV.3972 -@test Compat.indexin([1, 2], [1, 0, 1]) == [1, nothing] - -# 0.7.0-DEV.4585 -@test isuppercase('A') -@test !isuppercase('a') -@test islowercase('a') -@test !islowercase('A') -@test uppercasefirst("qwerty") == "Qwerty" -@test lowercasefirst("Qwerty") == "qwerty" - -# 0.7.0-DEV.4064 -# some tests are behind a version check below because Julia gave -# the wrong result between 0.7.0-DEV.3262 and 0.7.0-DEV.4646 -# see https://github.com/JuliaLang/julia/issues/26488 -Issue26488 = VERSION < v"0.7.0-DEV.3262" || VERSION >= v"0.7.0-DEV.4646" -@test Compat.Statistics.mean([1 2; 3 4]) == 2.5 -@test Compat.Statistics.mean([1 2; 3 4], dims=1) == [2 3] -@test Compat.Statistics.mean([1 2; 3 4], dims=2) == hcat([1.5; 3.5]) -@test Compat.cumsum([1 2; 3 4], dims=1) == [1 2; 4 6] -@test Compat.cumsum([1 2; 3 4], dims=2) == [1 3; 3 7] -@test Compat.cumprod([1 2; 3 4], dims=1) == [1 2; 3 8] -@test Compat.cumprod([1 2; 3 4], dims=2) == [1 2; 3 12] -@test Compat.sum([1 2; 3 4]) == 10 -@test Compat.sum([1 2; 3 4], dims=1) == [4 6] -@test Compat.sum([1 2; 3 4], dims=2) == hcat([3; 7]) -@test Compat.sum(x -> x+1, [1 2; 3 4]) == 14 -Issue26488 && @test Compat.sum(x -> x+1, [1 2; 3 4], dims=1) == [6 8] -Issue26488 && @test Compat.sum(x -> x+1, [1 2; 3 4], dims=2) == hcat([5; 9]) -@test Compat.prod([1 2; 3 4]) == 24 -@test Compat.prod([1 2; 3 4], dims=1) == [3 8] -@test Compat.prod([1 2; 3 4], dims=2) == hcat([2; 12]) -@test Compat.prod(x -> x+1, [1 2; 3 4]) == 120 -Issue26488 && @test Compat.prod(x -> x+1, [1 2; 3 4], dims=1) == [8 15] -Issue26488 && @test Compat.prod(x -> x+1, [1 2; 3 4], dims=2) == hcat([6; 20]) -@test Compat.maximum([1 2; 3 4]) == 4 -@test Compat.maximum([1 2; 3 4], dims=1) == [3 4] -@test Compat.maximum([1 2; 3 4], dims=2) == hcat([2; 4]) -@test Compat.maximum(x -> x+1, [1 2; 3 4]) == 5 -@test Compat.maximum(x -> x+1, [1 2; 3 4], dims=1) == [4 5] -@test Compat.maximum(x -> x+1, [1 2; 3 4], dims=2) == hcat([3; 5]) -@test Compat.minimum([1 2; 3 4]) == 1 -@test Compat.minimum([1 2; 3 4], dims=1) == [1 2] -@test Compat.minimum([1 2; 3 4], dims=2) == hcat([1; 3]) -@test Compat.minimum(x -> x+1, [1 2; 3 4]) == 2 -@test Compat.minimum(x -> x+1, [1 2; 3 4], dims=1) == [2 3] -@test Compat.minimum(x -> x+1, [1 2; 3 4], dims=2) == hcat([2; 4]) -@test Compat.all([true false; true false]) == false -@test Compat.all([true false; true false], dims=1) == [true false] -@test Compat.all([true false; true false], dims=2) == hcat([false; false]) -@test Compat.all(isodd, [1 2; 3 4]) == false -@test Compat.all(isodd, [1 2; 3 4], dims=1) == [true false] -@test Compat.all(isodd, [1 2; 3 4], dims=2) == hcat([false; false]) -@test Compat.any([true false; true false]) == true -@test Compat.any([true false; true false], dims=1) == [true false] -@test Compat.any([true false; true false], dims=2) == hcat([true; true]) -@test Compat.any(isodd, [1 2; 3 4]) == true -@test Compat.any(isodd, [1 2; 3 4], dims=1) == [true false] -@test Compat.any(isodd, [1 2; 3 4], dims=2) == hcat([true; true]) -@test Compat.findmax([3, 2, 7, 4]) == (7, 3) -@test Compat.findmax([3, 2, 7, 4], dims=1) == ([7], [3]) -@test Compat.findmax([1 2; 3 4], dims=1) == ([3 4], [CartesianIndex(2, 1) CartesianIndex(2, 2)]) -@test Compat.findmax([1 2; 3 4]) == (4, CartesianIndex(2, 2)) -@test Compat.findmax([1 2; 3 4], dims=1) == ([3 4], [CartesianIndex(2, 1) CartesianIndex(2, 2)]) -@test Compat.findmax([1 2; 3 4], dims=2) == (hcat([2; 4]), hcat([CartesianIndex(1, 2); CartesianIndex(2, 2)])) -@test Compat.findmin([3, 2, 7, 4]) == (2, 2) -@test Compat.findmin([3, 2, 7, 4], dims=1) == ([2], [2]) -@test Compat.findmin([1 2; 3 4]) == (1, CartesianIndex(1, 1)) -@test Compat.findmin([1 2; 3 4], dims=1) == ([1 2], [CartesianIndex(1, 1) CartesianIndex(1, 2)]) -@test Compat.findmin([1 2; 3 4], dims=2) == (hcat([1; 3]), hcat([CartesianIndex(1, 1); CartesianIndex(2, 1)])) -if VERSION < v"0.7.0-DEV.5238" - # Test these functions if their counterparts are defined in Base. In the future, this - # will be dealt with in StatsBase - @test Compat.Statistics.varm([1 2; 3 4], -1) == 18 - @test Compat.Statistics.varm([1 2; 3 4], [-1 -2], dims=1) == [20 52] - @test Compat.Statistics.varm([1 2; 3 4], [-1, -2], dims=2) == hcat([13, 61]) - @test Compat.Statistics.var([1 2; 3 4]) == 5/3 - @test Compat.Statistics.var([1 2; 3 4], dims=1) == [2 2] - @test Compat.Statistics.var([1 2; 3 4], dims=2) == hcat([0.5, 0.5]) - @test Compat.Statistics.var([1 2; 3 4], corrected=false) == 1.25 - @test Compat.Statistics.var([1 2; 3 4], corrected=false, dims=1) == [1 1] - @test Compat.Statistics.var([1 2; 3 4], corrected=false, dims=2) == hcat([0.25, 0.25]) - @test Compat.Statistics.std([1 2; 3 4]) == sqrt(5/3) - @test Compat.Statistics.std([1 2; 3 4], dims=1) == [sqrt(2) sqrt(2)] - @test Compat.Statistics.std([1 2; 3 4], dims=2) == hcat([sqrt(0.5), sqrt(0.5)]) - @test Compat.Statistics.std([1 2; 3 4], corrected=false) == sqrt(1.25) - @test Compat.Statistics.std([1 2; 3 4], corrected=false, dims=1) == [sqrt(1) sqrt(1)] - @test Compat.Statistics.std([1 2; 3 4], corrected=false, dims=2) == hcat([sqrt(0.25), sqrt(0.25)]) - @test Compat.Statistics.cov([1 2; 3 4]) == [2 2; 2 2] - @test Compat.Statistics.cov([1 2; 3 4], dims=1) == [2 2; 2 2] - @test Compat.Statistics.cov([1 2; 3 4], dims=2) == [0.5 0.5; 0.5 0.5] - @test Compat.Statistics.cov([1 2; 3 4], [4; 5]) == hcat([1; 1]) - @test Compat.Statistics.cov([1 2; 3 4], [4; 5], dims=1) == hcat([1; 1]) - @test Compat.Statistics.cov([1 2; 3 4], [4; 5], dims=2) == hcat([0.5; 0.5]) - @test Compat.Statistics.cov([1 2; 3 4], [4; 5], corrected=false) == hcat([0.5; 0.5]) - @test Compat.Statistics.cov([1 2; 3 4], [4; 5], corrected=false, dims=1) == hcat([0.5; 0.5]) - @test Compat.Statistics.cov([1 2; 3 4], [4; 5], corrected=false, dims=2) == hcat([0.25; 0.25]) - @test Compat.Statistics.cor([1 2; 3 4]) ≈ [1 1; 1 1] - @test Compat.Statistics.cor([1 2; 3 4], dims=1) ≈ [1 1; 1 1] - @test Compat.Statistics.cor([1 2; 3 4], dims=2) ≈ [1 1; 1 1] - @test Compat.Statistics.cor([1 2; 3 4], [4; 5]) ≈ [1; 1] - @test Compat.Statistics.cor([1 2; 3 4], [4; 5], dims=1) ≈ [1; 1] - @test Compat.Statistics.cor([1 2; 3 4], [4; 5], dims=2) ≈ [1; 1] -end -@test Compat.Statistics.median([1 2; 3 4]) == 2.5 -@test Compat.Statistics.median([1 2; 3 4], dims=1) == [2 3] -@test Compat.Statistics.median([1 2; 3 4], dims=2) == hcat([1.5; 3.5]) -@test Compat.mapreduce(string, *, [1 2; 3 4]) == "1324" -Issue26488 && @test Compat.mapreduce(string, *, [1 2; 3 4], dims=1) == ["13" "24"] -Issue26488 && @test Compat.mapreduce(string, *, [1 2; 3 4], dims=2) == hcat(["12", "34"]) -@test Compat.mapreduce(string, *, [1 2; 3 4], init="z") == "z1324" -@test Compat.mapreduce(string, *, (1, 2, 3, 4), init="z") == "z1234" -@test Compat.mapreduce(string, *, [1 2; 3 4], dims=1, init="z") == ["z13" "z24"] -@test Compat.mapreduce(string, *, [1 2; 3 4], dims=2, init="z") == hcat(["z12", "z34"]) -@test Compat.reduce(*, [1 2; 3 4]) == 24 -@test Compat.reduce(*, [1 2; 3 4], dims=1) == [3 8] -@test Compat.reduce(*, [1 2; 3 4], dims=2) == hcat([2, 12]) -@test Compat.reduce(*, [1 2; 3 4], init=10) == 240 -@test Compat.reduce(*, (1, 2, 3, 4), init=10) == 240 -@test Compat.reduce(*, [1 2; 3 4], dims=1, init=10) == [30 80] -@test Compat.reduce(*, [1 2; 3 4], dims=2, init=10) == hcat([20, 120]) -@test Compat.sort([1, 2, 3, 4]) == [1, 2, 3, 4] -@test Compat.sort([1 2; 3 4], dims=1) == [1 2; 3 4] -@test Compat.sort([1 2; 3 4], dims=2) == [1 2; 3 4] -@test Compat.sort([1, 2, 3, 4], rev=true) == [4, 3, 2, 1] -@test Compat.sort([1 2; 3 4], rev=true, dims=1) == [3 4; 1 2] -@test Compat.sort([1 2; 3 4], rev=true, dims=2) == [2 1; 4 3] -@test Compat.accumulate(*, [1 2; 3 4], dims=1) == [1 2; 3 8] -@test Compat.accumulate(*, [1 2; 3 4], dims=2) == [1 2; 3 12] -@test Compat.cumsum([1 2; 3 4], dims=1) == [1 2; 4 6] -@test Compat.cumsum([1 2; 3 4], dims=2) == [1 3; 3 7] -@test Compat.cumprod([1 2; 3 4], dims=1) == [1 2; 3 8] -@test Compat.cumprod([1 2; 3 4], dims=2) == [1 2; 3 12] -let b = zeros(2,2) - Compat.accumulate!(*, b, [1 2; 3 4], dims=1) - @test b == [1 2; 3 8] - Compat.accumulate!(*, b, [1 2; 3 4], dims=2) - @test b == [1 2; 3 12] - Compat.cumsum!(b, [1 2; 3 4], dims=1) - @test b == [1 2; 4 6] - Compat.cumsum!(b, [1 2; 3 4], dims=2) - @test b == [1 3; 3 7] - Compat.cumprod!(b, [1 2; 3 4], dims=1) - @test b == [1 2; 3 8] - Compat.cumprod!(b, [1 2; 3 4], dims=2) - @test b == [1 2; 3 12] -end -@test Compat.reverse([1, 2, 3, 4]) == [4, 3, 2, 1] -@test Compat.reverse([1 2; 3 4], dims=1) == [3 4; 1 2] -@test Compat.reverse([1 2; 3 4], dims=2) == [2 1; 4 3] - -# 0.7.0-DEV.4738 -if VERSION < v"0.7.0-beta2.143" - @test squeeze([1 2], dims=1) == [1, 2] - @test_throws ArgumentError squeeze([1 2], dims=2) - @test_throws ArgumentError squeeze(hcat([1, 2]), dims=1) - @test squeeze(hcat([1, 2]), dims=2) == [1, 2] - @test_throws Exception squeeze([1,2]) -end - -# 0.7.0-DEV.5165 -@test Compat.cat([1, 2], [3, 4, 5], dims = 1) == [1, 2, 3, 4, 5] -@test Compat.cat([1, 2], [3, 4], dims = 2) == [1 3; 2 4] -if VERSION < v"0.7.0-DEV.5165" - @test_throws UndefKeywordError Compat.cat([1, 2], [3, 4]) -end - -# 0.7.0-DEV.3976 -let A = rand(5,5) - @test selectdim(A, 1, 3) == A[3, :] - @test selectdim(A, 1, 1:3) == A[1:3, :] - @test selectdim(A, 2, 3) == A[:, 3] - @test selectdim(A, 2, 1:3) == A[:, 1:3] - selectdim(A, 1, 3)[3] = 42 - @test A[3,3] == 42 - B = rand(4, 3, 2) - @test IndexStyle(selectdim(B, 1, 1)) == IndexStyle(view(B, 1, :, :)) == IndexLinear() - @test IndexStyle(selectdim(B, 2, 1)) == IndexStyle(view(B, :, 1, :)) == IndexCartesian() - @test IndexStyle(selectdim(B, 3, 1)) == IndexStyle(view(B, :, :, 1)) == IndexLinear() -end - -@test repeat([1, 2], 3) == [1, 2, 1, 2, 1, 2] -@test repeat(1:4, 2) == [1, 2, 3, 4, 1, 2, 3, 4] -@test repeat([1 2; 3 4], 2, 3) == [1 2 1 2 1 2 - 3 4 3 4 3 4 - 1 2 1 2 1 2 - 3 4 3 4 3 4] -@test repeat([1, 2], 1, 2, 3) == [x for x in 1:2, y in 1:2, z in 1:3] - -# 0.7.0-DEV.3936 -@test let ct = current_task(), t = @task true - schedule(ct) - yieldto(t) - fetch(t) -end - -# 0.7.0-DEV.5087 -@test isletter('a') -@test isletter('β') -@test !isletter('3') - -# 0.7.0-DEV.4905 -@test isbitstype(Int) -@test !isbitstype(Vector{Int}) - -# 0.7.0-DEV.4762 -let ptr = @cfunction(+, Int, (Int, Int)) - @test ptr isa Ptr{Cvoid} - @test ptr != C_NULL - @test ccall(ptr, Int, (Int, Int), 2, 3) == 5 -end -# issue #565 -issue565(x) = x + 1 -const Issue565 = Int -let bar() = @cfunction(issue565, Issue565, (Issue565,)), ptr = bar() - @test ptr isa Ptr{Cvoid} - @test ptr != C_NULL - @test ccall(ptr, Int, (Int,), 2) === 3 -end - -@test codeunit("foo") == codeunit(SubString("fooαβγ",1,3)) == UInt8 - -# julia#24999 -let s = "∀α>β:α+" - @test [length(s,i,j) for i=1:ncodeunits(s)+1, j=0:ncodeunits(s)] == - [0 1 1 1 2 2 3 4 4 5 6 6 7; 0 0 0 0 1 1 2 3 3 4 5 5 6; 0 0 0 0 1 1 2 3 3 4 5 5 6; 0 0 0 0 1 1 2 3 3 4 5 5 6; 0 0 0 0 0 0 1 2 2 3 4 4 5; 0 0 0 0 0 0 1 2 2 3 4 4 5; 0 0 0 0 0 0 0 1 1 2 3 3 4; 0 0 0 0 0 0 0 0 0 1 2 2 3; 0 0 0 0 0 0 0 0 0 1 2 2 3; 0 0 0 0 0 0 0 0 0 0 1 1 2; 0 0 0 0 0 0 0 0 0 0 0 0 1; 0 0 0 0 0 0 0 0 0 0 0 0 1; 0 0 0 0 0 0 0 0 0 0 0 0 0] -end -@test_throws BoundsError length("hello", 1, -1) -@test_throws BoundsError length("hellø", 1, -1) -@test_throws BoundsError length("hello", 1, 10) -@test_throws BoundsError length("hellø", 1, 10) == 9 -@test_throws BoundsError prevind("hello", 0, 1) -@test_throws BoundsError prevind("hellø", 0, 1) -@test nextind("hello", 0, 10) == 10 -# julia#24414 -let strs = Any["∀α>β:α+1>β", SubString("123∀α>β:α+1>β123", 4, 18)] - for s in strs - @test_throws BoundsError thisind(s, -2) - @test_throws BoundsError thisind(s, -1) - @test thisind(s, 0) == 0 - @test thisind(s, 1) == 1 - @test thisind(s, 2) == 1 - @test thisind(s, 3) == 1 - @test thisind(s, 4) == 4 - @test thisind(s, 5) == 4 - @test thisind(s, 6) == 6 - @test thisind(s, 15) == 15 - @test thisind(s, 16) == 15 - @test thisind(s, 17) == 17 - @test_throws BoundsError thisind(s, 18) - @test_throws BoundsError thisind(s, 19) - end -end -let strs = Any["", SubString("123", 2, 1)] - for s in strs - @test_throws BoundsError thisind(s, -1) - @test thisind(s, 0) == 0 - @test thisind(s, 1) == 1 - @test_throws BoundsError thisind(s, 2) - end -end -# prevind and nextind, julia#23805 -let s = "∀α>β:α+1>β" - @test_throws BoundsError prevind(s, 0, 0) - @test_throws BoundsError prevind(s, 0, 1) - @test prevind(s, 1, 1) == 0 - @test prevind(s, 1, 0) == 1 - @test prevind(s, 2, 1) == 1 - @test prevind(s, 4, 1) == 1 - @test prevind(s, 5, 1) == 4 - @test prevind(s, 5, 2) == 1 - @test prevind(s, 5, 3) == 0 - @test prevind(s, 15, 1) == 14 - @test prevind(s, 15, 2) == 13 - @test prevind(s, 15, 3) == 12 - @test prevind(s, 15, 4) == 10 - @test prevind(s, 15, 10) == 0 - @test prevind(s, 15, 9) == 1 - @test prevind(s, 16, 1) == 15 - @test prevind(s, 16, 2) == 14 - @test prevind(s, 17, 1) == 15 - @test prevind(s, 17, 2) == 14 - @test_throws BoundsError prevind(s, 18, 0) - @test_throws BoundsError prevind(s, 18, 1) - @test_throws BoundsError nextind(s, -1, 0) - @test_throws BoundsError nextind(s, -1, 1) - @test nextind(s, 0, 2) == 4 - @test nextind(s, 0, 20) == 26 - @test nextind(s, 0, 10) == 15 - @test nextind(s, 1, 1) == 4 - @test nextind(s, 1, 2) == 6 - @test nextind(s, 1, 9) == 15 - @test nextind(s, 1, 10) == 17 - @test nextind(s, 2, 1) == 4 - @test nextind(s, 3, 1) == 4 - @test nextind(s, 4, 1) == 6 - @test nextind(s, 14, 1) == 15 - @test nextind(s, 15, 1) == 17 - @test nextind(s, 15, 2) == 18 - @test nextind(s, 16, 1) == 17 - @test nextind(s, 16, 2) == 18 - @test nextind(s, 16, 3) == 19 - @test_throws BoundsError nextind(s, 17, 0) - @test_throws BoundsError nextind(s, 17, 1) - for k in 0:ncodeunits(s)+1 - n = p = k - for j in 1:40 - if 1 ≤ p - p = prevind(s, p) - @test prevind(s, k, j) == p - end - if n ≤ ncodeunits(s) - n = nextind(s, n) - @test nextind(s, k, j) == n - end - end - end -end - -# 0.7.0-DEV.5278 -@test something(nothing, 1) === 1 -@test something(Some(2)) === 2 -@test something(Some(2), 1) === 2 -@test something(nothing, Some(1)) === 1 - -# julia#24839 -@test permutedims([1 2; 3 4]) == [1 3; 2 4] -@test permutedims([1,2,3]) == [1 2 3] - -# 0.7.0-alpha.44 -@test atan(1, 2) == atan(0.5) -@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 - -# 0.7.0-beta.73 -let a = rand(5,5) - s = mapslices(sort, a, dims=[1]) - S = mapslices(sort, a, dims=[2]) - for i = 1:5 - @test s[:,i] == sort(a[:,i]) - @test vec(S[i,:]) == sort(vec(a[i,:])) - end -end - -# 0.7.0-beta2.169 -@test floatmin(Float16) == @eval $(Core.Intrinsics.bitcast(Float16, 0x0400)) -@test floatmax(Float32) == @eval $(Core.Intrinsics.bitcast(Float32, 0x7f7fffff)) -@test floatmin(zero(Float64)) == floatmin(Float64) - -# 0.7.0-beta2.143 -if VERSION < v"0.7.0-beta2.143" - let a = reshape(Vector(1:4),(2,2,1,1)), b = reshape(Vector(1:4), (2,2,1)) - @test dropdims(a; dims=3) == b - @test_throws UndefKeywordError dropdims(a) - end -end - -let - # test required keyword arguments - @compat func1() = 1 - @test func1() == 1 # using the function works - @compat func2(x) = x - @test func2(3) == 3 # using the function works - @compat func3(;y) = y - @test func3(y=2) == 2 # using the function works - @test_throws UndefKeywordError func3() - @compat func4(x; z) = x*z - @test func4(2,z=3) == 6 # using the function works - @test_throws UndefKeywordError func4(2) - @compat func5(;x=1, y) = x*y - @test func5(y=3) == 3 - @test func5(y=3, x=2) == 6 - @test_throws UndefKeywordError func5(x=2) -end - -let - @compat cr(::CartesianIndices{2}) = 2 - @test cr(CartesianIndices((5, 3))) == 2 - @test_throws MethodError cr(CartesianIndices((5, 3, 2))) -end - -# 0.7 -let A = [1] - local x = 0 - @compat finalizer(a->(x+=1), A) - finalize(A) - @test x == 1 - A = 0 - GC.gc(); GC.gc() - @test x == 1 -end diff --git a/test/runtests.jl b/test/runtests.jl index fead53828..af6b808ee 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -90,6 +90,4 @@ end @test_throws DivideError mod(3, 1:0) end -include("old.jl") - nothing