This repository was archived by the owner on Jan 20, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
src/test/kotlin/com/mapk/core Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 11package com.mapk.core
22
3+ import kotlin.reflect.full.functions
4+ import org.junit.jupiter.api.Assertions.assertEquals
35import org.junit.jupiter.api.DisplayName
46import org.junit.jupiter.api.Nested
57import org.junit.jupiter.api.Test
@@ -33,4 +35,28 @@ class KFunctionForCallTest {
3335 assertDoesNotThrow { KFunctionForCall (this ::dummy2) }
3436 }
3537 }
38+
39+ @Nested
40+ @DisplayName(" 呼び出し関連テスト" )
41+ inner class CallTest {
42+ @Test
43+ @DisplayName(" コンパニオンオブジェクトから取得した場合" )
44+ fun fromCompanionObject () {
45+ val function =
46+ Companion ::class .functions.find { it.name == (KFunctionForCallTest )::declaredOnCompanionObject.name }!!
47+
48+ val kFunctionForCall = KFunctionForCall (function, Companion )
49+
50+ val bucket = kFunctionForCall.getArgumentBucket()
51+ kFunctionForCall.parameters.forEach { bucket.setArgument(it, it.index) }
52+ val result = kFunctionForCall.call(bucket)
53+ assertEquals(" 12" , result)
54+ }
55+ }
56+
57+ companion object {
58+ fun declaredOnCompanionObject (arg1 : Any , arg2 : Any ): String {
59+ return arg1.toString() + arg2.toString()
60+ }
61+ }
3662}
You can’t perform that action at this time.
0 commit comments