@@ -79,18 +79,25 @@ private class SingleArgFastKFunctionTest {
79
79
@Nested
80
80
inner class TopLevelFunctionOfTest {
81
81
@Nested
82
+ @TestInstance(TestInstance .Lifecycle .PER_CLASS )
82
83
inner class KindIsExtensionFunction {
83
84
val function: KFunction <Unit > = String ::topLevelExtensionFunc
84
85
val parameters = function.parameters
85
86
val javaMethod = function.javaMethod!!
86
87
87
- @Test
88
- fun nullInstanceTest () {
88
+ @ParameterizedTest
89
+ @MethodSource(" illegalReceiverProvider" )
90
+ fun illegalReceiverTest (receiver : Any? ) {
89
91
assertThrows<IllegalArgumentException > {
90
- SingleArgFastKFunction .topLevelFunctionOf(function, null , parameters, javaMethod)
92
+ SingleArgFastKFunction .topLevelFunctionOf(function, receiver , parameters, javaMethod)
91
93
}
92
94
}
93
95
96
+ fun illegalReceiverProvider (): Stream <Arguments > = Stream .of(
97
+ Arguments .of(null ),
98
+ Arguments .of(0 )
99
+ )
100
+
94
101
@Test
95
102
fun isCorrect () {
96
103
val result = assertDoesNotThrow {
@@ -107,6 +114,13 @@ private class SingleArgFastKFunctionTest {
107
114
val parameters = function.parameters
108
115
val javaMethod = function.javaMethod!!
109
116
117
+ @Test
118
+ fun withIllegalReceiverTest () {
119
+ assertThrows<IllegalArgumentException > {
120
+ SingleArgFastKFunction .topLevelFunctionOf(function, 0 , parameters, javaMethod)
121
+ }
122
+ }
123
+
110
124
@Test
111
125
fun withInstanceTest () {
112
126
val result = assertDoesNotThrow {
0 commit comments