Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengj committed Aug 10, 2015
1 parent e324d63 commit c049f92
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -543,4 +543,22 @@ if VERSION < v"0.4.0-dev+6506"
export include_dependency
end

if VERSION < v"0.4.0-dev+6068"
Base.real{T<:Real}(::Type{T}) = T
Base.real{T<:Real}(::Type{Complex{T}}) = T
end

if VERSION < v"0.4.0-dev+6578"
rtoldefault{T<:AbstractFloat}(::Type{T}) = sqrt(eps(T))
rtoldefault{T<:Real}(::Type{T}) = 0
rtoldefault{T<:Number,S<:Number}(x::Union(T,Type{T}), y::Union(S,Type{S})) = rtoldefault(promote_type(real(T),real(S)))
function Base.isapprox{T<:Number,S<:Number}(x::AbstractArray{T}, y::AbstractArray{S}; rtol::Real=rtoldefault(T,S), atol::Real=0, norm::Function=vecnorm)
d = norm(x - y)
return isfinite(d) ? d <= atol + rtol*max(norm(x), norm(y)) : x == y
end
const = isapprox
(x,y) = !(x y)
export ,
end

end # module
7 changes: 7 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -412,3 +412,10 @@ Compat.@irrational mathconst_one 1.0 big(1.)

@test nothing === __precompile__(false) # tests should never be precompiled
@test nothing === include_dependency("foo")

@test real(Int) == real(Complex{Int}) == Int

@test [1,2,3] [1,2,3+1e-9]
@test [0,1] [1e-9, 1]
@test [0,Inf] [0,Inf]
@test [0,Inf] [0,-Inf]

0 comments on commit c049f92

Please sign in to comment.