Closed favonia closed 10 months ago
Hey @favonia, I think this makes sense as a nice addition to the library. I think AnyOf
would be a better name than Some
though, since Some
leaves ambiguous how many would need to match.
@JacobOaks Done. Any other suggestions before I make a PR?
@favonia awesome, nope - go ahead and thanks!
Requested feature
A new matcher combinator like
All
but returns true when one of the matchers returns true.Why the feature is needed
We currently have
All
that matches all the matchers, just like the universal quantifier in the logic. It would be great to haveAnyOf
that matches at least one of them, similar to the existential quantifier in the logic. This is helpful when an argument can be one of several values. For example, with the newAnyOf
matcher, we may write the following:This means we expect a method call
SetDirection("north", true)
,SetDirection("south", true)
,SetDirection("west", true)
orSetDirection("east", true)
, which is then followed by a method callRun()
.(Optional) Proposed solution
Here is a sample implementation. It's trivial for me to make a PR if the maintainers feel positive about this feature.
Related issues and PRs (from the original gomock)