From fac44e07465a57bd95a08379caf6ec1f767e8ec7 Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Tue, 30 Jun 2020 09:48:14 +0200 Subject: Implement first simple JavadocModuleTemplateMapTest.kt --- .../src/main/kotlin/testApi/utils/assertIsInstance.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 testApi/src/main/kotlin/testApi/utils/assertIsInstance.kt (limited to 'testApi/src/main/kotlin') diff --git a/testApi/src/main/kotlin/testApi/utils/assertIsInstance.kt b/testApi/src/main/kotlin/testApi/utils/assertIsInstance.kt new file mode 100644 index 00000000..0220799a --- /dev/null +++ b/testApi/src/main/kotlin/testApi/utils/assertIsInstance.kt @@ -0,0 +1,17 @@ +package testApi.utils + +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.contract + +@OptIn(ExperimentalContracts::class) +inline fun 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") +} \ No newline at end of file -- cgit