[IR][tests] Make ABI compatibility tests less verbose, part 2

This commit is contained in:
Dmitriy Dolovov
2022-08-23 15:00:26 +02:00
parent db1c8cc7a7
commit 24d8ac97cd
24 changed files with 173 additions and 1242 deletions
@@ -1,26 +1,8 @@
import abitestutils.abiTest
import lib1.A
import lib2.B
fun box(): String {
fun box() = abiTest {
val a: A = B()
return try {
val answer: Int = a.foo() // <-- should throw linkage error here
println(answer)
"FAIL"
} catch (e: Throwable) {
e.checkLinkageError("foo", "B")
}
}
private fun Throwable.checkLinkageError(symbolName: String, className: String): String {
if (this::class.simpleName != "IrLinkageError") return "Unexpected throwable: ${this::class}"
val expectedMessage = "Abstract function $symbolName is not implemented in non-abstract class $className"
val actualMessage = message.orEmpty()
return if (expectedMessage == actualMessage)
"OK"
else
"EXPECTED: $expectedMessage, ACTUAL: $actualMessage"
expectFailure(nonImplementedCallable("function foo", "class B")) { a.foo() }
}