Skip to content

Commit

Permalink
Merge 67e0a03 into 5a98d42
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreySarnoff committed Mar 7, 2020
2 parents 5a98d42 + 67e0a03 commit 705862e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/MultiplesOfPi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ for op in Symbol[:+,:-,:/,:*]
end

Base.:(//)(p::PiTimes,n) = PiTimes(p.x//n)
Base.:(//)(n,p::PiTimes) = PiTimes(n//p.x)
Base.:(//)(p::PiTimes,q::PiTimes) = (p.x//q.x)*PiTimes(1)

# Conversion and promotion

Expand Down
4 changes: 3 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ end
@testset "Rational" begin
@test p//2 === PiTimes(p.x//2)
@test Pi//2 === PiTimes(1//2)
@test 1//Pi === 1//PiTimes(1)
@test 2//p === 2//PiTimes(p.x)
end

@testset "Irrational" begin
Expand Down Expand Up @@ -352,4 +354,4 @@ end
@test String(take!(io)) == "0 + Pi*im"
show(io,Pi + im*(2//3)Pi)
@test String(take!(io)) == "Pi + 2//3Pi*im"
end
end

0 comments on commit 705862e

Please sign in to comment.