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

When a second mock is created for the same class, dispose of the dynamically created subclass for the first mock. #352

Merged

Conversation

davidsansome
Copy link
Contributor

Previously that first dynamically created subclass was kept around forever,
and if accessed somehow (for example by enumerating objc_getClassList) would
always raise NSInternalInconsistencyException.

…mically created subclass for the first mock.

Previously that first dynamically created subclass was kept around forever,
and if accessed somehow (for example by enumerating objc_getClassList) would
always raise NSInternalInconsistencyException.
@erikdoe erikdoe merged commit 63aa2bb into erikdoe:master Apr 5, 2018
@pletoss
Copy link

pletoss commented Apr 25, 2018

Hey. So I had an issue and noticed this as well. When will this PR get into a new version on cocoapods ?

@erikdoe
Copy link
Owner

erikdoe commented Apr 26, 2018

I had planned to wait for the outcome of #339 to include in the next minor release. It's been taken a while, I know.

@swhitty
Copy link

swhitty commented Jul 5, 2018

This PR created a regression, If 2 partial mocks are created with the same underlying Class type, then the first mock stops forwarding @selectors to the real object.

p1.name = @"Person 1";
p2.name = @"Person 2";
Person *mock1 = OCMPartialMock(p1);
mock1.name == @"Person 1"
Person *mock2 = OCMPartialMock(p2);
mock2.name == @"Person 2"
mock1.name == nil //😱

@erikdoe
Copy link
Owner

erikdoe commented Oct 12, 2018

Could you check whether the fix I just committed works for you? The new tests introduced in this PR still pass, but the class pair is disposed a little later; not when the second mock takes over but when stopMocking is called on the first mock.

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

Successfully merging this pull request may close these issues.

4 participants