Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I call original function with different arguments? #30

Closed
mefcorvi opened this issue Jul 16, 2011 · 2 comments
Closed

Can I call original function with different arguments? #30

mefcorvi opened this issue Jul 16, 2011 · 2 comments
Assignees
Labels

Comments

@mefcorvi
Copy link

I tried to do that:

meck:unstick_mod(string),
meck:new(string),
meck:expect(string, strip, fun(String) -> meck:passthrough(["   foo   "]) end),
string:strip("   test  ").

I've expected "foo" as a result but I've got an exception: {{case_clause, {passthrough, [" foo "]}}, [{meck, handle_mock_exception, 4}, ... ]}

@mefcorvi
Copy link
Author

As I can see, exception raised because case clause expected what Args in {passthrough, Args} are the same arguments which were been passed to the mocked function:

handle_mock_exception(Mod, Func, Fun, Args) ->
    case Fun() of
        ...
        {passthrough, Args} ->
            % call_original(Args) called from mock function
            Result = apply(original_name(Mod), Func, Args),
            cast(Mod, {add_history, {{Mod, Func, Args}, Result}}),
            Result
    end.

I'm not sure if it is right or wrong behaviour. I suggest replacing Args in that clause to PassthroughArgs or something like this.

@ghost ghost assigned eproxus Jul 18, 2011
@eproxus
Copy link
Owner

eproxus commented Jul 18, 2011

Thanks for the bug report!

@eproxus eproxus added the bug label Jun 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants