Add a mechanism to check for map arguments in the args_matcher#244
Open
mrnovalles wants to merge 6 commits intoeproxus:masterfrom
Open
Add a mechanism to check for map arguments in the args_matcher#244mrnovalles wants to merge 6 commits intoeproxus:masterfrom
mrnovalles wants to merge 6 commits intoeproxus:masterfrom
Conversation
This was referenced Feb 5, 2024
Owner
|
Hi! Nice catch. I think the current solution has a problem in that it is only checking map size, but not the actual values. E.g.: 1> AM = meck_args_matcher:new([1, #{a => 1, b => 2}]).
{args_matcher,[1,#{a => 1,b => 2}],
#Ref<0.2522732729.1137311749.246851>,false}
2> meck_args_matcher:match([1, #{a => 1, b => 2}], AM).
true
3> meck_args_matcher:match([1, #{a => 1, b => 3}], AM).
true
4> meck_args_matcher:match([1, #{a => 1, b => 1}], AM).
trueIf the guard is created like so, it works: [{'==', IndexVar, Arg} | Acc];Which would simply be equivalent to In that case using |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is a working implementation to fix an issue with the args_matcher. I iniitally tried in #242 but never succeeded there.
When asserting on calls to functions were the arguments are maps, the matching function returns a false positive, ie. matching on a 3 items map, even when the called function had 2.
Current issue
On
master, the issue is in the MatchSpec that we send over toets:match_spec_run:Changes
meck_util:match_spec_itemin the case that the some of the args to the function is a mapThis PR adds a new matching function
meck_util:match_spec_item()that builds an erlang Match Specification in the case that any of the arguments given to the function are a map.I understand the complexity of
match_spec_itemis now way higher than it was before, opening this PR to hear your thoughts on it.