Add range iteration tests for rangeUntil
#KT-52932
This commit is contained in:
+7
@@ -167,7 +167,11 @@ public class GenerateRangesCodegenTestData {
|
||||
if (ignoreJs) {
|
||||
out.println("// IGNORE_BACKEND: JS");
|
||||
}
|
||||
boolean hasRangeUntil = generatedBody.contains("..<");
|
||||
out.println("// Auto-generated by " + GenerateRangesCodegenTestData.class.getName() + ". DO NOT EDIT!");
|
||||
if (hasRangeUntil) {
|
||||
out.println("// !LANGUAGE: +RangeUntilOperator"); // until rangeUntil is stable
|
||||
}
|
||||
out.println("// WITH_STDLIB");
|
||||
if (useOldManglingScheme) {
|
||||
out.println("// KOTLIN_CONFIGURATION_FLAGS: +JVM.USE_OLD_INLINE_CLASSES_MANGLING_SCHEME");
|
||||
@@ -184,6 +188,9 @@ public class GenerateRangesCodegenTestData {
|
||||
});
|
||||
|
||||
out.println();
|
||||
if (hasRangeUntil) {
|
||||
out.println("@OptIn(ExperimentalStdlibApi::class)"); // until open-ended ranges are stable
|
||||
}
|
||||
out.println("fun box(): String {");
|
||||
out.print(generatedBody);
|
||||
out.println(" return \"OK\"");
|
||||
|
||||
+8
-1
@@ -48,6 +48,7 @@ object GenerateSteppedRangesCodegenTestData {
|
||||
|
||||
private enum class Function(val infixFunctionName: String, val subdir: String) {
|
||||
RANGE_TO("..", "rangeTo"),
|
||||
RANGE_UNTIL("..<", "rangeUntil"),
|
||||
UNTIL(" until ", "until"),
|
||||
DOWN_TO(" downTo ", "downTo")
|
||||
}
|
||||
@@ -138,7 +139,9 @@ object GenerateSteppedRangesCodegenTestData {
|
||||
) {
|
||||
generateTestsForFunction(fileName, rangeToBuilder, Function.RANGE_TO, extraCode, subdir)
|
||||
// For convenience, derive test for "until" by incrementing "last"
|
||||
generateTestsForFunction(fileName, rangeToBuilder.copy(last = (rangeToBuilder.last as Int) + 1), Function.UNTIL, extraCode, subdir)
|
||||
val last = rangeToBuilder.last as Int
|
||||
generateTestsForFunction(fileName, rangeToBuilder.copy(last = last + 1), Function.UNTIL, extraCode, subdir)
|
||||
generateTestsForFunction(fileName, rangeToBuilder.copy(last = last + 1), Function.RANGE_UNTIL, extraCode, subdir)
|
||||
}
|
||||
|
||||
private fun generateTestsForFunction(
|
||||
@@ -181,6 +184,10 @@ object GenerateSteppedRangesCodegenTestData {
|
||||
if (asLiteral && KT_34166_AFFECTED_FILENAMES.contains(fileName)) {
|
||||
println(KT_34166_HEADER)
|
||||
}
|
||||
if (function == Function.RANGE_UNTIL) { // until 1.8
|
||||
println("// !LANGUAGE: +RangeUntilOperator")
|
||||
println("@file:OptIn(ExperimentalStdlibApi::class)")
|
||||
}
|
||||
println("import kotlin.test.*")
|
||||
println()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user