Skip to content
Permalink
Browse files
Add call to stacktrace when missing (fix #167)
  • Loading branch information
eproxus committed Feb 13, 2017
1 parent 44e4d4a commit e182a999ad238ae8ac21bfd885e85dc9c82c6976
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
@@ -190,8 +190,8 @@ raise(Pid, Mod, Func, Args, Class, Reason) ->
-spec inject(Mod::atom(), Func::atom(), Args::[any()],
meck_history:stack_trace()) ->
NewStackTrace::meck_history:stack_trace().
inject(_Mod, _Func, _Args, []) ->
[];
inject(Mod, Func, Args, []) ->
[{Mod, Func, Args}];
inject(Mod, Func, Args, [{?MODULE, exec, _AriOrArgs, _Loc}|Stack]) ->
[{Mod, Func, Args} | Stack];
inject(Mod, Func, Args, [{?MODULE, exec, _AriOrArgs}|Stack]) ->
@@ -75,6 +75,7 @@ meck_test_() ->
fun ?MODULE:shortcut_call_argument_/1,
fun ?MODULE:shortcut_re_add_/1,
fun ?MODULE:shortcut_opaque_/1,
fun ?MODULE:shortcut_stacktrace_/1,
fun ?MODULE:delete_/1,
fun ?MODULE:called_false_no_args_/1,
fun ?MODULE:called_true_no_args_/1,
@@ -396,6 +397,13 @@ shortcut_opaque_(Mod) ->
ok = meck:expect(Mod, test, 0, {test, [a, self()], Ref}),
?assertMatch({test, [a, P], Ref} when P == self(), Mod:test()).

shortcut_stacktrace_(Mod) ->
ok = meck:expect(Mod, test, [true], ok),
?assertEqual(
{'EXIT', {function_clause, [{mymod, test, [false], []}]}},
catch(Mod:test(false))
).

delete_(Mod) ->
ok = meck:expect(Mod, test, 2, ok),
?assertEqual(ok, meck:delete(Mod, test, 2)),

0 comments on commit e182a99

Please sign in to comment.