From 569e69b0623ac309b1af20e24fe1872447eefabb Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 13 Dec 2019 08:55:46 +0800 Subject: [PATCH] DSL for testing --- .../kotlin/net.mamoe.mirai.test/TestDSL.kt | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 mirai-core/src/commonTest/kotlin/net.mamoe.mirai.test/TestDSL.kt diff --git a/mirai-core/src/commonTest/kotlin/net.mamoe.mirai.test/TestDSL.kt b/mirai-core/src/commonTest/kotlin/net.mamoe.mirai.test/TestDSL.kt new file mode 100644 index 000000000..ae5b961ae --- /dev/null +++ b/mirai-core/src/commonTest/kotlin/net.mamoe.mirai.test/TestDSL.kt @@ -0,0 +1,23 @@ +@file:Suppress("NOTHING_TO_INLINE") + +package net.mamoe.mirai.test + +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertNotEquals +import kotlin.test.assertTrue + +@DslMarker +internal annotation class TestDSL + +@TestDSL +inline fun Boolean.shouldBeTrue() = assertTrue { this } + +@TestDSL +inline fun Boolean.shouldBeFalse() = assertFalse { this } + +@TestDSL +inline infix fun E.shouldBeEqualTo(another: E) = assertEquals(another, this) + +@TestDSL +inline infix fun E.shouldNotBeEqualTo(another: E) = assertNotEquals(another, this)