Add test with java reflection

This commit is contained in:
Ilmir Usmanov
2018-05-14 17:17:06 +03:00
parent de7aa23119
commit 6b777356e8
5 changed files with 90 additions and 0 deletions
@@ -0,0 +1,42 @@
// IGNORE_BACKEND: NATIVE, JS
// WITH_COROUTINES
// COMMON_COROUTINES_TEST
// MODULE: lib
// FILE: lib.kt
interface I {}
suspend inline fun foo() = object : I {}
// MODULE: useLib(lib)
// FILE: UseLib.java
import COROUTINES_PACKAGE.*;
import kotlin.Unit;
public class UseLib {
public static String useFoo() {
Object i = LibKt.foo(new MyContinuation());
return i.getClass().getName() + " " + i.getClass().getEnclosingClass().getName() + " " + i.getClass().getEnclosingClass().getEnclosingClass();
}
}
class MyContinuation implements Continuation<I> {
public CoroutineContext getContext() {
return EmptyCoroutineContext.INSTANCE;
}
public void resume(I value) {}
public void resumeWithException(Throwable e) {
throw new RuntimeException(e);
}
}
// MODULE: main(useLib)
// FILE: main.kt
fun box(): String {
val res = UseLib.useFoo()
if (res == "LibKt\$foo\$2 LibKt null") {
return "OK"
} else {
return res
}
}