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
}
}
@@ -7116,6 +7116,18 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines");
}
@TestMetadata("inlineWithJava.kt")
public void testInlineWithJava_1_2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multiModule/inlineWithJava.kt");
doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental");
}
@TestMetadata("inlineWithJava.kt")
public void testInlineWithJava_1_3() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multiModule/inlineWithJava.kt");
doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines");
}
@TestMetadata("simple.kt")
public void testSimple_1_2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multiModule/simple.kt");
@@ -7116,6 +7116,18 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines");
}
@TestMetadata("inlineWithJava.kt")
public void testInlineWithJava_1_2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multiModule/inlineWithJava.kt");
doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental");
}
@TestMetadata("inlineWithJava.kt")
public void testInlineWithJava_1_3() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multiModule/inlineWithJava.kt");
doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines");
}
@TestMetadata("simple.kt")
public void testSimple_1_2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multiModule/simple.kt");
@@ -7116,6 +7116,18 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines");
}
@TestMetadata("inlineWithJava.kt")
public void testInlineWithJava_1_2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multiModule/inlineWithJava.kt");
doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental");
}
@TestMetadata("inlineWithJava.kt")
public void testInlineWithJava_1_3() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multiModule/inlineWithJava.kt");
doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines");
}
@TestMetadata("simple.kt")
public void testSimple_1_2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multiModule/simple.kt");
@@ -5968,6 +5968,18 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental");
}
@TestMetadata("inlineWithJava.kt")
public void testInlineWithJava_1_2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multiModule/inlineWithJava.kt");
try {
doTestWithCoroutinesPackageReplacement(fileName, "kotlin.coroutines.experimental");
}
catch (Throwable ignore) {
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
}
@TestMetadata("simple.kt")
public void testSimple_1_2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multiModule/simple.kt");