Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Lambda matcher and more validation methods #5

Closed
wants to merge 1 commit into from

Conversation

liron-l
Copy link

@liron-l liron-l commented Aug 3, 2015

Lambda matcher allows comparing complex expressions compare instead of
eq or any
-- AtMost and AtLeast call validator (take a look at the following
variety in the moq library)
http://www.nudoq.org/#!/Packages/Moq/Moq/Times

Signed-off-by: Liron Levin [email protected]

Lambda matcher allows comparing complex expressions compare instead of
eq or any
-- AtMost and AtLeast call validator (take a look at the following
variety  in the moq library)
http://www.nudoq.org/#!/Packages/Moq/Moq/Times

Signed-off-by: Liron Levin <[email protected]>
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@liron-l
Copy link
Author

liron-l commented Aug 3, 2015

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

@dsymonds
Copy link
Contributor

dsymonds commented Aug 4, 2015

Thanks, but we don't need every possible matcher implementation to be in this repo. They can be elsewhere.

@liron-l
Copy link
Author

liron-l commented Aug 6, 2015

Thanks @dsymonds, what do you mean by elsewhere, as a consumer, I would expect a mocking framework to include as much API and utilities as possible.
Also, comparing using lambda (as opposed to property equality, All or nil) is much more common in practice (at least from my experience).
See for example:
It.Is -Moq (very popular framework for c#) - https://github.com/Moq/moq4/blob/8bc9b111640203af3995fbac98160a5d1f9e1ae2/Source/It.cs
Is.Matching (Rhino Mocks) ->
http://ayende.com/wiki/Rhino+Mocks+Constraints.ashx
We can replace lambda with Match or a less confusing term if you think it's more appropriate.

Also, adding validator such as at least, at most and between is very helpful in testing.

@liron-l liron-l mentioned this pull request Aug 6, 2015
@dsymonds
Copy link
Contributor

dsymonds commented Aug 6, 2015

Gomock does not aspire to be all-inclusive of every possible matcher and utility. They work just as well if they live elsewhere.

@dsymonds dsymonds closed this Aug 6, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants