]> git.saurik.com Git - apple/objc4.git/blob - test/atomicProperty.mm
objc4-756.2.tar.gz
[apple/objc4.git] / test / atomicProperty.mm
1 // TEST_CONFIG
2
3 #include "test.h"
4 #include <objc/runtime.h>
5 #include <objc/objc-internal.h>
6 #import <Foundation/NSObject.h>
7
8 class SerialNumber {
9 size_t _number;
10 public:
11 SerialNumber() : _number(42) {}
12 SerialNumber(const SerialNumber &number) : _number(number._number + 1) {}
13 SerialNumber &operator=(const SerialNumber &number) { _number = number._number + 1; return *this; }
14
15 int operator==(const SerialNumber &number) { return _number == number._number; }
16 int operator!=(const SerialNumber &number) { return _number != number._number; }
17 };
18
19 @interface TestAtomicProperty : NSObject {
20 SerialNumber number;
21 }
22 @property(atomic) SerialNumber number;
23 @end
24
25 @implementation TestAtomicProperty
26
27 @synthesize number;
28
29 @end
30
31 int main()
32 {
33 PUSH_POOL {
34 SerialNumber number;
35 TestAtomicProperty *test = [TestAtomicProperty new];
36 test.number = number;
37 testassert(test.number != number);
38 } POP_POOL;
39
40 succeed(__FILE__);
41 }