Add tests for nullable loop variable in for-loop over unsigned progression.

This commit is contained in:
Mark Punzalan
2020-05-08 23:34:52 -07:00
committed by Alexander Udalov
parent b85da8411d
commit b5b361bb09
9 changed files with 221 additions and 0 deletions
@@ -24419,6 +24419,34 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/ranges/unsigned/literal/simpleSteppedRange.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/ranges/unsigned/nullableLoopParameter")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class NullableLoopParameter extends AbstractFirBlackBoxCodegenTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.JVM_IR, testDataFilePath, "// IGNORE_BACKEND_FIR: ");
}
public void testAllFilesPresentInNullableLoopParameter() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/ranges/unsigned/nullableLoopParameter"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@TestMetadata("progressionExpression.kt")
public void testProgressionExpression() throws Exception {
runTest("compiler/testData/codegen/box/ranges/unsigned/nullableLoopParameter/progressionExpression.kt");
}
@TestMetadata("rangeExpression.kt")
public void testRangeExpression() throws Exception {
runTest("compiler/testData/codegen/box/ranges/unsigned/nullableLoopParameter/rangeExpression.kt");
}
@TestMetadata("rangeLiteral.kt")
public void testRangeLiteral() throws Exception {
runTest("compiler/testData/codegen/box/ranges/unsigned/nullableLoopParameter/rangeLiteral.kt");
}
}
}
}
@@ -0,0 +1,18 @@
// IGNORE_BACKEND: JVM
// See KT-38833: Runtime exception is "java.lang.ClassCastException: java.lang.Integer cannot be cast to kotlin.UInt"
// WITH_RUNTIME
// KJS_WITH_FULL_RUNTIME
fun box(): String {
var result = 0u
val uIntRange: UIntProgression = 1u..3u
for (i: UInt? in uIntRange) {
result = sum(result, i)
}
return if (result == 6u) "OK" else "fail: $result"
}
fun sum(i: UInt, z: UInt?): UInt {
return i + z!!
}
@@ -0,0 +1,18 @@
// IGNORE_BACKEND: JVM
// See KT-38833: Runtime exception is "java.lang.ClassCastException: java.lang.Integer cannot be cast to kotlin.UInt"
// WITH_RUNTIME
// KJS_WITH_FULL_RUNTIME
fun box(): String {
var result = 0u
val uIntRange = 1u..3u
for (i: UInt? in uIntRange) {
result = sum(result, i)
}
return if (result == 6u) "OK" else "fail: $result"
}
fun sum(i: UInt, z: UInt?): UInt {
return i + z!!
}
@@ -0,0 +1,17 @@
// IGNORE_BACKEND: JVM
// See KT-38833: Runtime exception is "java.lang.ClassCastException: java.lang.Integer cannot be cast to kotlin.UInt"
// WITH_RUNTIME
// KJS_WITH_FULL_RUNTIME
fun box(): String {
var result = 0u
for (i: UInt? in 1u..3u) {
result = sum(result, i)
}
return if (result == 6u) "OK" else "fail: $result"
}
fun sum(i: UInt, z: UInt?): UInt {
return i + z!!
}
@@ -26005,6 +26005,34 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/ranges/unsigned/literal/simpleSteppedRange.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/ranges/unsigned/nullableLoopParameter")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class NullableLoopParameter extends AbstractBlackBoxCodegenTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
}
public void testAllFilesPresentInNullableLoopParameter() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/ranges/unsigned/nullableLoopParameter"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@TestMetadata("progressionExpression.kt")
public void testProgressionExpression() throws Exception {
runTest("compiler/testData/codegen/box/ranges/unsigned/nullableLoopParameter/progressionExpression.kt");
}
@TestMetadata("rangeExpression.kt")
public void testRangeExpression() throws Exception {
runTest("compiler/testData/codegen/box/ranges/unsigned/nullableLoopParameter/rangeExpression.kt");
}
@TestMetadata("rangeLiteral.kt")
public void testRangeLiteral() throws Exception {
runTest("compiler/testData/codegen/box/ranges/unsigned/nullableLoopParameter/rangeLiteral.kt");
}
}
}
}
@@ -23639,6 +23639,34 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/ranges/unsigned/literal/simpleSteppedRange.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/ranges/unsigned/nullableLoopParameter")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class NullableLoopParameter extends AbstractLightAnalysisModeTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
}
public void testAllFilesPresentInNullableLoopParameter() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/ranges/unsigned/nullableLoopParameter"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@TestMetadata("progressionExpression.kt")
public void testProgressionExpression() throws Exception {
runTest("compiler/testData/codegen/box/ranges/unsigned/nullableLoopParameter/progressionExpression.kt");
}
@TestMetadata("rangeExpression.kt")
public void testRangeExpression() throws Exception {
runTest("compiler/testData/codegen/box/ranges/unsigned/nullableLoopParameter/rangeExpression.kt");
}
@TestMetadata("rangeLiteral.kt")
public void testRangeLiteral() throws Exception {
runTest("compiler/testData/codegen/box/ranges/unsigned/nullableLoopParameter/rangeLiteral.kt");
}
}
}
}
@@ -24419,6 +24419,34 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/ranges/unsigned/literal/simpleSteppedRange.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/ranges/unsigned/nullableLoopParameter")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class NullableLoopParameter extends AbstractIrBlackBoxCodegenTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath);
}
public void testAllFilesPresentInNullableLoopParameter() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/ranges/unsigned/nullableLoopParameter"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@TestMetadata("progressionExpression.kt")
public void testProgressionExpression() throws Exception {
runTest("compiler/testData/codegen/box/ranges/unsigned/nullableLoopParameter/progressionExpression.kt");
}
@TestMetadata("rangeExpression.kt")
public void testRangeExpression() throws Exception {
runTest("compiler/testData/codegen/box/ranges/unsigned/nullableLoopParameter/rangeExpression.kt");
}
@TestMetadata("rangeLiteral.kt")
public void testRangeLiteral() throws Exception {
runTest("compiler/testData/codegen/box/ranges/unsigned/nullableLoopParameter/rangeLiteral.kt");
}
}
}
}
@@ -20820,6 +20820,34 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/ranges/unsigned/literal/simpleSteppedRange.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/ranges/unsigned/nullableLoopParameter")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class NullableLoopParameter extends AbstractIrJsCodegenBoxTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath);
}
public void testAllFilesPresentInNullableLoopParameter() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/ranges/unsigned/nullableLoopParameter"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
}
@TestMetadata("progressionExpression.kt")
public void testProgressionExpression() throws Exception {
runTest("compiler/testData/codegen/box/ranges/unsigned/nullableLoopParameter/progressionExpression.kt");
}
@TestMetadata("rangeExpression.kt")
public void testRangeExpression() throws Exception {
runTest("compiler/testData/codegen/box/ranges/unsigned/nullableLoopParameter/rangeExpression.kt");
}
@TestMetadata("rangeLiteral.kt")
public void testRangeLiteral() throws Exception {
runTest("compiler/testData/codegen/box/ranges/unsigned/nullableLoopParameter/rangeLiteral.kt");
}
}
}
}
@@ -20835,6 +20835,34 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/ranges/unsigned/literal/simpleSteppedRange.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/ranges/unsigned/nullableLoopParameter")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class NullableLoopParameter extends AbstractJsCodegenBoxTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
}
public void testAllFilesPresentInNullableLoopParameter() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/ranges/unsigned/nullableLoopParameter"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
}
@TestMetadata("progressionExpression.kt")
public void testProgressionExpression() throws Exception {
runTest("compiler/testData/codegen/box/ranges/unsigned/nullableLoopParameter/progressionExpression.kt");
}
@TestMetadata("rangeExpression.kt")
public void testRangeExpression() throws Exception {
runTest("compiler/testData/codegen/box/ranges/unsigned/nullableLoopParameter/rangeExpression.kt");
}
@TestMetadata("rangeLiteral.kt")
public void testRangeLiteral() throws Exception {
runTest("compiler/testData/codegen/box/ranges/unsigned/nullableLoopParameter/rangeLiteral.kt");
}
}
}
}