From f008a07cd13f5861228d3aab35f0171236ca60cc Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Sat, 3 Feb 2018 15:53:00 -0800 Subject: [PATCH] Add Compat.Pkg and Compat.InteractiveUtils (#485) --- README.md | 8 ++++++++ src/Compat.jl | 29 +++++++++++++++++++++++++++++ test/runtests.jl | 16 ++++++++++++++++ 3 files changed, 53 insertions(+) diff --git a/README.md b/README.md index 54b573224cb70..6dc623fb5b2e6 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,12 @@ Currently, the `@compat` macro supports the following syntaxes: * `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]). + +* `using Compat.InteractiveUtils` is provided on versions older than 0.7, where this library is + not yet part of the standard library ([#25780]). + ## New functions, macros, and methods * `@views` takes an expression and converts all slices to views ([#20164]), while @@ -531,4 +537,6 @@ includes this fix. Find the minimum version from there. [#25634]: https://github.com/JuliaLang/julia/issues/25634 [#25646]: https://github.com/JuliaLang/julia/issues/25646 [#25654]: https://github.com/JuliaLang/julia/issues/25654 +[#25705]: https://github.com/JuliaLang/julia/issues/25705 +[#25780]: https://github.com/JuliaLang/julia/issues/25780 [#24182]: https://github.com/JuliaLang/julia/issues/24182 diff --git a/src/Compat.jl b/src/Compat.jl index 94c67def394b9..28a394b410a45 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -1491,6 +1491,35 @@ else import Distributed 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, + @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 + # 0.7.0-DEV.2695 @static if !isdefined(Base, :AbstractDisplay) const AbstractDisplay = Display diff --git a/test/runtests.jl b/test/runtests.jl index e9971a3587c61..ef9407992d4f2 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1286,6 +1286,22 @@ module TestSerialization @test isdefined(@__MODULE__, :SerializationState) end +module TestPkg + using Compat + using Compat.Pkg + using Compat.Test + @test isdefined(@__MODULE__, :Pkg) + @test isdefined(@__MODULE__, :add) +end + +module TestInteractiveUtils + using Compat + using Compat.InteractiveUtils + using Compat.Test + @test isdefined(@__MODULE__, :InteractiveUtils) + @test isdefined(@__MODULE__, :varinfo) +end + # 0.7.0-DEV.3469 @test GC.enable(true) @test GC.enable(false)