Skip to content

Commit

Permalink
Merge pull request #37 from invenia/cv/julia-0.7.0-DEV.3639
Browse files Browse the repository at this point in the history
Compatibility with Julia 0.7.0-DEV.3639
  • Loading branch information
omus authored Jan 30, 2018
2 parents 834ac12 + 5abdbfe commit db52245
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 22 deletions.
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
julia 0.6
Compat 0.38
Compat 0.47
17 changes: 5 additions & 12 deletions src/Mocking.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,10 @@ __precompile__(true)

module Mocking

import Compat: uninitialized

# Avoid using MicroLogging for compatibility as it significantly changes the formatting.
if VERSION < v"0.7.0-DEV.2988"
for func in (:info, :warn)
@eval begin
macro $func(args...)
Expr(:call, $func, map(esc, args)...)
end
end
end
import Compat: uninitialized, @info, @warn

if VERSION < v"0.7.0-DEV.3455"
hasmethod(f, t) = Base.method_exists(f, t)
end

include("expr.jl")
Expand Down Expand Up @@ -195,7 +188,7 @@ function ismocked(pe::PatchEnv, func_name::Symbol, args::Tuple)
if isdefined(pe.mod, func_name)
func = Core.eval(pe.mod, func_name)
types = map(arg -> isa(arg, Type) ? Type{arg} : typeof(arg), args)
exists = method_exists(func, types)
exists = hasmethod(func, types)

if pe.debug
@info("calling $func_name$(types)")
Expand Down
20 changes: 11 additions & 9 deletions src/expr.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Note: Needed for compatibility with the Julia 0.6 type system change:
# https://github.com/JuliaLang/julia/pull/18457
if isdefined(Base, :unwrap_unionall)
import Base: unwrap_unionall
else
unwrap_unionall(t::Type) = t
using Base: unwrap_unionall

if VERSION < v"0.7.0-DEV.3539"
nameof(f::Function) = Base.function_name(f)
end

if VERSION < v"0.7.0-DEV.3460"
parentmodule(f, t) = Base.function_module(f, t)
end


Expand Down Expand Up @@ -32,10 +34,10 @@ function binding_expr(t::Type)
end
function binding_expr(f::Function)
if isa(f, Core.Builtin)
return Base.function_name(f)
return nameof(f)
end
m = Base.function_module(f, Tuple)
joinbinding(fullname(m)..., Base.function_name(f))
m = parentmodule(f, Tuple)
joinbinding(fullname(m)..., nameof(f))
end


Expand Down

0 comments on commit db52245

Please sign in to comment.