Skip to content

Commit 5361f7c

Browse files
adienesKristofferC
authored andcommitted
Switch from segfault to zip behavior for mismatched indices in map! (#56673)
(cherry picked from commit 0947114)
1 parent 5721fda commit 5361f7c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/abstractarray.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,26 @@ generic_map_tests(map, map!)
909909
# @test_throws BoundsError map!(+, ones(3), ones(2, 2), ones(2, 2))
910910
end
911911

912+
@testset "#30624" begin
913+
### unstructured
914+
@test map!(+, ones(3), ones(3), ones(3), [1]) == [3, 1, 1]
915+
@test map!(+, ones(3), [1], ones(3), ones(3)) == [3, 1, 1]
916+
@test map!(+, [1], [1], [], []) == [1]
917+
@test map!(+, [[1]], [1], [], []) == [[1]]
918+
919+
# TODO: decide if input axes & lengths should be validated
920+
# @test_throws BoundsError map!(+, ones(1), ones(2))
921+
# @test_throws BoundsError map!(+, ones(1), ones(2, 2))
922+
923+
@test map!(+, ones(3), view(ones(2, 3), 1:2, 2:3), ones(3)) == [2, 2, 2]
924+
@test map!(+, ones(3), ones(2, 2), ones(3)) == [2, 2, 2]
925+
926+
### structured (all mapped arguments are <:AbstractArray equal ndims > 1)
927+
@test map!(+, ones(4), ones(2, 2), ones(2, 2)) == [2, 2, 2, 2]
928+
@test map!(+, ones(4), ones(2, 2), ones(1, 2)) == [2, 2, 1, 1]
929+
# @test_throws BoundsError map!(+, ones(3), ones(2, 2), ones(2, 2))
930+
end
931+
912932
test_UInt_indexing(TestAbstractArray)
913933
test_13315(TestAbstractArray)
914934
test_checksquare()

0 commit comments

Comments
 (0)