association-cf.m 817 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // TEST_CFLAGS -framework CoreFoundation
  2. // TEST_CONFIG MEM=mrc
  3. // not for ARC because ARC memory management doesn't
  4. // work on CF types whose ObjC side is not yet loaded
  5. #include <CoreFoundation/CoreFoundation.h>
  6. #include <objc/runtime.h>
  7. #include "test.h"
  8. #if __has_feature(objc_arc)
  9. int main()
  10. {
  11. testwarn("rdar://11368528 confused by Foundation");
  12. succeed(__FILE__);
  13. }
  14. #else
  15. int main()
  16. {
  17. // rdar://6164781 setAssociatedObject on unresolved future class crashes
  18. id mp = (id)CFMachPortCreate(0, 0, 0, 0);
  19. testassert(mp);
  20. testassert(! objc_getClass("NSMachPort"));
  21. objc_setAssociatedObject(mp, (void*)1, mp, OBJC_ASSOCIATION_ASSIGN);
  22. id obj = objc_getAssociatedObject(mp, (void*)1);
  23. testassert(obj == mp);
  24. CFRelease((CFTypeRef)mp);
  25. succeed(__FILE__);
  26. }
  27. #endif