petejkim/expecta — pull request #28 by pivotaltracker (2013-03-09 01:31:11+00:00)
Title: Fixed memory leaks in expectations and matchers

We used Instruments to profile our specs after leaked objects began to cause test pollution. We tracked the issue down to both the expect() macro and any matcher that took a parameter, such as equal().

For example:

expect(myObject).toNot.beNil()

will leak my object because the -[EXPExpect actualBlock] property is not released when the expectation is released.

The matcher in this assertion also leaks:

expect(nil).toNot.equal(myObject)

because the EXPBlockDefinedMatcher does not release any of the blocks it retains.

There were also a pair of other simple memory management bugs which we fixed:

* the block returned from -[EXPDynamicPredicateMatcher dispatch] was not autoreleased
* The dynamic matcher methods created by _EXPMatcherImplementationBegin would not release the EXPBlockDefinedMatcher *matcher

Cheers,

Christian and Ted