Add test for associated objects.

main
theraven 12 years ago
parent 9bb46919f6
commit 2d0ae6b79b

@ -0,0 +1,26 @@
#include "Test.h"
static BOOL deallocCalled = NO;
static const char* objc_setAssociatedObjectKey = "objc_setAssociatedObjectKey";
@interface Associated : Test
@end
@implementation Associated
-(void) dealloc
{
deallocCalled = YES;
[super dealloc];
}
@end
int main(void)
{
@autoreleasepool {
Associated *object = [Associated new];
Test *holder = [[Test new] autorelease];
objc_setAssociatedObject(object, &objc_setAssociatedObjectKey, holder, OBJC_ASSOCIATION_RETAIN);
[object release];
}
assert(deallocCalled);
}

@ -7,6 +7,7 @@
set(TESTS
#alignTest.m
AllocatePair.m
AssociatedObject.m
BlockImpTest.m
BlockTest_arc.m
BoxedForeignException.m

@ -1,4 +1,5 @@
#import "../objc/runtime.h"
#import "../objc/objc-arc.h"
#ifdef NDEBUG
#undef NDEBUG
#endif
@ -14,7 +15,7 @@ __attribute__((objc_root_class))
@interface Test { id isa; }
@end
@implementation Test
+ (id)class { return self; }
+ (Class)class { return self; }
+ (id)new
{
return class_createInstance(self, 0);
@ -23,4 +24,27 @@ __attribute__((objc_root_class))
{
object_dispose(self);
}
- (id)autorelease
{
return objc_autorelease(self);
}
- (id)retain
{
return objc_retain(self);
}
- (void)release
{
objc_release(self);
}
- (void)_ARCCompliantRetainRelease {}
@end
@interface NSAutoreleasePool : Test
@end
@implementation NSAutoreleasePool
- (void)_ARCCompatibleAutoreleasePool {}
+ (void)addObject:(id)anObject
{
objc_autorelease(anObject);
}
@end

Loading…
Cancel
Save