[K/N] Added test for checking C callback set with Kotlin function throwing exception

This commit is contained in:
Elena Lepilkina
2021-10-25 17:15:14 +03:00
committed by Space
parent 751f1a3b91
commit 23e5079391
4 changed files with 38 additions and 0 deletions
@@ -0,0 +1,9 @@
#include <stdio.h>
extern "C" void runAndCatch(void(*f)(void)) {
try {
f();
} catch (...) {
printf("CATCH IN C++!\n");
}
}
@@ -0,0 +1,5 @@
language = C
---
void runAndCatch(void(*f)(void));
@@ -0,0 +1,11 @@
import kotlinx.cinterop.staticCFunction
import cCallback.runAndCatch
fun throwingCallback() {
throw IllegalStateException("Kotlin Exception!")
}
fun main() {
runAndCatch(staticCFunction(::throwingCallback))
}