Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #922 from aSemy/patch-1
value class check - catch KotlinReflectionInternalError
- Loading branch information
Showing
4 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,9 @@ plugins { | |
} | ||
|
||
kotlin { | ||
jvm() | ||
jvm { | ||
withJava() | ||
} | ||
|
||
sourceSets { | ||
val commonMain by getting { | ||
|
10 changes: 10 additions & 0 deletions
10
test-modules/client-tests/src/jvmTest/java/io/mockk/core/JavaEnum.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.mockk.core; | ||
|
||
/** @see ValueClassSupport */ | ||
public enum JavaEnum { | ||
A { | ||
public String toString() { | ||
return "aaa"; | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
test-modules/client-tests/src/jvmTest/kotlin/io/mockk/core/ValueClassSupportTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package io.mockk.core | ||
|
||
import io.mockk.every | ||
import io.mockk.mockk | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
|
||
class ValueClassSupportTest { | ||
|
||
/** https://github.com/mockk/mockk/issues/868 */ | ||
@Test | ||
fun `verify Java class does not cause KotlinReflectionInternalError`() { | ||
val mock = mockk<MockTarget> { | ||
every { func() } returns JavaEnum.A | ||
} | ||
|
||
val result = mock.func() // check this doesn't throw KotlinReflectionInternalError | ||
|
||
assertEquals(JavaEnum.A, result) | ||
} | ||
|
||
} | ||
|
||
private class MockTarget { | ||
fun func(): JavaEnum = JavaEnum.A | ||
} |