Skip to content

Commit 25e7c51

Browse files
committed
Tests pass
1 parent 3d27318 commit 25e7c51

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ julia = "1"
1010
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1111

1212
[targets]
13-
test = ["Test"]
13+
test = ["Test"]

src/Infinities.jl

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
module Infinities
22

33
import Base: angle, isone, iszero, isinf, isfinite, abs, one, zero, isless,
4-
+, -, *, ==, <, , >, , fld, cld, div, mod, min, max, sign, string, show
4+
+, -, *, ==, <, , >, , fld, cld, div, mod, min, max, sign, signbit,
5+
string, show, promote_rule, convert
56

7+
export ∞, Infinity, RealInfinity, ComplexInfinity, NotANumber
68

79
"""
810
NotANumber()
@@ -290,19 +292,19 @@ angle(x::ComplexInfinity) = π*x.signbit
290292
mod(::ComplexInfinity{<:Integer}, ::Integer) = NotANumber()
291293

292294

293-
show(io::IO, x::ComplexInfinity) = print(io, "$(exp(im*π*x.angle))")
295+
show(io::IO, x::ComplexInfinity) = print(io, "$(exp(im*π*x.signbit))")
294296

295297
==(x::ComplexInfinity, y::Infinity) = x.signbit == 0
296298
==(y::Infinity, x::ComplexInfinity) = x.signbit == 0
297299
==(x::ComplexInfinity, y::RealInfinity) = x.signbit == signbit(y)
298300
==(y::RealInfinity, x::ComplexInfinity) = x.signbit == signbit(y)
299-
==(x::ComplexInfinity, y::ComplexInfinity) = x.signbit == y.angle
301+
==(x::ComplexInfinity, y::ComplexInfinity) = x.signbit == y.signbit
300302

301303
==(x::ComplexInfinity, y::Number) = isinf(y) && angle(y) == angle(x)
302304
==(y::Number, x::ComplexInfinity) = x == y
303305

304-
isless(x::ComplexInfinity{Bool}, y::ComplexInfinity{Bool}) = x.signbit && !y.angle
305-
isless(x::Number, y::ComplexInfinity{Bool}) = !y.angle && x  ∞
306+
isless(x::ComplexInfinity{Bool}, y::ComplexInfinity{Bool}) = x.signbit && !y.signbit
307+
isless(x::Number, y::ComplexInfinity{Bool}) = !y.signbit && x  ∞
306308
isless(x::ComplexInfinity{Bool}, y::Number) = x.signbit && y  -
307309

308310
-(y::ComplexInfinity{B}) where B<:Integer = sign(y) == 1 ? ComplexInfinity(one(B)) : ComplexInfinity(zero(B))
@@ -323,8 +325,8 @@ end
323325

324326

325327
# ⊻ is xor
326-
*(a::ComplexInfinity{Bool}, b::ComplexInfinity{Bool}) = ComplexInfinity(a.angle b.angle)
327-
*(a::ComplexInfinity, b::ComplexInfinity) = ComplexInfinity(a.angle + b.angle)
328+
*(a::ComplexInfinity{Bool}, b::ComplexInfinity{Bool}) = ComplexInfinity(a.signbit b.signbit)
329+
*(a::ComplexInfinity, b::ComplexInfinity) = ComplexInfinity(a.signbit + b.signbit)
328330
*(a::Infinity, b::ComplexInfinity) = ComplexInfinity(a)*b
329331
*(a::ComplexInfinity, b::Infinity) = a*ComplexInfinity(b)
330332
*(a::RealInfinity, b::ComplexInfinity) = ComplexInfinity(a)*b
@@ -333,7 +335,7 @@ end
333335
*(a::Real, y::ComplexInfinity) = a > 0 ? y : (-y)
334336
*(y::ComplexInfinity, a::Real) = a*y
335337

336-
*(a::Number, y::ComplexInfinity) = ComplexInfinity(y.angle+angle(a)/π)
338+
*(a::Number, y::ComplexInfinity) = ComplexInfinity(y.signbit+angle(a)/π)
337339
*(y::ComplexInfinity, a::Number) = a*y
338340

339341
*(a::Number, y::Infinity) = a*ComplexInfinity(y)

tests/runtests.jl renamed to test/runtests.jl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ using Infinities, Test
3838

3939
@test string(∞) == ""
4040

41-
@test Base.OneTo(∞) == OneToInf()
42-
4341
@test isinf(∞)
4442
@test !isfinite(∞)
4543

@@ -143,9 +141,6 @@ using Infinities, Test
143141
@test (-∞)*2 2*(-∞) -2 ** (-2) (-2) * RealInfinity() -
144142
@test (-∞)*2.3 2.3*(-∞) -2.3 ** (-2.3) (-2.3) * RealInfinity() -
145143

146-
@test Base.OneTo(1*∞) == OneToInf()
147-
@test_throws ArgumentError Base.OneTo(-∞)
148-
149144
@test isinf(-∞)
150145
@test !isfinite(-∞)
151146

0 commit comments

Comments
 (0)