Minor. Add regression test

#KT-39374 Fixed
This commit is contained in:
Ilmir Usmanov
2020-06-04 19:22:43 +02:00
parent a3c881da59
commit f0006f2405
8 changed files with 107 additions and 0 deletions
@@ -5078,6 +5078,10 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.JVM_IR, testDataFilePath, "// IGNORE_BACKEND_FIR: ");
}
private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception {
KotlinTestUtils.runTestWithCustomIgnoreDirective(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JVM_IR, testDataFilePath, "// IGNORE_BACKEND_FIR: ");
}
public void testAllFilesPresentInContracts() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/contracts"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@@ -5112,6 +5116,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/contracts/functionParameter.kt");
}
@TestMetadata("kt39374.kt")
public void testKt39374_1_3() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/contracts/kt39374.kt", "kotlin.coroutines");
}
@TestMetadata("lambdaParameter.kt")
public void testLambdaParameter() throws Exception {
runTest("compiler/testData/codegen/box/contracts/lambdaParameter.kt");
+34
View File
@@ -0,0 +1,34 @@
// IGNORE_BACKEND: NATIVE
// WITH_RUNTIME
// KJS_WITH_FULL_RUNTIME
// WITH_COROUTINES
// COMMON_COROUTINES_TEST
import kotlin.contracts.*
import COROUTINES_PACKAGE.*
import helpers.*
@ExperimentalContracts
public fun <T> runBlocking(block: suspend () -> T): T {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
var res: T? = null
suspend {
res = block()
}.startCoroutine(EmptyContinuation)
return res!!
}
sealed class S {
class Z : S() {
fun f(): String = "OK"
}
}
val z: S = S.Z()
@ExperimentalContracts
fun box(): String = when (val w = z) {
is S.Z -> runBlocking { w.f() }
}
@@ -5108,6 +5108,10 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
}
private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception {
KotlinTestUtils.runTest(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JVM, testDataFilePath);
}
public void testAllFilesPresentInContracts() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/contracts"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@@ -5142,6 +5146,16 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/contracts/functionParameter.kt");
}
@TestMetadata("kt39374.kt")
public void testKt39374_1_2() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/contracts/kt39374.kt", "kotlin.coroutines.experimental");
}
@TestMetadata("kt39374.kt")
public void testKt39374_1_3() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/contracts/kt39374.kt", "kotlin.coroutines");
}
@TestMetadata("lambdaParameter.kt")
public void testLambdaParameter() throws Exception {
runTest("compiler/testData/codegen/box/contracts/lambdaParameter.kt");
@@ -5108,6 +5108,10 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
}
private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception {
KotlinTestUtils.runTest(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JVM, testDataFilePath);
}
public void testAllFilesPresentInContracts() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/contracts"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@@ -5142,6 +5146,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/contracts/functionParameter.kt");
}
@TestMetadata("kt39374.kt")
public void testKt39374_1_2() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/contracts/kt39374.kt", "kotlin.coroutines.experimental");
}
@TestMetadata("kt39374.kt")
public void testKt39374_1_3() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/contracts/kt39374.kt", "kotlin.coroutines");
}
@TestMetadata("lambdaParameter.kt")
public void testLambdaParameter() throws Exception {
runTest("compiler/testData/codegen/box/contracts/lambdaParameter.kt");
@@ -5078,6 +5078,10 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath);
}
private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception {
KotlinTestUtils.runTest(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JVM_IR, testDataFilePath);
}
public void testAllFilesPresentInContracts() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/contracts"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@@ -5112,6 +5116,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/contracts/functionParameter.kt");
}
@TestMetadata("kt39374.kt")
public void testKt39374_1_3() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/contracts/kt39374.kt", "kotlin.coroutines");
}
@TestMetadata("lambdaParameter.kt")
public void testLambdaParameter() throws Exception {
runTest("compiler/testData/codegen/box/contracts/lambdaParameter.kt");
@@ -4108,6 +4108,10 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath);
}
private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception {
KotlinTestUtils.runTest0(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JS_IR_ES6, testDataFilePath);
}
public void testAllFilesPresentInContracts() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/contracts"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
}
@@ -4142,6 +4146,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
runTest("compiler/testData/codegen/box/contracts/functionParameter.kt");
}
@TestMetadata("kt39374.kt")
public void testKt39374_1_3() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/contracts/kt39374.kt", "kotlin.coroutines");
}
@TestMetadata("lambdaParameter.kt")
public void testLambdaParameter() throws Exception {
runTest("compiler/testData/codegen/box/contracts/lambdaParameter.kt");
@@ -4118,6 +4118,10 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath);
}
private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception {
KotlinTestUtils.runTest0(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JS_IR, testDataFilePath);
}
public void testAllFilesPresentInContracts() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/contracts"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
}
@@ -4152,6 +4156,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/contracts/functionParameter.kt");
}
@TestMetadata("kt39374.kt")
public void testKt39374_1_3() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/contracts/kt39374.kt", "kotlin.coroutines");
}
@TestMetadata("lambdaParameter.kt")
public void testLambdaParameter() throws Exception {
runTest("compiler/testData/codegen/box/contracts/lambdaParameter.kt");
@@ -4118,6 +4118,10 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
}
private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception {
KotlinTestUtils.runTest0(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JS, testDataFilePath);
}
public void testAllFilesPresentInContracts() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/contracts"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
}
@@ -4152,6 +4156,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/contracts/functionParameter.kt");
}
@TestMetadata("kt39374.kt")
public void testKt39374_1_3() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/contracts/kt39374.kt", "kotlin.coroutines");
}
@TestMetadata("lambdaParameter.kt")
public void testLambdaParameter() throws Exception {
runTest("compiler/testData/codegen/box/contracts/lambdaParameter.kt");