Commit b78d9ad3 authored by Him188's avatar Him188

Rearrange tests

parent 9ae02b5a
......@@ -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> E.shouldBeEqualTo(another: E) = assertEquals(another, this)
@TestDSL
infix fun <E> E.shouldNotBeEqualTo(another: E) = assertNotEquals(another, this)
internal expect fun <R> runBlocking(
context: CoroutineContext = EmptyCoroutineContext,
block: suspend CoroutineScope.() -> R
): R
\ No newline at end of file
infix fun <E> E.shouldNotBeEqualTo(another: E) = assertNotEquals(another, this)
\ No newline at end of file
......@@ -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
......
......@@ -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<Unit> { cont ->
launch {
syncFromEvent(5000) { _: TestEvent ->
syncFromEvent(500) { _: TestEvent ->
cont.resume(Unit)
}
}
delay(200)
launch {
delay(200)
TestEvent().broadcast()
}
}
......
package net.mamoe.mirai.test
import kotlinx.coroutines.CoroutineScope
import kotlin.coroutines.CoroutineContext
internal actual fun <R> runBlocking(
context: CoroutineContext,
block: suspend CoroutineScope.() -> R
): R = kotlinx.coroutines.runBlocking(context, block)
\ No newline at end of file
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment