[K/N][Tests] Migrate objcSmoke & objcTests tests
^KT-61259
This commit is contained in:
committed by
Space Team
parent
58f7dd1c83
commit
524f0d335e
@@ -0,0 +1,27 @@
|
||||
import kotlinx.cinterop.*
|
||||
import kotlin.test.*
|
||||
import objcTests.*
|
||||
|
||||
@Test fun testAllocNoRetain() {
|
||||
// Ensure that calling Kotlin constructor generated for Objective-C initializer doesn't result in
|
||||
// redundant retain-release sequence for `alloc` result, since it may provoke specific bugs to reproduce, e.g.
|
||||
// the one found in [[NSOutputStream alloc] initToMemory] sequence where initToMemory deallocates its receiver
|
||||
// forcibly when replacing it with other object: (to be compiled with ARC enabled)
|
||||
/*
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
void* mem;
|
||||
NSOutputStream* allocated = nil;
|
||||
|
||||
int main() {
|
||||
allocated = [NSOutputStream alloc];
|
||||
NSOutputStream* initialized = [allocated initToMemory];
|
||||
mem = calloc(1, 0x10); // To corrupt the 'allocated' object header.
|
||||
allocated = nil; // Crashes here in objc_release.
|
||||
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
assertTrue(TestAllocNoRetain().ok)
|
||||
}
|
||||
Reference in New Issue
Block a user