[Spec tests] Add test for Coercion to Unit error diagnostics absence
This commit is contained in:
+11
@@ -0,0 +1,11 @@
|
|||||||
|
// TESTCASE NUMBER: 1
|
||||||
|
|
||||||
|
val y0 = when (2) {
|
||||||
|
else -> if (true) {""}
|
||||||
|
}
|
||||||
|
|
||||||
|
val w:Any = TODO()
|
||||||
|
|
||||||
|
val y1 = when (2) {
|
||||||
|
else -> if (true) {""} // false ok with coercion to Unit
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE)
|
||||||
|
*
|
||||||
|
* SECTIONS: coercion-to-unit
|
||||||
|
* NUMBER: 1
|
||||||
|
* DESCRIPTION: Coercion to Unit error diagnostics absence
|
||||||
|
* ISSUES: KT-38490
|
||||||
|
*/
|
||||||
|
|
||||||
|
// TESTCASE NUMBER: 1
|
||||||
|
|
||||||
|
val y0 = when (<!UNUSED_EXPRESSION!>2<!>) {
|
||||||
|
else -> <!INVALID_IF_AS_EXPRESSION!>if<!> (true) {""}
|
||||||
|
}
|
||||||
|
|
||||||
|
val w:Any = TODO()
|
||||||
|
|
||||||
|
val y1 = when (2) {
|
||||||
|
else -> if (true) {""} // false ok with coercion to Unit
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public val w: kotlin.Any
|
||||||
|
public val y0: kotlin.Unit
|
||||||
|
public val y1: kotlin.Unit
|
||||||
Generated
+31
@@ -5055,6 +5055,37 @@ public class DiagnosticsTestSpecGenerated extends AbstractDiagnosticsTestSpec {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/tests-spec/testData/diagnostics/notLinked/coercion-to-unit")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class Coercion_to_unit extends AbstractDiagnosticsTestSpec {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInCoercion_to_unit() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/notLinked/coercion-to-unit"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/tests-spec/testData/diagnostics/notLinked/coercion-to-unit/neg")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class Neg extends AbstractDiagnosticsTestSpec {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("1.kt")
|
||||||
|
public void test1() throws Exception {
|
||||||
|
runTest("compiler/tests-spec/testData/diagnostics/notLinked/coercion-to-unit/neg/1.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInNeg() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/notLinked/coercion-to-unit/neg"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/notLinked/contracts")
|
@TestMetadata("compiler/tests-spec/testData/diagnostics/notLinked/contracts")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
Generated
+31
@@ -5055,6 +5055,37 @@ public class FirDiagnosticsTestSpecGenerated extends AbstractFirDiagnosticsTestS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/tests-spec/testData/diagnostics/notLinked/coercion-to-unit")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class Coercion_to_unit extends AbstractFirDiagnosticsTestSpec {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInCoercion_to_unit() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/notLinked/coercion-to-unit"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/tests-spec/testData/diagnostics/notLinked/coercion-to-unit/neg")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class Neg extends AbstractFirDiagnosticsTestSpec {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("1.kt")
|
||||||
|
public void test1() throws Exception {
|
||||||
|
runTest("compiler/tests-spec/testData/diagnostics/notLinked/coercion-to-unit/neg/1.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInNeg() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/notLinked/coercion-to-unit/neg"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/notLinked/contracts")
|
@TestMetadata("compiler/tests-spec/testData/diagnostics/notLinked/contracts")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
Reference in New Issue
Block a user