Mocking.activate
— MethodMocking.activate()
Enable @mock
call sites to allow for calling patches instead of the original function.
Mocking.anon_morespecific
— Methodanon_morespecific(a::Method, b::Method) -> Bool
Determine which method is more specific for multiple dispatch without considering the function type. By not considering the function type we can determine which method is more specific as if they are a part of the same generic function.
Mocking.anonymous_signature
— Methodanonymous_signature(m::Method) -> Type{<:Tuple}
Construct a Tuple of the methods signature with the function type removed
Example
julia> m = first(methods(first, (String,)));
julia> m.sig
Tuple{typeof(first),Any}
julia> anonymous_signature(m)
Tuple{Any}
Mocking.deactivate
— MethodMocking.deactivate()
Disable @mock
call sites to only call the original function.
Mocking.dispatch
— Methoddispatch(funcs::AbstractVector, args...) -> Tuple{Method, Any}
Choose which method to execute based upon the provided arguments (values not types). Emulates Julia's multiple dispatch system but allows for dispatching between methods of multiple generic functions instead of just methods of a single generic function. Returns a tuple of the selected method and the generic function of the method.
When the function to dispatch to is ambiguous last ambiguous function in the vector is used.
Mocking.extract_kwargs
— Methodextract_kwargs(expr::Expr) -> Vector{Expr}
Extract the :parameters and :kw value into an array of :kw expressions we don't evaluate any expressions for values yet though.
Mocking.nullify
— MethodMocking.nullify()
Force any packages loaded after this point to treat the @mock
macro as a no-op. Doing so will maximize performance by eliminating any runtime checks taking place at the @mock
call sites but will break any tests that require patches to be applied.
Note to ensure that all @mock
macros are inoperative be sure to call this function before loading any packages which depend on Mocking.jl.