Skip to content
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

Fix HaveExactElements to work inside ContainElement or other collection matchers #648

Merged
merged 1 commit into from
Mar 6, 2023

Conversation

eiiches
Copy link
Contributor

@eiiches eiiches commented Mar 6, 2023

Fixes #647

As described in #647, HaveExactElements() leaves some internal state once its Match() returns false. The state never gets cleaned afterwards and causes subsequent calls on the instance to return incorrect results. This can be a problem when the matcher is placed inside ContainElement() or any other matchers that reuse and call inner matcher instances multiple times.

This PR fixes the issue by resetting the matcher state at the beginning of the HaveExactElements#Match().

@onsi
Copy link
Owner

onsi commented Mar 6, 2023

LGTM! will merge when CI goes green

@onsi onsi merged commit 636757e into onsi:master Mar 6, 2023
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.

HaveExactElements() doesn't work properly inside ContainElement or collection matchers
2 participants