Skip to content

Commit

Permalink
BitArray constructors for uninitialized (#429)
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre authored Dec 6, 2017
1 parent 602c43a commit 0a09689
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ Currently, the `@compat` macro supports the following syntaxes:

* `Uninitialized` and `uninitialized` with corresponding `Array` constructors ([#24652]).

* `BitArray` constructors for `uninitialized` ([#24785]).

* `@compat finalizer(func, obj)` with the finalizer to run as the first argument and the object to be finalized
as the second ([#24605]).

Expand Down Expand Up @@ -376,3 +378,4 @@ includes this fix. Find the minimum version from there.
[#24605]: https://github.com/JuliaLang/julia/issues/24605
[#24652]: https://github.com/JuliaLang/julia/issues/24652
[#24657]: https://github.com/JuliaLang/julia/issues/24657
[#24785]: https://github.com/JuliaLang/julia/issues/24785
6 changes: 6 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,9 @@ end
Array{T,N}(::Uninitialized, args...) where {T,N} = Array{T,N}(args...)
Vector(::Uninitialized, args...) = Vector(args...)
Matrix(::Uninitialized, args...) = Matrix(args...)
BitArray{N}(::Uninitialized, args...) where {N} = BitArray{N}(args...)
BitArray(::Uninitialized, args...) = BitArray(args...)
""")
else
include_string(@__MODULE__, """
Expand All @@ -831,6 +834,9 @@ end
(::Type{Array{T,N}}){T,N}(::Uninitialized, args...) = Array{T,N}(args...)
(::Type{Vector})(::Uninitialized, args...) = Vector(args...)
(::Type{Matrix})(::Uninitialized, args...) = Matrix(args...)
(::Type{BitArray{N}}){N}(::Uninitialized, args...) = BitArray{N}(args...)
(::Type{BitArray})(::Uninitialized, args...) = BitArray(args...)
""")
end
const uninitialized = Uninitialized()
Expand Down
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,10 @@ end
@test isa(Array{Float64}(uninitialized, 2, 2), Matrix{Float64})
@test isa(Array{Float64,3}(uninitialized, 2, 2, 2), Array{Float64,3})

# 0.7.0-DEV.2687
@test isa(BitVector(uninitialized, 2), BitVector)
@test isa(BitArray(uninitialized, 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)
Expand Down

0 comments on commit 0a09689

Please sign in to comment.