Test-More / Test-More/test-more
bag has issues if an item matches multiple elements
Nobody has claimed this yet.
- Dominant language
- Perl
- Stars
- 149
- Forks
- 98
- PR merge metrics
- No merged PRs in 30d
Description
my $check = bag {
item match qr/a/;
item match qr/b/;
end(); # Ensure no other elements exist.
};
is(['fab', 'bad'], $check);
In this case we get a failure cause both items match the first element, so the second element is considered 'extra' for the end check. A quick-fix would be to never re-check an element, but that is not a valid fix:
my $check = bag {
item match qr/a/;
item match qr/ab/; # <---- change is here
end(); # Ensure no other elements exist.
};
is(['fab', 'bad'], $check);
This one will still fail because the less greedy bag item got 'fab' and 'ab' will not match against 'bad' but a human reader knows this should pass.
I think bag as it is currently needs a bit of an overhaul. We need to iterate over the array, not the bag items. We need to record all matches. When 'end; is not specified we just need to check that all items have at least 1 match in the array, easy. When 'end' is used we need to make sure both lists have a match in the other, but in cases where there are multiple matches we need to pick one. This can get complicated.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the two bag examples in issue #996, focusing on how bag items are matched and how end() checks for extra elements. Trace the bag matching implementation and add regression coverage for overlapping matches. Done means both examples pass while preserving correct behavior when end() is omitted or included.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- perl
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100