Skip to content

Commit

Permalink
Merge pull request mockito#1 from nhaarman/release-0.1.1
Browse files Browse the repository at this point in the history
Release 0.1.1
  • Loading branch information
nhaarman committed Jan 24, 2016
2 parents b113029 + b5a4e87 commit 78505b7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Expand Up @@ -74,6 +74,10 @@ private fun <T : Any> createInstance(jClass: Class<T>): T {
return defaultPrimitive(jClass)
}

if (jClass.isEnum) {
return jClass.enumConstants.first()
}

if (jClass.isArray) {
return jClass.toArrayInstance()
}
Expand Down
12 changes: 11 additions & 1 deletion mockito-kotlin/src/test/kotlin/AnyTest.kt
Expand Up @@ -27,7 +27,6 @@ import com.nhaarman.expect.expect
import com.nhaarman.mockito_kotlin.any
import com.nhaarman.mockito_kotlin.anyArray
import com.nhaarman.mockito_kotlin.mock
import com.nhaarman.mockito_kotlin.verify
import org.junit.After
import org.junit.Before
import org.junit.Test
Expand Down Expand Up @@ -377,6 +376,15 @@ class AnyTest {
expect(result).toNotBeNull()
}

@Test
fun anyEnum() {
/* When */
val result = any<MyEnum>()

/* Then */
expect(result).toBe(MyEnum.VALUE)
}

open class Fake {
open fun go(arg: Any?) {
}
Expand Down Expand Up @@ -404,4 +412,6 @@ class AnyTest {

class ParameterizedClass<T>(val t: T)
class NullableParameterClass(val s: String?)

enum class MyEnum { VALUE, ANOTHER_VALUE }
}

0 comments on commit 78505b7

Please sign in to comment.