Add hidden methods to keep binary compatibility in kotlin-test for JVM
This commit is contained in:
@@ -14,6 +14,7 @@ package kotlin.test
|
|||||||
|
|
||||||
import kotlin.contracts.*
|
import kotlin.contracts.*
|
||||||
import kotlin.internal.*
|
import kotlin.internal.*
|
||||||
|
import kotlin.jvm.JvmName
|
||||||
import kotlin.native.concurrent.ThreadLocal
|
import kotlin.native.concurrent.ThreadLocal
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
@@ -108,6 +109,7 @@ fun <@OnlyInputTypes T> expect(expected: T, message: String?, block: () -> T) {
|
|||||||
* The returned exception can be inspected further, for example by asserting its property values.
|
* The returned exception can be inspected further, for example by asserting its property values.
|
||||||
*/
|
*/
|
||||||
@InlineOnly
|
@InlineOnly
|
||||||
|
@JvmName("assertFailsInline")
|
||||||
inline fun assertFails(block: () -> Unit): Throwable =
|
inline fun assertFails(block: () -> Unit): Throwable =
|
||||||
checkResultIsFailure(null, runCatching(block))
|
checkResultIsFailure(null, runCatching(block))
|
||||||
|
|
||||||
@@ -121,6 +123,7 @@ inline fun assertFails(block: () -> Unit): Throwable =
|
|||||||
*/
|
*/
|
||||||
@SinceKotlin("1.1")
|
@SinceKotlin("1.1")
|
||||||
@InlineOnly
|
@InlineOnly
|
||||||
|
@JvmName("assertFailsInline")
|
||||||
inline fun assertFails(message: String?, block: () -> Unit): Throwable =
|
inline fun assertFails(message: String?, block: () -> Unit): Throwable =
|
||||||
checkResultIsFailure(message, runCatching(block))
|
checkResultIsFailure(message, runCatching(block))
|
||||||
|
|
||||||
@@ -154,9 +157,9 @@ inline fun <reified T : Throwable> assertFailsWith(message: String? = null, bloc
|
|||||||
* The returned exception can be inspected further, for example by asserting its property values.
|
* The returned exception can be inspected further, for example by asserting its property values.
|
||||||
*/
|
*/
|
||||||
@InlineOnly
|
@InlineOnly
|
||||||
|
@JvmName("assertFailsWithInline")
|
||||||
inline fun <T : Throwable> assertFailsWith(exceptionClass: KClass<T>, block: () -> Unit): T = assertFailsWith(exceptionClass, null, block)
|
inline fun <T : Throwable> assertFailsWith(exceptionClass: KClass<T>, block: () -> Unit): T = assertFailsWith(exceptionClass, null, block)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asserts that a [block] fails with a specific exception of type [exceptionClass] being thrown.
|
* Asserts that a [block] fails with a specific exception of type [exceptionClass] being thrown.
|
||||||
*
|
*
|
||||||
@@ -166,6 +169,7 @@ inline fun <T : Throwable> assertFailsWith(exceptionClass: KClass<T>, block: ()
|
|||||||
* The returned exception can be inspected further, for example by asserting its property values.
|
* The returned exception can be inspected further, for example by asserting its property values.
|
||||||
*/
|
*/
|
||||||
@InlineOnly
|
@InlineOnly
|
||||||
|
@JvmName("assertFailsWithInline")
|
||||||
inline fun <T : Throwable> assertFailsWith(exceptionClass: KClass<T>, message: String?, block: () -> Unit): T =
|
inline fun <T : Throwable> assertFailsWith(exceptionClass: KClass<T>, message: String?, block: () -> Unit): T =
|
||||||
checkResultIsFailure(exceptionClass, message, runCatching(block))
|
checkResultIsFailure(exceptionClass, message, runCatching(block))
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,22 @@ internal actual fun <T : Throwable> checkResultIsFailure(exceptionClass: KClass<
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
|
||||||
|
@JvmName("assertFails")
|
||||||
|
fun assertFailsNoInline(block: () -> Unit): Throwable = assertFails(block)
|
||||||
|
|
||||||
|
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
|
||||||
|
@JvmName("assertFails")
|
||||||
|
fun assertFailsNoInline(message: String?, block: () -> Unit): Throwable = assertFails(message, block)
|
||||||
|
|
||||||
|
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
|
||||||
|
@JvmName("assertFailsWith")
|
||||||
|
fun <T : Throwable> assertFailsWithNoInline(exceptionClass: KClass<T>, block: () -> Unit): T = assertFailsWith(exceptionClass, block)
|
||||||
|
|
||||||
|
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
|
||||||
|
@JvmName("assertFailsWith")
|
||||||
|
fun <T : Throwable> assertFailsWithNoInline(exceptionClass: KClass<T>, message: String?, block: () -> Unit): T =
|
||||||
|
assertFailsWith(exceptionClass, message, block)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user