Invoke GenerateInRangeExpressionTestData and
GeneratePrimitiveVsObjectEqualityTestData during :compiler:generateTests.
This commit is contained in:
committed by
max-kammerer
parent
3c775c598c
commit
1738c2d4f6
@@ -1,3 +1,4 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// Auto-generated by GenerateInRangeExpressionTestData. Do not edit!
|
||||
// WITH_RUNTIME
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// Auto-generated by GenerateInRangeExpressionTestData. Do not edit!
|
||||
// WITH_RUNTIME
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// Auto-generated by GenerateInRangeExpressionTestData. Do not edit!
|
||||
// WITH_RUNTIME
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// Auto-generated by GenerateInRangeExpressionTestData. Do not edit!
|
||||
// WITH_RUNTIME
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// Auto-generated by GenerateInRangeExpressionTestData. Do not edit!
|
||||
// WITH_RUNTIME
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// Auto-generated by GenerateInRangeExpressionTestData. Do not edit!
|
||||
// WITH_RUNTIME
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// Auto-generated by GenerateInRangeExpressionTestData. Do not edit!
|
||||
// WITH_RUNTIME
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// Auto-generated by GenerateInRangeExpressionTestData. Do not edit!
|
||||
// WITH_RUNTIME
|
||||
|
||||
|
||||
@@ -53,8 +53,8 @@ import org.jetbrains.kotlin.resolve.constraintSystem.AbstractConstraintSystemTes
|
||||
import org.jetbrains.kotlin.serialization.AbstractLocalClassProtoTest
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
import org.jetbrains.kotlin.types.AbstractTypeBindingTest
|
||||
import org.jetbrains.kotlin.visualizer.psi.AbstractPsiVisualizer
|
||||
import org.jetbrains.kotlin.visualizer.fir.AbstractFirVisualizer
|
||||
import org.jetbrains.kotlin.visualizer.psi.AbstractPsiVisualizer
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
System.setProperty("java.awt.headless", "true")
|
||||
@@ -152,6 +152,8 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
|
||||
GenerateRangesCodegenTestData.main(emptyArray<String>())
|
||||
GenerateInRangeExpressionTestData.main(emptyArray<String>())
|
||||
GeneratePrimitiveVsObjectEqualityTestData.main(emptyArray<String>())
|
||||
|
||||
testClass<AbstractBlackBoxCodegenTest> {
|
||||
model("codegen/box", targetBackend = TargetBackend.JVM)
|
||||
@@ -238,7 +240,12 @@ fun main(args: Array<String>) {
|
||||
model("loadJava/compiledKotlin", testMethod = "doTestCompiledKotlin")
|
||||
model("loadJava/compiledKotlinWithStdlib", testMethod = "doTestCompiledKotlinWithStdlib")
|
||||
model("loadJava/javaAgainstKotlin", extension = "txt", testMethod = "doTestJavaAgainstKotlin")
|
||||
model("loadJava/kotlinAgainstCompiledJavaWithKotlin", extension = "kt", testMethod = "doTestKotlinAgainstCompiledJavaWithKotlin", recursive = false)
|
||||
model(
|
||||
"loadJava/kotlinAgainstCompiledJavaWithKotlin",
|
||||
extension = "kt",
|
||||
testMethod = "doTestKotlinAgainstCompiledJavaWithKotlin",
|
||||
recursive = false
|
||||
)
|
||||
model("loadJava/sourceJava", extension = "java", testMethod = "doTestSourceJava")
|
||||
}
|
||||
|
||||
@@ -249,7 +256,12 @@ fun main(args: Array<String>) {
|
||||
model("loadJava/compiledKotlin", testMethod = "doTestCompiledKotlin")
|
||||
model("loadJava/compiledKotlinWithStdlib", testMethod = "doTestCompiledKotlinWithStdlib")
|
||||
model("loadJava/javaAgainstKotlin", extension = "txt", testMethod = "doTestJavaAgainstKotlin")
|
||||
model("loadJava/kotlinAgainstCompiledJavaWithKotlin", extension = "kt", testMethod = "doTestKotlinAgainstCompiledJavaWithKotlin", recursive = false)
|
||||
model(
|
||||
"loadJava/kotlinAgainstCompiledJavaWithKotlin",
|
||||
extension = "kt",
|
||||
testMethod = "doTestKotlinAgainstCompiledJavaWithKotlin",
|
||||
recursive = false
|
||||
)
|
||||
model("loadJava/sourceJava", extension = "java", testMethod = "doTestSourceJava")
|
||||
}
|
||||
|
||||
@@ -262,8 +274,18 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
|
||||
testClass<AbstractCompileJavaAgainstKotlinTest> {
|
||||
model("compileJavaAgainstKotlin", testClassName = "WithoutJavac", testMethod = "doTestWithoutJavac", targetBackend = TargetBackend.JVM)
|
||||
model("compileJavaAgainstKotlin", testClassName = "WithJavac", testMethod = "doTestWithJavac", targetBackend = TargetBackend.JVM)
|
||||
model(
|
||||
"compileJavaAgainstKotlin",
|
||||
testClassName = "WithoutJavac",
|
||||
testMethod = "doTestWithoutJavac",
|
||||
targetBackend = TargetBackend.JVM
|
||||
)
|
||||
model(
|
||||
"compileJavaAgainstKotlin",
|
||||
testClassName = "WithJavac",
|
||||
testMethod = "doTestWithJavac",
|
||||
targetBackend = TargetBackend.JVM
|
||||
)
|
||||
}
|
||||
|
||||
testClass<AbstractCompileKotlinAgainstJavaTest> {
|
||||
@@ -376,7 +398,12 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
|
||||
testClass<AbstractIrCompileJavaAgainstKotlinTest> {
|
||||
model("compileJavaAgainstKotlin", testClassName = "WithoutJavac", testMethod = "doTestWithoutJavac", targetBackend = TargetBackend.JVM_IR)
|
||||
model(
|
||||
"compileJavaAgainstKotlin",
|
||||
testClassName = "WithoutJavac",
|
||||
testMethod = "doTestWithoutJavac",
|
||||
targetBackend = TargetBackend.JVM_IR
|
||||
)
|
||||
//model("compileJavaAgainstKotlin", testClassName = "WithJavac", testMethod = "doTestWithJavac", targetBackend = TargetBackend.JVM_IR)
|
||||
}
|
||||
|
||||
|
||||
+232
@@ -0,0 +1,232 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.generators.tests
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import java.io.File
|
||||
import java.io.PrintWriter
|
||||
import java.io.StringWriter
|
||||
|
||||
object GenerateInRangeExpressionTestData {
|
||||
private val TEST_DATA_DIR = File("compiler/testData/codegen/box/ranges/contains")
|
||||
private val GENERATED_DIR = File(TEST_DATA_DIR, "generated")
|
||||
|
||||
private val PREAMBLE_MESSAGE = "Auto-generated by ${GenerateInRangeExpressionTestData::class.java.simpleName}. Do not edit!"
|
||||
|
||||
private fun generateMatrixTestCase(
|
||||
fileName: String,
|
||||
rangeExpressions: List<String>,
|
||||
elementExpressions: List<String>,
|
||||
header: String = ""
|
||||
) {
|
||||
PrintWriter(File(GENERATED_DIR, fileName)).use {
|
||||
it.generateTestCaseBody(header, rangeExpressions, elementExpressions)
|
||||
}
|
||||
}
|
||||
|
||||
private fun PrintWriter.generateTestCaseBody(header: String, rangeExpressions: List<String>, elementExpressions: List<String>) {
|
||||
println("// KJS_WITH_FULL_RUNTIME")
|
||||
println("// $PREAMBLE_MESSAGE")
|
||||
println("// WITH_RUNTIME")
|
||||
println()
|
||||
println(header)
|
||||
println()
|
||||
|
||||
val rangeValNames = generateGlobalValDefinitions(rangeExpressions, "range")
|
||||
|
||||
val elementValNames = generateGlobalValDefinitions(elementExpressions, "element")
|
||||
|
||||
val testFunctions = StringWriter()
|
||||
val testFunctionsWriter = PrintWriter(testFunctions)
|
||||
|
||||
println("fun box(): String {")
|
||||
rangeValNames.zip(rangeExpressions).forEachIndexed { i, (rangeValName, rangeExpression) ->
|
||||
elementValNames.zip(elementExpressions).forEachIndexed { j, (elementValName, elementExpression) ->
|
||||
val functionName = "testR${i}xE${j}"
|
||||
|
||||
println(" $functionName()")
|
||||
|
||||
testFunctionsWriter.generateTestCaseFunction(functionName, rangeValName, rangeExpression, elementValName, elementExpression)
|
||||
}
|
||||
}
|
||||
println(" return \"OK\"")
|
||||
println("}")
|
||||
println()
|
||||
println(testFunctions.toString())
|
||||
}
|
||||
|
||||
private fun PrintWriter.generateGlobalValDefinitions(expressions: List<String>, prefix: String): List<String> {
|
||||
val valNames = expressions.indices.map { "$prefix$it" }
|
||||
valNames.zip(expressions).forEach { (name, expression) -> println("val $name = $expression") }
|
||||
println()
|
||||
return valNames
|
||||
}
|
||||
|
||||
private fun PrintWriter.generateTestCaseFunction(
|
||||
functionName: String,
|
||||
rangeValName: String,
|
||||
rangeExpression: String,
|
||||
elementValName: String,
|
||||
elementExpression: String
|
||||
) {
|
||||
println("fun $functionName() {")
|
||||
println(" // with possible local optimizations")
|
||||
println(" if ($elementExpression in $rangeExpression != $rangeValName.contains($elementExpression)) throw AssertionError()")
|
||||
println(" if ($elementExpression !in $rangeExpression != !$rangeValName.contains($elementExpression)) throw AssertionError()")
|
||||
println(" if (!($elementExpression in $rangeExpression) != !$rangeValName.contains($elementExpression)) throw AssertionError()")
|
||||
println(" if (!($elementExpression !in $rangeExpression) != $rangeValName.contains($elementExpression)) throw AssertionError()")
|
||||
println(" // no local optimizations")
|
||||
println(" if ($elementValName in $rangeExpression != $rangeValName.contains($elementValName)) throw AssertionError()")
|
||||
println(" if ($elementValName !in $rangeExpression != !$rangeValName.contains($elementValName)) throw AssertionError()")
|
||||
println(" if (!($elementValName in $rangeExpression) != !$rangeValName.contains($elementValName)) throw AssertionError()")
|
||||
println(" if (!($elementValName !in $rangeExpression) != $rangeValName.contains($elementValName)) throw AssertionError()")
|
||||
println("}")
|
||||
println()
|
||||
}
|
||||
|
||||
private fun generateRangeOperatorTestCase(
|
||||
name: String,
|
||||
aExpression: String,
|
||||
op: String,
|
||||
bExpression: String,
|
||||
elementExpressions: List<String>
|
||||
) {
|
||||
generateMatrixTestCase(
|
||||
name,
|
||||
listOf(
|
||||
"$aExpression $op $bExpression",
|
||||
"$bExpression $op $aExpression"
|
||||
),
|
||||
elementExpressions
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) {
|
||||
if (!TEST_DATA_DIR.exists()) throw AssertionError("${TEST_DATA_DIR.path} doesn't exist")
|
||||
|
||||
FileUtil.delete(GENERATED_DIR)
|
||||
GENERATED_DIR.mkdirs()
|
||||
|
||||
val charLiterals = listOf("'0'", "'1'", "'2'", "'3'", "'4'")
|
||||
|
||||
val numericLiterals =
|
||||
listOf("(-1)", "0", "1", "2", "3", "4").flatMap {
|
||||
listOf("$it.toByte()", "$it.toShort()", it, "$it.toLong()", "$it.toFloat()", "$it.toDouble()")
|
||||
}
|
||||
|
||||
generateRangeOperatorTestCase(
|
||||
"charRangeLiteral.kt",
|
||||
"'1'",
|
||||
"..",
|
||||
"'3'",
|
||||
charLiterals
|
||||
)
|
||||
generateRangeOperatorTestCase(
|
||||
"charUntil.kt",
|
||||
"'1'",
|
||||
"until",
|
||||
"'3'",
|
||||
charLiterals
|
||||
)
|
||||
generateRangeOperatorTestCase(
|
||||
"charDownTo.kt",
|
||||
"'3'",
|
||||
"downTo",
|
||||
"'1'",
|
||||
charLiterals
|
||||
)
|
||||
|
||||
generateRangeOperatorTestCase(
|
||||
"intRangeLiteral.kt",
|
||||
"1",
|
||||
"..",
|
||||
"3",
|
||||
numericLiterals
|
||||
)
|
||||
generateRangeOperatorTestCase(
|
||||
"intUntil.kt",
|
||||
"1",
|
||||
"until",
|
||||
"3",
|
||||
numericLiterals
|
||||
)
|
||||
generateRangeOperatorTestCase(
|
||||
"intDownTo.kt",
|
||||
"3",
|
||||
"downTo",
|
||||
"1",
|
||||
listOf("1")
|
||||
)
|
||||
|
||||
generateRangeOperatorTestCase(
|
||||
"longRangeLiteral.kt",
|
||||
"1L",
|
||||
"..",
|
||||
"3L",
|
||||
numericLiterals
|
||||
)
|
||||
generateRangeOperatorTestCase(
|
||||
"longUntil.kt",
|
||||
"1L",
|
||||
"until",
|
||||
"3L",
|
||||
numericLiterals
|
||||
)
|
||||
generateRangeOperatorTestCase(
|
||||
"longDownTo.kt",
|
||||
"3L",
|
||||
"downTo",
|
||||
"1L",
|
||||
listOf("1L")
|
||||
)
|
||||
|
||||
generateRangeOperatorTestCase(
|
||||
"floatRangeLiteral.kt",
|
||||
"1.0F",
|
||||
"..",
|
||||
"3.0F",
|
||||
numericLiterals
|
||||
)
|
||||
|
||||
generateRangeOperatorTestCase(
|
||||
"doubleRangeLiteral.kt",
|
||||
"1.0",
|
||||
"..",
|
||||
"3.0",
|
||||
numericLiterals
|
||||
)
|
||||
|
||||
generateMatrixTestCase(
|
||||
"arrayIndices.kt",
|
||||
listOf("intArray.indices", "objectArray.indices", "emptyIntArray.indices", "emptyObjectArray.indices"),
|
||||
numericLiterals,
|
||||
"""val intArray = intArrayOf(1, 2, 3)
|
||||
|val objectArray = arrayOf(1, 2, 3)
|
||||
|val emptyIntArray = intArrayOf()
|
||||
|val emptyObjectArray = arrayOf<Any>()
|
||||
""".trimMargin()
|
||||
)
|
||||
|
||||
generateMatrixTestCase(
|
||||
"collectionIndices.kt",
|
||||
listOf("collection.indices", "emptyCollection.indices"),
|
||||
numericLiterals,
|
||||
"""val collection = listOf(1, 2, 3)
|
||||
|val emptyCollection = listOf<Any>()
|
||||
""".trimMargin()
|
||||
)
|
||||
|
||||
generateMatrixTestCase(
|
||||
"charSequenceIndices.kt",
|
||||
listOf("charSequence.indices", "emptyCharSequence.indices"),
|
||||
numericLiterals,
|
||||
"""val charSequence: CharSequence = "123"
|
||||
|val emptyCharSequence: CharSequence = ""
|
||||
""".trimMargin()
|
||||
)
|
||||
}
|
||||
}
|
||||
+270
@@ -0,0 +1,270 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.generators.tests
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import java.io.File
|
||||
import java.io.PrintWriter
|
||||
|
||||
object GeneratePrimitiveVsObjectEqualityTestData {
|
||||
private val TEST_DATA_DIR = File("compiler/testData/codegen/box/primitiveTypes/equalityWithObject")
|
||||
private val GENERATED_DIR = File(TEST_DATA_DIR, "generated")
|
||||
|
||||
private val PREAMBLE_MESSAGE = "Auto-generated by ${this::class.java.simpleName}. Do not edit!"
|
||||
|
||||
private fun generateBoxedVsPrimitiveTest(type: String, x: String, y: String) {
|
||||
PrintWriter(File(GENERATED_DIR, "boxedEqPrimitive$type.kt")).use {
|
||||
it.generateBoxedVsPrimitiveTestBody(type, x, y)
|
||||
}
|
||||
}
|
||||
|
||||
private fun PrintWriter.generateBoxedVsPrimitiveTestBody(type: String, x: String, y: String) {
|
||||
println("// $PREAMBLE_MESSAGE")
|
||||
println()
|
||||
generateGlobalVals(type, x, y)
|
||||
println()
|
||||
println("fun box(): String {")
|
||||
generateLocalVals(type, x, y)
|
||||
println()
|
||||
|
||||
println(" return when {")
|
||||
|
||||
generateFailureClauses(
|
||||
*failuresForEqualAndUnequalLeft("nx", x, y),
|
||||
*failuresForEqualAndUnequalLeft("nx", "x", "y"),
|
||||
*failuresForUnequalLeft("nn", x),
|
||||
*failuresForUnequalLeft("nn", "x"),
|
||||
*failuresForEqualAndUnequalLeft("ax", x, y),
|
||||
*failuresForEqualAndUnequalLeft("ax", "x", "y"),
|
||||
*failuresForEqualAndUnequalLeft(
|
||||
"ax",
|
||||
"bx",
|
||||
"by"
|
||||
),
|
||||
*failuresForUnequalLeft("an", x),
|
||||
*failuresForUnequalLeft("an", "x"),
|
||||
*failuresForUnequalLeft("an", "bx")
|
||||
)
|
||||
|
||||
println(" else -> \"OK\"")
|
||||
println(" }")
|
||||
println("}")
|
||||
}
|
||||
|
||||
private fun failuresForEqualAndUnequalLeft(lhs: String, equalRhs: String, unequalRhs: String) =
|
||||
arrayOf(
|
||||
"$lhs != $equalRhs",
|
||||
"$lhs == $unequalRhs",
|
||||
"!($lhs == $equalRhs)",
|
||||
"!($lhs != $unequalRhs)"
|
||||
)
|
||||
|
||||
private fun failuresForUnequalLeft(lhs: String, unequalRhs: String) =
|
||||
arrayOf(
|
||||
"$lhs == $unequalRhs",
|
||||
"!($lhs != $unequalRhs)"
|
||||
)
|
||||
|
||||
private fun PrintWriter.generateLocalVals(type: String, x: String, y: String, boxedType: String = "$type?") {
|
||||
println(" val ax: $boxedType = $x")
|
||||
println(" val an: $boxedType = null")
|
||||
println(" val bx: $type = $x")
|
||||
println(" val by: $type = $y")
|
||||
}
|
||||
|
||||
private fun PrintWriter.generateGlobalVals(type: String, x: String, y: String, boxedType: String = "$type?") {
|
||||
println("val nx: $boxedType = $x")
|
||||
println("val nn: $boxedType = null")
|
||||
println("val x: $type = $x")
|
||||
println("val y: $type = $y")
|
||||
}
|
||||
|
||||
private fun PrintWriter.generateFailureClauses(vararg failures: String) {
|
||||
failures.forEachIndexed { i, condition ->
|
||||
println(" $condition -> \"Fail $i\"")
|
||||
}
|
||||
}
|
||||
|
||||
private fun generatePrimitiveVsBoxedTest(type: String, x: String, y: String) {
|
||||
PrintWriter(File(GENERATED_DIR, "primitiveEqBoxed$type.kt")).use {
|
||||
it.generatePrimitiveVsBoxedTestBody(type, x, y)
|
||||
}
|
||||
}
|
||||
|
||||
private fun PrintWriter.generatePrimitiveVsBoxedTestBody(type: String, x: String, y: String) {
|
||||
println("// $PREAMBLE_MESSAGE")
|
||||
println()
|
||||
|
||||
generateGlobalVals(type, x, y)
|
||||
println()
|
||||
println("fun box(): String {")
|
||||
generateLocalVals(type, x, y)
|
||||
println()
|
||||
|
||||
println(" return when {")
|
||||
|
||||
generateFailureClauses(
|
||||
*failuresForEqualAndUnequalRight(x, y, "nx"),
|
||||
*failuresForEqualAndUnequalRight(
|
||||
"x",
|
||||
"y",
|
||||
"nx"
|
||||
),
|
||||
*failuresForUnequalRight(x, "nn"),
|
||||
*failuresForUnequalRight("x", "nn"),
|
||||
*failuresForEqualAndUnequalRight(x, y, "ax"),
|
||||
*failuresForEqualAndUnequalRight(
|
||||
"x",
|
||||
"y",
|
||||
"ax"
|
||||
),
|
||||
*failuresForEqualAndUnequalRight(
|
||||
"bx",
|
||||
"by",
|
||||
"ax"
|
||||
),
|
||||
*failuresForUnequalRight(x, "an"),
|
||||
*failuresForUnequalRight("x", "an"),
|
||||
*failuresForUnequalRight("bx", "an")
|
||||
)
|
||||
|
||||
println(" else -> \"OK\"")
|
||||
println(" }")
|
||||
println("}")
|
||||
}
|
||||
|
||||
private fun generatePrimitiveVsObjectTest(type: String, x: String, y: String) {
|
||||
PrintWriter(File(GENERATED_DIR, "primitiveEqObject$type.kt")).use {
|
||||
it.generatePrimitiveVsObjectTestBody(type, x, y)
|
||||
}
|
||||
}
|
||||
|
||||
private fun PrintWriter.generatePrimitiveVsObjectTestBody(type: String, x: String, y: String) {
|
||||
println("// $PREAMBLE_MESSAGE")
|
||||
println()
|
||||
|
||||
generateGlobalVals(type, x, y, boxedType = "Any?")
|
||||
println()
|
||||
println("fun box(): String {")
|
||||
generateLocalVals(type, x, y, boxedType = "Any?")
|
||||
println()
|
||||
|
||||
println(" return when {")
|
||||
|
||||
generateFailureClauses(
|
||||
*failuresForEqualAndUnequalRight(x, y, "nx"),
|
||||
*failuresForEqualAndUnequalRight(
|
||||
"x",
|
||||
"y",
|
||||
"nx"
|
||||
),
|
||||
*failuresForUnequalRight(x, "nn"),
|
||||
*failuresForUnequalRight("x", "nn"),
|
||||
*failuresForEqualAndUnequalRight(x, y, "ax"),
|
||||
*failuresForEqualAndUnequalRight(
|
||||
"x",
|
||||
"y",
|
||||
"ax"
|
||||
),
|
||||
*failuresForEqualAndUnequalRight(
|
||||
"bx",
|
||||
"by",
|
||||
"ax"
|
||||
),
|
||||
*failuresForUnequalRight(x, "an"),
|
||||
*failuresForUnequalRight("x", "an"),
|
||||
*failuresForUnequalRight("bx", "an")
|
||||
)
|
||||
|
||||
println(" else -> \"OK\"")
|
||||
println(" }")
|
||||
println("}")
|
||||
}
|
||||
|
||||
private fun failuresForEqualAndUnequalRight(equalLhs: String, unequalLhs: String, rhs: String) =
|
||||
arrayOf(
|
||||
"$equalLhs != $rhs",
|
||||
"$unequalLhs == $rhs",
|
||||
"!($equalLhs == $rhs)",
|
||||
"!($unequalLhs != $rhs)"
|
||||
)
|
||||
|
||||
private fun failuresForUnequalRight(unequalLhs: String, rhs: String) =
|
||||
arrayOf(
|
||||
"$unequalLhs == $rhs",
|
||||
"!($unequalLhs != $rhs)"
|
||||
)
|
||||
|
||||
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) {
|
||||
if (!TEST_DATA_DIR.exists()) throw AssertionError("${TEST_DATA_DIR.path} doesn't exist")
|
||||
|
||||
FileUtil.delete(GENERATED_DIR)
|
||||
GENERATED_DIR.mkdirs()
|
||||
|
||||
generateBoxedVsPrimitiveTest(
|
||||
"Boolean",
|
||||
"true",
|
||||
"false"
|
||||
)
|
||||
generateBoxedVsPrimitiveTest("Char", "'0'", "'1'")
|
||||
generateBoxedVsPrimitiveTest(
|
||||
"Byte",
|
||||
"0.toByte()",
|
||||
"1.toByte()"
|
||||
)
|
||||
generateBoxedVsPrimitiveTest(
|
||||
"Short",
|
||||
"0.toShort()",
|
||||
"1.toShort()"
|
||||
)
|
||||
generateBoxedVsPrimitiveTest("Int", "0", "1")
|
||||
generateBoxedVsPrimitiveTest("Long", "0L", "1L")
|
||||
|
||||
generatePrimitiveVsBoxedTest(
|
||||
"Boolean",
|
||||
"true",
|
||||
"false"
|
||||
)
|
||||
generatePrimitiveVsBoxedTest("Char", "'0'", "'1'")
|
||||
generatePrimitiveVsBoxedTest(
|
||||
"Byte",
|
||||
"0.toByte()",
|
||||
"1.toByte()"
|
||||
)
|
||||
generatePrimitiveVsBoxedTest(
|
||||
"Short",
|
||||
"0.toShort()",
|
||||
"1.toShort()"
|
||||
)
|
||||
generatePrimitiveVsBoxedTest("Int", "0", "1")
|
||||
generatePrimitiveVsBoxedTest("Long", "0L", "1L")
|
||||
|
||||
generatePrimitiveVsObjectTest(
|
||||
"Boolean",
|
||||
"true",
|
||||
"false"
|
||||
)
|
||||
generatePrimitiveVsObjectTest(
|
||||
"Char",
|
||||
"'0'",
|
||||
"'1'"
|
||||
) // KT-19081
|
||||
generatePrimitiveVsObjectTest(
|
||||
"Byte",
|
||||
"0.toByte()",
|
||||
"1.toByte()"
|
||||
)
|
||||
generatePrimitiveVsObjectTest(
|
||||
"Short",
|
||||
"0.toShort()",
|
||||
"1.toShort()"
|
||||
)
|
||||
generatePrimitiveVsObjectTest("Int", "0", "1")
|
||||
generatePrimitiveVsObjectTest("Long", "0L", "1L")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user