Invoke GenerateInRangeExpressionTestData and

GeneratePrimitiveVsObjectEqualityTestData during
:compiler:generateTests.
This commit is contained in:
Mark Punzalan
2019-10-04 14:56:40 -07:00
committed by max-kammerer
parent 3c775c598c
commit 1738c2d4f6
11 changed files with 288 additions and 141 deletions
@@ -1,3 +1,4 @@
// KJS_WITH_FULL_RUNTIME
// Auto-generated by GenerateInRangeExpressionTestData. Do not edit! // Auto-generated by GenerateInRangeExpressionTestData. Do not edit!
// WITH_RUNTIME // WITH_RUNTIME
@@ -1,3 +1,4 @@
// KJS_WITH_FULL_RUNTIME
// Auto-generated by GenerateInRangeExpressionTestData. Do not edit! // Auto-generated by GenerateInRangeExpressionTestData. Do not edit!
// WITH_RUNTIME // WITH_RUNTIME
@@ -1,3 +1,4 @@
// KJS_WITH_FULL_RUNTIME
// Auto-generated by GenerateInRangeExpressionTestData. Do not edit! // Auto-generated by GenerateInRangeExpressionTestData. Do not edit!
// WITH_RUNTIME // WITH_RUNTIME
@@ -1,3 +1,4 @@
// KJS_WITH_FULL_RUNTIME
// Auto-generated by GenerateInRangeExpressionTestData. Do not edit! // Auto-generated by GenerateInRangeExpressionTestData. Do not edit!
// WITH_RUNTIME // WITH_RUNTIME
@@ -1,3 +1,4 @@
// KJS_WITH_FULL_RUNTIME
// Auto-generated by GenerateInRangeExpressionTestData. Do not edit! // Auto-generated by GenerateInRangeExpressionTestData. Do not edit!
// WITH_RUNTIME // WITH_RUNTIME
@@ -1,3 +1,4 @@
// KJS_WITH_FULL_RUNTIME
// Auto-generated by GenerateInRangeExpressionTestData. Do not edit! // Auto-generated by GenerateInRangeExpressionTestData. Do not edit!
// WITH_RUNTIME // WITH_RUNTIME
@@ -1,3 +1,4 @@
// KJS_WITH_FULL_RUNTIME
// Auto-generated by GenerateInRangeExpressionTestData. Do not edit! // Auto-generated by GenerateInRangeExpressionTestData. Do not edit!
// WITH_RUNTIME // WITH_RUNTIME
@@ -1,3 +1,4 @@
// KJS_WITH_FULL_RUNTIME
// Auto-generated by GenerateInRangeExpressionTestData. Do not edit! // Auto-generated by GenerateInRangeExpressionTestData. Do not edit!
// WITH_RUNTIME // WITH_RUNTIME
@@ -53,8 +53,8 @@ import org.jetbrains.kotlin.resolve.constraintSystem.AbstractConstraintSystemTes
import org.jetbrains.kotlin.serialization.AbstractLocalClassProtoTest import org.jetbrains.kotlin.serialization.AbstractLocalClassProtoTest
import org.jetbrains.kotlin.test.TargetBackend import org.jetbrains.kotlin.test.TargetBackend
import org.jetbrains.kotlin.types.AbstractTypeBindingTest 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.fir.AbstractFirVisualizer
import org.jetbrains.kotlin.visualizer.psi.AbstractPsiVisualizer
fun main(args: Array<String>) { fun main(args: Array<String>) {
System.setProperty("java.awt.headless", "true") System.setProperty("java.awt.headless", "true")
@@ -152,6 +152,8 @@ fun main(args: Array<String>) {
} }
GenerateRangesCodegenTestData.main(emptyArray<String>()) GenerateRangesCodegenTestData.main(emptyArray<String>())
GenerateInRangeExpressionTestData.main(emptyArray<String>())
GeneratePrimitiveVsObjectEqualityTestData.main(emptyArray<String>())
testClass<AbstractBlackBoxCodegenTest> { testClass<AbstractBlackBoxCodegenTest> {
model("codegen/box", targetBackend = TargetBackend.JVM) model("codegen/box", targetBackend = TargetBackend.JVM)
@@ -238,7 +240,12 @@ fun main(args: Array<String>) {
model("loadJava/compiledKotlin", testMethod = "doTestCompiledKotlin") model("loadJava/compiledKotlin", testMethod = "doTestCompiledKotlin")
model("loadJava/compiledKotlinWithStdlib", testMethod = "doTestCompiledKotlinWithStdlib") model("loadJava/compiledKotlinWithStdlib", testMethod = "doTestCompiledKotlinWithStdlib")
model("loadJava/javaAgainstKotlin", extension = "txt", testMethod = "doTestJavaAgainstKotlin") 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") model("loadJava/sourceJava", extension = "java", testMethod = "doTestSourceJava")
} }
@@ -249,7 +256,12 @@ fun main(args: Array<String>) {
model("loadJava/compiledKotlin", testMethod = "doTestCompiledKotlin") model("loadJava/compiledKotlin", testMethod = "doTestCompiledKotlin")
model("loadJava/compiledKotlinWithStdlib", testMethod = "doTestCompiledKotlinWithStdlib") model("loadJava/compiledKotlinWithStdlib", testMethod = "doTestCompiledKotlinWithStdlib")
model("loadJava/javaAgainstKotlin", extension = "txt", testMethod = "doTestJavaAgainstKotlin") 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") model("loadJava/sourceJava", extension = "java", testMethod = "doTestSourceJava")
} }
@@ -262,8 +274,18 @@ fun main(args: Array<String>) {
} }
testClass<AbstractCompileJavaAgainstKotlinTest> { testClass<AbstractCompileJavaAgainstKotlinTest> {
model("compileJavaAgainstKotlin", testClassName = "WithoutJavac", testMethod = "doTestWithoutJavac", targetBackend = TargetBackend.JVM) model(
model("compileJavaAgainstKotlin", testClassName = "WithJavac", testMethod = "doTestWithJavac", targetBackend = TargetBackend.JVM) "compileJavaAgainstKotlin",
testClassName = "WithoutJavac",
testMethod = "doTestWithoutJavac",
targetBackend = TargetBackend.JVM
)
model(
"compileJavaAgainstKotlin",
testClassName = "WithJavac",
testMethod = "doTestWithJavac",
targetBackend = TargetBackend.JVM
)
} }
testClass<AbstractCompileKotlinAgainstJavaTest> { testClass<AbstractCompileKotlinAgainstJavaTest> {
@@ -376,7 +398,12 @@ fun main(args: Array<String>) {
} }
testClass<AbstractIrCompileJavaAgainstKotlinTest> { 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) //model("compileJavaAgainstKotlin", testClassName = "WithJavac", testMethod = "doTestWithJavac", targetBackend = TargetBackend.JVM_IR)
} }
@@ -1,23 +1,12 @@
/* /*
* Copyright 2010-2017 JetBrains s.r.o. * 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.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
package org.jetbrains.kotlin.generators.tests package org.jetbrains.kotlin.generators.tests
import java.io.File
import com.intellij.openapi.util.io.FileUtil import com.intellij.openapi.util.io.FileUtil
import java.io.File
import java.io.PrintWriter import java.io.PrintWriter
import java.io.StringWriter import java.io.StringWriter
@@ -28,10 +17,10 @@ object GenerateInRangeExpressionTestData {
private val PREAMBLE_MESSAGE = "Auto-generated by ${GenerateInRangeExpressionTestData::class.java.simpleName}. Do not edit!" private val PREAMBLE_MESSAGE = "Auto-generated by ${GenerateInRangeExpressionTestData::class.java.simpleName}. Do not edit!"
private fun generateMatrixTestCase( private fun generateMatrixTestCase(
fileName: String, fileName: String,
rangeExpressions: List<String>, rangeExpressions: List<String>,
elementExpressions: List<String>, elementExpressions: List<String>,
header: String = "" header: String = ""
) { ) {
PrintWriter(File(GENERATED_DIR, fileName)).use { PrintWriter(File(GENERATED_DIR, fileName)).use {
it.generateTestCaseBody(header, rangeExpressions, elementExpressions) it.generateTestCaseBody(header, rangeExpressions, elementExpressions)
@@ -39,6 +28,7 @@ object GenerateInRangeExpressionTestData {
} }
private fun PrintWriter.generateTestCaseBody(header: String, rangeExpressions: List<String>, elementExpressions: List<String>) { private fun PrintWriter.generateTestCaseBody(header: String, rangeExpressions: List<String>, elementExpressions: List<String>) {
println("// KJS_WITH_FULL_RUNTIME")
println("// $PREAMBLE_MESSAGE") println("// $PREAMBLE_MESSAGE")
println("// WITH_RUNTIME") println("// WITH_RUNTIME")
println() println()
@@ -76,11 +66,11 @@ object GenerateInRangeExpressionTestData {
} }
private fun PrintWriter.generateTestCaseFunction( private fun PrintWriter.generateTestCaseFunction(
functionName: String, functionName: String,
rangeValName: String, rangeValName: String,
rangeExpression: String, rangeExpression: String,
elementValName: String, elementValName: String,
elementExpression: String elementExpression: String
) { ) {
println("fun $functionName() {") println("fun $functionName() {")
println(" // with possible local optimizations") println(" // with possible local optimizations")
@@ -98,19 +88,19 @@ object GenerateInRangeExpressionTestData {
} }
private fun generateRangeOperatorTestCase( private fun generateRangeOperatorTestCase(
name: String, name: String,
aExpression: String, aExpression: String,
op: String, op: String,
bExpression: String, bExpression: String,
elementExpressions: List<String> elementExpressions: List<String>
) { ) {
generateMatrixTestCase( generateMatrixTestCase(
name, name,
listOf( listOf(
"$aExpression $op $bExpression", "$aExpression $op $bExpression",
"$bExpression $op $aExpression" "$bExpression $op $aExpression"
), ),
elementExpressions elementExpressions
) )
} }
@@ -124,31 +114,97 @@ object GenerateInRangeExpressionTestData {
val charLiterals = listOf("'0'", "'1'", "'2'", "'3'", "'4'") val charLiterals = listOf("'0'", "'1'", "'2'", "'3'", "'4'")
val numericLiterals = val numericLiterals =
listOf("(-1)", "0", "1", "2", "3", "4").flatMap { listOf("(-1)", "0", "1", "2", "3", "4").flatMap {
listOf("$it.toByte()", "$it.toShort()", it, "$it.toLong()", "$it.toFloat()", "$it.toDouble()") listOf("$it.toByte()", "$it.toShort()", it, "$it.toLong()", "$it.toFloat()", "$it.toDouble()")
} }
generateRangeOperatorTestCase("charRangeLiteral.kt", "'1'", "..", "'3'", charLiterals) generateRangeOperatorTestCase(
generateRangeOperatorTestCase("charUntil.kt", "'1'", "until", "'3'", charLiterals) "charRangeLiteral.kt",
generateRangeOperatorTestCase("charDownTo.kt", "'3'", "downTo", "'1'", charLiterals) "'1'",
"..",
"'3'",
charLiterals
)
generateRangeOperatorTestCase(
"charUntil.kt",
"'1'",
"until",
"'3'",
charLiterals
)
generateRangeOperatorTestCase(
"charDownTo.kt",
"'3'",
"downTo",
"'1'",
charLiterals
)
generateRangeOperatorTestCase("intRangeLiteral.kt", "1", "..", "3", numericLiterals) generateRangeOperatorTestCase(
generateRangeOperatorTestCase("intUntil.kt", "1", "until", "3", numericLiterals) "intRangeLiteral.kt",
generateRangeOperatorTestCase("intDownTo.kt", "3", "downTo", "1", listOf("1")) "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(
generateRangeOperatorTestCase("longUntil.kt", "1L", "until", "3L", numericLiterals) "longRangeLiteral.kt",
generateRangeOperatorTestCase("longDownTo.kt", "3L", "downTo", "1L", listOf("1L")) "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(
"floatRangeLiteral.kt",
"1.0F",
"..",
"3.0F",
numericLiterals
)
generateRangeOperatorTestCase("doubleRangeLiteral.kt", "1.0", "..", "3.0", numericLiterals) generateRangeOperatorTestCase(
"doubleRangeLiteral.kt",
"1.0",
"..",
"3.0",
numericLiterals
)
generateMatrixTestCase( generateMatrixTestCase(
"arrayIndices.kt", "arrayIndices.kt",
listOf("intArray.indices", "objectArray.indices", "emptyIntArray.indices", "emptyObjectArray.indices"), listOf("intArray.indices", "objectArray.indices", "emptyIntArray.indices", "emptyObjectArray.indices"),
numericLiterals, numericLiterals,
"""val intArray = intArrayOf(1, 2, 3) """val intArray = intArrayOf(1, 2, 3)
|val objectArray = arrayOf(1, 2, 3) |val objectArray = arrayOf(1, 2, 3)
|val emptyIntArray = intArrayOf() |val emptyIntArray = intArrayOf()
|val emptyObjectArray = arrayOf<Any>() |val emptyObjectArray = arrayOf<Any>()
@@ -156,19 +212,19 @@ object GenerateInRangeExpressionTestData {
) )
generateMatrixTestCase( generateMatrixTestCase(
"collectionIndices.kt", "collectionIndices.kt",
listOf("collection.indices", "emptyCollection.indices"), listOf("collection.indices", "emptyCollection.indices"),
numericLiterals, numericLiterals,
"""val collection = listOf(1, 2, 3) """val collection = listOf(1, 2, 3)
|val emptyCollection = listOf<Any>() |val emptyCollection = listOf<Any>()
""".trimMargin() """.trimMargin()
) )
generateMatrixTestCase( generateMatrixTestCase(
"charSequenceIndices.kt", "charSequenceIndices.kt",
listOf("charSequence.indices", "emptyCharSequence.indices"), listOf("charSequence.indices", "emptyCharSequence.indices"),
numericLiterals, numericLiterals,
"""val charSequence: CharSequence = "123" """val charSequence: CharSequence = "123"
|val emptyCharSequence: CharSequence = "" |val emptyCharSequence: CharSequence = ""
""".trimMargin() """.trimMargin()
) )
@@ -1,17 +1,6 @@
/* /*
* Copyright 2010-2017 JetBrains s.r.o. * 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.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
package org.jetbrains.kotlin.generators.tests package org.jetbrains.kotlin.generators.tests
@@ -44,16 +33,20 @@ object GeneratePrimitiveVsObjectEqualityTestData {
println(" return when {") println(" return when {")
generateFailureClauses( generateFailureClauses(
*failuresForEqualAndUnequalLeft("nx", x, y), *failuresForEqualAndUnequalLeft("nx", x, y),
*failuresForEqualAndUnequalLeft("nx", "x", "y"), *failuresForEqualAndUnequalLeft("nx", "x", "y"),
*failuresForUnequalLeft("nn", x), *failuresForUnequalLeft("nn", x),
*failuresForUnequalLeft("nn", "x"), *failuresForUnequalLeft("nn", "x"),
*failuresForEqualAndUnequalLeft("ax", x, y), *failuresForEqualAndUnequalLeft("ax", x, y),
*failuresForEqualAndUnequalLeft("ax", "x", "y"), *failuresForEqualAndUnequalLeft("ax", "x", "y"),
*failuresForEqualAndUnequalLeft("ax", "bx", "by"), *failuresForEqualAndUnequalLeft(
*failuresForUnequalLeft("an", x), "ax",
*failuresForUnequalLeft("an", "x"), "bx",
*failuresForUnequalLeft("an", "bx") "by"
),
*failuresForUnequalLeft("an", x),
*failuresForUnequalLeft("an", "x"),
*failuresForUnequalLeft("an", "bx")
) )
println(" else -> \"OK\"") println(" else -> \"OK\"")
@@ -62,18 +55,18 @@ object GeneratePrimitiveVsObjectEqualityTestData {
} }
private fun failuresForEqualAndUnequalLeft(lhs: String, equalRhs: String, unequalRhs: String) = private fun failuresForEqualAndUnequalLeft(lhs: String, equalRhs: String, unequalRhs: String) =
arrayOf( arrayOf(
"$lhs != $equalRhs", "$lhs != $equalRhs",
"$lhs == $unequalRhs", "$lhs == $unequalRhs",
"!($lhs == $equalRhs)", "!($lhs == $equalRhs)",
"!($lhs != $unequalRhs)" "!($lhs != $unequalRhs)"
) )
private fun failuresForUnequalLeft(lhs: String, unequalRhs: String) = private fun failuresForUnequalLeft(lhs: String, unequalRhs: String) =
arrayOf( arrayOf(
"$lhs == $unequalRhs", "$lhs == $unequalRhs",
"!($lhs != $unequalRhs)" "!($lhs != $unequalRhs)"
) )
private fun PrintWriter.generateLocalVals(type: String, x: String, y: String, boxedType: String = "$type?") { private fun PrintWriter.generateLocalVals(type: String, x: String, y: String, boxedType: String = "$type?") {
println(" val ax: $boxedType = $x") println(" val ax: $boxedType = $x")
@@ -114,16 +107,28 @@ object GeneratePrimitiveVsObjectEqualityTestData {
println(" return when {") println(" return when {")
generateFailureClauses( generateFailureClauses(
*failuresForEqualAndUnequalRight(x, y, "nx"), *failuresForEqualAndUnequalRight(x, y, "nx"),
*failuresForEqualAndUnequalRight("x", "y", "nx"), *failuresForEqualAndUnequalRight(
*failuresForUnequalRight(x, "nn"), "x",
*failuresForUnequalRight("x", "nn"), "y",
*failuresForEqualAndUnequalRight(x, y, "ax"), "nx"
*failuresForEqualAndUnequalRight("x", "y", "ax"), ),
*failuresForEqualAndUnequalRight("bx", "by", "ax"), *failuresForUnequalRight(x, "nn"),
*failuresForUnequalRight(x, "an"), *failuresForUnequalRight("x", "nn"),
*failuresForUnequalRight("x", "an"), *failuresForEqualAndUnequalRight(x, y, "ax"),
*failuresForUnequalRight("bx", "an") *failuresForEqualAndUnequalRight(
"x",
"y",
"ax"
),
*failuresForEqualAndUnequalRight(
"bx",
"by",
"ax"
),
*failuresForUnequalRight(x, "an"),
*failuresForUnequalRight("x", "an"),
*failuresForUnequalRight("bx", "an")
) )
println(" else -> \"OK\"") println(" else -> \"OK\"")
@@ -131,9 +136,8 @@ object GeneratePrimitiveVsObjectEqualityTestData {
println("}") println("}")
} }
private fun generatePrimitiveVsObjectTest(type: String, x: String, y: String, header: String = "") { private fun generatePrimitiveVsObjectTest(type: String, x: String, y: String) {
PrintWriter(File(GENERATED_DIR, "primitiveEqObject$type.kt")).use { PrintWriter(File(GENERATED_DIR, "primitiveEqObject$type.kt")).use {
if (header.isNotBlank()) it.println(header)
it.generatePrimitiveVsObjectTestBody(type, x, y) it.generatePrimitiveVsObjectTestBody(type, x, y)
} }
} }
@@ -151,16 +155,28 @@ object GeneratePrimitiveVsObjectEqualityTestData {
println(" return when {") println(" return when {")
generateFailureClauses( generateFailureClauses(
*failuresForEqualAndUnequalRight(x, y, "nx"), *failuresForEqualAndUnequalRight(x, y, "nx"),
*failuresForEqualAndUnequalRight("x", "y", "nx"), *failuresForEqualAndUnequalRight(
*failuresForUnequalRight(x, "nn"), "x",
*failuresForUnequalRight("x", "nn"), "y",
*failuresForEqualAndUnequalRight(x, y, "ax"), "nx"
*failuresForEqualAndUnequalRight("x", "y", "ax"), ),
*failuresForEqualAndUnequalRight("bx", "by", "ax"), *failuresForUnequalRight(x, "nn"),
*failuresForUnequalRight(x, "an"), *failuresForUnequalRight("x", "nn"),
*failuresForUnequalRight("x", "an"), *failuresForEqualAndUnequalRight(x, y, "ax"),
*failuresForUnequalRight("bx", "an") *failuresForEqualAndUnequalRight(
"x",
"y",
"ax"
),
*failuresForEqualAndUnequalRight(
"bx",
"by",
"ax"
),
*failuresForUnequalRight(x, "an"),
*failuresForUnequalRight("x", "an"),
*failuresForUnequalRight("bx", "an")
) )
println(" else -> \"OK\"") println(" else -> \"OK\"")
@@ -169,18 +185,18 @@ object GeneratePrimitiveVsObjectEqualityTestData {
} }
private fun failuresForEqualAndUnequalRight(equalLhs: String, unequalLhs: String, rhs: String) = private fun failuresForEqualAndUnequalRight(equalLhs: String, unequalLhs: String, rhs: String) =
arrayOf( arrayOf(
"$equalLhs != $rhs", "$equalLhs != $rhs",
"$unequalLhs == $rhs", "$unequalLhs == $rhs",
"!($equalLhs == $rhs)", "!($equalLhs == $rhs)",
"!($unequalLhs != $rhs)" "!($unequalLhs != $rhs)"
) )
private fun failuresForUnequalRight(unequalLhs: String, rhs: String) = private fun failuresForUnequalRight(unequalLhs: String, rhs: String) =
arrayOf( arrayOf(
"$unequalLhs == $rhs", "$unequalLhs == $rhs",
"!($unequalLhs != $rhs)" "!($unequalLhs != $rhs)"
) )
@JvmStatic @JvmStatic
@@ -190,24 +206,64 @@ object GeneratePrimitiveVsObjectEqualityTestData {
FileUtil.delete(GENERATED_DIR) FileUtil.delete(GENERATED_DIR)
GENERATED_DIR.mkdirs() GENERATED_DIR.mkdirs()
generateBoxedVsPrimitiveTest("Boolean", "true", "false") generateBoxedVsPrimitiveTest(
"Boolean",
"true",
"false"
)
generateBoxedVsPrimitiveTest("Char", "'0'", "'1'") generateBoxedVsPrimitiveTest("Char", "'0'", "'1'")
generateBoxedVsPrimitiveTest("Byte", "0.toByte()", "1.toByte()") generateBoxedVsPrimitiveTest(
generateBoxedVsPrimitiveTest("Short", "0.toShort()", "1.toShort()") "Byte",
"0.toByte()",
"1.toByte()"
)
generateBoxedVsPrimitiveTest(
"Short",
"0.toShort()",
"1.toShort()"
)
generateBoxedVsPrimitiveTest("Int", "0", "1") generateBoxedVsPrimitiveTest("Int", "0", "1")
generateBoxedVsPrimitiveTest("Long", "0L", "1L") generateBoxedVsPrimitiveTest("Long", "0L", "1L")
generatePrimitiveVsBoxedTest("Boolean", "true", "false") generatePrimitiveVsBoxedTest(
"Boolean",
"true",
"false"
)
generatePrimitiveVsBoxedTest("Char", "'0'", "'1'") generatePrimitiveVsBoxedTest("Char", "'0'", "'1'")
generatePrimitiveVsBoxedTest("Byte", "0.toByte()", "1.toByte()") generatePrimitiveVsBoxedTest(
generatePrimitiveVsBoxedTest("Short", "0.toShort()", "1.toShort()") "Byte",
"0.toByte()",
"1.toByte()"
)
generatePrimitiveVsBoxedTest(
"Short",
"0.toShort()",
"1.toShort()"
)
generatePrimitiveVsBoxedTest("Int", "0", "1") generatePrimitiveVsBoxedTest("Int", "0", "1")
generatePrimitiveVsBoxedTest("Long", "0L", "1L") generatePrimitiveVsBoxedTest("Long", "0L", "1L")
generatePrimitiveVsObjectTest("Boolean", "true", "false") generatePrimitiveVsObjectTest(
generatePrimitiveVsObjectTest("Char", "'0'", "'1'", header = "// IGNORE_BACKEND: JS") // KT-19081 "Boolean",
generatePrimitiveVsObjectTest("Byte", "0.toByte()", "1.toByte()") "true",
generatePrimitiveVsObjectTest("Short", "0.toShort()", "1.toShort()") "false"
)
generatePrimitiveVsObjectTest(
"Char",
"'0'",
"'1'"
) // KT-19081
generatePrimitiveVsObjectTest(
"Byte",
"0.toByte()",
"1.toByte()"
)
generatePrimitiveVsObjectTest(
"Short",
"0.toShort()",
"1.toShort()"
)
generatePrimitiveVsObjectTest("Int", "0", "1") generatePrimitiveVsObjectTest("Int", "0", "1")
generatePrimitiveVsObjectTest("Long", "0L", "1L") generatePrimitiveVsObjectTest("Long", "0L", "1L")
} }