Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Irrational zero & one #690

Merged
merged 1 commit into from
Feb 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Compat"
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "3.5.0"
version = "3.6.0"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ Please check the list below for the specific syntax you need.

## Supported features

* `zero(::Irrational)` and `one` now defined ([#34773]). (since Compat 3.6.0)

* `I1:I2`, when `I1` and `I2` are CartesianIndex values, constructs a CartesianIndices
iterator ([#29440]). (Since Compat 3.5.0)

Expand Down Expand Up @@ -126,3 +128,4 @@ Note that you should specify the correct minimum version for `Compat` in the
[#32968]: https://github.com/JuliaLang/julia/pull/32968
[#28761]: https://github.com/JuliaLang/julia/pull/28761
[#34652]: https://github.com/JuliaLang/julia/pull/34652
[#34773]: https://github.com/JuliaLang/julia/pull/34773
9 changes: 9 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,15 @@ else
using UUIDs: uuid5
end

# https://github.com/JuliaLang/julia/pull/34773
if VERSION < v"1.5.0-DEV.301"
Base.zero(::AbstractIrrational) = false
Base.zero(::Type{<:AbstractIrrational}) = false

Base.one(::AbstractIrrational) = true
Base.one(::Type{<:AbstractIrrational}) = true
end

include("deprecated.jl")

end # module Compat
7 changes: 7 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -272,4 +272,11 @@ end
end
end

@testset "Irrational zero and one" begin
@test one(pi) === true
@test zero(pi) === false
@test one(typeof(pi)) === true
@test zero(typeof(pi)) === false
end

nothing