Fix testData/js: replace deprecated usages: times, sortBy, reverse, splitBy.
This commit is contained in:
+1
-1
@@ -5,7 +5,7 @@ package foo
|
|||||||
internal fun test(a: Int, b: Int): Int {
|
internal fun test(a: Int, b: Int): Int {
|
||||||
var c = 0
|
var c = 0
|
||||||
|
|
||||||
b.times {
|
repeat(b) {
|
||||||
c += a
|
c += a
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ val Int.abs: Int
|
|||||||
get() = if (this >= 0) this else -this
|
get() = if (this >= 0) this else -this
|
||||||
|
|
||||||
fun test(xs: List<Int>): List<Int> =
|
fun test(xs: List<Int>): List<Int> =
|
||||||
xs.sortBy(comparator { a, b -> a.abs.compareTo(b.abs) })
|
xs.sortedWith(comparator { a, b -> a.abs.compareTo(b.abs) })
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
assertEquals(listOf(1, -2, 3, -4), test(listOf(-2, 1, -4, 3)))
|
assertEquals(listOf(1, -2, 3, -4), test(listOf(-2, 1, -4, 3)))
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ internal fun test(a: Int, b: Int): Int {
|
|||||||
with (a + b) {
|
with (a + b) {
|
||||||
val t = this
|
val t = this
|
||||||
|
|
||||||
t.times {
|
repeat(t) {
|
||||||
res += t - b
|
res += t - b
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ package foo
|
|||||||
internal var counter = 0
|
internal var counter = 0
|
||||||
|
|
||||||
internal fun test(a: Int) {
|
internal fun test(a: Int) {
|
||||||
a.times {
|
repeat(a) {
|
||||||
counter += 1
|
counter += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
package foo
|
package foo
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
assertEquals(listOf(7, 6, 5, 4, 3), (3..7).reverse())
|
assertEquals(listOf(7, 6, 5, 4, 3), (3..7).reversed().toList())
|
||||||
assertEquals(listOf(10, 11, 12, 13), (13 downTo 10).reverse())
|
assertEquals(listOf(10, 11, 12, 13), (13 downTo 10).reversed().toList())
|
||||||
|
|
||||||
return "OK"
|
return "OK"
|
||||||
}
|
}
|
||||||
@@ -130,7 +130,7 @@ fun <T, C : MutableCollection<T>> Array<T>.to(result: C): C {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun makeField(s: String): Field {
|
fun makeField(s: String): Field {
|
||||||
val lines: List<String> = s.splitBy("\n")
|
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 l1: Int = o1.length()
|
||||||
|
|||||||
Reference in New Issue
Block a user