Add overflow-related tests for 'reversed'

This commit is contained in:
Dmitry Petrov
2017-12-13 15:37:50 +03:00
parent 65b5cdbb8d
commit 1aab4e643c
10 changed files with 233 additions and 0 deletions
@@ -0,0 +1,15 @@
// WITH_RUNTIME
const val M = 0.toChar()
fun box(): String {
var count = 0
for (i in (M downTo M).reversed()) {
++count
if (count > 1) {
throw AssertionError("Loop should be executed once")
}
}
if (count != 1) throw AssertionError("Should be executed once")
return "OK"
}
@@ -0,0 +1,15 @@
// WITH_RUNTIME
const val M = Int.MIN_VALUE
fun box(): String {
var count = 0
for (i in (M downTo M).reversed()) {
++count
if (count > 1) {
throw AssertionError("Loop should be executed once")
}
}
if (count != 1) throw AssertionError("Should be executed once")
return "OK"
}
@@ -0,0 +1,15 @@
// WITH_RUNTIME
const val M = Long.MIN_VALUE
fun box(): String {
var count = 0
for (i in (M downTo M).reversed()) {
++count
if (count > 1) {
throw AssertionError("Loop should be executed once")
}
}
if (count != 1) throw AssertionError("Should be executed once")
return "OK"
}
@@ -0,0 +1,15 @@
// WITH_RUNTIME
const val M = 0xFFFF.toChar()
fun box(): String {
var count = 0
for (i in (M .. M).reversed()) {
++count
if (count > 1) {
throw AssertionError("Loop should be executed once")
}
}
if (count != 1) throw AssertionError("Should be executed once")
return "OK"
}
@@ -0,0 +1,14 @@
// WITH_RUNTIME
const val M = Int.MAX_VALUE
fun box(): String {
var step = 0
for (i in (M .. M).reversed()) {
++step
if (step > 1) throw AssertionError("Should be executed once")
}
if (step != 1) throw AssertionError("Should be executed once")
return "OK"
}
@@ -0,0 +1,15 @@
// WITH_RUNTIME
const val M = Long.MAX_VALUE
fun box(): String {
var count = 0
for (i in (M .. M).reversed()) {
++count
if (count > 1) {
throw AssertionError("Loop should be executed once")
}
}
if (count != 1) throw AssertionError("Should be executed once")
return "OK"
}
@@ -15430,36 +15430,72 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
doTest(fileName);
}
@TestMetadata("forInDownToCharMinValueReversed.kt")
public void testForInDownToCharMinValueReversed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInDownToCharMinValueReversed.kt");
doTest(fileName);
}
@TestMetadata("forInDownToIntMinValue.kt")
public void testForInDownToIntMinValue() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInDownToIntMinValue.kt");
doTest(fileName);
}
@TestMetadata("forInDownToIntMinValueReversed.kt")
public void testForInDownToIntMinValueReversed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInDownToIntMinValueReversed.kt");
doTest(fileName);
}
@TestMetadata("forInDownToLongMinValue.kt")
public void testForInDownToLongMinValue() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInDownToLongMinValue.kt");
doTest(fileName);
}
@TestMetadata("forInDownToLongMinValueReversed.kt")
public void testForInDownToLongMinValueReversed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInDownToLongMinValueReversed.kt");
doTest(fileName);
}
@TestMetadata("forInRangeToCharMaxValue.kt")
public void testForInRangeToCharMaxValue() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInRangeToCharMaxValue.kt");
doTest(fileName);
}
@TestMetadata("forInRangeToCharMaxValueReversed.kt")
public void testForInRangeToCharMaxValueReversed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInRangeToCharMaxValueReversed.kt");
doTest(fileName);
}
@TestMetadata("forInRangeToIntMaxValue.kt")
public void testForInRangeToIntMaxValue() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInRangeToIntMaxValue.kt");
doTest(fileName);
}
@TestMetadata("forInRangeToIntMaxValueReversed.kt")
public void testForInRangeToIntMaxValueReversed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInRangeToIntMaxValueReversed.kt");
doTest(fileName);
}
@TestMetadata("forInRangeToLongMaxValue.kt")
public void testForInRangeToLongMaxValue() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInRangeToLongMaxValue.kt");
doTest(fileName);
}
@TestMetadata("forInRangeToLongMaxValueReversed.kt")
public void testForInRangeToLongMaxValueReversed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInRangeToLongMaxValueReversed.kt");
doTest(fileName);
}
@TestMetadata("forInUntilIntMinValueReversed.kt")
public void testForInUntilIntMinValueReversed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInUntilIntMinValueReversed.kt");
@@ -15430,36 +15430,72 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest(fileName);
}
@TestMetadata("forInDownToCharMinValueReversed.kt")
public void testForInDownToCharMinValueReversed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInDownToCharMinValueReversed.kt");
doTest(fileName);
}
@TestMetadata("forInDownToIntMinValue.kt")
public void testForInDownToIntMinValue() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInDownToIntMinValue.kt");
doTest(fileName);
}
@TestMetadata("forInDownToIntMinValueReversed.kt")
public void testForInDownToIntMinValueReversed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInDownToIntMinValueReversed.kt");
doTest(fileName);
}
@TestMetadata("forInDownToLongMinValue.kt")
public void testForInDownToLongMinValue() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInDownToLongMinValue.kt");
doTest(fileName);
}
@TestMetadata("forInDownToLongMinValueReversed.kt")
public void testForInDownToLongMinValueReversed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInDownToLongMinValueReversed.kt");
doTest(fileName);
}
@TestMetadata("forInRangeToCharMaxValue.kt")
public void testForInRangeToCharMaxValue() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInRangeToCharMaxValue.kt");
doTest(fileName);
}
@TestMetadata("forInRangeToCharMaxValueReversed.kt")
public void testForInRangeToCharMaxValueReversed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInRangeToCharMaxValueReversed.kt");
doTest(fileName);
}
@TestMetadata("forInRangeToIntMaxValue.kt")
public void testForInRangeToIntMaxValue() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInRangeToIntMaxValue.kt");
doTest(fileName);
}
@TestMetadata("forInRangeToIntMaxValueReversed.kt")
public void testForInRangeToIntMaxValueReversed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInRangeToIntMaxValueReversed.kt");
doTest(fileName);
}
@TestMetadata("forInRangeToLongMaxValue.kt")
public void testForInRangeToLongMaxValue() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInRangeToLongMaxValue.kt");
doTest(fileName);
}
@TestMetadata("forInRangeToLongMaxValueReversed.kt")
public void testForInRangeToLongMaxValueReversed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInRangeToLongMaxValueReversed.kt");
doTest(fileName);
}
@TestMetadata("forInUntilIntMinValueReversed.kt")
public void testForInUntilIntMinValueReversed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInUntilIntMinValueReversed.kt");
@@ -15430,36 +15430,72 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
doTest(fileName);
}
@TestMetadata("forInDownToCharMinValueReversed.kt")
public void testForInDownToCharMinValueReversed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInDownToCharMinValueReversed.kt");
doTest(fileName);
}
@TestMetadata("forInDownToIntMinValue.kt")
public void testForInDownToIntMinValue() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInDownToIntMinValue.kt");
doTest(fileName);
}
@TestMetadata("forInDownToIntMinValueReversed.kt")
public void testForInDownToIntMinValueReversed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInDownToIntMinValueReversed.kt");
doTest(fileName);
}
@TestMetadata("forInDownToLongMinValue.kt")
public void testForInDownToLongMinValue() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInDownToLongMinValue.kt");
doTest(fileName);
}
@TestMetadata("forInDownToLongMinValueReversed.kt")
public void testForInDownToLongMinValueReversed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInDownToLongMinValueReversed.kt");
doTest(fileName);
}
@TestMetadata("forInRangeToCharMaxValue.kt")
public void testForInRangeToCharMaxValue() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInRangeToCharMaxValue.kt");
doTest(fileName);
}
@TestMetadata("forInRangeToCharMaxValueReversed.kt")
public void testForInRangeToCharMaxValueReversed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInRangeToCharMaxValueReversed.kt");
doTest(fileName);
}
@TestMetadata("forInRangeToIntMaxValue.kt")
public void testForInRangeToIntMaxValue() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInRangeToIntMaxValue.kt");
doTest(fileName);
}
@TestMetadata("forInRangeToIntMaxValueReversed.kt")
public void testForInRangeToIntMaxValueReversed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInRangeToIntMaxValueReversed.kt");
doTest(fileName);
}
@TestMetadata("forInRangeToLongMaxValue.kt")
public void testForInRangeToLongMaxValue() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInRangeToLongMaxValue.kt");
doTest(fileName);
}
@TestMetadata("forInRangeToLongMaxValueReversed.kt")
public void testForInRangeToLongMaxValueReversed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInRangeToLongMaxValueReversed.kt");
doTest(fileName);
}
@TestMetadata("forInUntilIntMinValueReversed.kt")
public void testForInUntilIntMinValueReversed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInUntilIntMinValueReversed.kt");
@@ -16846,36 +16846,72 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
doTest(fileName);
}
@TestMetadata("forInDownToCharMinValueReversed.kt")
public void testForInDownToCharMinValueReversed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInDownToCharMinValueReversed.kt");
doTest(fileName);
}
@TestMetadata("forInDownToIntMinValue.kt")
public void testForInDownToIntMinValue() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInDownToIntMinValue.kt");
doTest(fileName);
}
@TestMetadata("forInDownToIntMinValueReversed.kt")
public void testForInDownToIntMinValueReversed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInDownToIntMinValueReversed.kt");
doTest(fileName);
}
@TestMetadata("forInDownToLongMinValue.kt")
public void testForInDownToLongMinValue() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInDownToLongMinValue.kt");
doTest(fileName);
}
@TestMetadata("forInDownToLongMinValueReversed.kt")
public void testForInDownToLongMinValueReversed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInDownToLongMinValueReversed.kt");
doTest(fileName);
}
@TestMetadata("forInRangeToCharMaxValue.kt")
public void testForInRangeToCharMaxValue() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInRangeToCharMaxValue.kt");
doTest(fileName);
}
@TestMetadata("forInRangeToCharMaxValueReversed.kt")
public void testForInRangeToCharMaxValueReversed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInRangeToCharMaxValueReversed.kt");
doTest(fileName);
}
@TestMetadata("forInRangeToIntMaxValue.kt")
public void testForInRangeToIntMaxValue() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInRangeToIntMaxValue.kt");
doTest(fileName);
}
@TestMetadata("forInRangeToIntMaxValueReversed.kt")
public void testForInRangeToIntMaxValueReversed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInRangeToIntMaxValueReversed.kt");
doTest(fileName);
}
@TestMetadata("forInRangeToLongMaxValue.kt")
public void testForInRangeToLongMaxValue() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInRangeToLongMaxValue.kt");
doTest(fileName);
}
@TestMetadata("forInRangeToLongMaxValueReversed.kt")
public void testForInRangeToLongMaxValueReversed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInRangeToLongMaxValueReversed.kt");
doTest(fileName);
}
@TestMetadata("forInUntilIntMinValueReversed.kt")
public void testForInUntilIntMinValueReversed() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forWithPossibleOverflow/forInUntilIntMinValueReversed.kt");