diff --git a/src/meck.erl b/src/meck.erl index 9f847bdb..069d9274 100644 --- a/src/meck.erl +++ b/src/meck.erl @@ -108,7 +108,6 @@ %% It is used in {@link expect/3} and {@link expect/4} to define a function %% clause of complex multi-clause expectations. - %%%============================================================================ %%% Interface exports %%%============================================================================ @@ -120,7 +119,6 @@ new(Mod) when is_atom(Mod) -> new(Mod, []); new(Mod) when is_list(Mod) -> lists:foreach(fun new/1, Mod), ok. - %% @doc Creates new mocked module(s). %% %% This replaces the current version (if any) of the modules in `Mod' @@ -180,7 +178,6 @@ new(Mod, Options) when is_list(Mod) -> lists:foreach(fun(M) -> new(M, Options) end, Mod), ok. - %% @doc Add expectation for a function `Func' to the mocked modules `Mod'. %% %% An expectation is either of the following: @@ -214,7 +211,6 @@ expect(Mod, Func, Expectation) when is_atom(Mod), is_atom(Func) -> Expect = meck_expect:new(Func, Expectation), check_expect_result(meck_proc:set_expect(Mod, Expect)). - %% @doc Adds an expectation with the supplied arity and return value. %% %% This creates an expectation which takes `Arity' number of functions @@ -234,7 +230,6 @@ expect(Mod, Func, AriOrArgs, RetSpec) when is_atom(Mod), is_atom(Func) -> Expect = meck_expect:new(Func, AriOrArgs, RetSpec), check_expect_result(meck_proc:set_expect(Mod, Expect)). - %% @equiv expect(Mod, Func, Ari, seq(Sequence)) %% @deprecated Please use {@link expect/3} or {@link expect/4} along with %% {@link ret_spec()} generated by {@link seq/1}. @@ -252,7 +247,6 @@ sequence(Mod, Func, Ari, Sequence) when is_list(Mod) -> lists:foreach(fun(M) -> sequence(M, Func, Ari, Sequence) end, Mod), ok. - %% @equiv expect(Mod, Func, Ari, loop(Loop)) %% @deprecated Please use {@link expect/3} or {@link expect/4} along with %% {@link ret_spec()} generated by {@link loop/1}. @@ -270,7 +264,6 @@ loop(Mod, Func, Ari, Loop) when is_list(Mod) -> lists:foreach(fun(M) -> loop(M, Func, Ari, Loop) end, Mod), ok. - %% @doc Deletes an expectation. %% %% Deletes the expectation for the function `Func' with the matching @@ -287,7 +280,6 @@ delete(Mod, Func, Ari) when is_list(Mod) -> lists:foreach(fun(M) -> delete(M, Func, Ari) end, Mod), ok. - %% @doc Throws an expected exception inside an expect fun. %% %% This exception will get thrown without invalidating the mocked @@ -301,7 +293,6 @@ delete(Mod, Func, Ari) when is_list(Mod) -> exception(Class, Reason) when Class == throw; Class == error; Class == exit -> erlang:throw(meck_ret_spec:raise(Class, Reason)). - %% @doc Calls the original function (if existing) inside an expectation fun. %% %% Note: this code should only be used inside an expect fun. @@ -312,7 +303,6 @@ passthrough(Args) when is_list(Args) -> {Mod, Func} = meck_code_gen:get_current_call(), erlang:apply(meck_util:original_name(Mod), Func, Args). - %% @doc Validate the state of the mock module(s). %% %% The function returns `true' if the mocked module(s) has been used @@ -330,7 +320,6 @@ validate(Mod) when is_atom(Mod) -> validate(Mod) when is_list(Mod) -> not lists:member(false, [validate(M) || M <- Mod]). - %% @doc Return the call history of the mocked module for all processes. %% %% @equiv history(Mod, '_') @@ -338,7 +327,6 @@ validate(Mod) when is_list(Mod) -> Mod :: atom(). history(Mod) when is_atom(Mod) -> meck_history:get_history('_', Mod). - %% @doc Return the call history of the mocked module for the specified process. %% %% Returns a list of calls to the mocked module and their results for @@ -357,7 +345,6 @@ history(Mod, OptCallerPid) when is_atom(Mod), is_pid(OptCallerPid) orelse OptCallerPid == '_' -> meck_history:get_history(OptCallerPid, Mod). - %% @doc Unloads all mocked modules from memory. %% %% The function returns the list of mocked modules that were unloaded @@ -367,7 +354,6 @@ history(Mod, OptCallerPid) Mod :: atom(). unload() -> lists:foldl(fun unload_if_mocked/2, [], registered()). - %% @doc Unload a mocked module or a list of mocked modules. %% %% This will purge and delete the module(s) from the Erlang virtual @@ -383,7 +369,6 @@ unload(Mod) when is_atom(Mod) -> unload(Mods) when is_list(Mods) -> lists:foreach(fun unload/1, Mods), ok. - %% @doc Returns whether `Mod:Func' has been called with `Args'. %% %% @equiv called(Mod, Fun, Args, '_') @@ -394,7 +379,6 @@ unload(Mods) when is_list(Mods) -> called(Mod, OptFun, OptArgs) -> meck_history:num_calls('_', Mod, OptFun, OptArgs) > 0. - %% @doc Returns whether `Pid' has called `Mod:Func' with `Args'. %% %% This will check the history for the module, `Mod', to determine @@ -413,7 +397,6 @@ called(Mod, OptFun, OptArgs) -> called(Mod, OptFun, OptArgs, OptPid) -> meck_history:num_calls(OptPid, Mod, OptFun, OptArgs) > 0. - %% @doc Returns the number of times `Mod:Func' has been called with `Args'. %% %% @equiv num_calls(Mod, Fun, Args, '_') @@ -424,7 +407,6 @@ called(Mod, OptFun, OptArgs, OptPid) -> num_calls(Mod, OptFun, OptArgs) -> meck_history:num_calls('_', Mod, OptFun, OptArgs). - %% @doc Returns the number of times process `Pid' has called `Mod:Func' %% with `Args'. %% @@ -441,7 +423,6 @@ num_calls(Mod, OptFun, OptArgs) -> num_calls(Mod, OptFun, OptArgs, OptPid) -> meck_history:num_calls(OptPid, Mod, OptFun, OptArgs). - %% @doc Erases the call history for a mocked module or a list of mocked modules. %% %% This function will erase all calls made heretofore from the history of the @@ -455,7 +436,6 @@ reset(Mod) when is_atom(Mod) -> reset(Mods) when is_list(Mods) -> lists:foreach(fun(Mod) -> reset(Mod) end, Mods). - %% @doc Converts a list of terms into {@link ret_spec()} defining a loop of %% values. It is intended to be in construction of clause specs for the %% {@link expect/3} function. @@ -467,7 +447,6 @@ reset(Mods) when is_list(Mods) -> Loop :: [ret_spec()]. loop(Loop) -> meck_ret_spec:loop(Loop). - %% @doc Converts a list of terms into {@link ret_spec()} defining a sequence of %% values. It is intended to be in construction of clause specs for the %% {@link expect/3} function. @@ -479,7 +458,6 @@ loop(Loop) -> meck_ret_spec:loop(Loop). Sequence :: [ret_spec()]. seq(Sequence) -> meck_ret_spec:seq(Sequence). - %% @doc Converts a term into {@link ret_spec()} defining an individual value. %% It is intended to be in construction of clause specs for the %% {@link expect/3} function. @@ -487,7 +465,6 @@ seq(Sequence) -> meck_ret_spec:seq(Sequence). Value :: any(). val(Value) -> meck_ret_spec:val(Value). - %% @doc Creates a {@link ret_spec()} that defines an exception. %% %% Calls to an expect, created with {@link ret_spec()} returned by this function, @@ -497,7 +474,6 @@ val(Value) -> meck_ret_spec:val(Value). Reason :: term. raise(Class, Reason) -> meck_ret_spec:raise(Class, Reason). - %% @doc Creates a {@link ret_spec()} that makes the original module function be %% called. %% @@ -506,14 +482,12 @@ raise(Class, Reason) -> meck_ret_spec:raise(Class, Reason). -spec passthrough() -> ret_spec(). passthrough() -> meck_ret_spec:passthrough(). - %% @doc Creates a {@link ret_spec()} from a function. Calls to an expect, %% created with {@link ret_spec()} returned by this function, will be forwarded %% to the specified function. -spec exec(fun()) -> ret_spec(). exec(Fun) -> meck_ret_spec:exec(Fun). - %% @doc creates a {@link matcher/0} instance from either `Predicate' or %% `HamcrestMatcher'. %%