Skip to content

Commit

Permalink
Fixed the bug referenced in JuliaLang#43551 and added tests for the b…
Browse files Browse the repository at this point in the history
…itarray promotion
  • Loading branch information
JakobSachs committed Jan 3, 2022
1 parent fbe37e1 commit ea85e71
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions base/bitarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1913,3 +1913,5 @@ function read!(s::IO, B::BitArray)
end

sizeof(B::BitArray) = sizeof(B.chunks)

promote_rule(::Type{BitArray{N}},::Type{Array{T,M}}) where {T,N,M} = Array{T}
18 changes: 17 additions & 1 deletion test/bitarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,22 @@ end

timesofar("conversions")

@testset "Promotions for size $sz" for (sz, T) in allsizes
a1 = falses(sz...)
t1 = zeros(sz...)
@test isequal(promote(a1,t1),(t1,t1))

a2 = falses(sz...)
t2 = zeros(sz...)
@test isequal(promote(a2,t2),(t2,t2))

a3 = bitrand(sz...)
t3 = convert(T,a3)
@test isequal(promote(a3,t3),(t3,t3))
end

timesofar("promotions")

@testset "utility functions" begin
b1 = bitrand(v1)
@test isequal(fill!(b1, true), trues(size(b1)))
Expand Down Expand Up @@ -1767,4 +1783,4 @@ end
@test all(bitarray[rangeout, rangein] .== true)
@test all(bitarray[rangein, rangeout] .== true)
end
end
end

0 comments on commit ea85e71

Please sign in to comment.