You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
HaveKeyWithValue with a key matcher that accepts several keys succeeds on some calls and fails on others #929
This is another bug found by our automated process of writing hegel tests in hegel-zoo, filed as asked in #925 and, as before, reviewed by hand first.
When the key matcher passed to HaveKeyWithValue accepts more than one of the map's keys, the result of the same call on the same map changes from call to call: with "bFoo": "Bar" present and three other keys ending in Foo, HaveKeyWithValue(MatchRegexp(.+Foo$), "Bar") comes back true in about one call in eight. When bFoo is the only key ending in Foo, it is true every time:
The counts vary a little between runs (60 true on a second run) but the first map never comes out all true. I expected both maps to match every time, since each has a key matching the key matcher whose value is "Bar"; the doc comment says the matcher succeeds if the map has the passed-in key and value.
Tested on v1.43.1, which is also the current master (47f0f87).
I've delegated fixing this to Claude and checked the code it generated. Thanks for reporting!
HaveKeyWithValue now keeps looking after a key matches but its value does not. It succeeds if any key accepted by the key matcher has a matching value, instead of depending on which matching key the map happens to iterate first. (ffc577a)
Activity
onsi commentedon Sep 24, 2026
I've delegated fixing this to Claude and checked the code it generated. Thanks for reporting!
HaveKeyWithValuenow keeps looking after a key matches but its value does not. It succeeds if any key accepted by the key matcher has a matching value, instead of depending on which matching key the map happens to iterate first. (ffc577a)This will be released in v1.44.0.