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 index 4666d39e0..6726d4e55 100644 --- a/mirai-core/src/commonTest/kotlin/net/mamoe/mirai/test/TestDSL.kt +++ b/mirai-core/src/commonTest/kotlin/net/mamoe/mirai/test/TestDSL.kt @@ -11,9 +11,6 @@ package net.mamoe.mirai.test -import kotlinx.coroutines.CoroutineScope -import kotlin.coroutines.CoroutineContext -import kotlin.coroutines.EmptyCoroutineContext import kotlin.test.assertEquals import kotlin.test.assertFalse import kotlin.test.assertNotEquals @@ -32,9 +29,4 @@ fun Boolean.shouldBeFalse() = assertFalse { this } infix fun E.shouldBeEqualTo(another: E) = assertEquals(another, this) @TestDSL -infix fun E.shouldNotBeEqualTo(another: E) = assertNotEquals(another, this) - -internal expect fun runBlocking( - context: CoroutineContext = EmptyCoroutineContext, - block: suspend CoroutineScope.() -> R -): R \ No newline at end of file +infix fun E.shouldNotBeEqualTo(another: E) = assertNotEquals(another, this) \ No newline at end of file diff --git a/mirai-core/src/commonTest/kotlin/net/mamoe/mirai/event/EventTests.kt b/mirai-core/src/jvmTest/kotlin/net/mamoe/mirai/event/EventTests.kt similarity index 97% rename from mirai-core/src/commonTest/kotlin/net/mamoe/mirai/event/EventTests.kt rename to mirai-core/src/jvmTest/kotlin/net/mamoe/mirai/event/EventTests.kt index 6e265171b..75aa50a91 100644 --- a/mirai-core/src/commonTest/kotlin/net/mamoe/mirai/event/EventTests.kt +++ b/mirai-core/src/jvmTest/kotlin/net/mamoe/mirai/event/EventTests.kt @@ -11,7 +11,7 @@ package net.mamoe.mirai.event import kotlinx.coroutines.CompletableJob import kotlinx.coroutines.GlobalScope -import net.mamoe.mirai.test.runBlocking +import net.mamoe.mirai.utils.internal.runBlocking import kotlin.test.Test import kotlin.test.assertTrue diff --git a/mirai-core/src/commonTest/kotlin/net/mamoe/mirai/message/SubscribingGetTest.kt b/mirai-core/src/jvmTest/kotlin/net/mamoe/mirai/message/SubscribingGetTest.kt similarity index 88% rename from mirai-core/src/commonTest/kotlin/net/mamoe/mirai/message/SubscribingGetTest.kt rename to mirai-core/src/jvmTest/kotlin/net/mamoe/mirai/message/SubscribingGetTest.kt index 31594cf30..08facd865 100644 --- a/mirai-core/src/commonTest/kotlin/net/mamoe/mirai/message/SubscribingGetTest.kt +++ b/mirai-core/src/jvmTest/kotlin/net/mamoe/mirai/message/SubscribingGetTest.kt @@ -13,7 +13,6 @@ import kotlinx.coroutines.* import net.mamoe.mirai.event.TestEvent import net.mamoe.mirai.event.broadcast import net.mamoe.mirai.event.syncFromEvent -import net.mamoe.mirai.test.runBlocking import kotlin.coroutines.CoroutineContext import kotlin.coroutines.EmptyCoroutineContext import kotlin.coroutines.resume @@ -23,16 +22,16 @@ import kotlin.test.assertFailsWith internal class SubscribingGetTest { @Test - fun testSyncFromEvent(): Unit = runBlocking { - withTimeout(500) { + fun testSyncFromEvent() { + runBlockingWithTimeout(1000) { suspendCancellableCoroutine { cont -> launch { - syncFromEvent(5000) { _: TestEvent -> + syncFromEvent(500) { _: TestEvent -> cont.resume(Unit) } } - delay(200) launch { + delay(200) TestEvent().broadcast() } } diff --git a/mirai-core/src/jvmTest/kotlin/net/mamoe/mirai/test/runBlocking.kt b/mirai-core/src/jvmTest/kotlin/net/mamoe/mirai/test/runBlocking.kt deleted file mode 100644 index e954e0e5b..000000000 --- a/mirai-core/src/jvmTest/kotlin/net/mamoe/mirai/test/runBlocking.kt +++ /dev/null @@ -1,9 +0,0 @@ -package net.mamoe.mirai.test - -import kotlinx.coroutines.CoroutineScope -import kotlin.coroutines.CoroutineContext - -internal actual fun runBlocking( - context: CoroutineContext, - block: suspend CoroutineScope.() -> R -): R = kotlinx.coroutines.runBlocking(context, block) \ No newline at end of file diff --git a/mirai-core/src/commonTest/kotlin/net/mamoe/mirai/utils/LockFreeLinkedListTest.kt b/mirai-core/src/jvmTest/kotlin/net/mamoe/mirai/utils/LockFreeLinkedListTest.kt similarity index 99% rename from mirai-core/src/commonTest/kotlin/net/mamoe/mirai/utils/LockFreeLinkedListTest.kt rename to mirai-core/src/jvmTest/kotlin/net/mamoe/mirai/utils/LockFreeLinkedListTest.kt index 494b8205d..2009c8d3a 100644 --- a/mirai-core/src/commonTest/kotlin/net/mamoe/mirai/utils/LockFreeLinkedListTest.kt +++ b/mirai-core/src/jvmTest/kotlin/net/mamoe/mirai/utils/LockFreeLinkedListTest.kt @@ -12,7 +12,6 @@ package net.mamoe.mirai.utils import kotlinx.coroutines.* -import net.mamoe.mirai.test.runBlocking import net.mamoe.mirai.test.shouldBeEqualTo import net.mamoe.mirai.test.shouldBeTrue import kotlin.test.Test