Do not box primitives for 'primitive == object'
NB user-defined 'equals' can violate contract for 'Object#equals', e.g., it can be asymmetric. Thus we can't avoid boxing for 'object == primitive'.
This commit is contained in:
@@ -148,6 +148,10 @@ public class AsmUtil {
|
||||
return type == Type.INT_TYPE || type == Type.SHORT_TYPE || type == Type.BYTE_TYPE || type == Type.CHAR_TYPE;
|
||||
}
|
||||
|
||||
public static boolean isNonFloatingPointPrimitive(Type type) {
|
||||
return isIntPrimitive(type) || type == Type.LONG_TYPE || type == Type.BOOLEAN_TYPE;
|
||||
}
|
||||
|
||||
public static boolean isIntPrimitiveOrBoolean(Type type) {
|
||||
return isIntPrimitive(type) || type == Type.BOOLEAN_TYPE;
|
||||
}
|
||||
|
||||
+121
-25
@@ -23,19 +23,26 @@ import org.jetbrains.org.objectweb.asm.Opcodes
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
|
||||
abstract class NumberLikeCompare(
|
||||
left: StackValue,
|
||||
right: StackValue,
|
||||
operandType: Type,
|
||||
protected val opToken: IElementType
|
||||
) : BranchedValue(left, right, operandType, NumberCompare.getNumberCompareOpcode(opToken)) {
|
||||
override fun patchOpcode(opcode: Int, v: InstructionAdapter): Int =
|
||||
NumberCompare.patchOpcode(opcode, v, opToken, operandType)
|
||||
}
|
||||
|
||||
abstract class SafeCallFusedWithPrimitiveEqualityBase(
|
||||
private val opToken: IElementType,
|
||||
opToken: IElementType,
|
||||
operandType: Type,
|
||||
left: StackValue,
|
||||
right: StackValue
|
||||
) : BranchedValue(left, right, operandType, NumberCompare.getNumberCompareOpcode(opToken)) {
|
||||
) : NumberLikeCompare(left, right, operandType, opToken) {
|
||||
private val trueIfEqual = opToken == KtTokens.EQEQ || opToken == KtTokens.EQEQEQ
|
||||
|
||||
protected abstract fun cleanupOnNullReceiver(v: InstructionAdapter)
|
||||
|
||||
override fun patchOpcode(opcode: Int, v: InstructionAdapter): Int =
|
||||
NumberCompare.patchOpcode(opcode, v, opToken, operandType)
|
||||
|
||||
override fun condJump(jumpLabel: Label, v: InstructionAdapter, jumpIfFalse: Boolean) {
|
||||
val endLabel = Label()
|
||||
|
||||
@@ -117,13 +124,11 @@ class PrimitiveToSafeCallEquality(
|
||||
class BoxedToPrimitiveEquality private constructor(
|
||||
leftBoxed: StackValue,
|
||||
rightPrimitive: StackValue,
|
||||
primitiveType: Type
|
||||
) : BranchedValue(leftBoxed, rightPrimitive, primitiveType, Opcodes.IFNE) {
|
||||
primitiveType: Type,
|
||||
private val frameMap: FrameMap
|
||||
) : NumberLikeCompare(leftBoxed, rightPrimitive, primitiveType, KtTokens.EQEQ) {
|
||||
private val boxedType = arg1.type
|
||||
|
||||
override fun patchOpcode(opcode: Int, v: InstructionAdapter): Int =
|
||||
NumberCompare.patchOpcode(opcode, v, KtTokens.EQEQ, operandType)
|
||||
|
||||
override fun condJump(jumpLabel: Label, v: InstructionAdapter, jumpIfFalse: Boolean) {
|
||||
if (jumpIfFalse) {
|
||||
jumpIfFalse(v, jumpLabel)
|
||||
@@ -162,18 +167,22 @@ class BoxedToPrimitiveEquality private constructor(
|
||||
|
||||
arg1.put(boxedType, v)
|
||||
arg2!!.put(operandType, v)
|
||||
AsmUtil.swap(v, operandType, boxedType)
|
||||
|
||||
val tempArg2 = frameMap.enterTemp(operandType)
|
||||
|
||||
v.store(tempArg2, operandType)
|
||||
AsmUtil.dup(v, boxedType)
|
||||
v.ifnonnull(notNullLabel)
|
||||
|
||||
AsmUtil.pop(v, boxedType)
|
||||
AsmUtil.pop(v, operandType)
|
||||
v.goTo(endLabel)
|
||||
|
||||
v.mark(notNullLabel)
|
||||
coerce(boxedType, operandType, v)
|
||||
v.load(tempArg2, operandType)
|
||||
v.visitJumpInsn(patchOpcode(negatedOperations[opcode]!!, v), jumpLabel)
|
||||
|
||||
frameMap.leaveTemp(operandType)
|
||||
v.mark(endLabel)
|
||||
|
||||
}
|
||||
@@ -200,36 +209,47 @@ class BoxedToPrimitiveEquality private constructor(
|
||||
|
||||
private fun jumpIfFalseWithPossibleSideEffects(v: InstructionAdapter, jumpLabel: Label) {
|
||||
val notNullLabel = Label()
|
||||
|
||||
arg1.put(boxedType, v)
|
||||
arg2!!.put(operandType, v)
|
||||
AsmUtil.swap(v, operandType, boxedType)
|
||||
val tempArg2 = frameMap.enterTemp(operandType)
|
||||
v.store(tempArg2, operandType)
|
||||
AsmUtil.dup(v, boxedType)
|
||||
v.ifnonnull(notNullLabel)
|
||||
|
||||
AsmUtil.pop(v, boxedType)
|
||||
AsmUtil.pop(v, operandType)
|
||||
v.goTo(jumpLabel)
|
||||
|
||||
v.mark(notNullLabel)
|
||||
coerce(boxedType, operandType, v)
|
||||
v.load(tempArg2, operandType)
|
||||
v.visitJumpInsn(patchOpcode(opcode, v), jumpLabel)
|
||||
|
||||
frameMap.leaveTemp(operandType)
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun create(opToken: IElementType, leftBoxed: StackValue, leftType: Type, rightPrimitive: StackValue, primitiveType: Type): BranchedValue =
|
||||
if (!isApplicable(opToken, leftType, primitiveType))
|
||||
throw IllegalArgumentException("Not applicable for $opToken, $leftType, $primitiveType")
|
||||
fun create(
|
||||
opToken: IElementType,
|
||||
left: StackValue,
|
||||
leftType: Type,
|
||||
right: StackValue,
|
||||
rightType: Type,
|
||||
frameMap: FrameMap
|
||||
): BranchedValue =
|
||||
if (!isApplicable(opToken, leftType, rightType))
|
||||
throw IllegalArgumentException("Not applicable for $opToken, $leftType, $rightType")
|
||||
else when (opToken) {
|
||||
KtTokens.EQEQ -> BoxedToPrimitiveEquality(leftBoxed, rightPrimitive, primitiveType)
|
||||
KtTokens.EXCLEQ -> Invert(BoxedToPrimitiveEquality(leftBoxed, rightPrimitive, primitiveType))
|
||||
KtTokens.EQEQ -> BoxedToPrimitiveEquality(left, right, rightType, frameMap)
|
||||
KtTokens.EXCLEQ -> Invert(BoxedToPrimitiveEquality(left, right, rightType, frameMap))
|
||||
else -> throw AssertionError("Unexpected opToken: $opToken")
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun isApplicable(opToken: IElementType, leftType: Type, rightType: Type) =
|
||||
(opToken == KtTokens.EQEQ || opToken == KtTokens.EXCLEQ) &&
|
||||
AsmUtil.isIntPrimitiveOrBoolean(rightType) &&
|
||||
AsmUtil.isNonFloatingPointPrimitive(rightType) &&
|
||||
AsmUtil.isBoxedTypeOf(leftType, rightType)
|
||||
}
|
||||
}
|
||||
@@ -239,13 +259,10 @@ class PrimitiveToBoxedEquality private constructor(
|
||||
leftPrimitive: StackValue,
|
||||
rightBoxed: StackValue,
|
||||
primitiveType: Type
|
||||
) : BranchedValue(leftPrimitive, rightBoxed, primitiveType, Opcodes.IFNE) {
|
||||
) : NumberLikeCompare(leftPrimitive, rightBoxed, primitiveType, KtTokens.EQEQ) {
|
||||
private val primitiveType = leftPrimitive.type
|
||||
private val boxedType = rightBoxed.type
|
||||
|
||||
override fun patchOpcode(opcode: Int, v: InstructionAdapter): Int =
|
||||
NumberCompare.patchOpcode(opcode, v, KtTokens.EQEQ, operandType)
|
||||
|
||||
override fun condJump(jumpLabel: Label, v: InstructionAdapter, jumpIfFalse: Boolean) {
|
||||
if (jumpIfFalse) {
|
||||
jumpIfFalse(v, jumpLabel)
|
||||
@@ -306,7 +323,86 @@ class PrimitiveToBoxedEquality private constructor(
|
||||
@JvmStatic
|
||||
fun isApplicable(opToken: IElementType, leftType: Type, rightType: Type) =
|
||||
(opToken == KtTokens.EQEQ || opToken == KtTokens.EXCLEQ) &&
|
||||
AsmUtil.isIntPrimitiveOrBoolean(rightType) &&
|
||||
AsmUtil.isNonFloatingPointPrimitive(leftType) &&
|
||||
AsmUtil.isBoxedTypeOf(rightType, leftType)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class PrimitiveToObjectEquality private constructor(
|
||||
leftPrimitive: StackValue,
|
||||
rightObject: StackValue,
|
||||
primitiveType: Type
|
||||
) : NumberLikeCompare(leftPrimitive, rightObject, primitiveType, KtTokens.EQEQ) {
|
||||
private val primitiveType = leftPrimitive.type
|
||||
private val objectType = rightObject.type
|
||||
private val boxedType = AsmUtil.boxType(primitiveType)
|
||||
|
||||
override fun condJump(jumpLabel: Label, v: InstructionAdapter, jumpIfFalse: Boolean) {
|
||||
if (jumpIfFalse) {
|
||||
jumpIfFalse(v, jumpLabel)
|
||||
}
|
||||
else {
|
||||
jumpIfTrue(v, jumpLabel)
|
||||
}
|
||||
}
|
||||
|
||||
private fun jumpIfFalse(v: InstructionAdapter, jumpLabel: Label) {
|
||||
val isBoxedLabel = Label()
|
||||
|
||||
arg1.put(primitiveType, v)
|
||||
arg2!!.put(objectType, v)
|
||||
AsmUtil.dup(v, objectType)
|
||||
v.instanceOf(boxedType)
|
||||
v.ifne(isBoxedLabel)
|
||||
|
||||
AsmUtil.pop(v, objectType)
|
||||
AsmUtil.pop(v, primitiveType)
|
||||
v.goTo(jumpLabel)
|
||||
|
||||
v.mark(isBoxedLabel)
|
||||
coerce(objectType, boxedType, v)
|
||||
coerce(boxedType, primitiveType, v)
|
||||
v.visitJumpInsn(patchOpcode(opcode, v), jumpLabel)
|
||||
}
|
||||
|
||||
private fun jumpIfTrue(v: InstructionAdapter, jumpLabel: Label) {
|
||||
val isBoxedLabel = Label()
|
||||
val endLabel = Label()
|
||||
|
||||
arg1.put(primitiveType, v)
|
||||
arg2!!.put(objectType, v)
|
||||
AsmUtil.dup(v, objectType)
|
||||
v.instanceOf(boxedType)
|
||||
v.ifne(isBoxedLabel)
|
||||
|
||||
AsmUtil.pop(v, objectType)
|
||||
AsmUtil.pop(v, primitiveType)
|
||||
v.goTo(endLabel)
|
||||
|
||||
v.mark(isBoxedLabel)
|
||||
coerce(objectType, boxedType, v)
|
||||
coerce(boxedType, primitiveType, v)
|
||||
v.visitJumpInsn(patchOpcode(negatedOperations[opcode]!!, v), jumpLabel)
|
||||
|
||||
v.mark(endLabel)
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun create(opToken: IElementType, left: StackValue, leftType: Type, right: StackValue, rightType: Type): BranchedValue =
|
||||
if (!isApplicable(opToken, leftType, rightType))
|
||||
throw IllegalArgumentException("Not applicable for $opToken, $leftType, $rightType")
|
||||
else when (opToken) {
|
||||
KtTokens.EQEQ -> PrimitiveToObjectEquality(left, right, leftType)
|
||||
KtTokens.EXCLEQ -> Invert(PrimitiveToObjectEquality(left, right, leftType))
|
||||
else -> throw AssertionError("Unexpected opToken: $opToken")
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun isApplicable(opToken: IElementType, leftType: Type, rightType: Type) =
|
||||
(opToken == KtTokens.EQEQ || opToken == KtTokens.EXCLEQ) &&
|
||||
AsmUtil.isNonFloatingPointPrimitive(leftType) &&
|
||||
rightType.sort == Type.OBJECT
|
||||
}
|
||||
}
|
||||
@@ -2896,11 +2896,16 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
}
|
||||
|
||||
if (BoxedToPrimitiveEquality.isApplicable(opToken, leftType, rightType)) {
|
||||
return BoxedToPrimitiveEquality.create(opToken, genLazy(left, leftType), leftType, genLazy(right, rightType), rightType);
|
||||
return BoxedToPrimitiveEquality.create(opToken, genLazy(left, leftType), leftType, genLazy(right, rightType), rightType,
|
||||
myFrameMap);
|
||||
}
|
||||
|
||||
if (PrimitiveToBoxedEquality.isApplicable(opToken, leftType, rightType)) {
|
||||
return BoxedToPrimitiveEquality.create(opToken, genLazy(left, leftType), leftType, genLazy(right, rightType), rightType);
|
||||
return PrimitiveToBoxedEquality.create(opToken, genLazy(left, leftType), leftType, genLazy(right, rightType), rightType);
|
||||
}
|
||||
|
||||
if (PrimitiveToObjectEquality.isApplicable(opToken, leftType, rightType)) {
|
||||
return PrimitiveToObjectEquality.create(opToken, genLazy(left, leftType), leftType, genLazy(right, rightType), rightType);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
val x: Long = 0L
|
||||
|
||||
fun box(): String {
|
||||
val ax: Long? = 0L
|
||||
return if (ax != x) "Fail" else "OK"
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
// Auto-generated by GeneratePrimitiveVsObjectEqualityTestData. Do not edit!
|
||||
|
||||
val nx: Any? = true
|
||||
val nn: Any? = null
|
||||
val x: Boolean = true
|
||||
val y: Boolean = false
|
||||
|
||||
fun box(): String {
|
||||
val ax: Any? = true
|
||||
val an: Any? = null
|
||||
val bx: Boolean = true
|
||||
val by: Boolean = false
|
||||
|
||||
return when {
|
||||
true != nx -> "Fail 0"
|
||||
false == nx -> "Fail 1"
|
||||
!(true == nx) -> "Fail 2"
|
||||
!(false != nx) -> "Fail 3"
|
||||
x != nx -> "Fail 4"
|
||||
y == nx -> "Fail 5"
|
||||
!(x == nx) -> "Fail 6"
|
||||
!(y != nx) -> "Fail 7"
|
||||
true == nn -> "Fail 8"
|
||||
!(true != nn) -> "Fail 9"
|
||||
x == nn -> "Fail 10"
|
||||
!(x != nn) -> "Fail 11"
|
||||
true != ax -> "Fail 12"
|
||||
false == ax -> "Fail 13"
|
||||
!(true == ax) -> "Fail 14"
|
||||
!(false != ax) -> "Fail 15"
|
||||
x != ax -> "Fail 16"
|
||||
y == ax -> "Fail 17"
|
||||
!(x == ax) -> "Fail 18"
|
||||
!(y != ax) -> "Fail 19"
|
||||
bx != ax -> "Fail 20"
|
||||
by == ax -> "Fail 21"
|
||||
!(bx == ax) -> "Fail 22"
|
||||
!(by != ax) -> "Fail 23"
|
||||
true == an -> "Fail 24"
|
||||
!(true != an) -> "Fail 25"
|
||||
x == an -> "Fail 26"
|
||||
!(x != an) -> "Fail 27"
|
||||
bx == an -> "Fail 28"
|
||||
!(bx != an) -> "Fail 29"
|
||||
else -> "OK"
|
||||
}
|
||||
}
|
||||
Vendored
+47
@@ -0,0 +1,47 @@
|
||||
// Auto-generated by GeneratePrimitiveVsObjectEqualityTestData. Do not edit!
|
||||
|
||||
val nx: Any? = 0.toByte()
|
||||
val nn: Any? = null
|
||||
val x: Byte = 0.toByte()
|
||||
val y: Byte = 1.toByte()
|
||||
|
||||
fun box(): String {
|
||||
val ax: Any? = 0.toByte()
|
||||
val an: Any? = null
|
||||
val bx: Byte = 0.toByte()
|
||||
val by: Byte = 1.toByte()
|
||||
|
||||
return when {
|
||||
0.toByte() != nx -> "Fail 0"
|
||||
1.toByte() == nx -> "Fail 1"
|
||||
!(0.toByte() == nx) -> "Fail 2"
|
||||
!(1.toByte() != nx) -> "Fail 3"
|
||||
x != nx -> "Fail 4"
|
||||
y == nx -> "Fail 5"
|
||||
!(x == nx) -> "Fail 6"
|
||||
!(y != nx) -> "Fail 7"
|
||||
0.toByte() == nn -> "Fail 8"
|
||||
!(0.toByte() != nn) -> "Fail 9"
|
||||
x == nn -> "Fail 10"
|
||||
!(x != nn) -> "Fail 11"
|
||||
0.toByte() != ax -> "Fail 12"
|
||||
1.toByte() == ax -> "Fail 13"
|
||||
!(0.toByte() == ax) -> "Fail 14"
|
||||
!(1.toByte() != ax) -> "Fail 15"
|
||||
x != ax -> "Fail 16"
|
||||
y == ax -> "Fail 17"
|
||||
!(x == ax) -> "Fail 18"
|
||||
!(y != ax) -> "Fail 19"
|
||||
bx != ax -> "Fail 20"
|
||||
by == ax -> "Fail 21"
|
||||
!(bx == ax) -> "Fail 22"
|
||||
!(by != ax) -> "Fail 23"
|
||||
0.toByte() == an -> "Fail 24"
|
||||
!(0.toByte() != an) -> "Fail 25"
|
||||
x == an -> "Fail 26"
|
||||
!(x != an) -> "Fail 27"
|
||||
bx == an -> "Fail 28"
|
||||
!(bx != an) -> "Fail 29"
|
||||
else -> "OK"
|
||||
}
|
||||
}
|
||||
Vendored
+47
@@ -0,0 +1,47 @@
|
||||
// Auto-generated by GeneratePrimitiveVsObjectEqualityTestData. Do not edit!
|
||||
|
||||
val nx: Any? = '0'
|
||||
val nn: Any? = null
|
||||
val x: Char = '0'
|
||||
val y: Char = '1'
|
||||
|
||||
fun box(): String {
|
||||
val ax: Any? = '0'
|
||||
val an: Any? = null
|
||||
val bx: Char = '0'
|
||||
val by: Char = '1'
|
||||
|
||||
return when {
|
||||
'0' != nx -> "Fail 0"
|
||||
'1' == nx -> "Fail 1"
|
||||
!('0' == nx) -> "Fail 2"
|
||||
!('1' != nx) -> "Fail 3"
|
||||
x != nx -> "Fail 4"
|
||||
y == nx -> "Fail 5"
|
||||
!(x == nx) -> "Fail 6"
|
||||
!(y != nx) -> "Fail 7"
|
||||
'0' == nn -> "Fail 8"
|
||||
!('0' != nn) -> "Fail 9"
|
||||
x == nn -> "Fail 10"
|
||||
!(x != nn) -> "Fail 11"
|
||||
'0' != ax -> "Fail 12"
|
||||
'1' == ax -> "Fail 13"
|
||||
!('0' == ax) -> "Fail 14"
|
||||
!('1' != ax) -> "Fail 15"
|
||||
x != ax -> "Fail 16"
|
||||
y == ax -> "Fail 17"
|
||||
!(x == ax) -> "Fail 18"
|
||||
!(y != ax) -> "Fail 19"
|
||||
bx != ax -> "Fail 20"
|
||||
by == ax -> "Fail 21"
|
||||
!(bx == ax) -> "Fail 22"
|
||||
!(by != ax) -> "Fail 23"
|
||||
'0' == an -> "Fail 24"
|
||||
!('0' != an) -> "Fail 25"
|
||||
x == an -> "Fail 26"
|
||||
!(x != an) -> "Fail 27"
|
||||
bx == an -> "Fail 28"
|
||||
!(bx != an) -> "Fail 29"
|
||||
else -> "OK"
|
||||
}
|
||||
}
|
||||
Vendored
+47
@@ -0,0 +1,47 @@
|
||||
// Auto-generated by GeneratePrimitiveVsObjectEqualityTestData. Do not edit!
|
||||
|
||||
val nx: Any? = 0
|
||||
val nn: Any? = null
|
||||
val x: Int = 0
|
||||
val y: Int = 1
|
||||
|
||||
fun box(): String {
|
||||
val ax: Any? = 0
|
||||
val an: Any? = null
|
||||
val bx: Int = 0
|
||||
val by: Int = 1
|
||||
|
||||
return when {
|
||||
0 != nx -> "Fail 0"
|
||||
1 == nx -> "Fail 1"
|
||||
!(0 == nx) -> "Fail 2"
|
||||
!(1 != nx) -> "Fail 3"
|
||||
x != nx -> "Fail 4"
|
||||
y == nx -> "Fail 5"
|
||||
!(x == nx) -> "Fail 6"
|
||||
!(y != nx) -> "Fail 7"
|
||||
0 == nn -> "Fail 8"
|
||||
!(0 != nn) -> "Fail 9"
|
||||
x == nn -> "Fail 10"
|
||||
!(x != nn) -> "Fail 11"
|
||||
0 != ax -> "Fail 12"
|
||||
1 == ax -> "Fail 13"
|
||||
!(0 == ax) -> "Fail 14"
|
||||
!(1 != ax) -> "Fail 15"
|
||||
x != ax -> "Fail 16"
|
||||
y == ax -> "Fail 17"
|
||||
!(x == ax) -> "Fail 18"
|
||||
!(y != ax) -> "Fail 19"
|
||||
bx != ax -> "Fail 20"
|
||||
by == ax -> "Fail 21"
|
||||
!(bx == ax) -> "Fail 22"
|
||||
!(by != ax) -> "Fail 23"
|
||||
0 == an -> "Fail 24"
|
||||
!(0 != an) -> "Fail 25"
|
||||
x == an -> "Fail 26"
|
||||
!(x != an) -> "Fail 27"
|
||||
bx == an -> "Fail 28"
|
||||
!(bx != an) -> "Fail 29"
|
||||
else -> "OK"
|
||||
}
|
||||
}
|
||||
Vendored
+47
@@ -0,0 +1,47 @@
|
||||
// Auto-generated by GeneratePrimitiveVsObjectEqualityTestData. Do not edit!
|
||||
|
||||
val nx: Any? = 0L
|
||||
val nn: Any? = null
|
||||
val x: Long = 0L
|
||||
val y: Long = 1L
|
||||
|
||||
fun box(): String {
|
||||
val ax: Any? = 0L
|
||||
val an: Any? = null
|
||||
val bx: Long = 0L
|
||||
val by: Long = 1L
|
||||
|
||||
return when {
|
||||
0L != nx -> "Fail 0"
|
||||
1L == nx -> "Fail 1"
|
||||
!(0L == nx) -> "Fail 2"
|
||||
!(1L != nx) -> "Fail 3"
|
||||
x != nx -> "Fail 4"
|
||||
y == nx -> "Fail 5"
|
||||
!(x == nx) -> "Fail 6"
|
||||
!(y != nx) -> "Fail 7"
|
||||
0L == nn -> "Fail 8"
|
||||
!(0L != nn) -> "Fail 9"
|
||||
x == nn -> "Fail 10"
|
||||
!(x != nn) -> "Fail 11"
|
||||
0L != ax -> "Fail 12"
|
||||
1L == ax -> "Fail 13"
|
||||
!(0L == ax) -> "Fail 14"
|
||||
!(1L != ax) -> "Fail 15"
|
||||
x != ax -> "Fail 16"
|
||||
y == ax -> "Fail 17"
|
||||
!(x == ax) -> "Fail 18"
|
||||
!(y != ax) -> "Fail 19"
|
||||
bx != ax -> "Fail 20"
|
||||
by == ax -> "Fail 21"
|
||||
!(bx == ax) -> "Fail 22"
|
||||
!(by != ax) -> "Fail 23"
|
||||
0L == an -> "Fail 24"
|
||||
!(0L != an) -> "Fail 25"
|
||||
x == an -> "Fail 26"
|
||||
!(x != an) -> "Fail 27"
|
||||
bx == an -> "Fail 28"
|
||||
!(bx != an) -> "Fail 29"
|
||||
else -> "OK"
|
||||
}
|
||||
}
|
||||
Vendored
+47
@@ -0,0 +1,47 @@
|
||||
// Auto-generated by GeneratePrimitiveVsObjectEqualityTestData. Do not edit!
|
||||
|
||||
val nx: Any? = 0.toShort()
|
||||
val nn: Any? = null
|
||||
val x: Short = 0.toShort()
|
||||
val y: Short = 1.toShort()
|
||||
|
||||
fun box(): String {
|
||||
val ax: Any? = 0.toShort()
|
||||
val an: Any? = null
|
||||
val bx: Short = 0.toShort()
|
||||
val by: Short = 1.toShort()
|
||||
|
||||
return when {
|
||||
0.toShort() != nx -> "Fail 0"
|
||||
1.toShort() == nx -> "Fail 1"
|
||||
!(0.toShort() == nx) -> "Fail 2"
|
||||
!(1.toShort() != nx) -> "Fail 3"
|
||||
x != nx -> "Fail 4"
|
||||
y == nx -> "Fail 5"
|
||||
!(x == nx) -> "Fail 6"
|
||||
!(y != nx) -> "Fail 7"
|
||||
0.toShort() == nn -> "Fail 8"
|
||||
!(0.toShort() != nn) -> "Fail 9"
|
||||
x == nn -> "Fail 10"
|
||||
!(x != nn) -> "Fail 11"
|
||||
0.toShort() != ax -> "Fail 12"
|
||||
1.toShort() == ax -> "Fail 13"
|
||||
!(0.toShort() == ax) -> "Fail 14"
|
||||
!(1.toShort() != ax) -> "Fail 15"
|
||||
x != ax -> "Fail 16"
|
||||
y == ax -> "Fail 17"
|
||||
!(x == ax) -> "Fail 18"
|
||||
!(y != ax) -> "Fail 19"
|
||||
bx != ax -> "Fail 20"
|
||||
by == ax -> "Fail 21"
|
||||
!(bx == ax) -> "Fail 22"
|
||||
!(by != ax) -> "Fail 23"
|
||||
0.toShort() == an -> "Fail 24"
|
||||
!(0.toShort() != an) -> "Fail 25"
|
||||
x == an -> "Fail 26"
|
||||
!(x != an) -> "Fail 27"
|
||||
bx == an -> "Fail 28"
|
||||
!(bx != an) -> "Fail 29"
|
||||
else -> "OK"
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// Strictly speaking, asymmetric equals violates contract for 'Object#equals'.
|
||||
// However, we don't rely on this contract so far.
|
||||
class FakeInt(val value: Int) {
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is Int && other == value
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val fake: Any = FakeInt(42)
|
||||
|
||||
val int1 = 1
|
||||
val int42 = 42
|
||||
|
||||
if (fake == int1) return "FakeInt(42) == 1"
|
||||
if (fake != int42) return "FakeInt(42) != 42"
|
||||
if (int1 == fake) return "1 == FakeInt(42)"
|
||||
if (int42 == fake) return "42 == FakeInt(42)"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
fun testBoolean1(a: Boolean, b: Boolean?) = a == b
|
||||
fun testBoolean2(a: Boolean, b: Boolean?) = a != b
|
||||
|
||||
fun testChar1(a: Char, b: Char?) = a == b
|
||||
fun testChar2(a: Char, b: Char?) = a != b
|
||||
|
||||
fun testByte1(a: Byte, b: Byte?) = a == b
|
||||
fun testByte2(a: Byte, b: Byte?) = a != b
|
||||
|
||||
fun testShort1(a: Short, b: Short?) = a == b
|
||||
fun testShort2(a: Short, b: Short?) = a != b
|
||||
|
||||
fun testInt1(a: Int, b: Int?) = a == b
|
||||
fun testInt2(a: Int, b: Int?) = a != b
|
||||
|
||||
fun testLong1(a: Long, b: Long?) = a == b
|
||||
fun testLong2(a: Long, b: Long?) = a != b
|
||||
|
||||
// 2 booleanValue
|
||||
// 2 charValue
|
||||
// 2 byteValue
|
||||
// 2 shortValue
|
||||
// 2 intValue
|
||||
// 2 longValue
|
||||
// 0 valueOf
|
||||
// 0 areEqual
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
fun testBoolean1(a: Boolean, b: Any?) = a == b
|
||||
fun testBoolean2(a: Boolean, b: Any?) = a != b
|
||||
|
||||
fun testChar1(a: Char, b: Any?) = a == b
|
||||
fun testChar2(a: Char, b: Any?) = a != b
|
||||
|
||||
fun testByte1(a: Byte, b: Any?) = a == b
|
||||
fun testByte2(a: Byte, b: Any?) = a != b
|
||||
|
||||
fun testShort1(a: Short, b: Any?) = a == b
|
||||
fun testShort2(a: Short, b: Any?) = a != b
|
||||
|
||||
fun testInt1(a: Int, b: Any?) = a == b
|
||||
fun testInt2(a: Int, b: Any?) = a != b
|
||||
|
||||
fun testLong1(a: Long, b: Any?) = a == b
|
||||
fun testLong2(a: Long, b: Any?) = a != b
|
||||
|
||||
// 2 booleanValue
|
||||
// 2 charValue
|
||||
// 2 byteValue
|
||||
// 2 shortValue
|
||||
// 2 intValue
|
||||
// 2 longValue
|
||||
// 0 valueOf
|
||||
// 0 areEqual
|
||||
+67
-19
@@ -12500,97 +12500,145 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable")
|
||||
@TestMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class EqualityWithNullable extends AbstractIrBlackBoxCodegenTest {
|
||||
public void testAllFilesPresentInEqualityWithNullable() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||
public static class EqualityWithObject extends AbstractIrBlackBoxCodegenTest {
|
||||
public void testAllFilesPresentInEqualityWithObject() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/primitiveTypes/equalityWithObject"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("boxedEqPrimitiveEvaluationOrder.kt")
|
||||
public void testBoxedEqPrimitiveEvaluationOrder() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/boxedEqPrimitiveEvaluationOrder.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/boxedEqPrimitiveEvaluationOrder.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated")
|
||||
@TestMetadata("boxedLongEqualsLong.kt")
|
||||
public void testBoxedLongEqualsLong() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/boxedLongEqualsLong.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("objectWithAsymmetricEqualsEqPrimitive.kt")
|
||||
public void testObjectWithAsymmetricEqualsEqPrimitive() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/objectWithAsymmetricEqualsEqPrimitive.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Generated extends AbstractIrBlackBoxCodegenTest {
|
||||
public void testAllFilesPresentInGenerated() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("boxedEqPrimitiveBoolean.kt")
|
||||
public void testBoxedEqPrimitiveBoolean() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/boxedEqPrimitiveBoolean.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/boxedEqPrimitiveBoolean.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("boxedEqPrimitiveByte.kt")
|
||||
public void testBoxedEqPrimitiveByte() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/boxedEqPrimitiveByte.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/boxedEqPrimitiveByte.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("boxedEqPrimitiveChar.kt")
|
||||
public void testBoxedEqPrimitiveChar() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/boxedEqPrimitiveChar.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/boxedEqPrimitiveChar.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("boxedEqPrimitiveInt.kt")
|
||||
public void testBoxedEqPrimitiveInt() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/boxedEqPrimitiveInt.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/boxedEqPrimitiveInt.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("boxedEqPrimitiveLong.kt")
|
||||
public void testBoxedEqPrimitiveLong() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/boxedEqPrimitiveLong.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/boxedEqPrimitiveLong.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("boxedEqPrimitiveShort.kt")
|
||||
public void testBoxedEqPrimitiveShort() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/boxedEqPrimitiveShort.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/boxedEqPrimitiveShort.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqBoxedBoolean.kt")
|
||||
public void testPrimitiveEqBoxedBoolean() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/primitiveEqBoxedBoolean.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqBoxedBoolean.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqBoxedByte.kt")
|
||||
public void testPrimitiveEqBoxedByte() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/primitiveEqBoxedByte.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqBoxedByte.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqBoxedChar.kt")
|
||||
public void testPrimitiveEqBoxedChar() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/primitiveEqBoxedChar.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqBoxedChar.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqBoxedInt.kt")
|
||||
public void testPrimitiveEqBoxedInt() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/primitiveEqBoxedInt.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqBoxedInt.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqBoxedLong.kt")
|
||||
public void testPrimitiveEqBoxedLong() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/primitiveEqBoxedLong.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqBoxedLong.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqBoxedShort.kt")
|
||||
public void testPrimitiveEqBoxedShort() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/primitiveEqBoxedShort.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqBoxedShort.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqObjectBoolean.kt")
|
||||
public void testPrimitiveEqObjectBoolean() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqObjectBoolean.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqObjectByte.kt")
|
||||
public void testPrimitiveEqObjectByte() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqObjectByte.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqObjectChar.kt")
|
||||
public void testPrimitiveEqObjectChar() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqObjectChar.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqObjectInt.kt")
|
||||
public void testPrimitiveEqObjectInt() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqObjectInt.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqObjectLong.kt")
|
||||
public void testPrimitiveEqObjectLong() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqObjectLong.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqObjectShort.kt")
|
||||
public void testPrimitiveEqObjectShort() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqObjectShort.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12500,97 +12500,145 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable")
|
||||
@TestMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class EqualityWithNullable extends AbstractBlackBoxCodegenTest {
|
||||
public void testAllFilesPresentInEqualityWithNullable() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||
public static class EqualityWithObject extends AbstractBlackBoxCodegenTest {
|
||||
public void testAllFilesPresentInEqualityWithObject() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/primitiveTypes/equalityWithObject"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("boxedEqPrimitiveEvaluationOrder.kt")
|
||||
public void testBoxedEqPrimitiveEvaluationOrder() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/boxedEqPrimitiveEvaluationOrder.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/boxedEqPrimitiveEvaluationOrder.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated")
|
||||
@TestMetadata("boxedLongEqualsLong.kt")
|
||||
public void testBoxedLongEqualsLong() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/boxedLongEqualsLong.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("objectWithAsymmetricEqualsEqPrimitive.kt")
|
||||
public void testObjectWithAsymmetricEqualsEqPrimitive() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/objectWithAsymmetricEqualsEqPrimitive.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Generated extends AbstractBlackBoxCodegenTest {
|
||||
public void testAllFilesPresentInGenerated() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("boxedEqPrimitiveBoolean.kt")
|
||||
public void testBoxedEqPrimitiveBoolean() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/boxedEqPrimitiveBoolean.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/boxedEqPrimitiveBoolean.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("boxedEqPrimitiveByte.kt")
|
||||
public void testBoxedEqPrimitiveByte() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/boxedEqPrimitiveByte.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/boxedEqPrimitiveByte.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("boxedEqPrimitiveChar.kt")
|
||||
public void testBoxedEqPrimitiveChar() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/boxedEqPrimitiveChar.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/boxedEqPrimitiveChar.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("boxedEqPrimitiveInt.kt")
|
||||
public void testBoxedEqPrimitiveInt() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/boxedEqPrimitiveInt.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/boxedEqPrimitiveInt.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("boxedEqPrimitiveLong.kt")
|
||||
public void testBoxedEqPrimitiveLong() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/boxedEqPrimitiveLong.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/boxedEqPrimitiveLong.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("boxedEqPrimitiveShort.kt")
|
||||
public void testBoxedEqPrimitiveShort() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/boxedEqPrimitiveShort.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/boxedEqPrimitiveShort.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqBoxedBoolean.kt")
|
||||
public void testPrimitiveEqBoxedBoolean() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/primitiveEqBoxedBoolean.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqBoxedBoolean.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqBoxedByte.kt")
|
||||
public void testPrimitiveEqBoxedByte() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/primitiveEqBoxedByte.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqBoxedByte.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqBoxedChar.kt")
|
||||
public void testPrimitiveEqBoxedChar() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/primitiveEqBoxedChar.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqBoxedChar.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqBoxedInt.kt")
|
||||
public void testPrimitiveEqBoxedInt() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/primitiveEqBoxedInt.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqBoxedInt.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqBoxedLong.kt")
|
||||
public void testPrimitiveEqBoxedLong() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/primitiveEqBoxedLong.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqBoxedLong.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqBoxedShort.kt")
|
||||
public void testPrimitiveEqBoxedShort() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/primitiveEqBoxedShort.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqBoxedShort.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqObjectBoolean.kt")
|
||||
public void testPrimitiveEqObjectBoolean() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqObjectBoolean.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqObjectByte.kt")
|
||||
public void testPrimitiveEqObjectByte() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqObjectByte.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqObjectChar.kt")
|
||||
public void testPrimitiveEqObjectChar() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqObjectChar.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqObjectInt.kt")
|
||||
public void testPrimitiveEqObjectInt() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqObjectInt.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqObjectLong.kt")
|
||||
public void testPrimitiveEqObjectLong() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqObjectLong.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqObjectShort.kt")
|
||||
public void testPrimitiveEqObjectShort() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqObjectShort.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,12 +294,6 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("noBoxingForBoxedEqPrimitive.kt")
|
||||
public void testNoBoxingForBoxedEqPrimitive() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/noBoxingForBoxedEqPrimitive.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("noFlagAnnotations.kt")
|
||||
public void testNoFlagAnnotations() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/noFlagAnnotations.kt");
|
||||
@@ -875,6 +869,24 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("noBoxingForBoxedEqPrimitive.kt")
|
||||
public void testNoBoxingForBoxedEqPrimitive() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/conditions/noBoxingForBoxedEqPrimitive.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("noBoxingForPrimitiveEqBoxed.kt")
|
||||
public void testNoBoxingForPrimitiveEqBoxed() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/conditions/noBoxingForPrimitiveEqBoxed.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("noBoxingForPrimitiveEqObject.kt")
|
||||
public void testNoBoxingForPrimitiveEqObject() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/conditions/noBoxingForPrimitiveEqObject.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("nullCompare.kt")
|
||||
public void testNullCompare() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/conditions/nullCompare.kt");
|
||||
|
||||
@@ -12500,97 +12500,145 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable")
|
||||
@TestMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class EqualityWithNullable extends AbstractLightAnalysisModeTest {
|
||||
public void testAllFilesPresentInEqualityWithNullable() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||
public static class EqualityWithObject extends AbstractLightAnalysisModeTest {
|
||||
public void testAllFilesPresentInEqualityWithObject() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/primitiveTypes/equalityWithObject"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("boxedEqPrimitiveEvaluationOrder.kt")
|
||||
public void testBoxedEqPrimitiveEvaluationOrder() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/boxedEqPrimitiveEvaluationOrder.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/boxedEqPrimitiveEvaluationOrder.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated")
|
||||
@TestMetadata("boxedLongEqualsLong.kt")
|
||||
public void testBoxedLongEqualsLong() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/boxedLongEqualsLong.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("objectWithAsymmetricEqualsEqPrimitive.kt")
|
||||
public void testObjectWithAsymmetricEqualsEqPrimitive() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/objectWithAsymmetricEqualsEqPrimitive.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Generated extends AbstractLightAnalysisModeTest {
|
||||
public void testAllFilesPresentInGenerated() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("boxedEqPrimitiveBoolean.kt")
|
||||
public void testBoxedEqPrimitiveBoolean() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/boxedEqPrimitiveBoolean.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/boxedEqPrimitiveBoolean.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("boxedEqPrimitiveByte.kt")
|
||||
public void testBoxedEqPrimitiveByte() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/boxedEqPrimitiveByte.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/boxedEqPrimitiveByte.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("boxedEqPrimitiveChar.kt")
|
||||
public void testBoxedEqPrimitiveChar() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/boxedEqPrimitiveChar.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/boxedEqPrimitiveChar.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("boxedEqPrimitiveInt.kt")
|
||||
public void testBoxedEqPrimitiveInt() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/boxedEqPrimitiveInt.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/boxedEqPrimitiveInt.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("boxedEqPrimitiveLong.kt")
|
||||
public void testBoxedEqPrimitiveLong() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/boxedEqPrimitiveLong.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/boxedEqPrimitiveLong.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("boxedEqPrimitiveShort.kt")
|
||||
public void testBoxedEqPrimitiveShort() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/boxedEqPrimitiveShort.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/boxedEqPrimitiveShort.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqBoxedBoolean.kt")
|
||||
public void testPrimitiveEqBoxedBoolean() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/primitiveEqBoxedBoolean.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqBoxedBoolean.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqBoxedByte.kt")
|
||||
public void testPrimitiveEqBoxedByte() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/primitiveEqBoxedByte.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqBoxedByte.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqBoxedChar.kt")
|
||||
public void testPrimitiveEqBoxedChar() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/primitiveEqBoxedChar.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqBoxedChar.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqBoxedInt.kt")
|
||||
public void testPrimitiveEqBoxedInt() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/primitiveEqBoxedInt.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqBoxedInt.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqBoxedLong.kt")
|
||||
public void testPrimitiveEqBoxedLong() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/primitiveEqBoxedLong.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqBoxedLong.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqBoxedShort.kt")
|
||||
public void testPrimitiveEqBoxedShort() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/primitiveEqBoxedShort.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqBoxedShort.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqObjectBoolean.kt")
|
||||
public void testPrimitiveEqObjectBoolean() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqObjectBoolean.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqObjectByte.kt")
|
||||
public void testPrimitiveEqObjectByte() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqObjectByte.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqObjectChar.kt")
|
||||
public void testPrimitiveEqObjectChar() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqObjectChar.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqObjectInt.kt")
|
||||
public void testPrimitiveEqObjectInt() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqObjectInt.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqObjectLong.kt")
|
||||
public void testPrimitiveEqObjectLong() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqObjectLong.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqObjectShort.kt")
|
||||
public void testPrimitiveEqObjectShort() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqObjectShort.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
+50
-7
@@ -21,7 +21,7 @@ import java.io.File
|
||||
import java.io.PrintWriter
|
||||
|
||||
object GeneratePrimitiveVsObjectEqualityTestData {
|
||||
private val TEST_DATA_DIR = File("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable")
|
||||
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!"
|
||||
@@ -75,16 +75,16 @@ object GeneratePrimitiveVsObjectEqualityTestData {
|
||||
"!($lhs != $unequalRhs)"
|
||||
)
|
||||
|
||||
private fun PrintWriter.generateLocalVals(type: String, x: String, y: String) {
|
||||
println(" val ax: $type? = $x")
|
||||
println(" val an: $type? = null")
|
||||
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) {
|
||||
println("val nx: $type? = $x")
|
||||
println("val nn: $type? = null")
|
||||
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")
|
||||
}
|
||||
@@ -131,6 +131,42 @@ object GeneratePrimitiveVsObjectEqualityTestData {
|
||||
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",
|
||||
@@ -166,5 +202,12 @@ object GeneratePrimitiveVsObjectEqualityTestData {
|
||||
generatePrimitiveVsBoxedTest("Short", "0.toShort()", "1.toShort()")
|
||||
generatePrimitiveVsBoxedTest("Int", "0", "1")
|
||||
generatePrimitiveVsBoxedTest("Long", "0L", "1L")
|
||||
|
||||
generatePrimitiveVsObjectTest("Boolean", "true", "false")
|
||||
generatePrimitiveVsObjectTest("Char", "'0'", "'1'")
|
||||
generatePrimitiveVsObjectTest("Byte", "0.toByte()", "1.toByte()")
|
||||
generatePrimitiveVsObjectTest("Short", "0.toShort()", "1.toShort()")
|
||||
generatePrimitiveVsObjectTest("Int", "0", "1")
|
||||
generatePrimitiveVsObjectTest("Long", "0L", "1L")
|
||||
}
|
||||
}
|
||||
+67
-19
@@ -13958,97 +13958,145 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable")
|
||||
@TestMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class EqualityWithNullable extends AbstractJsCodegenBoxTest {
|
||||
public void testAllFilesPresentInEqualityWithNullable() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true);
|
||||
public static class EqualityWithObject extends AbstractJsCodegenBoxTest {
|
||||
public void testAllFilesPresentInEqualityWithObject() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/primitiveTypes/equalityWithObject"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true);
|
||||
}
|
||||
|
||||
@TestMetadata("boxedEqPrimitiveEvaluationOrder.kt")
|
||||
public void testBoxedEqPrimitiveEvaluationOrder() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/boxedEqPrimitiveEvaluationOrder.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/boxedEqPrimitiveEvaluationOrder.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated")
|
||||
@TestMetadata("boxedLongEqualsLong.kt")
|
||||
public void testBoxedLongEqualsLong() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/boxedLongEqualsLong.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("objectWithAsymmetricEqualsEqPrimitive.kt")
|
||||
public void testObjectWithAsymmetricEqualsEqPrimitive() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/objectWithAsymmetricEqualsEqPrimitive.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Generated extends AbstractJsCodegenBoxTest {
|
||||
public void testAllFilesPresentInGenerated() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true);
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true);
|
||||
}
|
||||
|
||||
@TestMetadata("boxedEqPrimitiveBoolean.kt")
|
||||
public void testBoxedEqPrimitiveBoolean() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/boxedEqPrimitiveBoolean.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/boxedEqPrimitiveBoolean.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("boxedEqPrimitiveByte.kt")
|
||||
public void testBoxedEqPrimitiveByte() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/boxedEqPrimitiveByte.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/boxedEqPrimitiveByte.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("boxedEqPrimitiveChar.kt")
|
||||
public void testBoxedEqPrimitiveChar() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/boxedEqPrimitiveChar.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/boxedEqPrimitiveChar.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("boxedEqPrimitiveInt.kt")
|
||||
public void testBoxedEqPrimitiveInt() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/boxedEqPrimitiveInt.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/boxedEqPrimitiveInt.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("boxedEqPrimitiveLong.kt")
|
||||
public void testBoxedEqPrimitiveLong() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/boxedEqPrimitiveLong.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/boxedEqPrimitiveLong.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("boxedEqPrimitiveShort.kt")
|
||||
public void testBoxedEqPrimitiveShort() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/boxedEqPrimitiveShort.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/boxedEqPrimitiveShort.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqBoxedBoolean.kt")
|
||||
public void testPrimitiveEqBoxedBoolean() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/primitiveEqBoxedBoolean.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqBoxedBoolean.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqBoxedByte.kt")
|
||||
public void testPrimitiveEqBoxedByte() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/primitiveEqBoxedByte.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqBoxedByte.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqBoxedChar.kt")
|
||||
public void testPrimitiveEqBoxedChar() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/primitiveEqBoxedChar.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqBoxedChar.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqBoxedInt.kt")
|
||||
public void testPrimitiveEqBoxedInt() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/primitiveEqBoxedInt.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqBoxedInt.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqBoxedLong.kt")
|
||||
public void testPrimitiveEqBoxedLong() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/primitiveEqBoxedLong.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqBoxedLong.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqBoxedShort.kt")
|
||||
public void testPrimitiveEqBoxedShort() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithNullable/generated/primitiveEqBoxedShort.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqBoxedShort.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqObjectBoolean.kt")
|
||||
public void testPrimitiveEqObjectBoolean() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqObjectBoolean.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqObjectByte.kt")
|
||||
public void testPrimitiveEqObjectByte() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqObjectByte.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqObjectChar.kt")
|
||||
public void testPrimitiveEqObjectChar() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqObjectChar.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqObjectInt.kt")
|
||||
public void testPrimitiveEqObjectInt() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqObjectInt.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqObjectLong.kt")
|
||||
public void testPrimitiveEqObjectLong() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqObjectLong.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqObjectShort.kt")
|
||||
public void testPrimitiveEqObjectShort() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/generated/primitiveEqObjectShort.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user