-
Notifications
You must be signed in to change notification settings - Fork 120
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
verify macro replaces argument type with id #148
Comments
I think this is a good idea! |
There's one wrinkle: propagating the type through means you now need to cast to Example of errorsWithout the cast, and with propagating the type, clang issues errors like:
Example of fixing the errorsThe errors are fixed by casting to the type of objects conforming to the protocol: @@ -120,7 +136,7 @@ static inline double *createArrayOf10Doubles(void)
{
[mockArray removeObjectAtIndex:2];
- [[verify(mockArray) withMatcher:greaterThan(@1) forArgument:0]
+ [[(id<MKTNonObjectArgumentMatching>)verify(mockArray) withMatcher:greaterThan(@1) forArgument:0]
removeObjectAtIndex:0];
}
@@ -128,7 +144,7 @@ static inline double *createArrayOf10Doubles(void)
{
[mockArray removeObjectAtIndex:2];
- [[verify(mockArray) withMatcher:greaterThan(@1)]
+ [[(id<MKTNonObjectArgumentMatching>)verify(mockArray) withMatcher:greaterThan(@1)]
removeObjectAtIndex:0];
} Proposed enhancementThis could be made more ergonomic by adding macros like As a bonus, that would also make the "use a matcher for a primitive" behavior more discoverable through autocomplete of |
Without the cast, autocomplete is also less helpful.
I've been able to fix both by rewriting
verify
:Would this be worth PRing as a change to OCMockito's own definition of
verify
?Version: OCMockito v5.0.1, OCHamcrest v7.0.2
The text was updated successfully, but these errors were encountered: