#import "Testing.h"
#import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSObject.h>
#import <Foundation/NSString.h>


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

int main()
{
  NSAutoreleasePool *arp = [NSAutoreleasePool new];
  associatedObjectTestAllocatedObject* object = 
  	[associatedObjectTestAllocatedObject new];

  associatedObjectTestAssociatedObject *info = 
  	[[associatedObjectTestAssociatedObject new] autorelease];
  // silence -Wunused-variable
  [info description];
  objc_setAssociatedObject(object, &objc_setAssociatedObjectKey, info, 
	OBJC_ASSOCIATION_RETAIN);
  [object release];

  PASS(AssociatedObjectDeallocCalled == YES, 
       "'objc_setAssociatedObject' was released");
  return 0;
}
