Add tests for sorting operations

This commit is contained in:
Vitaliy.Bibaev
2017-12-21 11:08:18 +03:00
committed by Yan Zhulanow
parent 3114691a02
commit fd17d9959a
11 changed files with 198 additions and 0 deletions
@@ -0,0 +1,32 @@
LineBreakpoint created at Sorted.kt:5
Run Java
Connected to the target VM
Sorted.kt:5
intArrayOf(2, 1, 3).asSequence()
.sorted()
.toList()
sorted
before: 1,2,3
after: 4,5,6
toList
before: 4,5,6
after: nothing
mappings for sorted
direct:
1 -> 5
2 -> 4
3 -> 6
reverse:
2 <- 4
1 <- 5
3 <- 6
mappings for toList
direct:
4 -> nothing
5 -> nothing
6 -> nothing
reverse:
empty
Disconnected from the target VM
Process finished with exit code 0
@@ -0,0 +1,29 @@
LineBreakpoint created at SortedBy.kt:6
Run Java
Connected to the target VM
SortedBy.kt:6
arrayOf(Person("Bob", 42), Person("Alice", 27)).asSequence()
.sortedBy({ it.age })
.count()
sortedBy
before: 1,2
after: 3,4
count
before: 3,4
after: nothing
mappings for sortedBy
direct:
1 -> 4
2 -> 3
reverse:
2 <- 3
1 <- 4
mappings for count
direct:
3 -> nothing
4 -> nothing
reverse:
empty
Disconnected from the target VM
Process finished with exit code 0
@@ -0,0 +1,29 @@
LineBreakpoint created at SortedByDescending.kt:5
Run Java
Connected to the target VM
SortedByDescending.kt:5
arrayOf(Person("Bob", 42), Person("Alice", 27)).asSequence()
.sortedByDescending({ it.age })
.count()
sortedByDescending
before: 1,2
after: 3,4
count
before: 3,4
after: nothing
mappings for sortedByDescending
direct:
1 -> nothing
2 -> nothing
reverse:
nothing <- 3
nothing <- 4
mappings for count
direct:
3 -> nothing
4 -> nothing
reverse:
empty
Disconnected from the target VM
Process finished with exit code 0
@@ -0,0 +1,32 @@
LineBreakpoint created at SortedDescending.kt:5
Run Java
Connected to the target VM
SortedDescending.kt:5
intArrayOf(2, 1, 3).asSequence()
.sortedDescending()
.toList()
sortedDescending
before: 1,2,3
after: 4,5,6
toList
before: 4,5,6
after: nothing
mappings for sortedDescending
direct:
1 -> 5
2 -> 6
3 -> 4
reverse:
3 <- 4
1 <- 5
2 <- 6
mappings for toList
direct:
4 -> nothing
5 -> nothing
6 -> nothing
reverse:
empty
Disconnected from the target VM
Process finished with exit code 0
@@ -0,0 +1,29 @@
LineBreakpoint created at SortedWith.kt:5
Run Java
Connected to the target VM
SortedWith.kt:5
arrayOf(Person("Bob", 42), Person("Alice", 27)).asSequence()
.sortedWith(compareBy { it.name })
.count()
sortedWith
before: 1,2
after: 3,4
count
before: 3,4
after: nothing
mappings for sortedWith
direct:
1 -> 4
2 -> 3
reverse:
2 <- 3
1 <- 4
mappings for count
direct:
3 -> nothing
4 -> nothing
reverse:
empty
Disconnected from the target VM
Process finished with exit code 0
@@ -0,0 +1,6 @@
package sort
fun main(args: Array<String>) {
// Breakpoint!
intArrayOf(2, 1, 3).asSequence().sorted().toList()
}
@@ -0,0 +1,9 @@
// 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 sort
fun main(args: Array<String>) {
// Breakpoint!
arrayOf(Person("Bob", 42), Person("Alice", 27)).asSequence().sortedBy { it.age }.count()
}
internal data class Person(val name: String, val age: Int)
@@ -0,0 +1,6 @@
package sort
fun main(args: Array<String>) {
// Breakpoint!
arrayOf(Person("Bob", 42), Person("Alice", 27)).asSequence().sortedByDescending { it.age }.count()
}
@@ -0,0 +1,6 @@
package sort
fun main(args: Array<String>) {
// Breakpoint!
intArrayOf(2, 1, 3).asSequence().sortedDescending().toList()
}
@@ -0,0 +1,7 @@
package sort
fun main(args: Array<String>) {
// Breakpoint!
arrayOf(Person("Bob", 42), Person("Alice", 27)).asSequence()
.sortedWith(compareBy { it.name }).count()
}