[IR] Add more tests for inline/value classes secondary constructors

Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-55333
This commit is contained in:
Evgeniy.Zhelenskiy
2023-04-12 00:59:14 +02:00
committed by Space Team
parent f75b72990e
commit 8c748bfea4
52 changed files with 909 additions and 31 deletions
@@ -9,12 +9,19 @@ val l = mutableListOf<Any>()
OPTIONAL_JVM_INLINE_ANNOTATION
value class VC(val x: Int) {
constructor(xD: Double): this(-xD.toInt()) {
constructor(xD: Double) : this(-xD.toInt()) {
l.add(xD)
l.add(x)
l.add(this)
l.add(xD.let { it - 1.0 }.let(fun(x: Double) = x - 1.0))
class Inner(val x: Int) {
constructor(x: Long): this(x.toInt()) {
l.add(x)
}
}
Inner(Long.MAX_VALUE)
}
init {
l.add(x)
l.add(this)
@@ -23,8 +30,8 @@ value class VC(val x: Int) {
fun box(): String {
val vc = VC(1)
require(vc == VC(-1.0)) { "$vc\n${VC(-1.0)}"}
val actual = listOf(1, vc, 1, vc, -1.0, 1, vc)
require(vc == VC(-1.0)) { "$vc\n${VC(-1.0)}" }
val actual = listOf(1, vc, 1, vc, -1.0, 1, vc, -3.0, Long.MAX_VALUE)
require(l == actual) { "$l\n$actual" }
return "OK"
}