Skip to content

Commit

Permalink
Support get(::Function, ::EnvHash, key) (#430)
Browse files Browse the repository at this point in the history
  • Loading branch information
omus authored and fredrikekre committed Dec 7, 2017
1 parent 838890b commit 89740ef
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ Currently, the `@compat` macro supports the following syntaxes:

* `IOContext` accepting key-value `Pair`s ([#23271]).

* `get` do-block syntax supported when using `ENV` ([#23412]).

## Renaming


Expand Down Expand Up @@ -366,6 +368,7 @@ includes this fix. Find the minimum version from there.
[#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
[#23666]: https://github.com/JuliaLang/julia/issues/23666
Expand Down
7 changes: 7 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,13 @@ end
export Uninitialized, uninitialized
end

# 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

include("deprecated.jl")

end # module Compat
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,12 @@ 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

if VERSION < v"0.6.0"
include("deprecated.jl")
end
Expand Down

0 comments on commit 89740ef

Please sign in to comment.