Skip to content

Commit

Permalink
Merge pull request #344 from JuliaLang/teh/unsafe_trunc
Browse files Browse the repository at this point in the history
Support unsafe_trunc(::Type{<:Integer}, ::Integer)
  • Loading branch information
timholy committed Apr 7, 2017
2 parents e3ba915 + a2fb0a4 commit 92fd097
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ Currently, the `@compat` macro supports the following syntaxes:

* `convert` can convert between different `Set` types on 0.5 and below. ([#18727])

* `unsafe_trunc(::Type{<:Integer}, ::Integer)` is supported on 0.5. ([#18629])

## Renamed functions

* `pointer_to_array` and `pointer_to_string` have been replaced with `unsafe_wrap(Array, ...)` and `unsafe_wrap(String, ...)` respectively
Expand Down Expand Up @@ -352,3 +354,4 @@ includes this fix. Find the minimum version from there.
[#20414]: https://github.com/JuliaLang/julia/issues/20414
[#20418]: https://github.com/JuliaLang/julia/issues/20418
[#20500]: https://github.com/JuliaLang/julia/issues/20500
[#18629]: https://github.com/JuliaLang/julia/pull/18629
4 changes: 4 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,10 @@ if VERSION < v"0.6.0-dev.838"
Base.convert{T}(::Type{Set{T}}, s::Set) = Set{T}(s)
end

if VERSION < v"0.6.0-dev.735"
Base.unsafe_trunc{T<:Integer}(::Type{T}, x::Integer) = rem(x, T)
end

include("to-be-deprecated.jl")

end # module Compat
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1805,6 +1805,9 @@ let
@test cssset == Set(["foo", "bar"])
end

@test unsafe_trunc(Int8, 128) === Int8(-128)
@test_throws InexactError trunc(Int8, 128)

include("to-be-deprecated.jl")

nothing

0 comments on commit 92fd097

Please sign in to comment.