Add more tests for inline class equality

This commit is contained in:
Steven Schäfer
2019-08-22 16:02:43 +02:00
committed by Alexander Udalov
parent cdc5e1347b
commit b85b2d9af8
23 changed files with 1028 additions and 9 deletions
@@ -0,0 +1,32 @@
// !LANGUAGE: +InlineClasses
inline class A(val x: String = "")
var i = 0
fun set1(): A {
i = 1
return A()
}
fun test1(n: Int): A {
if (i != 1)
throw IllegalStateException("Fail $n")
i = 0
return A()
}
fun set1Boxed(): Any? = set1()
fun test1Boxed(n: Int): Any? = test1(n)
fun box(): String {
try {
set1() == test1(1)
set1Boxed() == test1(2)
set1() == test1Boxed(3)
set1Boxed() == test1Boxed(4)
} catch (e: IllegalStateException) {
return e.message ?: "Fail no message"
}
return "OK"
}