Skip to content

Commit

Permalink
Add call to stacktrace when missing (fix #167)
Browse files Browse the repository at this point in the history
  • Loading branch information
eproxus committed Feb 13, 2017
1 parent 44e4d4a commit e182a99
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/meck_code_gen.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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]) ->
Expand Down
8 changes: 8 additions & 0 deletions test/meck_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)),
Expand Down

0 comments on commit e182a99

Please sign in to comment.