diff options
author | Kamil Doległo <kamilok1965@interia.pl> | 2020-07-29 12:21:06 +0200 |
---|---|---|
committer | Sebastian Sellmair <34319766+sellmair@users.noreply.github.com> | 2020-07-30 15:08:24 +0200 |
commit | e5200753708274a96fe3036305d1b0696dce7022 (patch) | |
tree | 20886ce9d28f111a8f571b65f315806a1cbc2eb1 /testApi/src/main/kotlin/org/jetbrains | |
parent | 29d088ddd4a177a76f20c6941c6c18cc1538524a (diff) | |
download | dokka-e5200753708274a96fe3036305d1b0696dce7022.tar.gz dokka-e5200753708274a96fe3036305d1b0696dce7022.tar.bz2 dokka-e5200753708274a96fe3036305d1b0696dce7022.zip |
Move `testApi.utils` to `org.jetbrains.dokka.testApi.utils`
Diffstat (limited to 'testApi/src/main/kotlin/org/jetbrains')
-rw-r--r-- | testApi/src/main/kotlin/org/jetbrains/dokka/testApi/utils/assertIsInstance.kt | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/testApi/src/main/kotlin/org/jetbrains/dokka/testApi/utils/assertIsInstance.kt b/testApi/src/main/kotlin/org/jetbrains/dokka/testApi/utils/assertIsInstance.kt new file mode 100644 index 00000000..00c00ebb --- /dev/null +++ b/testApi/src/main/kotlin/org/jetbrains/dokka/testApi/utils/assertIsInstance.kt @@ -0,0 +1,17 @@ +package org.jetbrains.dokka.testApi.utils + +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.contract + +@OptIn(ExperimentalContracts::class) +inline fun <reified T> assertIsInstance(obj: Any?): T { + contract { + returns() implies (obj is T) + } + + if (obj is T) { + return obj + } + + throw AssertionError("Expected instance of type ${T::class.qualifiedName} but found $obj") +} |