177177 str = String (take! (io))
178178 @test occursin (" x1 + x2" , str)
179179end
180+
181+ @testset " mapreduce" begin
182+ for T in [Int, Float64]
183+ x = rand (T, 10 ); y = similar (x);
184+
185+ f = x-> x^ 2 ; op = +
186+ @test mapreduce (f, op, x) == mappedarrayreduce (f, op, x)
187+ @test mapreduce (f, op, x, init = zero (T)) == mappedarrayreduce (f, op, x, init = zero (T))
188+ @test mapreduce (f, op, x, init = zero (T), dims = 1 ) == mappedarrayreduce (f, op, x, init = zero (T), dims = 1 )
189+ @test mapreduce (f, op, x, init = zero (T), dims = :) == mappedarrayreduce (f, op, x, init = zero (T), dims = :)
190+
191+ if VERSION >= v " 1.2"
192+ f = == ; op = +
193+ @test mapreduce (f, op, x, y) == mappedarrayreduce (f, op, x, y)
194+ @test mapreduce (f, op, x, y, init = 0 ) == mappedarrayreduce (f, op, x, y, init = 0 )
195+ @test mapreduce (f, op, x, y, init = 0 , dims = 1 ) == mappedarrayreduce (f, op, x, y, init = 0 , dims = 1 )
196+ @test mapreduce (f, op, x, y, init = 0 , dims = :) == mappedarrayreduce (f, op, x, y, init = 0 , dims = :)
197+ end
198+ end
199+ end
0 commit comments