FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Allow matching against polymorphic collections by tumbarumba · Pull Request #422 · hamcrest/JavaHamcrest · GitHub

Allow matching against polymorphic collections - #422

Merged
tumbarumba merged 4 commits into
hamcrest:masterfrom
tumbarumba:collection-polymorphism
Sep 22, 2024
Merged

Allow matching against polymorphic collections#422
tumbarumba merged 4 commits into
hamcrest:masterfrom
tumbarumba:collection-polymorphism

Conversation

Copy link
Copy Markdown
Member

As discussed in #252, there are problems with matching against polymorphic collections.

This fix attempts to apply the PECS rule (producer extends, consumer super) to the Hamcrest IsIterableContaining matcher. In this instance, a collection of items should be treated as a producer according to this rule, while a matcher acts as a consumer. There was some confustion about PECS in the context of collections of matchers, but I'm hoping this change addresses those issues.

I'm keen for others to test this work out

foal commented Sep 9, 2024

Copy link
Copy Markdown

Nice!
About PECS, INHO it is clear - the itemMatcher is consumer - it consumes the elements of the target collection to check them.It may check the element or any parent of the element (e.g. object != null). The output is producer - it produces global matcher for a whole collection and should be applied to collection of the elements or to collection of element's children.

tumbarumba merged commit 242604a into hamcrest:master Sep 22, 2024
tumbarumba deleted the collection-polymorphism branch September 22, 2024 01:38
jstewmon mentioned this pull request Oct 17, 2024
13 tasks
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL