Quick / Nimble

A Matcher Framework for Swift and Objective-C
https://quick.github.io/Nimble/documentation/nimble/
Apache License 2.0
4.79k stars 595 forks source link

Fix bug where expect(nil).toAlways(equal(0)) would erroneously pass #1121

Closed younata closed 4 months ago

younata commented 4 months ago

Fixes #1120

expect(nil).toAlways(equal(0)) would erroneously pass. Interestingly, expect(1).toAlways(equal(0)) would correctly fail. Given what changed here, I would have expected expect(1).toAlways(equal(0)) to erroneously pass as well. Yet that matcher correctly fails without this PR. 🤷🏻‍♀️

I don't quite know why nil is special here, I think it's related to an inversion in the ExpectationStyle as passed to execute and poll for toAlways and toNever. But I'm not 100% certain.

So, this fixes that refactor, and also adds logic to catch that the continuous polling matchers (toAlways/toNever) should immediately fail if the matcher doesn't match. Just to be certain there.

Minor version bump on release.