Rearrange tests

This commit is contained in:
Him188 2020-04-22 11:40:44 +08:00
parent 9ae02b5ade
commit b78d9ad3bb
5 changed files with 6 additions and 25 deletions

View File

@ -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
infix fun <E> E.shouldNotBeEqualTo(another: E) = assertNotEquals(another, this)

View 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

View File

@ -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()
}
}

View File

@ -1,9 +0,0 @@
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)

View 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