JVM IR: Support parameterless main methods
This commit: - introduces tests explicating what is and isn't considered a proper main method on the JVM backends. - implements support for parameterless main methods on the JVM IR backend - See KT-34338 for more tests.
This commit is contained in:
committed by
Alexander Udalov
parent
4b77db8979
commit
28b6913a25
@@ -3438,6 +3438,39 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/bytecodeText/parameterlessMain")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class ParameterlessMain extends AbstractBytecodeTextTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInParameterlessMain() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/bytecodeText/parameterlessMain"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("dontGenerateOnJvmNameMain.kt")
|
||||
public void testDontGenerateOnJvmNameMain() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/parameterlessMain/dontGenerateOnJvmNameMain.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("dontGenerateOnMain.kt")
|
||||
public void testDontGenerateOnMain() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/parameterlessMain/dontGenerateOnMain.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("dontGenerateOnMainExtension.kt")
|
||||
public void testDontGenerateOnMainExtension() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/parameterlessMain/dontGenerateOnMainExtension.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("dontGenerateOnNullableArray.kt")
|
||||
public void testDontGenerateOnNullableArray() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/parameterlessMain/dontGenerateOnNullableArray.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/bytecodeText/properties")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
+33
@@ -3408,6 +3408,39 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/bytecodeText/parameterlessMain")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class ParameterlessMain extends AbstractIrBytecodeTextTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInParameterlessMain() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/bytecodeText/parameterlessMain"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("dontGenerateOnJvmNameMain.kt")
|
||||
public void testDontGenerateOnJvmNameMain() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/parameterlessMain/dontGenerateOnJvmNameMain.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("dontGenerateOnMain.kt")
|
||||
public void testDontGenerateOnMain() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/parameterlessMain/dontGenerateOnMain.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("dontGenerateOnMainExtension.kt")
|
||||
public void testDontGenerateOnMainExtension() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/parameterlessMain/dontGenerateOnMainExtension.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("dontGenerateOnNullableArray.kt")
|
||||
public void testDontGenerateOnNullableArray() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/parameterlessMain/dontGenerateOnNullableArray.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/bytecodeText/properties")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
+38
@@ -613,4 +613,42 @@ public class IrWriteSignatureTestGenerated extends AbstractIrWriteSignatureTest
|
||||
runTest("compiler/testData/writeSignature/nothing/nullableNothing.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/writeSignature/parameterlessMain")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class ParameterlessMain extends AbstractIrWriteSignatureTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInParameterlessMain() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/writeSignature/parameterlessMain"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("arrayWithContravariantStringIsNotMainMethod.kt")
|
||||
public void testArrayWithContravariantStringIsNotMainMethod() throws Exception {
|
||||
runTest("compiler/testData/writeSignature/parameterlessMain/arrayWithContravariantStringIsNotMainMethod.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("impostorMains.kt")
|
||||
public void testImpostorMains() throws Exception {
|
||||
runTest("compiler/testData/writeSignature/parameterlessMain/impostorMains.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("main.kt")
|
||||
public void testMain() throws Exception {
|
||||
runTest("compiler/testData/writeSignature/parameterlessMain/main.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notJvmMainName.kt")
|
||||
public void testNotJvmMainName() throws Exception {
|
||||
runTest("compiler/testData/writeSignature/parameterlessMain/notJvmMainName.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("compiler/testData/writeSignature/parameterlessMain/simple.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+38
@@ -613,4 +613,42 @@ public class WriteSignatureTestGenerated extends AbstractWriteSignatureTest {
|
||||
runTest("compiler/testData/writeSignature/nothing/nullableNothing.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/writeSignature/parameterlessMain")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class ParameterlessMain extends AbstractWriteSignatureTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInParameterlessMain() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/writeSignature/parameterlessMain"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("arrayWithContravariantStringIsNotMainMethod.kt")
|
||||
public void testArrayWithContravariantStringIsNotMainMethod() throws Exception {
|
||||
runTest("compiler/testData/writeSignature/parameterlessMain/arrayWithContravariantStringIsNotMainMethod.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("impostorMains.kt")
|
||||
public void testImpostorMains() throws Exception {
|
||||
runTest("compiler/testData/writeSignature/parameterlessMain/impostorMains.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("main.kt")
|
||||
public void testMain() throws Exception {
|
||||
runTest("compiler/testData/writeSignature/parameterlessMain/main.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notJvmMainName.kt")
|
||||
public void testNotJvmMainName() throws Exception {
|
||||
runTest("compiler/testData/writeSignature/parameterlessMain/notJvmMainName.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("compiler/testData/writeSignature/parameterlessMain/simple.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user