-
-
Notifications
You must be signed in to change notification settings - Fork 770
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
Matching multiple arguments at once #445
Conversation
|
Care to elaborate? |
Ah, sorry. Now I get it. You are overriding it only in the specific case of a single argument which also happens to be a matcher. I'll have a closer look at your proposal later today. |
Exactly. To clarify further, the reason I added a new matcher (sinon.match.all) was to avoid changing behaviour of existing matchers (sinon.match.number, etc). Since sinon.match are used to create them, they would also receive all arguments had I used sinon.match instead of sinon.match.all (in case of a single argument). Thinking about it some more, I'm not sure that would be a problem. What do you think? |
Did you have a chance to look at it? |
Sorry. There is something I don't like about it, but I can't really say why. |
You don't like the new feature, or the implementation? If it's the latter I would be glad if you can improve my implementation. The important part here is to be able to make a custom matcher that gets passed all arguments, which is currently not possible. |
Ok, letting it sink in a while did help in this case. There are three things:
|
This needs a rebase |
Should we swap out the yoda conditions? They aren't present anywhere else. Those should be caught by ESLint also.
One thing to think about, your suggested solution and the one in this PR don't allow for partial matches: |
This has lingered far too long. Let's get this out for Christmas 🎁
Not sure what @fearphage means with the partial matching example, as I don't understand the code snippet without context. Anyone opposed? |
It doesn't seem like a way to not match all or the rest of the arguments. It's "greedy" in regular expression terms. And to explain using code, there's no way to do this as I understand it: calledWith(42, true, sinon.match.args(matchNext3Args), 'catpants', 'test'); The sample function call would match: |
@fearphage I practically never use matchers, so I feel a bit out on thin ice here, but that use case seems awfully narrow too me. Is partial matching something we feel is useful, and if so, is there a way of modifying this to support it? I have freed up some time and I am simply trying to find a way of moving this forward 🙂 |
The original author has not participated in this PR for nearly three years. I am closing this |
These two commits makes it possible to match multiple arguments with a single matcher.
The first commit makes the following scenario work:
The second commit makes this, slighly less verbose, example work: