diff --git a/src/HalfIntegers.jl b/src/HalfIntegers.jl index 75c1bb3..ce50b29 100644 --- a/src/HalfIntegers.jl +++ b/src/HalfIntegers.jl @@ -23,7 +23,7 @@ export # Functions half, ishalfinteger, - ishalfoddinteger, + ishalfodd, onehalf, twice @@ -563,27 +563,27 @@ ishalfinteger(::AbstractIrrational) = false ishalfinteger(::Missing) = missing """ - ishalfoddinteger(x) + ishalfodd(x) Test whether `x` is numerically equal to some half-odd-integer. # Examples ```jldoctest -julia> ishalfoddinteger(3.5) +julia> ishalfodd(3.5) true -julia> ishalfoddinteger(2) +julia> ishalfodd(2) false -julia> ishalfoddinteger(1//3) +julia> ishalfodd(1//3) false ``` """ -ishalfoddinteger(x::Number) = _isodd(twice(x)) -ishalfoddinteger(x::Rational) = denominator(x) == 2 -ishalfoddinteger(::Integer) = false -ishalfoddinteger(::Missing) = missing +ishalfodd(x::Number) = _isodd(twice(x)) +ishalfodd(x::Rational) = denominator(x) == 2 +ishalfodd(::Integer) = false +ishalfodd(::Missing) = missing if VERSION ≥ v"1.7" _isodd(x) = isodd(x) diff --git a/test/customtypes.jl b/test/customtypes.jl index a163caa..27fa117 100644 --- a/test/customtypes.jl +++ b/test/customtypes.jl @@ -62,7 +62,7 @@ Base.convert(::Type{One}, x::Int) = x == 1 ? One() : error("can't convert $x to @testset "Properties" begin @test isfinite(MyHalfInt(2)) @test ishalfinteger(MyHalfInt(3/2)) - @test ishalfoddinteger(MyHalfInt(3/2)) + @test ishalfodd(MyHalfInt(3/2)) @test isinteger(MyHalfInt(3)) @test !isinteger(MyHalfInt(3/2)) @test iszero(MyHalfInt(0)) diff --git a/test/runtests.jl b/test/runtests.jl index 445c50c..9280a98 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -374,22 +374,22 @@ end @test !ishalfinteger(im) end - @testset "ishalfoddinteger" begin + @testset "ishalfodd" begin for T in (halfinttypes..., halfuinttypes..., :BigHalfInt) - @eval @test !ishalfoddinteger($T(3)) - @eval @test ishalfoddinteger($T(5/2)) - end - @test !ishalfoddinteger(5) - @test !ishalfoddinteger(big(-5)) - @test ishalfoddinteger(5//2) - @test ishalfoddinteger(-3//2) - @test !ishalfoddinteger(4//3) - @test !ishalfoddinteger(2.0) - @test ishalfoddinteger(-7.5) - @test !ishalfoddinteger(2.3) - @test !ishalfoddinteger(π) - @test !ishalfoddinteger(ℯ) - @test !ishalfoddinteger(im) + @eval @test !ishalfodd($T(3)) + @eval @test ishalfodd($T(5/2)) + end + @test !ishalfodd(5) + @test !ishalfodd(big(-5)) + @test ishalfodd(5//2) + @test ishalfodd(-3//2) + @test !ishalfodd(4//3) + @test !ishalfodd(2.0) + @test ishalfodd(-7.5) + @test !ishalfodd(2.3) + @test !ishalfodd(π) + @test !ishalfodd(ℯ) + @test !ishalfodd(im) end @testset "isinteger" begin @@ -1708,7 +1708,7 @@ end @test onehalf(missing) === onehalf(Missing) === missing @test ishalfinteger(missing) === missing - @test ishalfoddinteger(missing) === missing + @test ishalfodd(missing) === missing end include("ranges.jl")