@@ -300,7 +300,6 @@ import Base.Meta: isexpr
300300# PR 16988
301301@test Base. promote_op (+ , Bool) === Int
302302@test isa (broadcast (+ , [true ]), Array{Int,1 })
303- @test Base. promote_op (Float64, Bool) === Float64
304303
305304# issue #17304
306305let foo = [[1 ,2 ,3 ],[4 ,5 ,6 ],[7 ,8 ,9 ]]
312311let f17314 = x -> x < 0 ? false : x
313312 @test eltype (broadcast (f17314, 1 : 3 )) === Int
314313 @test eltype (broadcast (f17314, - 1 : 1 )) === Integer
315- @test eltype (broadcast (f17314, Int[])) === Any
314+ @test eltype (broadcast (f17314, Int[])) === Union{Bool,Int}
316315end
317316let io = IOBuffer ()
318317 broadcast (x-> print (io,x), 1 : 5 ) # broadcast with side effects
337336@test broadcast (+ , 1.0 , (0 , - 2.0 )) == (1.0 ,- 1.0 )
338337@test broadcast (+ , 1.0 , (0 , - 2.0 ), [1 ]) == [2.0 , 0.0 ]
339338@test broadcast (* , [" Hello" ], " , " , [" World" ], " !" ) == [" Hello, World!" ]
339+
340+ # Ensure that even strange constructors that break `T(x)::T` work with broadcast
341+ immutable StrangeType18623 end
342+ StrangeType18623 (x) = x
343+ StrangeType18623 (x,y) = (x,y)
344+ @test @inferred broadcast (StrangeType18623, 1 : 3 ) == [1 ,2 ,3 ]
345+ @test @inferred broadcast (StrangeType18623, 1 : 3 , 4 : 6 ) == [(1 ,4 ),(2 ,5 ),(3 ,6 )]
346+
347+ @test typeof (Int .(Number[1 , 2 , 3 ])) === typeof ((x-> Int (x)). (Number[1 , 2 , 3 ]))
348+
349+ @test @inferred broadcast (CartesianIndex, 1 : 2 ) == [CartesianIndex (1 ), CartesianIndex (2 )]
350+ @test @inferred broadcast (CartesianIndex, 1 : 2 , 3 : 4 ) == [CartesianIndex (1 ,3 ), CartesianIndex (2 ,4 )]
351+
352+ # Issue 18622
353+ @test @inferred tuple .(1 : 3 , 4 : 6 , 7 : 9 ):: Vector{Tuple{Int,Int,Int}} == [(1 ,4 ,7 ), (2 ,5 ,8 ), (3 ,6 ,9 )]
0 commit comments