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