Fix loops over progressions near to MAX_VALUE/MIN_VALUE

#KT-492 Fixed

For Byte, Char and Short ranges, promote the type of the loop parameter to int
to avoid overflows. For Int and Long ranges at the end of the loop over a
progression we now check if the new (incremented) value of the loop parameter
is greater than the old value iff increment > 0
This commit is contained in:
Alexander Udalov
2013-06-18 19:41:38 +04:00
parent 33d6347876
commit ee80e0b8ca
25 changed files with 1148 additions and 36 deletions
@@ -424,6 +424,11 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/ranges/expression/emptyRange.kt");
}
@TestMetadata("inexactDownToMinValue.kt")
public void testInexactDownToMinValue() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactDownToMinValue.kt");
}
@TestMetadata("inexactSteppedDownTo.kt")
public void testInexactSteppedDownTo() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactSteppedDownTo.kt");
@@ -434,6 +439,11 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactSteppedRange.kt");
}
@TestMetadata("inexactToMaxValue.kt")
public void testInexactToMaxValue() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactToMaxValue.kt");
}
@TestMetadata("infiniteSteps.kt")
public void testInfiniteSteps() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/ranges/expression/infiniteSteps.kt");
@@ -469,6 +479,31 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/ranges/expression/oneElementRange.kt");
}
@TestMetadata("progressionDownToMinValue.kt")
public void testProgressionDownToMinValue() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionDownToMinValue.kt");
}
@TestMetadata("progressionMaxValueMinusTwoToMaxValue.kt")
public void testProgressionMaxValueMinusTwoToMaxValue() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionMaxValueMinusTwoToMaxValue.kt");
}
@TestMetadata("progressionMaxValueToMaxValue.kt")
public void testProgressionMaxValueToMaxValue() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionMaxValueToMaxValue.kt");
}
@TestMetadata("progressionMaxValueToMinValue.kt")
public void testProgressionMaxValueToMinValue() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionMaxValueToMinValue.kt");
}
@TestMetadata("progressionMinValueToMinValue.kt")
public void testProgressionMinValueToMinValue() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionMinValueToMinValue.kt");
}
@TestMetadata("reversedBackSequence.kt")
public void testReversedBackSequence() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedBackSequence.kt");
@@ -542,6 +577,11 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/ranges/literal/emptyRange.kt");
}
@TestMetadata("inexactDownToMinValue.kt")
public void testInexactDownToMinValue() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactDownToMinValue.kt");
}
@TestMetadata("inexactSteppedDownTo.kt")
public void testInexactSteppedDownTo() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactSteppedDownTo.kt");
@@ -552,6 +592,11 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactSteppedRange.kt");
}
@TestMetadata("inexactToMaxValue.kt")
public void testInexactToMaxValue() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactToMaxValue.kt");
}
@TestMetadata("infiniteSteps.kt")
public void testInfiniteSteps() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/ranges/literal/infiniteSteps.kt");
@@ -587,6 +632,31 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/ranges/literal/oneElementRange.kt");
}
@TestMetadata("progressionDownToMinValue.kt")
public void testProgressionDownToMinValue() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionDownToMinValue.kt");
}
@TestMetadata("progressionMaxValueMinusTwoToMaxValue.kt")
public void testProgressionMaxValueMinusTwoToMaxValue() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionMaxValueMinusTwoToMaxValue.kt");
}
@TestMetadata("progressionMaxValueToMaxValue.kt")
public void testProgressionMaxValueToMaxValue() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionMaxValueToMaxValue.kt");
}
@TestMetadata("progressionMaxValueToMinValue.kt")
public void testProgressionMaxValueToMinValue() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionMaxValueToMinValue.kt");
}
@TestMetadata("progressionMinValueToMinValue.kt")
public void testProgressionMinValueToMinValue() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionMinValueToMinValue.kt");
}
@TestMetadata("reversedBackSequence.kt")
public void testReversedBackSequence() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedBackSequence.kt");