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

New features - pid in history and count_calls and wildcard_count_calls functions #40

Merged
merged 4 commits into from
Oct 12, 2011

Conversation

daha
Copy link
Contributor

@daha daha commented Oct 1, 2011

Hi Adam,

I hacked around a little in meck today and added a few new functions.
I'm wondering if you would be interested in merging my changes.

The main additions is that I added the pids to the history (the output
from meck:history/1 is still like it used to be) and added count_calls
and wildcard_count_calls functions. I have listed the functions below.
I have separe branches for for different "features" if you are not
interested in all the new functions.

  • meck:called/4
    • same as meck:called/3 but for a specific pid
  • meck:count_calls/3
    • Returns the number of times the specified M:F(A) has been called.
  • meck:count_calls/4
    • same as meck:count_calls/3 but for a specific pid
  • meck:wildcard_count_calls/3
    • Returns the number of times the specified M:F(A) has been called.
      The wildcard '_' token matches any value.
  • meck:wildcard_count_calls/4
    • same as meck:wildcard_count_calls/3 but for a specific pid
  • meck:history_with_pid/1
    • Return the internal history, with the pid as the first element in
      the tuple
  • meck:history/2
    • same as meck:history/1 but for a specific pid

Best Regards,
David Haglund

…ions.

* Added meck:history_with_pid/1.
  Returns the new format of the history including the pid.
* Added meck:history/2.
  Returns the history for a specified pid, in the "old" format.

Refactoring: Extracted the cast add_history calls to one place
… pid.

* Added meck:called/4
* Added meck:count_calls/4
* Added meck:wildcard_count_calls/4
@eproxus eproxus merged commit 16fbe86 into eproxus:master Oct 12, 2011
@eproxus
Copy link
Owner

eproxus commented Oct 12, 2011

Merged it and added quite a few refactorings on top.

Caution: decided to break the interface instead of adding a bunch of new functions! This is a 0.X version after all.

@daha
Copy link
Contributor Author

daha commented Oct 13, 2011

Great!

It looks like good refactorings.

I noticed that you are using match specs so that allows for more variants than just the wildcard token '_'. You can write tests to for instance make sure argument 1 is equal to argument 3, without caring of their exact value.

Example:
Mod:test1(a,b,a),
1 = meck:num_calls(Mod, test1, ['$1', '_', '$1']).

@eproxus
Copy link
Owner

eproxus commented Oct 14, 2011

Ah, true. Need to document that.

I did plan to implement the full match spec interface at some point (allowing guards and return values etc). Something generic, like history_match(Mod, Spec).

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