[IR][tests] Update tests to reflect changes in partial linkage error messages
This commit is contained in:
+23
-15
@@ -1,31 +1,39 @@
|
||||
fun test1(): String {
|
||||
try {
|
||||
return qux(true)
|
||||
return try {
|
||||
qux(true)
|
||||
} catch(e: Throwable) {
|
||||
if (e.isLinkageError("/exp_foo")) return "OK"
|
||||
e.checkLinkageError("function exp_foo can not be called")
|
||||
}
|
||||
|
||||
return "FAIL5"
|
||||
}
|
||||
|
||||
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")) return "OK"
|
||||
e.checkLinkageError("function exp_foo can not be called")
|
||||
}
|
||||
|
||||
return "FAIL6"
|
||||
}
|
||||
|
||||
fun test4(): String = qux2(false)
|
||||
|
||||
fun box(): String {
|
||||
val result = test1() + test2() + test3() + test4()
|
||||
return if (result == "OKOKOKOK") "OK" else result
|
||||
fun box() = checkResults(test1(), test2(), test3(), test4())
|
||||
|
||||
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