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

Implement 'implicit new' feature #80 #104

Merged
merged 1 commit into from
Apr 24, 2013
Merged

Implement 'implicit new' feature #80 #104

merged 1 commit into from
Apr 24, 2013

Conversation

horkhe
Copy link
Contributor

@horkhe horkhe commented Apr 22, 2013

Implements feature request #80. Implicitly created mock is:

  • honest, an attempt to create an expectation for a module that is not available on a code path will fail. If a user does need one he can create it explicitly with non_strict option;
  • passthrow, forwards functions that had no expectations created to the original module functions.

case gen_server:start({local, Proc}, ?MODULE, Props, []) of
{ok, Pid} ->
Result = gen_server:call(Proc, {set_expect, Expect}),
true = erlang:link(Pid),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the link needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted implicit mock to have start_link semantic. But it is possible that start will fail due to undefined_module (when the respective module is not available on the code path), in that cases I wanted to throw error not_mocked, as it did before, to do that I started process without linking to survive possible process startup failure and converted undefined_module to not_mocked if it happened.

But may be it is better to just do start_link and fail with module_undefined if a user tries to create implicit mock of a module that is not available on the code path.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to keep the semantics from new rather than expect. Will update it.

eproxus added a commit that referenced this pull request Apr 24, 2013
@eproxus eproxus merged commit 334e89d into eproxus:develop Apr 24, 2013
@horkhe horkhe deleted the feature/implicit-new branch April 25, 2013 04:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants