aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/util/assertions.kt
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-07-04 04:22:13 +0200
committernea <nea@nea.moe>2023-07-04 04:22:13 +0200
commit4444fcca44d9a53c8162d69e0e9f19fd214c2f54 (patch)
tree3061008b93a4f994923c6523c99c754abfe3e4d1 /src/main/kotlin/moe/nea/firmament/util/assertions.kt
parentd4410a67fb43cf467194b67552cdf4b85c6753bd (diff)
downloadFirmament-4444fcca44d9a53c8162d69e0e9f19fd214c2f54.tar.gz
Firmament-4444fcca44d9a53c8162d69e0e9f19fd214c2f54.tar.bz2
Firmament-4444fcca44d9a53c8162d69e0e9f19fd214c2f54.zip
Add text rendering debugging
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/util/assertions.kt')
-rw-r--r--src/main/kotlin/moe/nea/firmament/util/assertions.kt20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/util/assertions.kt b/src/main/kotlin/moe/nea/firmament/util/assertions.kt
new file mode 100644
index 0000000..0fe569a
--- /dev/null
+++ b/src/main/kotlin/moe/nea/firmament/util/assertions.kt
@@ -0,0 +1,20 @@
+package moe.nea.firmament.util
+
+/**
+ * Less aggressive version of `require(obj != null)`, which fails in devenv but continues at runtime.
+ */
+inline fun <T : Any> assertNotNullOr(obj: T?, block: () -> T): T {
+ assert(obj != null)
+ return obj ?: block()
+}
+
+
+/**
+ * Less aggressive version of `require(condition)`, which fails in devenv but continues at runtime.
+ */
+inline fun assertTrueOr(condition: Boolean, block: () -> Unit) {
+ assert(condition)
+ if (!condition) block()
+}
+
+