Fix deprecations in testData

This commit is contained in:
Ilya Gorbunov
2016-01-27 16:03:27 +03:00
parent eabac9dcf6
commit d49f5b95b0
15 changed files with 26 additions and 21 deletions
@@ -1,7 +1,7 @@
package foo
fun sequenceFromFunctionWithInitialValue() {
val values = sequence(3) { n -> if (n > 0) n - 1 else null }
val values = generateSequence(3) { n -> if (n > 0) n - 1 else null }
assertEquals(arrayListOf(3, 2, 1, 0), values.toList())
}
@@ -1,10 +1,12 @@
package foo
import kotlin.comparisons.*
val Int.abs: Int
get() = if (this >= 0) this else -this
fun test(xs: List<Int>): List<Int> =
xs.sortedWith(comparator { a, b -> a.abs.compareTo(b.abs) })
xs.sortedWith(compareBy { it.abs })
fun box(): String {
assertEquals(listOf(1, -2, 3, -4), test(listOf(-2, 1, -4, 3)))
+1 -1
View File
@@ -123,7 +123,7 @@ fun printField(s: String, steps: Int) {
fun makeField(s: String): Field {
val lines: List<String> = s.split("\n")
val w = Collections.max<String>(lines.toList(), comparator<String> { o1, o2 ->
val w = Collections.max<String>(lines.toList(), Comparator<String> { o1, o2 ->
val l1: Int = o1.length
val l2 = o2.length
l1 - l2