I've encountered a weird behavior when using HaveExactElements matcher. See this example:
actual := [][]bool{
{true},
{false},
}
g.Expect(actual).To(ContainElement( // this fails, even though it should pass
HaveExactElements(Equal(false)),
))
I expect this assertion to pass, because actual contains an element []bool{false} which matches HaveExactElements(Equal(false)). But the assertion fails instead.
I believe the culprit is that HaveExactElementsMatcher leaves some internal state once its Match() returns false, which never gets cleaned and causes subsequent calls to always return false. Fwiw, cleaning the state at the beginning of the Match() fixed the issue for me.
Hi,
I've encountered a weird behavior when using HaveExactElements matcher. See this example:
I expect this assertion to pass, because
actual
contains an element[]bool{false}
which matchesHaveExactElements(Equal(false))
. But the assertion fails instead.I believe the culprit is that HaveExactElementsMatcher leaves some internal state once its Match() returns false, which never gets cleaned and causes subsequent calls to always return false. Fwiw, cleaning the state at the beginning of the Match() fixed the issue for me.
Version: 1.27.2