JVM_IR indy-SAM conversions: add more tests

KT-44278 KT-26060 KT-42621
This commit is contained in:
Dmitry Petrov
2021-01-26 17:28:40 +03:00
parent 98b0c07b18
commit ad1d80d700
10 changed files with 151 additions and 0 deletions
@@ -18481,6 +18481,18 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/invokedynamic/sam/simpleIndySam.kt");
}
@Test
@TestMetadata("streamApi1.kt")
public void testStreamApi1() throws Exception {
runTest("compiler/testData/codegen/box/invokedynamic/sam/streamApi1.kt");
}
@Test
@TestMetadata("streamApi2.kt")
public void testStreamApi2() throws Exception {
runTest("compiler/testData/codegen/box/invokedynamic/sam/streamApi2.kt");
}
@Test
@TestMetadata("suspendFunInterface.kt")
public void testSuspendFunInterface() throws Exception {
@@ -3923,6 +3923,22 @@ public class FirBytecodeTextTestGenerated extends AbstractFirBytecodeTextTest {
}
}
@Nested
@TestMetadata("compiler/testData/codegen/bytecodeText/invokedynamic")
@TestDataPath("$PROJECT_ROOT")
public class Invokedynamic extends AbstractFirBytecodeTextTest {
@Test
public void testAllFilesPresentInInvokedynamic() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeText/invokedynamic"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("streamApi.kt")
public void testStreamApi() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/invokedynamic/streamApi.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/bytecodeText/jvm8")
@TestDataPath("$PROJECT_ROOT")
@@ -0,0 +1,13 @@
// TARGET_BACKEND: JVM
// JVM_TARGET: 1.8
// SAM_CONVERSIONS: INDY
// WITH_RUNTIME
// FULL_JDK
import java.util.stream.Collectors
fun box(): String {
return listOf("o", "k")
.stream()
.map { it.toUpperCase() }
.collect(Collectors.joining())
}
@@ -0,0 +1,21 @@
// TARGET_BACKEND: JVM
// JVM_TARGET: 1.8
// SAM_CONVERSIONS: INDY
// WITH_RUNTIME
// FULL_JDK
import java.util.stream.*
fun box(): String {
val xs = IntStream.of(1, 1, 4, 5, 1, 4)
.map { a: Int -> a + 1 }
.map { a: Int -> a - 1 }
.filter { a: Int -> a > 3 }
.flatMap { a: Int -> IntStream.of(a, a, a) }
.boxed()
.collect(Collectors.toList())
if (xs != listOf(4, 4, 4, 5, 5, 5, 4, 4, 4))
return "Failed: xs=$xs"
return "OK"
}
@@ -0,0 +1,23 @@
// TARGET_BACKEND: JVM
// JVM_TARGET: 1.8
// SAM_CONVERSIONS: INDY
// WITH_RUNTIME
// FULL_JDK
import java.util.stream.*
fun test() =
IntStream.of(1, 1, 4, 5, 1, 4)
.map { a: Int -> a + 1 }
.map { a: Int -> a - 1 }
.filter { a: Int -> a > 3 }
.flatMap { a: Int -> IntStream.of(a, a, a) }
.boxed()
.collect(Collectors.toList())
// JVM_IR_TEMPLATES
// 4 INVOKEDYNAMIC
// 0 class StreamApiKt\$test\$
// JVM_TEMPLATES
// 0 INVOKEDYNAMIC
// 4 class StreamApiKt\$test\$
@@ -18481,6 +18481,18 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/invokedynamic/sam/simpleIndySam.kt");
}
@Test
@TestMetadata("streamApi1.kt")
public void testStreamApi1() throws Exception {
runTest("compiler/testData/codegen/box/invokedynamic/sam/streamApi1.kt");
}
@Test
@TestMetadata("streamApi2.kt")
public void testStreamApi2() throws Exception {
runTest("compiler/testData/codegen/box/invokedynamic/sam/streamApi2.kt");
}
@Test
@TestMetadata("suspendFunInterface.kt")
public void testSuspendFunInterface() throws Exception {
@@ -3791,6 +3791,22 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
}
}
@Nested
@TestMetadata("compiler/testData/codegen/bytecodeText/invokedynamic")
@TestDataPath("$PROJECT_ROOT")
public class Invokedynamic extends AbstractBytecodeTextTest {
@Test
public void testAllFilesPresentInInvokedynamic() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeText/invokedynamic"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@Test
@TestMetadata("streamApi.kt")
public void testStreamApi() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/invokedynamic/streamApi.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/bytecodeText/jvm8")
@TestDataPath("$PROJECT_ROOT")
@@ -18481,6 +18481,18 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/invokedynamic/sam/simpleIndySam.kt");
}
@Test
@TestMetadata("streamApi1.kt")
public void testStreamApi1() throws Exception {
runTest("compiler/testData/codegen/box/invokedynamic/sam/streamApi1.kt");
}
@Test
@TestMetadata("streamApi2.kt")
public void testStreamApi2() throws Exception {
runTest("compiler/testData/codegen/box/invokedynamic/sam/streamApi2.kt");
}
@Test
@TestMetadata("suspendFunInterface.kt")
public void testSuspendFunInterface() throws Exception {
@@ -3923,6 +3923,22 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
}
}
@Nested
@TestMetadata("compiler/testData/codegen/bytecodeText/invokedynamic")
@TestDataPath("$PROJECT_ROOT")
public class Invokedynamic extends AbstractIrBytecodeTextTest {
@Test
public void testAllFilesPresentInInvokedynamic() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeText/invokedynamic"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("streamApi.kt")
public void testStreamApi() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/invokedynamic/streamApi.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/bytecodeText/jvm8")
@TestDataPath("$PROJECT_ROOT")
@@ -16203,6 +16203,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/invokedynamic/sam/simpleIndySam.kt");
}
@TestMetadata("streamApi1.kt")
public void testStreamApi1() throws Exception {
runTest("compiler/testData/codegen/box/invokedynamic/sam/streamApi1.kt");
}
@TestMetadata("streamApi2.kt")
public void testStreamApi2() throws Exception {
runTest("compiler/testData/codegen/box/invokedynamic/sam/streamApi2.kt");
}
@TestMetadata("suspendFunInterface.kt")
public void testSuspendFunInterface() throws Exception {
runTest("compiler/testData/codegen/box/invokedynamic/sam/suspendFunInterface.kt");