Skip to content

Commit d3240af

Browse files
committed
Adjust documentation on Matcher functions
1 parent 53e5146 commit d3240af

File tree

1 file changed

+15
-10
lines changed
  • mockito-kotlin/src/main/kotlin/org/mockito/kotlin

1 file changed

+15
-10
lines changed

mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Matchers.kt

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ import org.mockito.kotlin.internal.unboxValueClass
3535
import org.mockito.kotlin.internal.valueClassInnerClass
3636
import kotlin.reflect.KClass
3737

38-
/** Object argument that is equal to the given value. */
38+
/** Matches an argument that is equal to the given value. */
3939
inline fun <reified T : Any?> eq(value: T): T {
4040
if (T::class.isValue)
4141
return eqValueClass(value)
4242

4343
return ArgumentMatchers.eq(value) ?: value
4444
}
4545

46-
/** Object argument that is the same as the given value. */
46+
/** Matches an argument that is the same as the given value. */
4747
fun <T> same(value: T): T {
4848
return ArgumentMatchers.same(value) ?: value
4949
}
@@ -61,7 +61,7 @@ inline fun <reified T : Any> anyOrNull(): T {
6161
return ArgumentMatchers.any<T>() ?: createInstance()
6262
}
6363

64-
/** Matches any vararg object, including nulls. */
64+
/** Matches any vararg argument, including nulls. */
6565
inline fun <reified T : Any> anyVararg(): T {
6666
return anyVararg(T::class)
6767
}
@@ -88,6 +88,7 @@ inline fun <reified T> anyValueClass(): T {
8888
return ArgumentMatchers.any(clazz.valueClassInnerClass().java).boxAsValueClass(clazz)
8989
}
9090

91+
/** Matches an argument that is equal to the given Kotlin value class value. */
9192
inline fun <reified T> eqValueClass(value: T): T {
9293
require(value::class.isValue) { "${value::class.qualifiedName} is not a value class." }
9394

@@ -101,7 +102,7 @@ inline fun <reified T> eqValueClass(value: T): T {
101102
}
102103

103104
/**
104-
* Creates a custom argument matcher.
105+
* Matches an argument that is matching the given predicate.
105106
* `null` values will never evaluate to `true`.
106107
*
107108
* @param predicate An extension function on [T] that returns `true` when a [T] matches the predicate.
@@ -113,6 +114,8 @@ inline fun <reified T : Any> argThat(noinline predicate: T.() -> Boolean): T {
113114
}
114115

115116
/**
117+
* Matches an argument that is matching the given [ArgumentMatcher].
118+
*
116119
* Registers a custom ArgumentMatcher. The original Mockito function registers the matcher and returns null,
117120
* here the required type is returned.
118121
*
@@ -123,6 +126,8 @@ inline fun <reified T : Any> argThat(matcher: ArgumentMatcher<T>): T {
123126
}
124127

125128
/**
129+
* Matches an argument that is matching the given [ArgumentMatcher].
130+
*
126131
* Alias for [argThat].
127132
*
128133
* Creates a custom argument matcher.
@@ -135,7 +140,7 @@ inline fun <reified T : Any> argForWhich(noinline predicate: T.() -> Boolean): T
135140
}
136141

137142
/**
138-
* Creates a custom argument matcher.
143+
* Matches an argument that is matching the given predicate.
139144
* `null` values will never evaluate to `true`.
140145
*
141146
* @param predicate A function that returns `true` when given [T] matches the predicate.
@@ -145,33 +150,33 @@ inline fun <reified T : Any> argWhere(noinline predicate: (T) -> Boolean): T {
145150
}
146151

147152
/**
148-
* Argument that implements the given class.
153+
* Matches an argument that is instance of the given class.
149154
*/
150155
inline fun <reified T : Any> isA(): T {
151156
return ArgumentMatchers.isA(T::class.java) ?: createInstance()
152157
}
153158

154159
/**
155-
* `null` argument.
160+
* Matches an argument that is `null`.
156161
*/
157162
fun <T : Any> isNull(): T? = ArgumentMatchers.isNull()
158163

159164
/**
160-
* Not `null` argument.
165+
* Matches an argument that is not `null`.
161166
*/
162167
fun <T : Any> isNotNull(): T? {
163168
return ArgumentMatchers.isNotNull()
164169
}
165170

166171
/**
167-
* Not `null` argument.
172+
* Matches an argument that is not `null`.
168173
*/
169174
fun <T : Any> notNull(): T? {
170175
return ArgumentMatchers.notNull()
171176
}
172177

173178
/**
174-
* Object argument that is reflection-equal to the given value with support for excluding
179+
* Matches an argument that is reflection-equal to the given value with support for excluding
175180
* selected fields from a class.
176181
*/
177182
inline fun <reified T : Any> refEq(value: T, vararg excludeFields: String): T {

0 commit comments

Comments
 (0)