[PL][tests] K/JS: Avoid any unexpected warnings to appear in tests
This commit is contained in:
committed by
Space Team
parent
715aba3d18
commit
938146749d
@@ -74,33 +74,33 @@ fun box() = abiTest {
|
||||
}
|
||||
|
||||
// Shortcuts:
|
||||
private inline fun TestBuilder.success(expectedOutcome: String, noinline block: () -> Any) =
|
||||
private fun TestBuilder.success(expectedOutcome: String, block: () -> Any) =
|
||||
expectSuccess(expectedOutcome) { block().toString() }
|
||||
|
||||
private inline fun TestBuilder.successViaException(testExceptionId: String, noinline block: () -> Unit) =
|
||||
private fun TestBuilder.successViaException(testExceptionId: String, block: () -> Unit) =
|
||||
expectFailure(custom { (it as? TestException)?.id == testExceptionId }, block)
|
||||
|
||||
private inline fun TestBuilder.inaccessible(className: String, noinline block: () -> Unit) = expectFailure(
|
||||
private fun TestBuilder.inaccessible(className: String, block: () -> Unit) = expectFailure(
|
||||
linkage("Constructor '$className.<init>' can not be called: Private constructor declared in module <lib1> can not be accessed in module <lib2>"),
|
||||
block
|
||||
)
|
||||
|
||||
private inline fun TestBuilder.unlinkedSymbolInValueParameter(signature: String, noinline block: () -> Unit) {
|
||||
private fun TestBuilder.unlinkedSymbolInValueParameter(signature: String, block: () -> Unit) {
|
||||
val functionName = signature.removePrefix("/").replace('.', '_') + "_valueParameter"
|
||||
unlinkedSymbol(signature, functionName, block)
|
||||
}
|
||||
|
||||
private inline fun TestBuilder.unlinkedSymbolInReturnType(signature: String, noinline block: () -> Unit) {
|
||||
private fun TestBuilder.unlinkedSymbolInReturnType(signature: String, block: () -> Unit) {
|
||||
val functionName = signature.removePrefix("/").replace('.', '_') + "_returnType"
|
||||
unlinkedSymbol(signature, functionName, block)
|
||||
}
|
||||
|
||||
private inline fun TestBuilder.unlinkedConstructorSymbol(signature: String, noinline block: () -> Unit) {
|
||||
private fun TestBuilder.unlinkedConstructorSymbol(signature: String, block: () -> Unit) {
|
||||
val constructorName = signature.removePrefix("/").split('.').takeLast(2).joinToString(".")
|
||||
expectFailure(linkage("Constructor '$constructorName' can not be called: No constructor found for symbol '$signature'"), block)
|
||||
}
|
||||
|
||||
private inline fun TestBuilder.unlinkedSymbol(signature: String, functionName: String, noinline block: () -> Unit) {
|
||||
private fun TestBuilder.unlinkedSymbol(signature: String, functionName: String, block: () -> Unit) {
|
||||
// Need to slightly adjust the expected IR linkage error message. Reason: When Lazy IR is used the type of the
|
||||
// symbol is determined more accurately.
|
||||
val symbolKind = if ("InnerClass" in functionName && testMode.lazyIr.usedEverywhere)
|
||||
|
||||
@@ -51,15 +51,15 @@ fun box() = abiTest {
|
||||
}
|
||||
|
||||
// Shortcuts:
|
||||
private inline fun TestBuilder.success(expectedOutcome: String, noinline block: () -> String) =
|
||||
private fun TestBuilder.success(expectedOutcome: String, block: () -> String) =
|
||||
expectSuccess(expectedOutcome, block)
|
||||
|
||||
private inline fun TestBuilder.unlinkedSymbol(signature: String, noinline block: () -> Unit) {
|
||||
private fun TestBuilder.unlinkedSymbol(signature: String, block: () -> Unit) {
|
||||
val functionName = signature.removePrefix("/").substringAfterLast(".")
|
||||
expectFailure(linkage("Function '$functionName' can not be called: No function found for symbol '$signature'"), block)
|
||||
}
|
||||
|
||||
private inline fun TestBuilder.unlinkedTopLevelPrivateSymbol(signature: String, noinline block: () -> Unit) {
|
||||
private fun TestBuilder.unlinkedTopLevelPrivateSymbol(signature: String, block: () -> Unit) {
|
||||
if (testMode.lazyIr.usedEverywhere) {
|
||||
val functionName = signature.removePrefix("/").substringAfterLast(".")
|
||||
expectFailure(linkage("Function '$functionName' can not be called: Private function declared in module <lib1> can not be accessed in module <main>"), block)
|
||||
@@ -67,7 +67,7 @@ private inline fun TestBuilder.unlinkedTopLevelPrivateSymbol(signature: String,
|
||||
unlinkedSymbol(signature, block)
|
||||
}
|
||||
|
||||
private inline fun TestBuilder.inaccessible(functionName: String, noinline block: () -> Unit) = expectFailure(
|
||||
private fun TestBuilder.inaccessible(functionName: String, block: () -> Unit) = expectFailure(
|
||||
linkage("Function '$functionName' can not be called: Private function declared in module <lib1> can not be accessed in module <main>"),
|
||||
block
|
||||
)
|
||||
|
||||
@@ -114,15 +114,15 @@ fun box() = abiTest {
|
||||
}
|
||||
|
||||
// Shortcuts:
|
||||
private inline fun TestBuilder.success(expectedOutcome: String, noinline block: () -> String) =
|
||||
private fun TestBuilder.success(expectedOutcome: String, block: () -> String) =
|
||||
expectSuccess(expectedOutcome, block)
|
||||
|
||||
private inline fun TestBuilder.unlinkedSymbol(signature: String, noinline block: () -> Unit) {
|
||||
private fun TestBuilder.unlinkedSymbol(signature: String, block: () -> Unit) {
|
||||
val accessorName = signature.removePrefix("/").split('.').takeLast(2).joinToString(".")
|
||||
expectFailure(linkage("Property accessor '$accessorName' can not be called: No property accessor found for symbol '$signature'"), block)
|
||||
}
|
||||
|
||||
private inline fun TestBuilder.unlinkedTopLevelPrivateSymbol(signature: String, noinline block: () -> Unit) {
|
||||
private fun TestBuilder.unlinkedTopLevelPrivateSymbol(signature: String, block: () -> Unit) {
|
||||
if (testMode.lazyIr.usedEverywhere) {
|
||||
val accessorName = signature.removePrefix("/").split('.').takeLast(2).joinToString(".")
|
||||
expectFailure(linkage("Property accessor '$accessorName' can not be called: Private property accessor declared in module <lib1> can not be accessed in module <main>"), block)
|
||||
@@ -130,7 +130,7 @@ private inline fun TestBuilder.unlinkedTopLevelPrivateSymbol(signature: String,
|
||||
unlinkedSymbol(signature, block)
|
||||
}
|
||||
|
||||
private inline fun TestBuilder.inaccessible(accessorName: String, noinline block: () -> Unit) = expectFailure(
|
||||
private fun TestBuilder.inaccessible(accessorName: String, block: () -> Unit) = expectFailure(
|
||||
linkage("Property accessor '$accessorName' can not be called: Private property accessor declared in module <lib1> can not be accessed in module <main>"),
|
||||
block
|
||||
)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
@file:Suppress("NOTHING_TO_INLINE")
|
||||
|
||||
fun getClassToEnumFoo(): ClassToEnum.Foo = ClassToEnum.Foo()
|
||||
inline fun getClassToEnumFooInline(): ClassToEnum.Foo = ClassToEnum.Foo()
|
||||
|
||||
@@ -27,5 +27,5 @@ fun box() = abiTest {
|
||||
expectSuccess("RegularClassInheritedFromExternalInterfaceInheritedFromOpenExternalClass.abstractFunction") { rcifeiifoec.abstractFunction() }
|
||||
}
|
||||
|
||||
private inline fun TestBuilder.expectRuntimeFailure(errorMessage: String, noinline block: () -> Any) =
|
||||
private fun TestBuilder.expectRuntimeFailure(errorMessage: String, block: () -> Any) =
|
||||
expectFailure(custom { throwable -> throwable !is Exception && throwable.message == errorMessage }) { block() }
|
||||
|
||||
@@ -129,8 +129,8 @@ class OpenClassImpl : OpenClass() {
|
||||
override fun openNonInlineToInlineFunction(x: Int): String = "OpenClassImpl.openNonInlineToInlineFunction($x)"
|
||||
override fun openNonInlineToInlineFunctionWithDelegation(x: Int): String = super.openNonInlineToInlineFunctionWithDelegation(x) + " called from OpenClassImpl.openNonInlineToInlineFunctionWithDelegation($x)"
|
||||
fun newInlineFunction1(x: Int): String = "OpenClassImpl.newInlineFunction1($x)" // overrides accidentally appeared inline function
|
||||
inline fun newInlineFunction2(x: Int): String = "OpenClassImpl.newInlineFunction2($x)" // overrides accidentally appeared inline function
|
||||
inline fun newNonInlineFunction(x: Int): String = "OpenClassImpl.newNonInlineFunction($x)" // overrides accidentally appeared non-inline function
|
||||
@Suppress("NOTHING_TO_INLINE") inline fun newInlineFunction2(x: Int): String = "OpenClassImpl.newInlineFunction2($x)" // overrides accidentally appeared inline function
|
||||
@Suppress("NOTHING_TO_INLINE") inline fun newNonInlineFunction(x: Int): String = "OpenClassImpl.newNonInlineFunction($x)" // overrides accidentally appeared non-inline function
|
||||
}
|
||||
|
||||
fun suspendToNonSuspendFunctionInInterface(i: Interface, x: Int): String = runCoroutine { i.suspendToNonSuspendFunction(x) }
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("NOTHING_TO_INLINE")
|
||||
|
||||
fun getInterfaceToAbstractClass() = object : InterfaceToAbstractClass {}
|
||||
inline fun getInterfaceToAbstractClassInline() = object : InterfaceToAbstractClass {}
|
||||
fun getInterfaceToAbstractClassAsAny(): Any = object : InterfaceToAbstractClass {}
|
||||
|
||||
+2
-2
@@ -5,8 +5,8 @@ fun readRemovedOrNormalProperty(removed: Boolean): String = if (removed) removed
|
||||
fun readRemovedOrNormalPropertyOnObject1(removed: Boolean): String = if (removed) A().removedProperty1 else A().property1
|
||||
fun readRemovedOrNormalPropertyOnObject2(removed: Boolean): String = if (removed) A().removedProperty2 else A().property2
|
||||
|
||||
inline fun callInlinedRemovedFunction() = removedFunction()
|
||||
inline fun readInlinedRemovedProperty() = removedProperty
|
||||
@Suppress("NOTHING_TO_INLINE") inline fun callInlinedRemovedFunction() = removedFunction()
|
||||
@Suppress("NOTHING_TO_INLINE") inline fun readInlinedRemovedProperty() = removedProperty
|
||||
|
||||
class C2 : C() {
|
||||
override fun removedOpenFunction(): String = "O" // does not call super
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("NOTHING_TO_INLINE")
|
||||
|
||||
fun createRemovedClass() {
|
||||
check(RemovedClass().toString() != "Yellow Submarine")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user