Skip to content

Commit

Permalink
Merge pull request #404 from JuliaLang/fw/stdlib2
Browse files Browse the repository at this point in the history
Add Compat for standard library imports
  • Loading branch information
TotalVerb authored Oct 6, 2017
2 parents 3dbca5d + 91485f7 commit a2b9b90
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ 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.

* `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])

## Module Aliases

* In 0.6, some 0.5 iterator functions have been moved to the `Base.Iterators`
Expand Down Expand Up @@ -298,6 +302,7 @@ includes this fix. Find the minimum version from there.
[#18977]: https://github.com/JuliaLang/julia/issues/18977
[#19088]: https://github.com/JuliaLang/julia/issues/19088
[#19246]: https://github.com/JuliaLang/julia/issues/19246
[#19331]: https://github.com/JuliaLang/julia/issues/19331
[#19449]: https://github.com/JuliaLang/julia/issues/19449
[#19635]: https://github.com/JuliaLang/julia/issues/19635
[#19784]: https://github.com/JuliaLang/julia/issues/19784
Expand All @@ -317,6 +322,7 @@ includes this fix. Find the minimum version from there.
[#21257]: https://github.com/JuliaLang/julia/issues/21257
[#21346]: https://github.com/JuliaLang/julia/issues/21346
[#21378]: https://github.com/JuliaLang/julia/issues/21378
[#21419]: https://github.com/JuliaLang/julia/issues/21419
[#21709]: https://github.com/JuliaLang/julia/issues/21709
[#22064]: https://github.com/JuliaLang/julia/issues/22064
[#22182]: https://github.com/JuliaLang/julia/issues/22182
Expand All @@ -334,3 +340,4 @@ includes this fix. Find the minimum version from there.
[#23570]: https://github.com/JuliaLang/julia/issues/23570
[#23666]: https://github.com/JuliaLang/julia/issues/23666
[#23812]: https://github.com/JuliaLang/julia/issues/23812
[#23931]: https://github.com/JuliaLang/julia/issues/23931
18 changes: 18 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,24 @@ end
export isconcrete
end

# 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

# 0.7.0-DEV.1993
@static if !isdefined(Base, :EqualTo)
if VERSION >= v"0.6.0"
Expand Down
19 changes: 16 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Compat
using Base.Test
using Compat.Test

# Issue #291
# 0.6
Expand Down Expand Up @@ -513,7 +513,7 @@ module Test18839

using Compat
using Compat.Iterators
using Base.Test
using Compat.Test

@test collect(take(countfrom(2), 3)) == [2, 3, 4]
@test collect(take(cycle(5:8), 9)) == [5:8; 5:8; 5]
Expand Down Expand Up @@ -627,7 +627,8 @@ b = Compat.collect(a)

# PR 22064
module Test22064
using Base.Test, Compat
using Compat
using Compat.Test
@test (@__MODULE__) === Test22064
end

Expand Down Expand Up @@ -824,6 +825,18 @@ end
@test isconcrete(Int)

# 0.7
module Test23876
using Compat
using Compat.Test
import Compat.DelimitedFiles
using Compat.Mmap, Compat.SharedArrays
@test isdefined(@__MODULE__, :DelimitedFiles)
@test isdefined(SharedArrays, :SharedArray)
@test isdefined(@__MODULE__, :SharedArray)
@test isdefined(@__MODULE__, :procs)
@test isdefined(Mmap, :mmap)
end

let a = [0,1,2,3,0,1,2,3]
@test findfirst(equalto(3), [1,2,4,1,2,3,4]) == 6
@test findfirst(!equalto(1), [1,2,4,1,2,3,4]) == 2
Expand Down

0 comments on commit a2b9b90

Please sign in to comment.