File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
main/kotlin/com/nhaarman/mockito_kotlin Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,10 @@ private fun <T : Any> createInstance(jClass: Class<T>): T {
7474 return defaultPrimitive(jClass)
7575 }
7676
77+ if (jClass.isEnum) {
78+ return jClass.enumConstants.first()
79+ }
80+
7781 if (jClass.isArray) {
7882 return jClass.toArrayInstance()
7983 }
Original file line number Diff line number Diff line change @@ -27,7 +27,6 @@ import com.nhaarman.expect.expect
2727import com.nhaarman.mockito_kotlin.any
2828import com.nhaarman.mockito_kotlin.anyArray
2929import com.nhaarman.mockito_kotlin.mock
30- import com.nhaarman.mockito_kotlin.verify
3130import org.junit.After
3231import org.junit.Before
3332import org.junit.Test
@@ -377,6 +376,15 @@ class AnyTest {
377376 expect(result).toNotBeNull()
378377 }
379378
379+ @Test
380+ fun anyEnum () {
381+ /* When */
382+ val result = any<MyEnum >()
383+
384+ /* Then */
385+ expect(result).toBe(MyEnum .VALUE )
386+ }
387+
380388 open class Fake {
381389 open fun go (arg : Any? ) {
382390 }
@@ -404,4 +412,6 @@ class AnyTest {
404412
405413 class ParameterizedClass <T >(val t : T )
406414 class NullableParameterClass (val s : String? )
415+
416+ enum class MyEnum { VALUE , ANOTHER_VALUE }
407417}
You can’t perform that action at this time.
0 commit comments