]> git.saurik.com Git - apple/objc4.git/blob - test/weakcopy.m
objc4-493.9.tar.gz
[apple/objc4.git] / test / weakcopy.m
1 // TEST_CONFIG
2
3 #include "test.h"
4 #include <stdint.h>
5 #include <string.h>
6 #include <objc/objc-runtime.h>
7
8 @interface Base {
9 @public
10 id isa;
11 }
12 @end
13 @implementation Base
14 +(void)initialize { }
15 +class { return self; }
16 @end
17
18 @interface Weak : Base {
19 @public
20 __weak id value;
21 }
22 @end
23 @implementation Weak
24 @end
25
26 int main()
27 {
28 Base *value = class_createInstance([Base class], 0);
29 Weak *oldObject = class_createInstance([Weak class], 0);
30 oldObject->value = value;
31 Weak *newObject = object_copy(oldObject, 0);
32 testassert(newObject->value == oldObject->value);
33 newObject->value = nil;
34 succeed(__FILE__);
35 return 0;
36 }