From 4936541975cc12ea69ea06164cf97ab74469e39b Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Tue, 8 Aug 2017 06:18:19 -0500 Subject: [PATCH] Add support for multiarg InexactError, DomainError, OverflowError --- src/Compat.jl | 16 ++++++++++++++++ test/runtests.jl | 10 ++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/Compat.jl b/src/Compat.jl index c06d4e86e..2cba3246f 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -488,6 +488,22 @@ if VERSION < v"0.7.0-DEV.1053" Base.read(obj::Cmd, ::Type{String}) = readstring(obj) end +# https://github.com/JuliaLang/julia/pull/20005 +if VERSION < v"0.7.0-DEV.896" + Base.InexactError(name::Symbol, T, val) = InexactError() +end + +# https://github.com/JuliaLang/julia/pull/22751 +if VERSION < v"0.7.0-DEV.924" + Base.DomainError(val) = DomainError() + Base.DomainError(val, msg) = DomainError() +end + +# https://github.com/JuliaLang/julia/pull/222761 +if VERSION < v"0.7.0-DEV.1285" + Base.OverflowError(msg) = OverflowError() +end + include("deprecated.jl") end # module Compat diff --git a/test/runtests.jl b/test/runtests.jl index efa8bc81a..bc0099145 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -658,6 +658,16 @@ eval(Expr(:type, false, :TestType, Expr(:block, :(a::Int), :b))) @test fieldcount(TestType) == 2 @test fieldcount(Int) == 0 +# PR 20005 +@test_throws InexactError throw(InexactError(:func, Int, 3.2)) + +# PR 22751 +@test_throws DomainError throw(DomainError(-2)) +@test_throws DomainError throw(DomainError(-2, "negative")) + +# PR 22761 +@test_throws OverflowError throw(OverflowError("overflow")) + let x = fill!(StringVector(5), 0x61) # 0.7 @test pointer(x) == pointer(String(x))