erikdoe/ocmock — pull request #33 by Infiniverse (2013-03-14 07:40:25+00:00)
Title: Bug fix: prevent a crash in ARC managed tests.

ARC managed calling code releases the value, causing an exception.

This is documented on StackOverflow:
http://stackoverflow.com/questions/15345899/unexpected-crash-using-ocmock-mocking-mutablecopy-on-an-nsstring

The following code crashes, for example, when the compiler auto generates
a [foo release] during dealloc.

NSString *string = [OCMockObject mockForClass:NSString.class];
NSMutableString *copy = [@"foo" mutableCopy];
id foo = [(NSString *) [[(id) string expect] andReturn:copy] mutableCopy];

It may be that not all returned values need releasing and this is a special
circumstance because the compiler knows that foo is a Toll Free Bridged
data type. However, a memory leak in a test is preferable to a test that
crashes.