Minor: add tests for KT-45893

This commit is contained in:
Dmitry Petrov
2021-04-05 15:47:35 +03:00
parent e10df86037
commit 120eba8d3d
10 changed files with 144 additions and 0 deletions
@@ -28390,6 +28390,18 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/ranges/forInCustomIterable.kt");
}
@Test
@TestMetadata("forInDoubleRangeWithCustomIterator.kt")
public void testForInDoubleRangeWithCustomIterator() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInDoubleRangeWithCustomIterator.kt");
}
@Test
@TestMetadata("forInFloatRangeWithCustomIterator.kt")
public void testForInFloatRangeWithCustomIterator() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInFloatRangeWithCustomIterator.kt");
}
@Test
@TestMetadata("forInRangeLiteralWithMixedTypeBounds.kt")
public void testForInRangeLiteralWithMixedTypeBounds() throws Exception {
@@ -0,0 +1,29 @@
// IGNORE_BACKEND: JVM
// WITH_RUNTIME
// KJS_WITH_FULL_RUNTIME
operator fun ClosedRange<Double>.iterator() =
object : Iterator<Double> {
private var current = this@iterator.start
private val end = this@iterator.endInclusive
override fun hasNext(): Boolean =
current <= end
override fun next(): Double {
val next = current
current += 0.1
return next
}
}
fun box(): String {
var s = 0.0
for (x in 0.0 .. 1.0) {
s += x
}
if (s != 5.5)
return "Failed: $s"
return "OK"
}
@@ -0,0 +1,29 @@
// IGNORE_BACKEND: JVM
// WITH_RUNTIME
// KJS_WITH_FULL_RUNTIME
operator fun ClosedRange<Float>.iterator() =
object : Iterator<Float> {
private var current = this@iterator.start
private val end = this@iterator.endInclusive
override fun hasNext(): Boolean =
current <= end
override fun next(): Float {
val next = current
current += 0.125f
return next
}
}
fun box(): String {
var s = 0.0
for (x in 0.0f .. 1.0f) {
s += x
}
if (s != 4.5)
return "Failed: $s"
return "OK"
}
@@ -28372,6 +28372,18 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/ranges/forInCustomIterable.kt");
}
@Test
@TestMetadata("forInDoubleRangeWithCustomIterator.kt")
public void testForInDoubleRangeWithCustomIterator() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInDoubleRangeWithCustomIterator.kt");
}
@Test
@TestMetadata("forInFloatRangeWithCustomIterator.kt")
public void testForInFloatRangeWithCustomIterator() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInFloatRangeWithCustomIterator.kt");
}
@Test
@TestMetadata("forInRangeLiteralWithMixedTypeBounds.kt")
public void testForInRangeLiteralWithMixedTypeBounds() throws Exception {
@@ -28390,6 +28390,18 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/ranges/forInCustomIterable.kt");
}
@Test
@TestMetadata("forInDoubleRangeWithCustomIterator.kt")
public void testForInDoubleRangeWithCustomIterator() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInDoubleRangeWithCustomIterator.kt");
}
@Test
@TestMetadata("forInFloatRangeWithCustomIterator.kt")
public void testForInFloatRangeWithCustomIterator() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInFloatRangeWithCustomIterator.kt");
}
@Test
@TestMetadata("forInRangeLiteralWithMixedTypeBounds.kt")
public void testForInRangeLiteralWithMixedTypeBounds() throws Exception {
@@ -24124,6 +24124,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/ranges/forInCustomIterable.kt");
}
@TestMetadata("forInDoubleRangeWithCustomIterator.kt")
public void testForInDoubleRangeWithCustomIterator() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInDoubleRangeWithCustomIterator.kt");
}
@TestMetadata("forInFloatRangeWithCustomIterator.kt")
public void testForInFloatRangeWithCustomIterator() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInFloatRangeWithCustomIterator.kt");
}
@TestMetadata("forInRangeLiteralWithMixedTypeBounds.kt")
public void testForInRangeLiteralWithMixedTypeBounds() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInRangeLiteralWithMixedTypeBounds.kt");
@@ -19213,6 +19213,16 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
runTest("compiler/testData/codegen/box/ranges/forInCustomIterable.kt");
}
@TestMetadata("forInDoubleRangeWithCustomIterator.kt")
public void testForInDoubleRangeWithCustomIterator() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInDoubleRangeWithCustomIterator.kt");
}
@TestMetadata("forInFloatRangeWithCustomIterator.kt")
public void testForInFloatRangeWithCustomIterator() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInFloatRangeWithCustomIterator.kt");
}
@TestMetadata("forInRangeLiteralWithMixedTypeBounds.kt")
public void testForInRangeLiteralWithMixedTypeBounds() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInRangeLiteralWithMixedTypeBounds.kt");
@@ -18634,6 +18634,16 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/ranges/forInCustomIterable.kt");
}
@TestMetadata("forInDoubleRangeWithCustomIterator.kt")
public void testForInDoubleRangeWithCustomIterator() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInDoubleRangeWithCustomIterator.kt");
}
@TestMetadata("forInFloatRangeWithCustomIterator.kt")
public void testForInFloatRangeWithCustomIterator() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInFloatRangeWithCustomIterator.kt");
}
@TestMetadata("forInRangeLiteralWithMixedTypeBounds.kt")
public void testForInRangeLiteralWithMixedTypeBounds() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInRangeLiteralWithMixedTypeBounds.kt");
@@ -18684,6 +18684,16 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/ranges/forInCustomIterable.kt");
}
@TestMetadata("forInDoubleRangeWithCustomIterator.kt")
public void testForInDoubleRangeWithCustomIterator() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInDoubleRangeWithCustomIterator.kt");
}
@TestMetadata("forInFloatRangeWithCustomIterator.kt")
public void testForInFloatRangeWithCustomIterator() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInFloatRangeWithCustomIterator.kt");
}
@TestMetadata("forInRangeLiteralWithMixedTypeBounds.kt")
public void testForInRangeLiteralWithMixedTypeBounds() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInRangeLiteralWithMixedTypeBounds.kt");
@@ -11971,6 +11971,16 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/ranges/forByteProgressionWithIntIncrement.kt");
}
@TestMetadata("forInDoubleRangeWithCustomIterator.kt")
public void testForInDoubleRangeWithCustomIterator() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInDoubleRangeWithCustomIterator.kt");
}
@TestMetadata("forInFloatRangeWithCustomIterator.kt")
public void testForInFloatRangeWithCustomIterator() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInFloatRangeWithCustomIterator.kt");
}
@TestMetadata("forInRangeLiteralWithMixedTypeBounds.kt")
public void testForInRangeLiteralWithMixedTypeBounds() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInRangeLiteralWithMixedTypeBounds.kt");