@@ -65,38 +65,44 @@ testSuite.test("KVO/Simple") {
65
65
// We use object_getClass in this test to not look through KVO's artificial
66
66
// subclass.
67
67
let obj = SimpleNSObject ( )
68
- let observation = obj. observe ( \. observableName) { _, _ in }
69
- withExtendedLifetime ( observation) {
70
- let theClass = object_getClass ( obj)
71
- precondition ( theClass !== SimpleNSObject . self, " no KVO subclass? " )
72
- expectNil ( class_getImageName ( theClass) ,
73
- " should match what happens with NSObject (below) " )
68
+ autoreleasepool {
69
+ let observation = obj. observe ( \. observableName) { _, _ in }
70
+ withExtendedLifetime ( observation) {
71
+ let theClass = object_getClass ( obj)
72
+ precondition ( theClass !== SimpleNSObject . self, " no KVO subclass? " )
73
+ expectNil ( class_getImageName ( theClass) ,
74
+ " should match what happens with NSObject (below) " )
75
+ }
74
76
}
75
77
}
76
78
77
79
testSuite. test ( " KVO/GenericAncestry " ) {
78
80
// We use object_getClass in this test to not look through KVO's artificial
79
81
// subclass.
80
82
let obj = GenericAncestryNSObject ( )
81
- let observation = obj. observe ( \. observableName) { _, _ in }
82
- withExtendedLifetime ( observation) {
83
- let theClass = object_getClass ( obj)
84
- precondition ( theClass !== GenericAncestryNSObject . self, " no KVO subclass? " )
85
- expectNil ( class_getImageName ( theClass) ,
86
- " should match what happens with NSObject (below) " )
83
+ autoreleasepool {
84
+ let observation = obj. observe ( \. observableName) { _, _ in }
85
+ withExtendedLifetime ( observation) {
86
+ let theClass = object_getClass ( obj)
87
+ precondition ( theClass !== GenericAncestryNSObject . self, " no KVO subclass? " )
88
+ expectNil ( class_getImageName ( theClass) ,
89
+ " should match what happens with NSObject (below) " )
90
+ }
87
91
}
88
92
}
89
93
90
94
testSuite. test ( " KVO/ObjC " ) {
91
95
// We use object_getClass in this test to not look through KVO's artificial
92
96
// subclass.
93
97
let obj = NSObject ( )
94
- let observation = obj. observe ( \. description) { _, _ in }
95
- withExtendedLifetime ( observation) {
96
- let theClass = object_getClass ( obj)
97
- precondition ( theClass !== NSObject . self, " no KVO subclass? " )
98
- expectNil ( class_getImageName ( theClass) ,
99
- " should match what happens with the Swift objects (above) " )
98
+ autoreleasepool {
99
+ let observation = obj. observe ( \. description) { _, _ in }
100
+ withExtendedLifetime ( observation) {
101
+ let theClass = object_getClass ( obj)
102
+ precondition ( theClass !== NSObject . self, " no KVO subclass? " )
103
+ expectNil ( class_getImageName ( theClass) ,
104
+ " should match what happens with the Swift objects (above) " )
105
+ }
100
106
}
101
107
}
102
108
0 commit comments