Skip to content

Commit

Permalink
undo #17318 workaround, add more constant-folding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengj committed Jul 12, 2016
1 parent 319a01a commit 77b9ecf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions test/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ rt = Base.return_types(broadcast!, Tuple{Function, Array{Float64, 3}, Array{Floa
@test length(rt) == 1 && rt[1] == Array{Float64, 3}

# f.(args...) syntax (#15032)
let x = [1,3.2,4.7], y = [3.5, pi, 1e-4], α = 0.2342, n = 3
let x = [1,3.2,4.7], y = [3.5, pi, 1e-4], α = 0.2342
@test sin.(x) == broadcast(sin, x)
@test sin.(α) == broadcast(sin, α)
@test factorial.(n) == broadcast(factorial, n)
@test factorial.(3) == broadcast(factorial, 3)
@test atan2.(x, y) == broadcast(atan2, x, y)
@test atan2.(x, y') == broadcast(atan2, x, y')
@test atan2.(x, α) == broadcast(atan2, x, α)
Expand Down Expand Up @@ -220,6 +220,7 @@ end
let x = sin.(1:10)
@test atan2.((x->x+1).(x), (x->x+2).(x)) == atan2(x+1, x+2) == atan2(x.+1, x.+2)
@test sin.(atan2.([x+1,x+2]...)) == sin.(atan2.(x+1,x+2))
@test sin.(atan2.(x, 3.7)) == broadcast(x -> sin(atan2(x,3.7)), x)
@test atan2.(x, 3.7) == broadcast(x -> atan2(x,3.7), x) == broadcast(atan2, x, 3.7)
end
# Use side effects to check for loop fusion. Note that, due to #17314,
Expand All @@ -236,6 +237,7 @@ let x = sin.(1:10), a = [x]
@test atan2.(x, cos.(x)) == atan2.(a..., cos.(x)) == atan2(x, cos.(a...)) == atan2(a..., cos.(a...))
@test ((args...)->cos(args[1])).(x) == cos.(x) == ((y,args...)->cos(y)).(x)
end
@test atan2.(3,4) == atan2(3,4) == (() -> atan2(3,4)).()

# PR 16988
@test Base.promote_op(+, Bool) === Int
Expand Down

0 comments on commit 77b9ecf

Please sign in to comment.