[K/N][Tests] Polish test sharing_with_weak.kt
^KT-61259
This commit is contained in:
+5
-8
@@ -18,7 +18,7 @@ void setObject(NSObject* obj) {
|
||||
|
||||
// Make sure this function persists, because the test expects to find this function in the stack trace.
|
||||
__attribute__((noinline))
|
||||
bool isObjectAliveShouldCrash() {
|
||||
bool isObjectAlive() {
|
||||
return globalObject != nil;
|
||||
}
|
||||
|
||||
@@ -33,12 +33,11 @@ import objclib.*
|
||||
val sb = StringBuilder()
|
||||
|
||||
fun box(): String {
|
||||
autoreleasepool {
|
||||
val success = autoreleasepool {
|
||||
run()
|
||||
}
|
||||
// Experimental MM supports arbitrary object sharing.
|
||||
assertEquals("Before\nAfter true\n", sb.toString())
|
||||
return "OK"
|
||||
return if (success) "OK" else "FAIL"
|
||||
}
|
||||
|
||||
private class NSObjectImpl : NSObject() {
|
||||
@@ -49,13 +48,11 @@ fun run() = withWorker {
|
||||
val obj = NSObjectImpl()
|
||||
setObject(obj)
|
||||
|
||||
sb.appendLine("Before")
|
||||
val isAlive = try {
|
||||
try {
|
||||
execute(TransferMode.SAFE, {}) {
|
||||
isObjectAliveShouldCrash()
|
||||
isObjectAlive()
|
||||
}.result
|
||||
} catch (e: Throwable) {
|
||||
false
|
||||
}
|
||||
sb.appendLine("After $isAlive")
|
||||
}
|
||||
+6
-6
@@ -5074,12 +5074,6 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe
|
||||
runTest("compiler/testData/codegen/box/cinterop/objc/direct.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("illegal_sharing_with_weak.kt")
|
||||
public void testIllegal_sharing_with_weak() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/cinterop/objc/illegal_sharing_with_weak.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt34467.kt")
|
||||
public void testKt34467() throws Exception {
|
||||
@@ -5109,6 +5103,12 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe
|
||||
public void testOverridabilityCondition() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/cinterop/objc/overridabilityCondition.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("sharing_with_weak.kt")
|
||||
public void testSharing_with_weak() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/cinterop/objc/sharing_with_weak.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+6
-6
@@ -5190,12 +5190,6 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB
|
||||
runTest("compiler/testData/codegen/box/cinterop/objc/direct.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("illegal_sharing_with_weak.kt")
|
||||
public void testIllegal_sharing_with_weak() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/cinterop/objc/illegal_sharing_with_weak.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt34467.kt")
|
||||
public void testKt34467() throws Exception {
|
||||
@@ -5225,6 +5219,12 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB
|
||||
public void testOverridabilityCondition() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/cinterop/objc/overridabilityCondition.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("sharing_with_weak.kt")
|
||||
public void testSharing_with_weak() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/cinterop/objc/sharing_with_weak.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+6
-6
@@ -4958,12 +4958,6 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
|
||||
runTest("compiler/testData/codegen/box/cinterop/objc/direct.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("illegal_sharing_with_weak.kt")
|
||||
public void testIllegal_sharing_with_weak() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/cinterop/objc/illegal_sharing_with_weak.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt34467.kt")
|
||||
public void testKt34467() throws Exception {
|
||||
@@ -4993,6 +4987,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
|
||||
public void testOverridabilityCondition() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/cinterop/objc/overridabilityCondition.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("sharing_with_weak.kt")
|
||||
public void testSharing_with_weak() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/cinterop/objc/sharing_with_weak.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+6
-6
@@ -5075,12 +5075,6 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT
|
||||
runTest("compiler/testData/codegen/box/cinterop/objc/direct.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("illegal_sharing_with_weak.kt")
|
||||
public void testIllegal_sharing_with_weak() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/cinterop/objc/illegal_sharing_with_weak.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt34467.kt")
|
||||
public void testKt34467() throws Exception {
|
||||
@@ -5110,6 +5104,12 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT
|
||||
public void testOverridabilityCondition() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/cinterop/objc/overridabilityCondition.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("sharing_with_weak.kt")
|
||||
public void testSharing_with_weak() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/cinterop/objc/sharing_with_weak.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
Reference in New Issue
Block a user