mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-05 00:10:13 +08:00
Add tests for #436
This commit is contained in:
parent
2e7370a0e7
commit
9ebfef2dd8
@ -144,7 +144,7 @@ import kotlin.reflect.jvm.kotlinFunction
|
|||||||
* Events.registerEvents(new MyEventHandlers())
|
* Events.registerEvents(new MyEventHandlers())
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @sample net.mamoe.mirai.event.JvmMethodEventsTest
|
* //@sample net.mamoe.mirai.event.JvmMethodEventsTest
|
||||||
*/
|
*/
|
||||||
@Target(AnnotationTarget.FUNCTION)
|
@Target(AnnotationTarget.FUNCTION)
|
||||||
@Retention(AnnotationRetention.RUNTIME)
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
|
@ -11,12 +11,13 @@
|
|||||||
|
|
||||||
package net.mamoe.mirai.event
|
package net.mamoe.mirai.event
|
||||||
|
|
||||||
import junit.framework.TestCase.assertEquals
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import net.mamoe.mirai.utils.internal.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
|
import org.jetbrains.annotations.NotNull
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import java.util.concurrent.atomic.AtomicInteger
|
import java.util.concurrent.atomic.AtomicInteger
|
||||||
import kotlin.coroutines.EmptyCoroutineContext
|
import kotlin.coroutines.EmptyCoroutineContext
|
||||||
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
|
|
||||||
internal class JvmMethodEventsTest {
|
internal class JvmMethodEventsTest {
|
||||||
@ -46,13 +47,6 @@ internal class JvmMethodEventsTest {
|
|||||||
called.getAndIncrement()
|
called.getAndIncrement()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("unused")
|
|
||||||
@EventHandler
|
|
||||||
suspend fun `suspend param Void`(event: TestEvent): Void? {
|
|
||||||
called.getAndIncrement()
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
fun TestEvent.`receiver param Unit`(event: TestEvent) {
|
fun TestEvent.`receiver param Unit`(event: TestEvent) {
|
||||||
@ -80,6 +74,13 @@ internal class JvmMethodEventsTest {
|
|||||||
return ListeningStatus.STOPPED
|
return ListeningStatus.STOPPED
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
@Suppress("unused")
|
||||||
|
private fun TestEvent.`test annotations`(@NotNull event: TestEvent): ListeningStatus {
|
||||||
|
called.getAndIncrement()
|
||||||
|
return ListeningStatus.STOPPED
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
fun TestEvent.`receiver param LS`(event: TestEvent): ListeningStatus {
|
fun TestEvent.`receiver param LS`(event: TestEvent): ListeningStatus {
|
||||||
@ -88,15 +89,15 @@ internal class JvmMethodEventsTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestClass().run {
|
TestClass().run {
|
||||||
// this.registerEvents()
|
this.registerEvents()
|
||||||
//
|
|
||||||
// runBlocking {
|
runBlocking {
|
||||||
// TestEvent().broadcast()
|
TestEvent().broadcast()
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// assertEquals(9, this.getCalled())
|
assertEquals(9, this.getCalled())
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user