Files
kotlin-fork/compiler/testData/ir/irText/expressions/exhaustiveWhenElseBranch.kt
T
Dmitriy Dolovov 4532f52898 IR text tests: Unmute enum class-related tests
Making enum class-related tests unmuted requires implementing
a special "compatibility" mode for IR tree dumper to filter out
fake override declarations leaking from java.enum.Enum and
kotlin.Enum (JVM-only) classes.
2023-11-30 08:32:35 +00:00

80 lines
1.3 KiB
Kotlin
Vendored

enum class A { V1 }
fun testVariableAssignment_throws(a: A) {
val x: Int
when (a) {
A.V1 -> x = 11
// else -> throw
}
}
fun testStatement_empty(a: A) {
when (a) {
A.V1 -> 1
// else -> {}
}
}
fun testParenthesized_throwsJvm(a: A) {
(when (a) {
A.V1 -> 1
// JVM: else -> throw, but we don't care
})
}
fun testAnnotated_throwsJvm(a: A) {
@Suppress("") when (a) {
A.V1 -> 1
// JVM: else -> throw, but we don't care
}
}
fun testExpression_throws(a: A) =
when (a) {
A.V1 -> 1
// else -> throw
}
fun testIfTheElseStatement_empty(a: A, flag: Boolean) {
if (flag)
0
else {
when (a) {
A.V1 -> 1
// else -> {}
}
}
}
fun testIfTheElseParenthesized_throwsJvm(a: A, flag: Boolean) {
(if (flag)
0
else {
when (a) {
A.V1 -> 1
// JVM: else -> throw, but we don't care
}
})
}
fun testIfTheElseAnnotated_throwsJvm(a: A, flag: Boolean) {
@Suppress("")
if (flag)
0
else {
when (a) {
A.V1 -> 1
// JVM: else -> throw, but we don't care
}
}
}
fun testLambdaResultExpression_throws(a: A) {
{
when (a) {
A.V1 -> 1
// else -> throw
}
}()
}