Skip to content
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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ Currently, the `@compat` macro supports the following syntaxes:

* `Compat.range` supporting keyword arguments ([#25896]).

* `Compat.trunc`, `Compat.floor`, `Compat.ceil`, `Compat.round`, `Compat.signif` take a keyword argument for `base` ([#26156]).

## Renaming

* `Display` is now `AbstractDisplay` ([#24831]).
Expand Down Expand Up @@ -580,3 +582,4 @@ includes this fix. Find the minimum version from there.
[#25896]: https://github.com/JuliaLang/julia/issues/25896
[#25990]: https://github.com/JuliaLang/julia/issues/25990
[#26089]: https://github.com/JuliaLang/julia/issues/26089
[#26156]: https://github.com/JuliaLang/julia/issues/26156
13 changes: 11 additions & 2 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ if VERSION < v"0.7.0-DEV.2402"
inconsistent length.
"""
function Base.ceil(x::Compat.ConvertiblePeriod, precision::Compat.ConvertiblePeriod)
f = floor(x, precision)
f = Base.floor(x, precision)
return (x == f) ? f : f + precision
end

Expand All @@ -742,7 +742,7 @@ if VERSION < v"0.7.0-DEV.2402"
than calling both `floor` and `ceil` individually.
"""
function floorceil(x::Compat.ConvertiblePeriod, precision::Compat.ConvertiblePeriod)
f = floor(x, precision)
f = Base.floor(x, precision)
return f, (x == f) ? f : f + precision
end

Expand Down Expand Up @@ -1569,6 +1569,15 @@ else
end
end

# https://github.com/JuliaLang/julia/pull/26156
@static if VERSION < v"0.7.0-DEV.4062"
trunc(x, digits; base = base) = Base.trunc(x, digits, base)
floor(x, digits; base = base) = Base.floor(x, digits, base)
ceil(x, digits; base = base) = Base.ceil(x, digits, base)
round(x, digits; base = base) = Base.round(x, digits, base)
signif(x, digits; base = base) = Base.signif(x, digits, base)
end

# https://github.com/JuliaLang/julia/pull/25872
if VERSION < v"0.7.0-DEV.3734"
if isdefined(Base, :open_flags)
Expand Down
7 changes: 7 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1435,6 +1435,13 @@ end
@test :foo in Compat.names(TestNames)
@test :bar in Compat.names(TestNames, all=true)

# 0.7.0-DEV.4062
@test Compat.trunc(pi, 3, base = 2) == 3.125
@test Compat.floor(pi, 3, base = 2) == 3.125
@test Compat.ceil(pi, 3, base = 2) == 3.25
@test Compat.round(pi, 3, base = 2) == 3.125
@test Compat.signif(pi, 5, base = 2) == 3.125

# 0.7.0-DEV.3734
let buf = Compat.IOBuffer(read=true, write=false, maxsize=25)
@test buf.readable
Expand Down