Add tests for flat-mapping operations
This commit is contained in:
committed by
Yan Zhulanow
parent
a4e72067a9
commit
42aba80eb7
@@ -0,0 +1,32 @@
|
|||||||
|
LineBreakpoint created at FlatMap.kt:5
|
||||||
|
Run Java
|
||||||
|
Connected to the target VM
|
||||||
|
FlatMap.kt:5
|
||||||
|
listOf(1, 0, 2).asSequence()
|
||||||
|
.flatMap({ (0 until it).asSequence() })
|
||||||
|
.count()
|
||||||
|
flatMap
|
||||||
|
before: 1,3,4
|
||||||
|
after: 2,5,6
|
||||||
|
count
|
||||||
|
before: 2,5,6
|
||||||
|
after: nothing
|
||||||
|
mappings for flatMap
|
||||||
|
direct:
|
||||||
|
1 -> 2
|
||||||
|
3 -> nothing
|
||||||
|
4 -> 5,6
|
||||||
|
reverse:
|
||||||
|
1 <- 2
|
||||||
|
4 <- 5
|
||||||
|
4 <- 6
|
||||||
|
mappings for count
|
||||||
|
direct:
|
||||||
|
2 -> nothing
|
||||||
|
5 -> nothing
|
||||||
|
6 -> nothing
|
||||||
|
reverse:
|
||||||
|
empty
|
||||||
|
Disconnected from the target VM
|
||||||
|
|
||||||
|
Process finished with exit code 0
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
LineBreakpoint created at Flatten.kt:5
|
||||||
|
Run Java
|
||||||
|
Connected to the target VM
|
||||||
|
Flatten.kt:5
|
||||||
|
listOf(listOf(1,2,3), listOf(), listOf(4,5,6)).asSequence()
|
||||||
|
.flatten()
|
||||||
|
.toList()
|
||||||
|
flatten
|
||||||
|
before: 1,5,6
|
||||||
|
after: 2,3,4,7,8,9
|
||||||
|
toList
|
||||||
|
before: 2,3,4,7,8,9
|
||||||
|
after: nothing
|
||||||
|
mappings for flatten
|
||||||
|
direct:
|
||||||
|
1 -> 2,3,4
|
||||||
|
5 -> nothing
|
||||||
|
6 -> 7,8,9
|
||||||
|
reverse:
|
||||||
|
1 <- 2
|
||||||
|
1 <- 3
|
||||||
|
1 <- 4
|
||||||
|
6 <- 7
|
||||||
|
6 <- 8
|
||||||
|
6 <- 9
|
||||||
|
mappings for toList
|
||||||
|
direct:
|
||||||
|
2 -> nothing
|
||||||
|
3 -> nothing
|
||||||
|
4 -> nothing
|
||||||
|
7 -> nothing
|
||||||
|
8 -> nothing
|
||||||
|
9 -> nothing
|
||||||
|
reverse:
|
||||||
|
empty
|
||||||
|
Disconnected from the target VM
|
||||||
|
|
||||||
|
Process finished with exit code 0
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package flatMap
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
// Breakpoint!
|
||||||
|
listOf(1, 0, 2).asSequence().flatMap { (0 until it).asSequence() }.count()
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package flatMap
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
// Breakpoint!
|
||||||
|
listOf(listOf(1,2,3), listOf(), listOf(4,5,6)).asSequence().flatten().toList()
|
||||||
|
}
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||||
|
package com.intellij.debugger.streams.kotlin.exec.sequence
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Vitaliy.Bibaev
|
||||||
|
*/
|
||||||
|
class FlatMapOperationsTest : OperationsTestCase("flatMap") {
|
||||||
|
fun testFlatMap() = doTestWithResult()
|
||||||
|
fun testFlatten() = doTestWithResult()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user