]> git.saurik.com Git - apple/objc4.git/blob - test/xref.m
objc4-680.tar.gz
[apple/objc4.git] / test / xref.m
1 // TEST_CFLAGS
2
3 #include <Foundation/NSObject.h>
4 #include <objc/runtime.h>
5 #include <objc/objc-internal.h>
6
7 #include "test.h"
8
9 int main()
10 {
11 // rdar://8350188 External references (handles)
12
13 id object = [NSObject new];
14 testassert(object);
15
16 // STRONG
17 objc_xref_t xref = _object_addExternalReference(object, OBJC_XREF_STRONG);
18 testassert(xref);
19 testassert(_object_readExternalReference(xref) == object);
20 _object_removeExternalReference(xref);
21 // TODO: expect a crash if a stale xref is used.
22
23 // WEAK
24 xref = _object_addExternalReference(object, OBJC_XREF_WEAK);
25 testassert(xref);
26 testassert(_object_readExternalReference(xref) == object);
27 _object_removeExternalReference(xref);
28
29 RELEASE_VAR(object);
30
31 succeed(__FILE__);
32 }