Enum.valueOf throws inconsistent exception across multiple platforms #KT-35116
This commit is contained in:
committed by
Space Team
parent
d6867917c9
commit
295fdc36ce
+14
-1
@@ -1,5 +1,18 @@
|
||||
// WITH_STDLIB
|
||||
|
||||
import kotlin.test.assertSame
|
||||
import kotlin.test.assertFailsWith
|
||||
|
||||
enum class E { OK }
|
||||
|
||||
fun <T> id(x: T) = x
|
||||
|
||||
fun box() = enumValueOf<E>(id("OK")).name
|
||||
fun box(): String {
|
||||
assertSame(E.OK, E.valueOf("OK"))
|
||||
assertSame(E.OK, enumValueOf<E>("OK"))
|
||||
|
||||
assertFailsWith<IllegalArgumentException> { E.valueOf("NO") }
|
||||
assertFailsWith<IllegalArgumentException> { enumValueOf<E>("NO") }
|
||||
|
||||
return enumValueOf<E>(id("OK")).name
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user