K1/K2: add test for streams situation from intellij

This commit is contained in:
Mikhail Glukhikh
2024-02-22 11:35:35 +01:00
committed by Space Team
parent 6e1b6427ab
commit 993509c057
9 changed files with 158 additions and 33 deletions
@@ -0,0 +1,24 @@
// FULL_JDK
// JVM_TARGET: 1.8
import java.util.function.IntPredicate
import java.util.stream.Stream
import kotlin.streams.toList
class IntLongPair(val i: Int, val l: Long)
interface Process {
fun pid(): Int
fun totalCpuDuration(): Long?
}
fun run(filter: IntPredicate, allProcesses: Stream<Process>): List<IntLongPair> {
return allProcesses.filter {
filter.test(it.pid())
}.map<IntLongPair?> {
val duration = it.totalCpuDuration()
if (duration != null) IntLongPair(it.pid(), duration)
else null
}.toList()
}