diff --git a/src/infinite/comparison.jl b/src/infinite/comparison.jl index b324490..ab76e28 100644 --- a/src/infinite/comparison.jl +++ b/src/infinite/comparison.jl @@ -5,6 +5,8 @@ Base.isinf(x::Infinite) = true Base.iszero(::Infinite) = false Base.:(==)(x::Infinite, y::Infinite) = x.signbit == y.signbit +Base.:(==)(x::Infinite, y::Real) = isinf(y) && signbit(x) == signbit(y) +Base.:(==)(x::Real, y::Infinite) = y == x Base.hash(x::Infinite, h::UInt) = hash(isposinf(x) ? Inf : -Inf, h) diff --git a/test/infextendedreal.jl b/test/infextendedreal.jl index 0aacf88..a490f20 100644 --- a/test/infextendedreal.jl +++ b/test/infextendedreal.jl @@ -118,6 +118,7 @@ @test InfExtendedReal(5) == 5 @test InfExtendedReal(7) == 7.0 @test InfExtendedReal(4) != InfExtendedReal(1) + @test InfExtendedReal(Inf) == InfExtendedReal(∞) @test hash(InfExtendedReal(3)) == hash(3) diff --git a/test/infinite.jl b/test/infinite.jl index 36785c0..493eb0f 100644 --- a/test/infinite.jl +++ b/test/infinite.jl @@ -59,7 +59,11 @@ @test !iszero(x) @test !iszero(-x) @test x == x + @test x == Inf + @test Inf == x @test x != -x + @test x != -Inf + @test Inf != -x @test hash(x) != hash(-x) @test -x < x @test x > -x