Skip to content

Commit

Permalink
Test fixes to #21094, #22053
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Jan 3, 2018
1 parent 551b6b7 commit 53b3d14
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
7 changes: 7 additions & 0 deletions base/tuple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,13 @@ end
convert(::Type{Tuple}, tt::TupleLL) = map(identity, tt)
(::Type{Tuple})(tt::TupleLL) = convert(Tuple, tt)

any(f::Function, tt::TupleLL{Nothing, Nothing}) = false
any(f::Function, tt::TupleLL{<:Any, Nothing}) = f(tt.head)
any(f::Function, tt::TupleLL) = f(tt.head) || any(f, tt.rest)

all(f::Function, tt::TupleLL{Nothing, Nothing}) = true
all(f::Function, tt::TupleLL{<:Any, Nothing}) = f(tt.head)
all(f::Function, tt::TupleLL) = f(tt.head) && all(f, tt.rest)

start(tt::TupleLL) = tt
next(::TupleLL, tt::TupleLL) = (tt.head, tt.rest)
Expand Down
24 changes: 24 additions & 0 deletions test/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -626,3 +626,27 @@ let x = [[1, 4], [2, 5], [3, 6]]
z .= .+(x..., .*(x..., x...)..., x[1]..., x[2]..., x[3]...)
@test z == Float64[14463, 14472]
end

# Issue #21094
@generated function foo21094(out, x)
quote
out .= x .+ x
end
end
@test foo21094([0.0], [1.0]) == [2.0]

# Issue #22053
struct T22053
t
end
Broadcast.BroadcastStyle(::Type{T22053}) = Broadcast.Style{T22053}()
Broadcast.broadcast_indices(::Broadcast.Style{T22053}, ::T22053) = ()
function Base.copy(bc::Broadcast.Broadcasted{Broadcast.Style{T22053}})
all(x->isa(x, T22053), bc.args) && return 1
return 0
end
Base.:*(::T22053, ::T22053) = 2
let x = T22053(1)
@test x*x == 2
@test x.*x == 1
end

0 comments on commit 53b3d14

Please sign in to comment.