Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jishnub committed Nov 24, 2020
1 parent 0c72e55 commit e6baa71
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,19 @@ end
@testset "mapreduce" begin
for T in [Int, Float64]
x = rand(T, 10); y = similar(x);
@test mapreduce(==, +, x, y) == mappedarrayreduce(==, +, x, y)
@test mapreduce(==, +, x, y, init = 0) == mappedarrayreduce(==, +, x, y, init = 0)
@test mapreduce(==, +, x, y, init = 0, dims = 1) == mappedarrayreduce(==, +, x, y, init = 0, dims = 1)
@test mapreduce(==, +, x, y, init = 0, dims = :) == mappedarrayreduce(==, +, x, y, init = 0, dims = :)

f = x->x^2; op = +
@test mapreduce(f, op, x) == mappedarrayreduce(f, op, x)
@test mapreduce(f, op, x, init = zero(eltype(x))) == mappedarrayreduce(f, op, x, init = zero(eltype(x)))
@test mapreduce(f, op, x, init = zero(eltype(x)), dims = 1) == mappedarrayreduce(f, op, x, init = zero(eltype(x)), dims = 1)
@test mapreduce(f, op, x, init = 0, dims = :) == mappedarrayreduce(f, op, x, init = 0, dims = :)

if VERSION >= v"1.2"
f = ==; op = +
@test mapreduce(f, op, x, y) == mappedarrayreduce(f, op, x, y)
@test mapreduce(f, op, x, y, init = 0) == mappedarrayreduce(f, op, x, y, init = 0)
@test mapreduce(f, op, x, y, init = 0, dims = 1) == mappedarrayreduce(f, op, x, y, init = 0, dims = 1)
@test mapreduce(f, op, x, y, init = 0, dims = :) == mappedarrayreduce(f, op, x, y, init = 0, dims = :)
end
end
end

0 comments on commit e6baa71

Please sign in to comment.