[IR][tests] Update tests to reflect changes in partial linkage error messages
This commit is contained in:
+75
-54
@@ -1,61 +1,82 @@
|
||||
fun box(): String {
|
||||
try {
|
||||
fun test1(): String {
|
||||
return try {
|
||||
fooVariableType()
|
||||
return "FAIL1"
|
||||
"FAIL1"
|
||||
} catch (e: Throwable) {
|
||||
if (!e.isUnlinkedTypeOfExpression()) return "FAIL2"
|
||||
e.checkLinkageError("val foo can not be read")
|
||||
}
|
||||
|
||||
try {
|
||||
barVariableType()
|
||||
return "FAIL3"
|
||||
} catch (e: Throwable) {
|
||||
if (!e.isUnlinkedTypeOfExpression()) return "FAIL4"
|
||||
}
|
||||
|
||||
try {
|
||||
fooInstance()
|
||||
return "FAIL5"
|
||||
} catch(e: Throwable) {
|
||||
if (!e.isUnlinkedSymbolLinkageError("/Foo.<init>")) return "FAIL6"
|
||||
}
|
||||
|
||||
try {
|
||||
barInstance()
|
||||
return "FAIL7"
|
||||
} catch(e: Throwable) {
|
||||
if (!e.isUnlinkedTypeInSignature("/Bar.<init>")) return "FAIL8"
|
||||
}
|
||||
|
||||
try {
|
||||
fooInstance2()
|
||||
return "FAIL9"
|
||||
} catch(e: Throwable) {
|
||||
if (!e.isUnlinkedSymbolLinkageError("/Foo.<init>")) return "FAIL10"
|
||||
}
|
||||
|
||||
try {
|
||||
barInstance2()
|
||||
return "FAIL11"
|
||||
} catch(e: Throwable) {
|
||||
if (!e.isUnlinkedTypeInSignature("/Bar.<init>")) return "FAIL12"
|
||||
}
|
||||
|
||||
try {
|
||||
fooAnonymousObject()
|
||||
return "FAIL13"
|
||||
} catch(e: Throwable) {
|
||||
if (!e.isUnlinkedTypeOfExpression()) return "FAIL14"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
private fun Throwable.isUnlinkedTypeOfExpression(): Boolean =
|
||||
this::class.simpleName == "IrLinkageError" && message == "Unlinked type of IR expression"
|
||||
fun test2(): String {
|
||||
return try {
|
||||
barVariableType()
|
||||
"FAIL2"
|
||||
} catch (e: Throwable) {
|
||||
e.checkLinkageError("val bar can not be read")
|
||||
}
|
||||
}
|
||||
|
||||
private fun Throwable.isUnlinkedSymbolLinkageError(symbolName: String): Boolean =
|
||||
this::class.simpleName == "IrLinkageError" && message?.startsWith("Unlinked IR symbol $symbolName|") == true
|
||||
fun test3(): String {
|
||||
return try {
|
||||
fooInstance()
|
||||
"FAIL3"
|
||||
} catch (e: Throwable) {
|
||||
e.checkLinkageError("constructor Foo.<init> can not be called")
|
||||
}
|
||||
}
|
||||
|
||||
private fun Throwable.isUnlinkedTypeInSignature(symbolName: String): Boolean =
|
||||
this::class.simpleName == "IrLinkageError" && message?.startsWith("Unlinked type in signature of IR symbol $symbolName|") == true
|
||||
fun test4(): String {
|
||||
return try {
|
||||
barInstance()
|
||||
"FAIL4"
|
||||
} catch (e: Throwable) {
|
||||
e.checkLinkageError("constructor Bar.<init> can not be called")
|
||||
}
|
||||
}
|
||||
|
||||
fun test5(): String {
|
||||
return try {
|
||||
fooInstance2()
|
||||
"FAIL5"
|
||||
} catch (e: Throwable) {
|
||||
e.checkLinkageError("reference to constructor Foo.<init> can not be evaluated")
|
||||
}
|
||||
}
|
||||
|
||||
fun test6(): String {
|
||||
return try {
|
||||
barInstance2()
|
||||
"FAIL6"
|
||||
} catch (e: Throwable) {
|
||||
e.checkLinkageError("reference to constructor Bar.<init> can not be evaluated")
|
||||
}
|
||||
}
|
||||
|
||||
fun test7(): String {
|
||||
return try {
|
||||
fooAnonymousObject()
|
||||
"FAIL7"
|
||||
} catch (e: Throwable) {
|
||||
e.checkLinkageError("val foo can not be read")
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String = checkResults(test1(), test2(), test3(), test4(), test5(), test6(), test7())
|
||||
|
||||
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 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