[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:
committed by
Space Team
parent
f75b72990e
commit
8c748bfea4
+11
-4
@@ -8,14 +8,21 @@ val l = mutableListOf<Any>()
|
||||
|
||||
@JvmInline
|
||||
value class VC(val x: Int, val y: ULong) {
|
||||
constructor(xD: Double, yD: Double): this(xD.toInt() - 2, yD.toULong() - 2UL) {
|
||||
constructor(xD: Double, yD: Double) : this(xD.toInt() - 2, yD.toULong() - 2UL) {
|
||||
l.add(xD)
|
||||
l.add(yD)
|
||||
l.add(x)
|
||||
l.add(y)
|
||||
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(y)
|
||||
@@ -25,8 +32,8 @@ value class VC(val x: Int, val y: ULong) {
|
||||
|
||||
fun box(): String {
|
||||
val vc = VC(1, 2UL)
|
||||
require(vc == VC(3.0, 4.0)) { "$vc\n${VC(3.0, 4.0)}"}
|
||||
val actual = listOf(1, 2UL, vc, 1, 2UL, vc, 3.0, 4.0, 1, 2UL, vc)
|
||||
require(vc == VC(3.0, 4.0)) { "$vc\n${VC(3.0, 4.0)}" }
|
||||
val actual = listOf(1, 2UL, vc, 1, 2UL, vc, 3.0, 4.0, 1, 2UL, vc, 1.0, Long.MAX_VALUE)
|
||||
require(l == actual) { "$l\n$actual" }
|
||||
return "OK"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user