Skip to content

Commit

Permalink
Add simple tests for Core.Compiler.extrema
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf committed Jun 19, 2020
1 parent 2d70b7d commit 4a27df9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/reduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -246,24 +246,29 @@ prod2(itr) = invoke(prod, Tuple{Any}, itr)
@test maximum(Int[]; init=-1) == -1
@test minimum(Int[]; init=-1) == -1
@test extrema(Int[]; init=(1, -1)) == (1, -1)
@test Core.Compiler.extrema(Int[]; init=(1, -1)) == (1, -1)

@test maximum(sin, []; init=-1) == -1
@test minimum(sin, []; init=1) == 1
@test extrema(sin, []; init=(1, -1)) == (1, -1)
@test Core.Compiler.extrema(sin, []; init=(1, -1)) == (1, -1)

@test maximum(5) == 5
@test minimum(5) == 5
@test extrema(5) == (5, 5)
@test extrema(abs2, 5) == (25, 25)
@test Core.Compiler.extrema(abs2, 5) == (25, 25)

let x = [4,3,5,2]
@test maximum(x) == 5
@test minimum(x) == 2
@test extrema(x) == (2, 5)
@test Core.Compiler.extrema(x) == (2, 5)

@test maximum(abs2, x) == 25
@test minimum(abs2, x) == 4
@test extrema(abs2, x) == (4, 25)
@test Core.Compiler.extrema(abs2, x) == (4, 25)
end

@test maximum([-0.,0.]) === 0.0
Expand Down

0 comments on commit 4a27df9

Please sign in to comment.