Skip to content

Commit

Permalink
make union(::Tuple,...) work again (fix #25338)
Browse files Browse the repository at this point in the history
  • Loading branch information
rfourquet committed Jan 2, 2018
1 parent c3c0964 commit 2a258c9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ empty(a::AbstractVector{T}, ::Type{U}=T) where {T,U} = Vector{U}()

# like empty, but should return a mutable collection, a Vector by default
emptymutable(a::AbstractVector{T}, ::Type{U}=T) where {T,U} = Vector{U}()
emptymutable(itr, ::Type{U}) where {U} = Vector{U}()

## from general iterable to any array

Expand Down Expand Up @@ -2043,4 +2044,4 @@ function hash(a::AbstractArray{T}, h::UInt) where T
end
!isequal(x2, x1) && (h = hash(x2, h))
return h
end
end
9 changes: 9 additions & 0 deletions test/arrayops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,15 @@ end
@test isequal(symdiff([1,2,3], Float64[]), Float64[1.0,2,3])
@test isequal(symdiff(Int64[], [1,2,3]), Int64[1,2,3])
@test isequal(symdiff(Int64[]), Int64[])
@testset "tuples" begin # Issue #25338
@test union((1, 2), (3)) == [1, 2, 3]
u = union((1, 0x2), [3])
@test eltype(u) == Integer
@test u == [1, 2, 3]
@test intersect((1, 2), (3, 2)) == [2]
@test setdiff((1, 2), (3, 2)) == [1]
@test symdiff((1, 2), (3, 2)) == [1, 3]
end
end

@testset "mapslices" begin
Expand Down

0 comments on commit 2a258c9

Please sign in to comment.