[IR][tests] Make ABI compatibility tests less verbose, part 2

This commit is contained in:
Dmitriy Dolovov
2022-08-23 15:00:26 +02:00
parent db1c8cc7a7
commit 24d8ac97cd
24 changed files with 173 additions and 1242 deletions
+13 -124
View File
@@ -1,127 +1,16 @@
fun test1(): String {
return try {
publicToInternalFunction()
"OK"
} catch(e: Throwable) {
e.message.orEmpty().ifBlank { "FAIL1" }
}
}
import abitestutils.abiTest
fun test2(): String {
return try {
publicToPrivateFunction()
"FAIL2"
} catch(e: Throwable) {
e.checkLinkageError("function publicToPrivateFunction can not be called")
}
}
fun test3(): String {
fun box() = abiTest {
val c = ContainerImpl()
return try {
c.publicToProtectedFunction()
"OK"
} catch(e: Throwable) {
e.message.orEmpty().ifBlank { "FAIL3" }
}
}
fun test4(): String {
val c = ContainerImpl()
return try {
c.publicToInternalFunction()
"FAIL4"
} catch(e: Throwable) {
e.checkLinkageError("function publicToInternalFunction can not be called")
}
}
fun test5(): String {
val c = ContainerImpl()
return try {
c.publicToPrivateFunction()
"FAIL5"
} catch(e: Throwable) {
e.checkLinkageError("function publicToPrivateFunction can not be called")
}
}
fun test6(): String {
val c = ContainerImpl()
return try {
c.publicToProtectedFunctionAccess()
"OK"
} catch(e: Throwable) {
e.message.orEmpty().ifBlank { "FAIL6" }
}
}
fun test7(): String {
val c = ContainerImpl()
return try {
c.publicToInternalFunctionAccess()
"FAIL7"
} catch(e: Throwable) {
e.checkLinkageError("function publicToInternalFunction can not be called")
}
}
fun test8(): String {
val c = ContainerImpl()
return try {
c.publicToPrivateFunctionAccess()
"FAIL8"
} catch(e: Throwable) {
e.checkLinkageError("function publicToPrivateFunction can not be called")
}
}
fun test9(): String {
val c = ContainerImpl()
return try {
c.protectedToPublicFunctionAccess()
"OK"
} catch(e: Throwable) {
e.message.orEmpty().ifBlank { "FAIL9" }
}
}
fun test10(): String {
val c = ContainerImpl()
return try {
c.protectedToInternalFunctionAccess()
"FAIL10"
} catch(e: Throwable) {
e.checkLinkageError("function protectedToInternalFunction can not be called")
}
}
fun test11(): String {
val c = ContainerImpl()
return try {
c.protectedToPrivateFunctionAccess()
"FAIL11"
} catch(e: Throwable) {
e.checkLinkageError("function protectedToPrivateFunction can not be called")
}
}
fun box() = checkResults(test1(), test2(), test3(), test4(), test5(), test6(), test7(), test8(), test9(), test10(), test11())
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")
expectSuccess(42) { publicToInternalFunction() }
expectFailure(prefixed("function publicToPrivateFunction can not be called")) { publicToPrivateFunction() }
expectSuccess(42) { c.publicToProtectedFunction() }
expectFailure(prefixed("function publicToInternalFunction can not be called")) { c.publicToInternalFunction() }
expectFailure(prefixed("function publicToPrivateFunction can not be called")) { c.publicToPrivateFunction() }
expectSuccess(42) { c.publicToProtectedFunctionAccess() }
expectFailure(prefixed("function publicToInternalFunction can not be called")) { c.publicToInternalFunctionAccess() }
expectFailure(prefixed("function publicToPrivateFunction can not be called")) { c.publicToPrivateFunctionAccess() }
expectSuccess(42) { c.protectedToPublicFunctionAccess() }
expectFailure(prefixed("function protectedToInternalFunction can not be called")) { c.protectedToInternalFunctionAccess() }
expectFailure(prefixed("function protectedToPrivateFunction can not be called")) { c.protectedToPrivateFunctionAccess() }
}
+24 -235
View File
@@ -1,238 +1,27 @@
fun test1(): String {
return try {
publicToInternalProperty1
"OK"
} catch(e: Throwable) {
e.message.orEmpty().ifBlank { "FAIL1" }
}
}
import abitestutils.abiTest
fun test2(): String {
return try {
publicToInternalProperty2
"OK"
} catch(e: Throwable) {
e.message.orEmpty().ifBlank { "FAIL2" }
}
}
fun test3(): String {
return try {
publicToPrivateProperty1
"FAIL3"
} catch(e: Throwable) {
e.checkLinkageError("property accessor publicToPrivateProperty1.<get-publicToPrivateProperty1> can not be called")
}
}
fun test4(): String {
return try {
publicToPrivateProperty2
"FAIL4"
} catch(e: Throwable) {
e.checkLinkageError("property accessor publicToPrivateProperty2.<get-publicToPrivateProperty2> can not be called")
}
}
fun test5(): String {
fun box() = abiTest {
val c = ContainerImpl()
return try {
c.publicToProtectedProperty1
"OK"
} catch(e: Throwable) {
e.message.orEmpty().ifBlank { "FAIL5" }
}
}
fun test6(): String {
val c = ContainerImpl()
return try {
c.publicToProtectedProperty2
"OK"
} catch(e: Throwable) {
e.message.orEmpty().ifBlank { "FAIL6" }
}
}
fun test7(): String {
val c = ContainerImpl()
return try {
c.publicToInternalProperty1
"FAIL7"
} catch(e: Throwable) {
e.checkLinkageError("property accessor publicToInternalProperty1.<get-publicToInternalProperty1> can not be called")
}
}
fun test8(): String {
val c = ContainerImpl()
return try {
c.publicToInternalProperty2
"FAIL8"
} catch(e: Throwable) {
e.checkLinkageError("property accessor publicToInternalProperty2.<get-publicToInternalProperty2> can not be called")
}
}
fun test9(): String {
val c = ContainerImpl()
return try {
c.publicToPrivateProperty1
"FAIL9"
} catch(e: Throwable) {
e.checkLinkageError("property accessor publicToPrivateProperty1.<get-publicToPrivateProperty1> can not be called")
}
}
fun test10(): String {
val c = ContainerImpl()
return try {
c.publicToPrivateProperty2
"FAIL10"
} catch(e: Throwable) {
e.checkLinkageError("property accessor publicToPrivateProperty2.<get-publicToPrivateProperty2> can not be called")
}
}
fun test11(): String {
val c = ContainerImpl()
return try {
c.publicToProtectedProperty1Access()
"OK"
} catch(e: Throwable) {
e.message.orEmpty().ifBlank { "FAIL11" }
}
}
fun test12(): String {
val c = ContainerImpl()
return try {
c.publicToProtectedProperty2Access()
"OK"
} catch(e: Throwable) {
e.message.orEmpty().ifBlank { "FAIL12" }
}
}
fun test13(): String {
val c = ContainerImpl()
return try {
c.publicToInternalProperty1Access()
"FAIL13"
} catch(e: Throwable) {
e.checkLinkageError("property accessor publicToInternalProperty1.<get-publicToInternalProperty1> can not be called")
}
}
fun test14(): String {
val c = ContainerImpl()
return try {
c.publicToInternalProperty2Access()
"FAIL14"
} catch(e: Throwable) {
e.checkLinkageError("property accessor publicToInternalProperty2.<get-publicToInternalProperty2> can not be called")
}
}
fun test15(): String {
val c = ContainerImpl()
return try {
c.publicToPrivateProperty1Access()
"FAIL15"
} catch(e: Throwable) {
e.checkLinkageError("property accessor publicToPrivateProperty1.<get-publicToPrivateProperty1> can not be called")
}
}
fun test16(): String {
val c = ContainerImpl()
return try {
c.publicToPrivateProperty2Access()
"FAIL16"
} catch(e: Throwable) {
e.checkLinkageError("property accessor publicToPrivateProperty2.<get-publicToPrivateProperty2> can not be called")
}
}
fun test17(): String {
val c = ContainerImpl()
return try {
c.protectedToPublicProperty1Access()
"OK"
} catch(e: Throwable) {
e.message.orEmpty().ifBlank { "FAIL17" }
}
}
fun test18(): String {
val c = ContainerImpl()
return try {
c.protectedToPublicProperty2Access()
"OK"
} catch(e: Throwable) {
e.message.orEmpty().ifBlank { "FAIL18" }
}
}
fun test19(): String {
val c = ContainerImpl()
return try {
c.protectedToInternalProperty1Access()
"FAIL19"
} catch(e: Throwable) {
e.checkLinkageError("property accessor protectedToInternalProperty1.<get-protectedToInternalProperty1> can not be called")
}
}
fun test20(): String {
val c = ContainerImpl()
return try {
c.protectedToInternalProperty2Access()
"FAIL20"
} catch(e: Throwable) {
e.checkLinkageError("property accessor protectedToInternalProperty2.<get-protectedToInternalProperty2> can not be called")
}
}
fun test21(): String {
val c = ContainerImpl()
return try {
c.protectedToPrivateProperty1Access()
"FAIL21"
} catch(e: Throwable) {
e.checkLinkageError("property accessor protectedToPrivateProperty1.<get-protectedToPrivateProperty1> can not be called")
}
}
fun test22(): String {
val c = ContainerImpl()
return try {
c.protectedToPrivateProperty2Access()
"FAIL22"
} catch(e: Throwable) {
e.checkLinkageError("property accessor protectedToPrivateProperty2.<get-protectedToPrivateProperty2> can not be called")
}
}
fun box() = checkResults(
test1(), test2(), test3(), test4(), test5(), test6(), test7(), test8(), test9(), test10(),
test11(), test12(), test13(), test14(), test15(), test16(), test17(), test18(), test19(), test20(),
test21(), test22())
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")
expectSuccess(42) { publicToInternalProperty1 }
expectSuccess(42) { publicToInternalProperty2 }
expectFailure(prefixed("property accessor publicToPrivateProperty1.<get-publicToPrivateProperty1> can not be called")) { publicToPrivateProperty1 }
expectFailure(prefixed("property accessor publicToPrivateProperty2.<get-publicToPrivateProperty2> can not be called")) { publicToPrivateProperty2 }
expectSuccess(42) { c.publicToProtectedProperty1 }
expectSuccess(42) { c.publicToProtectedProperty2 }
expectFailure(prefixed("property accessor publicToInternalProperty1.<get-publicToInternalProperty1> can not be called")) { c.publicToInternalProperty1 }
expectFailure(prefixed("property accessor publicToInternalProperty2.<get-publicToInternalProperty2> can not be called")) { c.publicToInternalProperty2 }
expectFailure(prefixed("property accessor publicToPrivateProperty1.<get-publicToPrivateProperty1> can not be called")) { c.publicToPrivateProperty1 }
expectFailure(prefixed("property accessor publicToPrivateProperty2.<get-publicToPrivateProperty2> can not be called")) { c.publicToPrivateProperty2 }
expectSuccess(42) { c.publicToProtectedProperty1Access() }
expectSuccess(42) { c.publicToProtectedProperty2Access() }
expectFailure(prefixed("property accessor publicToInternalProperty1.<get-publicToInternalProperty1> can not be called")) { c.publicToInternalProperty1Access() }
expectFailure(prefixed("property accessor publicToInternalProperty2.<get-publicToInternalProperty2> can not be called")) { c.publicToInternalProperty2Access() }
expectFailure(prefixed("property accessor publicToPrivateProperty1.<get-publicToPrivateProperty1> can not be called")) { c.publicToPrivateProperty1Access() }
expectFailure(prefixed("property accessor publicToPrivateProperty2.<get-publicToPrivateProperty2> can not be called")) { c.publicToPrivateProperty2Access() }
expectSuccess(42) { c.protectedToPublicProperty1Access() }
expectSuccess(42) { c.protectedToPublicProperty2Access() }
expectFailure(prefixed("property accessor protectedToInternalProperty1.<get-protectedToInternalProperty1> can not be called")) { c.protectedToInternalProperty1Access() }
expectFailure(prefixed("property accessor protectedToInternalProperty2.<get-protectedToInternalProperty2> can not be called")) { c.protectedToInternalProperty2Access() }
expectFailure(prefixed("property accessor protectedToPrivateProperty1.<get-protectedToPrivateProperty1> can not be called")) { c.protectedToPrivateProperty1Access() }
expectFailure(prefixed("property accessor protectedToPrivateProperty2.<get-protectedToPrivateProperty2> can not be called")) { c.protectedToPrivateProperty2Access() }
}
@@ -1,81 +1,16 @@
import abitestutils.abiTest
import lib1.A
import lib2.B
import lib2.B1
import lib2.B2
fun test1(): String {
fun box() = abiTest {
val a: A = B()
return try {
val answer: Int = a.foo() // <-- should throw linkage error here
println(answer)
"FAIL1"
} catch (e: Throwable) {
e.checkLinkageError("foo", "B")
}
}
fun test2(): String {
val a: A = B()
return try {
val answer: Int = a.bar() // <-- should throw linkage error here
println(answer)
"FAIL2"
} catch (e: Throwable) {
e.checkLinkageError("bar", "B")
}
}
fun test3(): String {
val a: A = B()
val baz = a.baz()
return if (baz == -42) "OK" else "baz=$baz"
}
fun test4(): String {
val b = B()
return try {
val answer: Int = b.unlinkedFunctionUsage // <-- should throw linkage error here
println(answer)
"FAIL3"
} catch (e: Throwable) {
e.checkLinkageError("foo", "B")
}
}
fun test5(): String {
return try {
B1()
"FAIL4"
} catch (e: Throwable) {
e.checkLinkageError("foo", "B1")
}
}
fun test6(): String {
return try {
B2()
"FAIL5"
} catch (e: Throwable) {
e.checkLinkageError("bar", "B2")
}
}
fun box(): String = checkResults(test1(), test2(), test3(), test4(), test5(), test6())
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"
}
private fun checkResults(vararg results: String): String = when {
results.isEmpty() -> "no results to check"
results.all { it == "OK" } -> "OK"
else -> results.joinToString("\n")
expectFailure(nonImplementedCallable("function foo", "class B")) { a.foo() }
expectFailure(nonImplementedCallable("function bar", "class B")) { a.bar() }
expectSuccess(-42) { a.baz() }
expectFailure(nonImplementedCallable("function foo", "class B")) { b.unlinkedFunctionUsage }
expectFailure(nonImplementedCallable("function foo", "class B1")) { B1() }
expectFailure(nonImplementedCallable("function bar", "class B2")) { B2() }
}
@@ -1,60 +1,13 @@
import abitestutils.abiTest
import lib1.A
import lib2.B
import lib2.B1
fun test1(): String {
fun box() = abiTest {
val a: A = B()
return try {
val answer: Int = a.foo() // <-- should throw linkage error here
println(answer)
"FAIL1"
} catch(e: Throwable) {
e.checkLinkageError("foo", "B")
}
}
fun test2(): String {
val a: A = B()
val bar = a.bar()
return if (bar == -42) "OK" else "bar=$bar"
}
fun test3(): String {
val b = B()
return try {
val answer: Int = b.unlinkedFunctionUsage // <-- should throw linkage error here
println(answer)
"FAIL2"
} catch (e: Throwable) {
e.checkLinkageError("foo", "B")
}
}
fun test4(): String {
return try {
B1()
"FAIL3"
} catch (e: Throwable) {
e.checkLinkageError("foo", "B1")
}
}
fun box(): String = checkResults(test1(), test2(), test3(), test4())
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"
}
private fun checkResults(vararg results: String): String = when {
results.isEmpty() -> "no results to check"
results.all { it == "OK" } -> "OK"
else -> results.joinToString("\n")
expectFailure(nonImplementedCallable("function foo", "class B")) { a.foo() }
expectSuccess(-42) { a.bar() }
expectFailure(nonImplementedCallable("function foo", "class B")) { b.unlinkedFunctionUsage }
expectFailure(nonImplementedCallable("function foo", "class B1")) { B1() }
}
@@ -1,3 +1,4 @@
import abitestutils.abiTest
import lib1.A
import lib2.B
import lib2.B1
@@ -5,125 +6,18 @@ import lib2.B2
import lib2.B3
import lib2.B4
fun test1(): String {
fun box() = abiTest {
val a: A = B()
return try {
val answer: Int = a.foo1 // <-- should throw linkage error here
println(answer)
"FAIL1"
} catch(e: Throwable) {
e.checkLinkageError("foo1.<get-foo1>", "B")
}
}
fun test2(): String {
val a: A = B()
return try {
val answer: Int = a.foo2 // <-- should throw linkage error here
println(answer)
"FAIL2"
} catch(e: Throwable) {
e.checkLinkageError("foo2.<get-foo2>", "B")
}
}
fun test3(): String {
val a: A = B()
return try {
val answer: Int = a.bar1 // <-- should throw linkage error here
println(answer)
"FAIL1"
} catch(e: Throwable) {
e.checkLinkageError("bar1.<get-bar1>", "B")
}
}
fun test4(): String {
val a: A = B()
return try {
val answer: Int = a.bar2 // <-- should throw linkage error here
println(answer)
"FAIL2"
} catch(e: Throwable) {
e.checkLinkageError("bar2.<get-bar2>", "B")
}
}
fun test5(): String {
val a: A = B()
val baz1 = a.baz1
return if (baz1 == -42) "OK" else "baz1=$baz1"
}
fun test6(): String {
val a: A = B()
val baz2 = a.baz2
return if (baz2 == -42) "OK" else "baz2=$baz2"
}
fun test7(): String {
val b = B()
return try {
val answer: Int = b.unlinkedPropertyUsage // <-- should throw linkage error here
println(answer)
"FAIL3"
} catch (e: Throwable) {
e.checkLinkageError("foo1.<get-foo1>", "B")
}
}
fun test8(): String {
return try {
B1()
"FAIL4"
} catch (e: Throwable) {
e.checkLinkageError("foo1.<get-foo1>", "B1")
}
}
fun test9(): String {
return try {
B2()
"FAIL5"
} catch (e: Throwable) {
e.checkLinkageError("foo2.<get-foo2>", "B2")
}
}
fun test10(): String {
return try {
B3()
"FAIL6"
} catch (e: Throwable) {
e.checkLinkageError("bar1.<get-bar1>", "B3")
}
}
fun test11(): String {
return try {
B4()
"FAIL7"
} catch (e: Throwable) {
e.checkLinkageError("bar2.<get-bar2>", "B4")
}
}
fun box(): String = checkResults(test1(), test2(), test3(), test4(), test5(), test6(), test7(), test8(), test9(), test10(), test11())
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"
}
private fun checkResults(vararg results: String): String = when {
results.isEmpty() -> "no results to check"
results.all { it == "OK" } -> "OK"
else -> results.joinToString("\n")
expectFailure(nonImplementedCallable("property accessor foo1.<get-foo1>", "class B")) { a.foo1 }
expectFailure(nonImplementedCallable("property accessor foo2.<get-foo2>", "class B")) { a.foo2 }
expectFailure(nonImplementedCallable("property accessor bar1.<get-bar1>", "class B")) { a.bar1 }
expectFailure(nonImplementedCallable("property accessor bar2.<get-bar2>", "class B")) { a.bar2 }
expectSuccess(-42) { a.baz1 }
expectSuccess(-42) { a.baz2 }
expectFailure(nonImplementedCallable("property accessor foo1.<get-foo1>", "class B")) { b.unlinkedPropertyUsage }
expectFailure(nonImplementedCallable("property accessor foo1.<get-foo1>", "class B1")) { B1() }
expectFailure(nonImplementedCallable("property accessor foo2.<get-foo2>", "class B2")) { B2() }
expectFailure(nonImplementedCallable("property accessor bar1.<get-bar1>", "class B3")) { B3() }
expectFailure(nonImplementedCallable("property accessor bar2.<get-bar2>", "class B4")) { B4() }
}
@@ -1,60 +1,13 @@
import abitestutils.abiTest
import lib1.A
import lib2.B
import lib2.B1
fun test1(): String {
fun box() = abiTest {
val a: A = B()
return try {
val answer: Int = a.foo // <-- should throw linkage error here
println(answer)
"FAIL"
} catch(e: Throwable) {
e.checkLinkageError("foo.<get-foo>", "B")
}
}
fun test2(): String {
val a: A = B()
val bar = a.bar
return if (bar == -42) "OK" else "bar=$bar"
}
fun test3(): String {
val b = B()
return try {
val answer: Int = b.unlinkedPropertyUsage // <-- should throw linkage error here
println(answer)
"FAIL2"
} catch (e: Throwable) {
e.checkLinkageError("foo.<get-foo>", "B")
}
}
fun test4(): String {
return try {
B1()
"FAIL3"
} catch (e: Throwable) {
e.checkLinkageError("foo.<get-foo>", "B1")
}
}
fun box(): String = checkResults(test1(), test2(), test3(), test4())
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"
}
private fun checkResults(vararg results: String): String = when {
results.isEmpty() -> "no results to check"
results.all { it == "OK" } -> "OK"
else -> results.joinToString("\n")
expectFailure(nonImplementedCallable("property accessor foo.<get-foo>", "class B")) { a.foo }
expectSuccess(-42) { a.bar }
expectFailure(nonImplementedCallable("property accessor foo.<get-foo>", "class B")) { b.unlinkedPropertyUsage }
expectFailure(nonImplementedCallable("property accessor foo.<get-foo>", "class B1")) { B1() }
}
@@ -1,26 +1,8 @@
import abitestutils.abiTest
import lib1.A
import lib2.B
fun box(): String {
fun box() = abiTest {
val a: A = B()
return try {
val answer: Int = a.foo() // <-- should throw linkage error here
println(answer)
"FAIL"
} catch (e: Throwable) {
e.checkLinkageError("foo", "B")
}
}
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"
expectFailure(nonImplementedCallable("function foo", "class B")) { a.foo() }
}
@@ -1,26 +1,8 @@
import abitestutils.abiTest
import lib1.A
import lib2.B
fun box(): String {
fun box() = abiTest {
val a: A = B()
return try {
val answer: Int = a.foo() // <-- should throw linkage error here
println(answer)
"FAIL"
} catch (e: Throwable) {
e.checkLinkageError("foo", "B")
}
}
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"
expectFailure(nonImplementedCallable("function foo", "class B")) { a.foo() }
}
@@ -1,26 +1,8 @@
import abitestutils.abiTest
import lib1.A
import lib2.B
fun box(): String {
fun box() = abiTest {
val a: A = B()
return try {
val answer: Int = a.foo // <-- should throw linkage error here
println(answer)
"FAIL"
} catch (e: Throwable) {
e.checkLinkageError("foo.<get-foo>", "B")
}
}
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"
expectFailure(nonImplementedCallable("property accessor foo.<get-foo>", "class B")) { a.foo }
}
@@ -1,26 +1,8 @@
import abitestutils.abiTest
import lib1.A
import lib2.B
fun box(): String {
fun box() = abiTest {
val a: A = B()
return try {
val answer: Int = a.foo // <-- should throw linkage error here
println(answer)
"FAIL"
} catch (e: Throwable) {
e.checkLinkageError("foo.<get-foo>", "B")
}
}
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"
expectFailure(nonImplementedCallable("property accessor foo.<get-foo>", "class B")) { a.foo }
}
@@ -1,20 +1,5 @@
fun box(): String {
return try {
bar()
"FAIL"
} catch (e: Throwable) {
e.checkLinkageError("constructor Foo.<init> can not be called")
}
}
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"
import abitestutils.abiTest
fun box() = abiTest {
expectFailure(prefixed("constructor Foo.<init> can not be called")) { bar() }
}
@@ -1,31 +1,7 @@
fun test1(d: D): String {
return try {
d.bar()
} catch(e: Throwable) {
e.checkLinkageError("constructor E.<init> can not be called")
}
}
fun test2(d: D): String {
return d.foo()
}
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 checkResults(vararg results: String): String = when {
results.isEmpty() -> "no results to check"
results.all { it == "OK" } -> "OK"
else -> results.joinToString("\n")
import abitestutils.abiTest
fun box() = abiTest {
val d = D()
expectFailure(prefixed("constructor E.<init> can not be called")) { d.bar() }
expectSuccess { d.foo() }
}
+14 -95
View File
@@ -1,96 +1,15 @@
fun test1(d: D): String {
return try {
d.barF()
} catch(e: Throwable) {
e.checkLinkageError("function expF can not be called")
}
}
fun test2(d: D): String {
return d.fooF()
}
fun test3(d: D): String {
return try {
d.barP1
} catch(e: Throwable) {
e.checkLinkageError("property accessor expP1.<get-expP1> can not be called")
}
}
fun test4(d: D): String {
return d.fooP1
}
fun test5(): String {
return try {
D2().barP2
} catch(e: Throwable) {
e.checkLinkageError("property accessor expP2.<get-expP2> can not be called")
}
}
fun test6(): String {
return try {
bar()
return "FAIL6"
} catch (e: Throwable) {
e.checkLinkageError("function foo can not be called")
}
}
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")
import abitestutils.abiTest
fun box() = abiTest {
val d = D()
expectFailure(prefixed("function expF can not be called")) { d.barF() }
expectSuccess { d.fooF() }
expectFailure(prefixed("property accessor expP1.<get-expP1> can not be called")) { d.barP1 }
expectSuccess { d.fooP1 }
expectFailure(prefixed("property accessor expP2.<get-expP2> can not be called")) { D2().barP2 }
expectFailure(prefixed("function foo can not be called")) { bar() }
expectFailure(prefixed("function foo can not be called")) { baz() }
expectFailure(prefixed("function foo can not be called")) { quux() }
expectFailure(prefixed("function foo can not be called")) { grault() }
expectFailure(prefixed("function foo can not be called")) { waldo() }
}
@@ -1,31 +1,7 @@
fun test1(d: D): String {
return try {
d.bar()
} catch(e: Throwable) {
e.checkLinkageError("function exp can not be called")
}
}
fun test2(d: D): String {
return d.foo()
}
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 checkResults(vararg results: String): String = when {
results.isEmpty() -> "no results to check"
results.all { it == "OK" } -> "OK"
else -> results.joinToString("\n")
import abitestutils.abiTest
fun box() = abiTest {
val d = D()
expectFailure(prefixed("function exp can not be called")) { d.bar() }
expectSuccess { d.foo() }
}
@@ -1,31 +1,7 @@
fun test1(d: D): String {
return try {
d.bar()
} catch(e: Throwable) {
e.checkLinkageError("function exp can not be called")
}
}
fun test2(d: D): String {
return d.foo()
}
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 checkResults(vararg results: String): String = when {
results.isEmpty() -> "no results to check"
results.all { it == "OK" } -> "OK"
else -> results.joinToString("\n")
import abitestutils.abiTest
fun box() = abiTest {
val d = D()
expectFailure(prefixed("function exp can not be called")) { d.bar() }
expectSuccess { d.foo() }
}
@@ -1,64 +1,9 @@
fun test1(): String {
return try {
bar()
return "FAIL1"
} catch (e: Throwable) {
e.checkLinkageError("var foo can not be read")
}
}
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")
import abitestutils.abiTest
fun box() = abiTest {
expectFailure(prefixed("var foo can not be read")) { bar() }
expectFailure(prefixed("var foo can not be read")) { baz() }
expectFailure(prefixed("var foo can not be read")) { quux() }
expectFailure(prefixed("var foo can not be read")) { grault() }
expectFailure(prefixed("var foo can not be read")) { waldo() }
}
+7 -38
View File
@@ -1,39 +1,8 @@
fun test1(): String {
return try {
qux(true)
} catch(e: Throwable) {
e.checkLinkageError("function exp_foo can not be called")
}
}
fun test2(): String = qux(false)
fun test3(): String {
return try {
qux2(true)
} catch(e: Throwable) {
e.checkLinkageError("function exp_foo can not be called")
}
}
fun test4(): String = qux2(false)
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 checkResults(vararg results: String): String = when {
results.isEmpty() -> "no results to check"
results.all { it == "OK" } -> "OK"
else -> results.joinToString("\n")
import abitestutils.abiTest
fun box() = abiTest {
expectFailure(prefixed("function exp_foo can not be called")) { qux(true) }
expectSuccess { qux(false) }
expectFailure(prefixed("function exp_foo can not be called")) { qux2(true) }
expectSuccess { qux2(false) }
}
+10 -81
View File
@@ -1,82 +1,11 @@
fun test1(): String {
return try {
fooVariableType()
"FAIL1"
} catch (e: Throwable) {
e.checkLinkageError("val foo can not be read")
}
}
fun test2(): String {
return try {
barVariableType()
"FAIL2"
} catch (e: Throwable) {
e.checkLinkageError("val bar can not be read")
}
}
fun test3(): String {
return try {
fooInstance()
"FAIL3"
} catch (e: Throwable) {
e.checkLinkageError("constructor Foo.<init> can not be called")
}
}
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")
import abitestutils.abiTest
fun box() = abiTest {
expectFailure(prefixed("val foo can not be read")) { fooVariableType() }
expectFailure(prefixed("val bar can not be read")) { barVariableType() }
expectFailure(prefixed("constructor Foo.<init> can not be called")) { fooInstance() }
expectFailure(prefixed("constructor Bar.<init> can not be called")) { barInstance() }
expectFailure(prefixed("reference to constructor Foo.<init> can not be evaluated")) { fooInstance2() }
expectFailure(prefixed("reference to constructor Bar.<init> can not be evaluated")) { barInstance2() }
expectFailure(prefixed("val foo can not be read")) { fooAnonymousObject() }
}
+4 -18
View File
@@ -1,19 +1,5 @@
fun box(): String {
return try {
bar()
} catch(e: Throwable) {
e.checkLinkageError("function foo can not be called")
}
}
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"
import abitestutils.abiTest
fun box() = abiTest {
expectFailure(prefixed("function foo can not be called")) { bar() }
}
+4 -18
View File
@@ -1,19 +1,5 @@
fun box(): String {
return try {
bar()
} catch(e: Throwable) {
e.checkLinkageError("property accessor foo.<get-foo> can not be called")
}
}
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"
import abitestutils.abiTest
fun box() = abiTest {
expectFailure(prefixed("property accessor foo.<get-foo> can not be called")) { bar() }
}
+4 -2
View File
@@ -1,3 +1,5 @@
fun box(): String {
return C2().foo() + I2().foo()
import abitestutils.abiTest
fun box() = abiTest {
expectSuccess { C2().foo() + I2().foo() }
}
+4 -2
View File
@@ -1,3 +1,5 @@
fun box(): String {
return C2().foo + I2().foo
import abitestutils.abiTest
fun box() = abiTest {
expectSuccess { C2().foo + I2().foo }
}
+9 -48
View File
@@ -1,49 +1,10 @@
fun test1(): String {
return try {
qux(true)
} catch(e: Throwable) {
e.checkLinkageError("property accessor exp_foo.<get-exp_foo> can not be called")
}
}
fun test2(): String = qux(false)
fun test3(): String {
return try {
qux2(true)
} catch(e: Throwable) {
e.checkLinkageError("property accessor exp_foo.<get-exp_foo> can not be called")
}
}
fun test4(): String = qux2(false)
fun test5(): String {
return try {
return qux3(true)
} catch(e: Throwable) {
e.checkLinkageError("property accessor exp_foo.<get-exp_foo> can not be called")
}
}
fun test6(): String = qux3(false)
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 checkResults(vararg results: String): String = when {
results.isEmpty() -> "no results to check"
results.all { it == "OK" } -> "OK"
else -> results.joinToString("\n")
import abitestutils.abiTest
fun box() = abiTest {
expectFailure(prefixed("property accessor exp_foo.<get-exp_foo> can not be called")) { qux(true) }
expectSuccess { qux(false) }
expectFailure(prefixed("property accessor exp_foo.<get-exp_foo> can not be called")) { qux2(true) }
expectSuccess { qux2(false) }
expectFailure(prefixed("property accessor exp_foo.<get-exp_foo> can not be called")) { qux3(true) }
expectSuccess { qux3(false) }
}
+5 -27
View File
@@ -1,28 +1,6 @@
fun test1() = try {
callFoo()
"FAIL"
} catch (e: Throwable) {
e.checkLinkageError("function foo can not be called")
}
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")
import abitestutils.abiTest
fun box() = abiTest {
expectFailure(prefixed("function foo can not be called")) { callFoo() }
expectSuccess { bar() }
}