Quick fix "Add remaining when branches" with some tests
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
// "Add remaining branches" "true"
|
||||
fun test(b: Boolean) = wh<caret>en(b) {
|
||||
false -> 0
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// "Add remaining branches" "true"
|
||||
fun test(b: Boolean) = when(b) {
|
||||
false -> 0
|
||||
true -> throw AssertionError("")
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// "Add remaining branches" "true"
|
||||
enum class Color { R, G, B }
|
||||
fun test(c: Color) = wh<caret>en(c) {
|
||||
Color.B -> 0xff
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// "Add remaining branches" "true"
|
||||
enum class Color { R, G, B }
|
||||
fun test(c: Color) = when(c) {
|
||||
Color.B -> 0xff
|
||||
Color.R -> throw AssertionError("")
|
||||
Color.G -> throw AssertionError("")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// "Add remaining branches" "true"
|
||||
sealed class Variant {
|
||||
object Singleton : Variant()
|
||||
|
||||
class Something(val x: Int) : Variant()
|
||||
|
||||
object Another : Variant()
|
||||
}
|
||||
fun test(v: Variant?) = wh<caret>en(v) {
|
||||
Variant.Singleton -> "s"
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// "Add remaining branches" "true"
|
||||
sealed class Variant {
|
||||
object Singleton : Variant()
|
||||
|
||||
class Something(val x: Int) : Variant()
|
||||
|
||||
object Another : Variant()
|
||||
}
|
||||
fun test(v: Variant?) = when(v) {
|
||||
Variant.Singleton -> "s"
|
||||
is Variant.Something -> throw AssertionError("")
|
||||
Variant.Another -> throw AssertionError("")
|
||||
null -> throw AssertionError("")
|
||||
}
|
||||
Reference in New Issue
Block a user