[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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
+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.<get-foo>")) return "OK"
|
||||
e.checkLinkageError("foo.<get-foo>", "B")
|
||||
}
|
||||
|
||||
return "FAIL"
|
||||
}
|
||||
|
||||
private fun Throwable.isLinkageError(symbolName: String): Boolean =
|
||||
this::class.simpleName == "IrLinkageError"
|
||||
&& message == "Abstract property accessor $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 property accessor $symbolName is not implemented in non-abstract class $className"
|
||||
val actualMessage = message.orEmpty()
|
||||
|
||||
return if (expectedMessage == actualMessage)
|
||||
"OK"
|
||||
else
|
||||
"EXPECTED: $expectedMessage, ACTUAL: $actualMessage"
|
||||
}
|
||||
|
||||
@@ -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.<get-foo>")) return "OK"
|
||||
e.checkLinkageError("foo.<get-foo>", "B")
|
||||
}
|
||||
|
||||
return "FAIL"
|
||||
}
|
||||
|
||||
private fun Throwable.isLinkageError(symbolName: String): Boolean =
|
||||
this::class.simpleName == "IrLinkageError"
|
||||
&& message == "Abstract property accessor $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 property accessor $symbolName is not implemented in non-abstract class $className"
|
||||
val actualMessage = message.orEmpty()
|
||||
|
||||
return if (expectedMessage == actualMessage)
|
||||
"OK"
|
||||
else
|
||||
"EXPECTED: $expectedMessage, ACTUAL: $actualMessage"
|
||||
}
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
fun box(): String {
|
||||
try {
|
||||
return try {
|
||||
bar()
|
||||
return "FAIL1"
|
||||
"FAIL"
|
||||
} catch (e: Throwable) {
|
||||
if (!e.isLinkageError("/Foo.<init>")) return "FAIL2"
|
||||
e.checkLinkageError("constructor Foo.<init> can not be called")
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
private fun Throwable.isLinkageError(symbolName: String): Boolean =
|
||||
this::class.simpleName == "IrLinkageError" && message?.startsWith("Unlinked IR symbol $symbolName|") == true
|
||||
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"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class D {
|
||||
fun stable(c: C): String = "K"
|
||||
fun stable(c: C): String = "OK"
|
||||
fun foo(): String = stable(C())
|
||||
|
||||
fun exp(e: E): String = "FAIL1"
|
||||
|
||||
@@ -1,20 +1,31 @@
|
||||
fun test1(d: D): String {
|
||||
try {
|
||||
return try {
|
||||
d.bar()
|
||||
} catch(e: Throwable) {
|
||||
if (e.isLinkageError("/E.<init>")) return "O"
|
||||
e.checkLinkageError("constructor E.<init> can not be called")
|
||||
}
|
||||
|
||||
return "FAIL2"
|
||||
}
|
||||
|
||||
fun test2(d: D): String {
|
||||
return d.foo()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return test1(D()) + test2(D())
|
||||
fun box(): String =checkResults(test1(D()), test2(D()))
|
||||
|
||||
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")
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
class C {
|
||||
fun o(): String = "O"
|
||||
val op: String get() = "O"
|
||||
fun o(): String = "FAIL1"
|
||||
val op: String get() = "FAIL2"
|
||||
}
|
||||
|
||||
class E {
|
||||
fun e(): String = "FAIL1"
|
||||
val ep: String get() = "FAIL2"
|
||||
fun e(): String = "FAIL3"
|
||||
val ep: String get() = "FAIL4"
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class C {
|
||||
fun o(): String = "K"
|
||||
val op: String get() = "K"
|
||||
fun o(): String = "OK"
|
||||
val op: String get() = "OK"
|
||||
}
|
||||
|
||||
@@ -19,3 +19,45 @@ class D2 {
|
||||
val expP2: E = E()
|
||||
val barP2: String = expP2.ep
|
||||
}
|
||||
|
||||
fun bar() {
|
||||
fun foo(): E = E()
|
||||
foo()
|
||||
}
|
||||
|
||||
fun baz() {
|
||||
fun qux() {
|
||||
fun foo(): E = E()
|
||||
foo()
|
||||
}
|
||||
qux()
|
||||
}
|
||||
|
||||
fun quux() {
|
||||
class Local {
|
||||
fun corge() {
|
||||
fun foo(): E = E()
|
||||
foo()
|
||||
}
|
||||
}
|
||||
Local().corge()
|
||||
}
|
||||
|
||||
fun grault() {
|
||||
object {
|
||||
fun garply() {
|
||||
fun foo(): E = E()
|
||||
foo()
|
||||
}
|
||||
}.garply()
|
||||
}
|
||||
|
||||
fun waldo() {
|
||||
val fred = object {
|
||||
fun garply() {
|
||||
fun foo(): E = E()
|
||||
foo()
|
||||
}
|
||||
}
|
||||
fred.garply()
|
||||
}
|
||||
|
||||
+68
-18
@@ -1,11 +1,9 @@
|
||||
fun test1(d: D): String {
|
||||
try {
|
||||
return try {
|
||||
d.barF()
|
||||
} catch(e: Throwable) {
|
||||
if (e.isLinkageError("/D.expF")) return "O"
|
||||
e.checkLinkageError("function expF can not be called")
|
||||
}
|
||||
|
||||
return "FAIL3"
|
||||
}
|
||||
|
||||
fun test2(d: D): String {
|
||||
@@ -13,13 +11,11 @@ fun test2(d: D): String {
|
||||
}
|
||||
|
||||
fun test3(d: D): String {
|
||||
try {
|
||||
return try {
|
||||
d.barP1
|
||||
} catch(e: Throwable) {
|
||||
if (e.isLinkageError("/D.expP1.<get-expP1>")) return "O"
|
||||
e.checkLinkageError("property accessor expP1.<get-expP1> can not be called")
|
||||
}
|
||||
|
||||
return "FAIL4"
|
||||
}
|
||||
|
||||
fun test4(d: D): String {
|
||||
@@ -27,20 +23,74 @@ fun test4(d: D): String {
|
||||
}
|
||||
|
||||
fun test5(): String {
|
||||
try {
|
||||
return try {
|
||||
D2().barP2
|
||||
} catch(e: Throwable) {
|
||||
if (e.isLinkageError("/D2.expP2.<get-expP2>")) return "OK"
|
||||
else throw e
|
||||
e.checkLinkageError("property accessor expP2.<get-expP2> can not be called")
|
||||
}
|
||||
|
||||
return "FAIL5"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val result = test1(D()) + test2(D()) + test3(D()) + test4(D()) + test5()
|
||||
return if (result == "OKOKOK") "OK" else result
|
||||
fun test6(): String {
|
||||
return try {
|
||||
bar()
|
||||
return "FAIL6"
|
||||
} catch (e: Throwable) {
|
||||
e.checkLinkageError("function foo can not be called")
|
||||
}
|
||||
}
|
||||
|
||||
private fun Throwable.isLinkageError(symbolName: String): Boolean =
|
||||
this::class.simpleName == "IrLinkageError" && message?.startsWith("Unlinked type in signature of IR symbol $symbolName|") == true
|
||||
fun test7(): String {
|
||||
return try {
|
||||
baz()
|
||||
return "FAIL7"
|
||||
} catch (e: Throwable) {
|
||||
e.checkLinkageError("function foo can not be called")
|
||||
}
|
||||
}
|
||||
|
||||
fun test8(): String {
|
||||
return try {
|
||||
quux()
|
||||
return "FAIL8"
|
||||
} catch (e: Throwable) {
|
||||
e.checkLinkageError("function foo can not be called")
|
||||
}
|
||||
}
|
||||
|
||||
fun test9(): String {
|
||||
return try {
|
||||
grault()
|
||||
return "FAIL9"
|
||||
} catch (e: Throwable) {
|
||||
e.checkLinkageError("function foo can not be called")
|
||||
}
|
||||
}
|
||||
|
||||
fun test10(): String {
|
||||
return try {
|
||||
waldo()
|
||||
return "FAIL10"
|
||||
} catch (e: Throwable) {
|
||||
e.checkLinkageError("function foo can not be called")
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String = checkResults(test1(D()), test2(D()), test3(D()), test4(D()), test5(), test6(), test7(), test8(), test9(), test10())
|
||||
|
||||
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")
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class C {
|
||||
fun o(): String = "K"
|
||||
fun o(): String = "FAIL1"
|
||||
}
|
||||
|
||||
class E {
|
||||
fun e(): String = "FAIL"
|
||||
fun e(): String = "FAIL2"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
class C {
|
||||
fun o(): String = "K"
|
||||
fun o(): String = "OK"
|
||||
}
|
||||
|
||||
@@ -1,20 +1,31 @@
|
||||
fun test1(d: D): String {
|
||||
try {
|
||||
return try {
|
||||
d.bar()
|
||||
} catch(e: Throwable) {
|
||||
if (e.isLinkageError("/D.exp")) return "O"
|
||||
e.checkLinkageError("function exp can not be called")
|
||||
}
|
||||
|
||||
return "FAIL2"
|
||||
}
|
||||
|
||||
fun test2(d: D): String {
|
||||
return d.foo()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return test1(D()) + test2(D())
|
||||
fun box(): String = checkResults(test1(D()), test2(D()))
|
||||
|
||||
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 type in signature of 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")
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class C {
|
||||
fun o(): String = "K"
|
||||
fun o(): String = "FAIL1"
|
||||
}
|
||||
|
||||
class E {
|
||||
fun e(): String = "FAIL"
|
||||
fun e(): String = "FAIL2"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
class C {
|
||||
fun o(): String = "K"
|
||||
fun o(): String = "OK"
|
||||
}
|
||||
|
||||
@@ -1,20 +1,31 @@
|
||||
fun test1(d: D): String {
|
||||
try {
|
||||
return try {
|
||||
d.bar()
|
||||
} catch(e: Throwable) {
|
||||
if (e.isLinkageError("/D.exp")) return "O"
|
||||
e.checkLinkageError("function exp can not be called")
|
||||
}
|
||||
|
||||
return "FAIL2"
|
||||
}
|
||||
|
||||
fun test2(d: D): String {
|
||||
return d.foo()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return test1(D()) + test2(D())
|
||||
fun box(): String =checkResults(test1(D()), test2(D()))
|
||||
|
||||
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 type in signature of 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")
|
||||
}
|
||||
|
||||
@@ -2,3 +2,40 @@ fun bar() {
|
||||
var foo: Foo? = null
|
||||
check(foo == null)
|
||||
}
|
||||
|
||||
fun baz() {
|
||||
fun qux() {
|
||||
var foo: Foo? = null
|
||||
check(foo == null)
|
||||
}
|
||||
qux()
|
||||
}
|
||||
|
||||
fun quux() {
|
||||
class Local {
|
||||
fun corge() {
|
||||
var foo: Foo? = null
|
||||
check(foo == null)
|
||||
}
|
||||
}
|
||||
Local().corge()
|
||||
}
|
||||
|
||||
fun grault() {
|
||||
object {
|
||||
fun garply() {
|
||||
var foo: Foo? = null
|
||||
check(foo == null)
|
||||
}
|
||||
}.garply()
|
||||
}
|
||||
|
||||
fun waldo() {
|
||||
val fred = object {
|
||||
fun garply() {
|
||||
var foo: Foo? = null
|
||||
check(foo == null)
|
||||
}
|
||||
}
|
||||
fred.garply()
|
||||
}
|
||||
|
||||
@@ -1,13 +1,64 @@
|
||||
fun box(): String {
|
||||
try {
|
||||
fun test1(): String {
|
||||
return try {
|
||||
bar()
|
||||
return "FAIL1"
|
||||
} catch (e: Throwable) {
|
||||
if (!e.isLinkageError()) return "FAIL2"
|
||||
e.checkLinkageError("var foo can not be read")
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
private fun Throwable.isLinkageError(): Boolean =
|
||||
this::class.simpleName == "IrLinkageError" && message == "Unlinked type of IR expression"
|
||||
fun test2(): String {
|
||||
return try {
|
||||
baz()
|
||||
return "FAIL2"
|
||||
} catch (e: Throwable) {
|
||||
e.checkLinkageError("var foo can not be read")
|
||||
}
|
||||
}
|
||||
|
||||
fun test3(): String {
|
||||
return try {
|
||||
quux()
|
||||
return "FAIL3"
|
||||
} catch (e: Throwable) {
|
||||
e.checkLinkageError("var foo can not be read")
|
||||
}
|
||||
}
|
||||
|
||||
fun test4(): String {
|
||||
return try {
|
||||
grault()
|
||||
return "FAIL4"
|
||||
} catch (e: Throwable) {
|
||||
e.checkLinkageError("var foo can not be read")
|
||||
}
|
||||
}
|
||||
|
||||
fun test5(): String {
|
||||
return try {
|
||||
waldo()
|
||||
return "FAIL5"
|
||||
} catch (e: Throwable) {
|
||||
e.checkLinkageError("var foo can not be read")
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = checkResults(test1(), test2(), test3(), test4(), test5())
|
||||
|
||||
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")
|
||||
}
|
||||
|
||||
+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")
|
||||
}
|
||||
|
||||
+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")
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
fun foo() = "FAIL1"
|
||||
fun foo() = "FAIL"
|
||||
|
||||
@@ -1 +1 @@
|
||||
// fun foo() = "FAIL1"
|
||||
// fun foo() = "FAIL"
|
||||
|
||||
+14
-7
@@ -1,12 +1,19 @@
|
||||
fun box(): String {
|
||||
try {
|
||||
return bar()
|
||||
return try {
|
||||
bar()
|
||||
} catch(e: Throwable) {
|
||||
if (e.isLinkageError("/foo")) return "OK"
|
||||
e.checkLinkageError("function foo can not be called")
|
||||
}
|
||||
|
||||
return "FAIL2"
|
||||
}
|
||||
|
||||
private fun Throwable.isLinkageError(symbolName: String): Boolean =
|
||||
this::class.simpleName == "IrLinkageError" && message?.startsWith("Unlinked IR symbol $symbolName|") == true
|
||||
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"
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
val foo: String get() = "FAIL1"
|
||||
val foo: String get() = "FAIL"
|
||||
|
||||
@@ -1 +1 @@
|
||||
// val foo: String get() = "FAIL1"
|
||||
// val foo: String get() = "FAIL"
|
||||
|
||||
+14
-7
@@ -1,12 +1,19 @@
|
||||
fun box(): String {
|
||||
try {
|
||||
return bar()
|
||||
return try {
|
||||
bar()
|
||||
} catch(e: Throwable) {
|
||||
if (e.isLinkageError("/foo.<get-foo>")) return "OK"
|
||||
e.checkLinkageError("property accessor foo.<get-foo> can not be called")
|
||||
}
|
||||
|
||||
return "FAIL2"
|
||||
}
|
||||
|
||||
private fun Throwable.isLinkageError(symbolName: String): Boolean =
|
||||
this::class.simpleName == "IrLinkageError" && message?.startsWith("Unlinked IR symbol $symbolName|") == true
|
||||
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"
|
||||
}
|
||||
|
||||
+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")
|
||||
}
|
||||
|
||||
+26
-11
@@ -1,13 +1,28 @@
|
||||
fun box(): String {
|
||||
try {
|
||||
callFoo()
|
||||
return "FAIL1"
|
||||
} catch(e: Throwable) {
|
||||
if (!e.isLinkageError("/foo")) return "FAIL2"
|
||||
}
|
||||
|
||||
return bar()
|
||||
fun test1() = try {
|
||||
callFoo()
|
||||
"FAIL"
|
||||
} catch (e: Throwable) {
|
||||
e.checkLinkageError("function foo can not be called")
|
||||
}
|
||||
|
||||
private fun Throwable.isLinkageError(symbolName: String): Boolean =
|
||||
this::class.simpleName == "IrLinkageError" && message?.startsWith("Unlinked IR symbol $symbolName|") == true
|
||||
fun test2() = bar()
|
||||
|
||||
fun box(): String = checkResults(test1(), test2())
|
||||
|
||||
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