Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
Tests for mapreduce on empty collection (JuliaLang#22486)
Browse files Browse the repository at this point in the history
* Tests for mapreduce on empty collection
  • Loading branch information
kshyatt authored and DrTodd13 committed Jun 26, 2017
1 parent f3b310d commit e53da99
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/reduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@
@test mapreduce(abs2, +, [-9, -3]) == 81 + 9
@test mapreduce(-, +, [-9, -3, -4, 8, -2]) == (9 + 3 + 4 - 8 + 2)
@test mapreduce(-, +, collect(linspace(1.0, 10000.0, 10000))) == -50005000.0
# empty mr
@test mapreduce(abs2, +, Float64[]) === 0.0
@test mapreduce(abs2, Base.scalarmax, Float64[]) === 0.0
@test mapreduce(abs, max, Float64[]) === 0.0
@test mapreduce(abs2, &, Float64[]) === true
@test mapreduce(abs2, |, Float64[]) === false

# mapreduce() type stability
@test typeof(mapreduce(*, +, Int8[10])) ===
typeof(mapreduce(*, +, Int8[10, 11])) ===
Expand Down

0 comments on commit e53da99

Please sign in to comment.