-
Notifications
You must be signed in to change notification settings - Fork 140
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
Improve handling of object-typed nil values during argument matching #226
Improve handling of object-typed nil values during argument matching #226
Conversation
Hm I see. Could elaborate a bit on the motivation for reverting #100, perhaps with an example? I'd like to add some tests to specify the aspects of the equals matcher that we want to preserve before taking another go at this. |
The reason for reverting #100 is to not have to constantly check for nil when writing expectations. Say comparing this: Items.firstObject should equal(array.lastObject) This expectation can pass in a case that can be more surprising since both can return nils. It's more common in tests to expect non-nil than nil values. On Sat, Apr 19, 2014 at 5:28 PM, Brian Croom notifications@github.com
|
Got it. I've been doing some additional work on this, but I did have one question. Given the same context as above, should it pass or fail with the negative matcher?
I'm thinking it should fail based on the same reasoning, but that does not appear to be the current behavior. |
I'm thinking that it should, but that fix might introduce unintended regressions at this point. We'll need to discuss this more for that case.— On Wed, Apr 23, 2014 at 8:45 AM, Brian Croom notifications@github.com
|
I've pushed out some more work that corrects the behavior of |
This behavior looks good now. I'm not sure the series of commits to arrive at this behavior should be on master, though. What do you think about squashing them? |
…ching method arguments - Properly match methods invocations which include a `nil` argument [#63351266] - Fix stringifiers for NSNumber and for generic objects to correctly handle nil values - Fix the compare_equal matcher for two NSNumber's to not blow up if the expectedValue is nil [#69580148] - Equal matcher fails explicitly when used with nil - In this situation, presumably the value passed in was intended to not be nil, hence it is treated as a failure - The be_nil matcher is mentioned in case checking for nil was the actual intention - be_nil matcher can be used with block values [#42698619]
Thanks for tidying up! |
…er-with-nil-as-id Improve handling of object-typed nil values during argument matching
The existing tests around the usage of nil generally use a simple
nil
literal, which seems to be treated as typeint
by the compiler. I've fixed behavior and crashes around the usage of nil which is typed asid
.