[IR][tests] Update tests to reflect changes in partial linkage error messages
This commit is contained in:
+25
-19
@@ -1,43 +1,49 @@
|
||||
fun test1(): String {
|
||||
try {
|
||||
return qux(true)
|
||||
return try {
|
||||
qux(true)
|
||||
} catch(e: Throwable) {
|
||||
if (e.isLinkageError("/exp_foo.<get-exp_foo>")) return "OK"
|
||||
e.checkLinkageError("property accessor exp_foo.<get-exp_foo> can not be called")
|
||||
}
|
||||
|
||||
return "FAIL7"
|
||||
}
|
||||
|
||||
fun test2(): String = qux(false)
|
||||
|
||||
fun test3(): String {
|
||||
try {
|
||||
return qux2(true)
|
||||
return try {
|
||||
qux2(true)
|
||||
} catch(e: Throwable) {
|
||||
if (e.isLinkageError("/A.exp_foo.<get-exp_foo>")) return "OK"
|
||||
e.checkLinkageError("property accessor exp_foo.<get-exp_foo> can not be called")
|
||||
}
|
||||
|
||||
return "FAIL8"
|
||||
}
|
||||
|
||||
fun test4(): String = qux2(false)
|
||||
|
||||
fun test5(): String {
|
||||
try {
|
||||
return try {
|
||||
return qux3(true)
|
||||
} catch(e: Throwable) {
|
||||
if (e.isLinkageError("/B.exp_foo.<get-exp_foo>")) return "OK"
|
||||
e.checkLinkageError("property accessor exp_foo.<get-exp_foo> can not be called")
|
||||
}
|
||||
|
||||
return "FAIL9"
|
||||
}
|
||||
|
||||
fun test6(): String = qux3(false)
|
||||
|
||||
fun box(): String {
|
||||
val result = test1() + test2() + test3() + test4() + test5() + test6()
|
||||
return if (result == "OKOKOKOKOKOK") "OK" else result
|
||||
fun box(): String = checkResults(test1(), test2(), test3(), test4(), test5(), test6())
|
||||
|
||||
private fun Throwable.checkLinkageError(prefix: String): String {
|
||||
if (this::class.simpleName != "IrLinkageError") return "Unexpected throwable: ${this::class}"
|
||||
|
||||
val expectedMessagePrefix = "$prefix because it uses unlinked symbols"
|
||||
val actualMessage = message.orEmpty()
|
||||
|
||||
return if (actualMessage.startsWith(expectedMessagePrefix))
|
||||
"OK"
|
||||
else
|
||||
"EXPECTED: $expectedMessagePrefix, ACTUAL: $actualMessage"
|
||||
}
|
||||
|
||||
private fun Throwable.isLinkageError(symbolName: String): Boolean =
|
||||
this::class.simpleName == "IrLinkageError" && message?.startsWith("Unlinked IR symbol $symbolName|") == true
|
||||
private fun checkResults(vararg results: String): String = when {
|
||||
results.isEmpty() -> "no results to check"
|
||||
results.all { it == "OK" } -> "OK"
|
||||
else -> results.joinToString("\n")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user