I saw the test that you checked in to svn and modified my code to match it:
static BOOL associatedObjectDeallocCalled = NO;
static const char* objc_setAssociatedObjectKey = "objc_setAssociatedObjectKey";
@interface associatedObjectTestAssociatedObject : NSObject
@end
@implementation associatedObjectTestAssociatedObject
-(void) dealloc
{
associatedObjectDeallocCalled = YES;
[super dealloc];
}
@end
@interface associatedObjectTestAllocatedObject : NSObject
@end
@implementation associatedObjectTestAllocatedObject
@end
TEST(objc_setAssociatedObject, AssociatedObjectsAreReleased)
{
#if !Z2_APPLE
GSDebugAllocationActive(YES);
GSDebugAllocationList(YES);
#endif
@autoreleasepool {
associatedObjectTestAllocatedObject* object = [associatedObjectTestAllocatedObject new];
associatedObjectTestAssociatedObject *info = [[associatedObjectTestAssociatedObject new] autorelease];
objc_setAssociatedObject(object, &objc_setAssociatedObjectKey, info, OBJC_ASSOCIATION_RETAIN);
[object release];
}
#if !Z2_APPLE
EXPECT_STREQ(GSDebugAllocationList(YES), "1\tNSDataMalloc\n");
#endif
ASSERT_TRUE(associatedObjectDeallocCalled);
}
On the Apple runtime it passes still:
[----------] 1 test from objc_setAssociatedObject
[ RUN ] objc_setAssociatedObject.AssociatedObjectsAreReleased
[ OK ] objc_setAssociatedObject.AssociatedObjectsAreReleased (0 ms)
[----------] 1 test from objc_setAssociatedObject (0 ms total)
On Gnustep/objc2:
E/Z2GameLog(12157): STDOUT: [----------] 1 test from objc_setAssociatedObject
E/Z2GameLog(12157): STDOUT: [ RUN ] objc_setAssociatedObject.AssociatedObjectsAreReleased
E/Z2GameLog(12157): STDOUT: /data/testnations.git/jujulib/Tests/objc-utility/objc_setAssociatedObjectTest.h:44: Failure
E/Z2GameLog(12157): STDOUT: Value of: "1\tNSDataMalloc\n"
E/Z2GameLog(12157): STDOUT: Actual: "1 NSDataMalloc
E/Z2GameLog(12157): STDOUT: "
E/Z2GameLog(12157): STDOUT: Expected: GSDebugAllocationList(((BOOL)1))
E/Z2GameLog(12157): STDOUT: Which is: "1 NSDataMalloc
E/Z2GameLog(12157): STDOUT: 1 associatedObjectTestAssociatedObject
E/Z2GameLog(12157): STDOUT: "
E/Z2GameLog(12157): STDOUT: /data/testnations.git/jujulib/Tests/objc-utility/objc_setAssociatedObjectTest.h:47: Failure
E/Z2GameLog(12157): STDOUT: Value of: innerObjectDeallocCalled
E/Z2GameLog(12157): STDOUT: Actual: false
E/Z2GameLog(12157): STDOUT: Expected: true
E/Z2GameLog(12157): STDOUT: [ FAILED ] objc_setAssociatedObject.AssociatedObjectsAreReleased (1 ms)
E/Z2GameLog(12157): STDOUT: [----------] 1 test from objc_setAssociatedObject (2 ms total)
My runtime environment unfortunately isn't in a position to run the libobjc tests directly. Do you have any suggestions as to what I should be looking for? Perhaps there's something in the GNUStep Foundation NSObject that's causing it to fail but works with the libobjc Test object?