[IR][tests] Update tests to reflect changes in partial linkage error messages
This commit is contained in:
+14
-7
@@ -4,16 +4,23 @@ import lib2.B
|
||||
fun box(): String {
|
||||
val a: A = B()
|
||||
|
||||
try {
|
||||
return try {
|
||||
val answer: Int = a.foo() // <-- should throw linkage error here
|
||||
println(answer)
|
||||
"FAIL"
|
||||
} catch (e: Throwable) {
|
||||
if (e.isLinkageError("lib2.B.foo")) return "OK"
|
||||
e.checkLinkageError("foo", "B")
|
||||
}
|
||||
|
||||
return "FAIL"
|
||||
}
|
||||
|
||||
private fun Throwable.isLinkageError(symbolName: String): Boolean =
|
||||
this::class.simpleName == "IrLinkageError"
|
||||
&& message == "Abstract function $symbolName is not implemented in non-abstract class ${symbolName.substringBeforeLast(".")}"
|
||||
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"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user