@@ -1070,6 +1070,26 @@ end
10701070 check_merge ([Dict (3 => 4 ), Dict (:a => 5 )], Dict (:a => 5 , 3 => 4 ))
10711071end
10721072
1073+ @testset " AbstractDict mergewith!" begin
1074+ # we use IdDict to test the mergewith! implementation for AbstractDict
1075+ d1 = IdDict (1 => 1 , 2 => 2 )
1076+ d2 = IdDict (2 => 3 , 3 => 4 )
1077+ d3 = IdDict {Int, Float64} (1 => 5 , 3 => 6 )
1078+ d = copy (d1)
1079+ @inferred mergewith! (- , d, d2)
1080+ @test d == IdDict (1 => 1 , 2 => - 1 , 3 => 4 )
1081+ d = copy (d1)
1082+ @inferred mergewith! (- , d, d3)
1083+ @test d == IdDict (1 => - 4 , 2 => 2 , 3 => 6 )
1084+ d = copy (d1)
1085+ @inferred mergewith! (+ , d, d2, d3)
1086+ @test d == IdDict (1 => 6 , 2 => 5 , 3 => 10 )
1087+ @inferred mergewith (+ , d1, d2, d3)
1088+ d = mergewith (+ , d1, d2, d3)
1089+ @test d isa Dict{Int, Float64}
1090+ @test d == Dict (1 => 6 , 2 => 5 , 3 => 10 )
1091+ end
1092+
10731093@testset " misc error/io" begin
10741094 d = Dict (' a' => 1 , ' b' => 1 , ' c' => 3 )
10751095 @test_throws ErrorException ' a' in d
0 commit comments