Skip to content
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

Test case failed #27

Open
phamquy opened this issue Nov 11, 2015 · 2 comments
Open

Test case failed #27

phamquy opened this issue Nov 11, 2015 · 2 comments

Comments

@phamquy
Copy link

phamquy commented Nov 11, 2015

I just pull the code, and run the test case. But two of those failed

  1. testBlockTransformations but the cause is not from SOCKit, but from sockitBetterURLEncodeString
  2. testPerformSelectorOnObjectWithSourceString failed with the following message:
*** error for object 0x7ca6f7b0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
@phamquy
Copy link
Author

phamquy commented Nov 11, 2015

Look like the issue lay in the ARC-bridging code

@phamquy
Copy link
Author

phamquy commented Nov 11, 2015

i update the -(id)performSelector:(SEL)selector onObject:(id)object sourceString:(NSString *)sourceString as following, and the problem solve, but I'm not sure what the reason, and if the issue will not occurs with others test cases (e.g the init method does not return same object as self)

- (id)performSelector:(SEL)selector onObject:(id)object sourceString:(NSString *)sourceString {
  BOOL isInitializer = [NSStringFromSelector(selector) hasPrefix:@"init"] && [object class] == object;

  if (isInitializer) {
    object = [object alloc];
  }

  NSArray* values = nil;
  BOOL succeeded = [self gatherParameterValues:&values fromString:sourceString];
  NSAssert(succeeded, @"The pattern can't be used with this string.");

  id returnValue = nil;

  if (succeeded) {
    returnValue = object;  //<< added line
    NSMethodSignature* sig = [object methodSignatureForSelector:selector];
    NSAssert(nil != sig, @"%@ does not respond to selector: '%@'", object, NSStringFromSelector(selector));

    NSInvocation* invocation = [NSInvocation invocationWithMethodSignature:sig];
    [invocation setTarget:object];
    [invocation setSelector:selector];
    [self setArgumentsFromValues:values forInvocation:invocation];
    [invocation invoke];

    if (sig.methodReturnLength) {
      [invocation getReturnValue:&returnValue];
    }

    // Necessary for transferring this object into ARC-world.
    returnValue = CFBridgingRelease(CFBridgingRetain(returnValue));
  }

  return returnValue;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant