Cuckoo
Cuckoo copied to clipboard
Support calling objective-c methods and closures with nil
Hello, I'm trying to fix 2 issues I found when trying to use Cuckoo/OCMock in a project. I'm currently unable to cover a few code branches because of them.
- Calling
mock.say(nil)currently fails with-[_NSArrayM insertObject:atIndex:]: object cannot be nil (NSInvalidArgumentException)becauseNSInvocation+OCMockWrapperdoesn't do a null check. - Using
objectiveArgumentClosureand calling the closure withnilfails with-[NSNull count]: unrecognized selector sent to instance 0x7fff8002ebb0 (NSInvalidArgumentException). I think it's causeTrustMedoesn't support nullable types. I proposeobjectiveOptionalArgumentClosure(or maybeobjcArgumentClosureWithOptional?). I can add more of them to support closures with more args if you think this is alright.
I also removed the reference to ObjectiveExamplesTest.swift. It doesn't exist in the project so it's making the build fail.
Cheers
Hey, @dekpient. Thanks for the PR and thanks for using the OCMock integration!
It's a nice find with the nil, I'll take a look at the code and see what we can do with the second problem you're proposing a solution to.