Skip to content

Commit

Permalink
Export and test Base.iszero
Browse files Browse the repository at this point in the history
  • Loading branch information
ararslan committed Jan 10, 2017
1 parent f864b22 commit b3a99ad
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ export
isreal,
isimag,
issubnormal,
iszero,
lcm,
ldexp,
leading_ones,
Expand Down
1 change: 1 addition & 0 deletions doc/src/stdlib/numbers.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Base.issubnormal
Base.isfinite
Base.isinf
Base.isnan
Base.iszero
Base.nextfloat
Base.prevfloat
Base.isinteger
Expand Down
16 changes: 16 additions & 0 deletions test/numbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2864,3 +2864,19 @@ let types = (Base.BitInteger_types..., BigInt, Bool)
end

@test !isempty(complex(1,2))

@testset "iszero" begin
# Numeric scalars
for T in Iterators.flatten(subtypes.([AbstractFloat, Signed, Unsigned]))
@test iszero(T(0))
@test iszero(Complex{T}(0))
end
@test iszero(BigFloat(0))
@test !iszero(nextfloat(BigFloat(0)))
@test iszero(BigInt(0))
@test iszero(0//1)

# Array reduction
@test !iszero([0, 1, 2, 3])
@test iszero(zeros(Int, 5))
end

0 comments on commit b3a99ad

Please sign in to comment.