mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-20 15:24:45 +08:00
Rearrange tests
This commit is contained in:
parent
9ae02b5ade
commit
b78d9ad3bb
@ -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)
|
@ -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()
|
||||
}
|
||||
}
|
@ -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)
|
@ -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
|
Loading…
Reference in New Issue
Block a user