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
Precondition:
Using MobileCoreServices.framework target is real object or mock - doesn't matter
What I do:
[target stub:@selector(methodWithStringArg:) andReturn:mock withArguments:@"=string"];
id result = [target methodWithStringArg:@"=string"];
What I expect:
result is mock
What I receive:
result is nil
Reason: +[KWGenericMatchEvaluator isGenericMatcher:] detects matcher by looking for a method with signature bool matches(id).
Method with this signature is added by MobileCoreServices to NSString (bool -[NSString matches:]) via category, so any string detected as matcher now. It seems that it is already undefined behavior for Kiwi.
Method matches: in NSString works fine in most cases, and we can't see the bug.
But when string starts with = symbol, it fails (actually, the problem is in method matchesString:, that is called inside matches:):
Ex:
(lldb) p (BOOL)[@"abra" matchesString:@"abra"]
(BOOL) $7 = YES
(lldb) p (BOOL)[@"=1" matchesString:@"=1"]
(BOOL) $8 = NO
Proposed solution:
Best solution - replace the way of determining generic matchers with something more strict and certain.
Slightly worse - add NSString with subclasses to blacklist.
The text was updated successfully, but these errors were encountered:
Yep, I can create a PR, but it seems that I need an additional information about generic matchers.
I found 2 classes that implements method with signature - (BOOL)matches:(id)item: KWStringContainsMatcher & KWStringPrefixMatcher.
KWStringContainsMatcher implements KWGenericMatching, but all public methods marked as DEPRECATED. KWStringPrefixMatcher doesn't implement KWGenericMatching, but can be used as generic matcher.
Also, why all methods in KiwiGenericMatchingAdditions.h marked as DEPRECATED, but still in use?
Would it be correct if I will add KWGenericMatching into KWStringPrefixMatcher and replace part of + (BOOL)isGenericMatcher:(id)object with
Precondition:
Using
MobileCoreServices.framework
target
is real object or mock - doesn't matterWhat I do:
What I expect:
result is mock
What I receive:
result is nil
Reason:
+[KWGenericMatchEvaluator isGenericMatcher:]
detects matcher by looking for a method with signaturebool matches(id)
.Method with this signature is added by
MobileCoreServices
toNSString
(bool -[NSString matches:]
) via category, so any string detected as matcher now. It seems that it is already undefined behavior for Kiwi.Method
matches:
in NSString works fine in most cases, and we can't see the bug.But when string starts with
=
symbol, it fails (actually, the problem is in methodmatchesString:
, that is called insidematches:
):Ex:
Proposed solution:
Best solution - replace the way of determining generic matchers with something more strict and certain.
Slightly worse - add NSString with subclasses to blacklist.
The text was updated successfully, but these errors were encountered: