[tests] Cover KT-63654 with test cases
This commit is contained in:
committed by
Space Team
parent
6471080c48
commit
9956c0f83b
+15
@@ -0,0 +1,15 @@
|
||||
// ISSUE: KT-63654
|
||||
// WITH_STDLIB
|
||||
|
||||
data class State<S, out A>(private val action: (S) -> Pair<A, S>) {
|
||||
fun <B> flatMap(f: (A) -> State<S, B>): State<S, B> =
|
||||
State { s0: S ->
|
||||
val (a, s1) = action(s0)
|
||||
f(a).action(s1)
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
State<String, Int> { 42 to "" }.flatMap { i -> State { i.toLong() to "" } }
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
// ISSUE: KT-63654
|
||||
|
||||
class Klass<in A>(private val action: (A) -> Unit) {
|
||||
fun <B> execute(value: B, klassB: Klass<B>) {
|
||||
klassB.action(value)
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
Klass { a: Int -> a.inc() }.execute("", Klass { b: String -> b.length })
|
||||
return "OK"
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// ISSUE: KT-63654
|
||||
|
||||
class Klass<out A>(private val action: () -> A) {
|
||||
fun <B> execute(klassB: Klass<B>) {
|
||||
klassB.action()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
Klass { 42 }.execute(Klass { "" })
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user