Code Monkey home page Code Monkey logo

Comments (13)

codyaray avatar codyaray commented on May 18, 2024

I've reproduced this problem using the instructions from @lightforce.

Also found another problem that I believe is related. The same error occurs when using dictionaries as arguments in messages to mock object.

@interface Actor : NSObject
- (void)doIt:(NSDictionary *) dict;
@end

@implementation Actor
- (void)doIt:(NSDictionary *) dict {}
@end

@interface SomeTest : SenTestCase
@end

@implementation SomeTest

- (void)testBigTrouble
{
    NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
                          @"value1", @"key1", @"value2", @"key2", nil];
    [mock([Actor class]) doIt:dict];
}

@end

This results in an error message like

error: -[SomeTest testBigTrouble] : -[__NSArrayM setObject:atIndexedSubscript:]: unrecognized selector sent to instance 0xa2449b0

from ocmockito.

codyaray avatar codyaray commented on May 18, 2024

On that note, almost all of the examples in the README are broken. So... this seems to be a high priority bug.

from ocmockito.

sebromero avatar sebromero commented on May 18, 2024

Thank you @codyaray for pointing that out. As for my example it crashes inside MKTInvocationMatcher at line 51, where the new array subscription syntax is used. I think a solution might be to use Clang's _has feature. E.g.

#if __has_feature(objc_array_literals)
    // new way.
    _argumentMatchers[argumentIndex] = matcher;
#else
    // old way (equivalent).        
    [_argumentMatchers replaceObjectAtIndex:argumentIndex withObject:matcher];
#endif

from ocmockito.

jonreid avatar jonreid commented on May 18, 2024

Thanks, you guys. I'll check it out.

from ocmockito.

codyaray avatar codyaray commented on May 18, 2024

Any updates?

from ocmockito.

jonreid avatar jonreid commented on May 18, 2024

I can't reproduce either problem. But @lightforce you have a clear symptom. What kind of OS / Xcode version are you using that doesn't support new literals?

from ocmockito.

codyaray avatar codyaray commented on May 18, 2024

I'm using OCMockito 0.23 downloaded from http://qualitycoding.org/resources/ with XCode 4.3.2 on Mac OS X 10.7.5 and building for iPhone 5.1 Simulator. (Thanks for the TDD tutorial that references OCMockito!) Is there any other information that could help?

from ocmockito.

jonreid avatar jonreid commented on May 18, 2024

@codyarray It's odd, but I still can't reproduce. I'm using your Actor / SomeTest sample above, in a Cocoa Touch Static Library project. Could you boil it down to a sample project that you could email to me?

from ocmockito.

codyaray avatar codyaray commented on May 18, 2024

Absolutely. I just sent an email with a sample project. Thanks for your help!

from ocmockito.

sebromero avatar sebromero commented on May 18, 2024

I configured my testing unit to use OCMockito via Cocoapods

pod 'OCMockito', '~> 0.23'

The Apple LLVM compiler 4.2 is used and the deployment target is iOS 6.1 for both the test bundle and the Pods project. No test host is set for the testing bundle (logic tests). Although I am able to use the new literal syntax inside the test classes without problems, the literals syntax used inside OCMockito makes the tests crash.

from ocmockito.

codyaray avatar codyaray commented on May 18, 2024

Okay, so I just upgraded to XCode 4.6 (4H127) through the mac app store and the sample I sent no longer fails. Tested with iPhone 5.1 and 6.1 simulators. Hmm.

from ocmockito.

jonreid avatar jonreid commented on May 18, 2024

Though I can't reproduce the problem, I changed the new array use in MKTInvocationMatcher at line 51. @lightforce maybe you could give it a whirl.

from ocmockito.

sebromero avatar sebromero commented on May 18, 2024

Works perfectly. Thx!

from ocmockito.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.