From a74542ae4f264b199704d5291784effc3d0a25bd Mon Sep 17 00:00:00 2001 From: David Chisnall Date: Mon, 23 Mar 2015 14:10:43 +0000 Subject: [PATCH] =?UTF-8?q?Add=20a=20test=20that=20hidden=20classes=20are?= =?UTF-8?q?=20correctly=20deallocated=20and=20don=E2=80=99t=20leave=20the?= =?UTF-8?q?=20runtime=20in=20an=20undefined=20state.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Test/AssociatedObject2.m | 37 +++++++++++++++++++++++++++++++++++++ Test/CMakeLists.txt | 1 + Test/Test.h | 6 ++++++ 3 files changed, 44 insertions(+) create mode 100644 Test/AssociatedObject2.m diff --git a/Test/AssociatedObject2.m b/Test/AssociatedObject2.m new file mode 100644 index 0000000..e8f7d53 --- /dev/null +++ b/Test/AssociatedObject2.m @@ -0,0 +1,37 @@ +#include "Test.h" + +@interface MLTestClass : Test { +@public +} +- (void)someF; +@end + +@implementation MLTestClass +- (void)someF +{ +} + +@end + +static void ff(id obj, SEL _cmd) +{ +} + + +int main() +{ + static char static_char; + MLTestClass * tc; + tc = [MLTestClass new]; + objc_setAssociatedObject(tc, &static_char, (id)1223, OBJC_ASSOCIATION_ASSIGN); + [tc release]; + int i = 0; + tc = [MLTestClass new]; + objc_setAssociatedObject(tc, &static_char, (id)1223, OBJC_ASSOCIATION_ASSIGN); + SEL some_sel = sel_registerName(".some_sel"); + const char *types = "v@:"; + class_addMethod(object_getClass(tc), some_sel, + (IMP)ff, types); + int j = (int)objc_getAssociatedObject(tc, &static_char); + [tc release]; +} diff --git a/Test/CMakeLists.txt b/Test/CMakeLists.txt index e8db645..8e253ae 100644 --- a/Test/CMakeLists.txt +++ b/Test/CMakeLists.txt @@ -8,6 +8,7 @@ set(TESTS #alignTest.m AllocatePair.m AssociatedObject.m + AssociatedObject2.m BlockImpTest.m BlockTest_arc.m BoxedForeignException.m diff --git a/Test/Test.h b/Test/Test.h index d61d90b..6ca0261 100644 --- a/Test/Test.h +++ b/Test/Test.h @@ -15,6 +15,12 @@ __attribute__((objc_root_class)) @interface Test { id isa; } + (Class)class; + (id)new; +#if !__has_feature(objc_arc) +- (void)dealloc; +- (id)autorelease; +- (id)retain; +- (void)release; +#endif @end #if !__has_feature(objc_arc)