aboutsummaryrefslogtreecommitdiff
path: root/testApi/src/main/kotlin/org/jetbrains
diff options
context:
space:
mode:
authorKamil Doległo <kamilok1965@interia.pl>2020-07-29 12:21:06 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-07-30 15:08:24 +0200
commite5200753708274a96fe3036305d1b0696dce7022 (patch)
tree20886ce9d28f111a8f571b65f315806a1cbc2eb1 /testApi/src/main/kotlin/org/jetbrains
parent29d088ddd4a177a76f20c6941c6c18cc1538524a (diff)
downloaddokka-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.kt17
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")
+}