Fix testData/codegen: replace deprecated sort usages.
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
class K {
|
class K {
|
||||||
fun reverse(s: String): String {
|
fun reverse(s: String): String {
|
||||||
return s.reverse()
|
return s.reversed()
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
+3
-3
@@ -2,9 +2,9 @@ import kotlin.reflect.*
|
|||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
assertEquals(listOf("equals", "hashCode", "member", "staticMethod", "toString"), J::class.members.map { it.name }.toSortedList())
|
assertEquals(listOf("equals", "hashCode", "member", "staticMethod", "toString"), J::class.members.map { it.name }.sorted())
|
||||||
assertEquals(listOf("equals", "hashCode", "member", "staticMethod", "toString"), J::class.functions.map { it.name }.toSortedList())
|
assertEquals(listOf("equals", "hashCode", "member", "staticMethod", "toString"), J::class.functions.map { it.name }.sorted())
|
||||||
assertEquals(listOf("member", "staticMethod"), J::class.declaredFunctions.map { it.name }.toSortedList())
|
assertEquals(listOf("member", "staticMethod"), J::class.declaredFunctions.map { it.name }.sorted())
|
||||||
|
|
||||||
assertEquals(1, J::class.constructors.size())
|
assertEquals(1, J::class.constructors.size())
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
assertEquals(listOf("Inner", "Nested", "PrivateNested"), J::class.nestedClasses.map { it.simpleName!! }.toSortedList())
|
assertEquals(listOf("Inner", "Nested", "PrivateNested"), J::class.nestedClasses.map { it.simpleName!! }.sorted())
|
||||||
|
|
||||||
return "OK"
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+1
-1
@@ -7,7 +7,7 @@ class C @Primary constructor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
val ans = C::class.constructors.map { it.annotations.single().annotationType().simpleName }.toSortedList()
|
val ans = C::class.constructors.map { it.annotations.single().annotationType().simpleName }.sorted()
|
||||||
if (ans != listOf("Primary", "Secondary")) return "Fail: $ans"
|
if (ans != listOf("Primary", "Secondary")) return "Fail: $ans"
|
||||||
return "OK"
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ class A {
|
|||||||
private class PrivateNested
|
private class PrivateNested
|
||||||
}
|
}
|
||||||
|
|
||||||
fun nestedNames(c: KClass<*>) = c.nestedClasses.map { it.simpleName ?: throw AssertionError("Unnamed class: ${it.java}") }.toSortedList()
|
fun nestedNames(c: KClass<*>) = c.nestedClasses.map { it.simpleName ?: throw AssertionError("Unnamed class: ${it.java}") }.sorted()
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
// Kotlin class without nested classes
|
// Kotlin class without nested classes
|
||||||
|
|||||||
+3
-3
@@ -8,13 +8,13 @@ open class A {
|
|||||||
class B : A()
|
class B : A()
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
val all = A::class.functions.map { it.name }.toSortedList()
|
val all = A::class.functions.map { it.name }.sorted()
|
||||||
assert(all == listOf("equals", "hashCode", "mem", "memExt", "toString")) { "Fail A functions: ${A::class.functions}" }
|
assert(all == listOf("equals", "hashCode", "mem", "memExt", "toString")) { "Fail A functions: ${A::class.functions}" }
|
||||||
|
|
||||||
val declared = A::class.declaredFunctions.map { it.name }.toSortedList()
|
val declared = A::class.declaredFunctions.map { it.name }.sorted()
|
||||||
assert(declared == listOf("mem", "memExt")) { "Fail A declaredFunctions: ${A::class.declaredFunctions}" }
|
assert(declared == listOf("mem", "memExt")) { "Fail A declaredFunctions: ${A::class.declaredFunctions}" }
|
||||||
|
|
||||||
val declaredSubclass = B::class.declaredFunctions.map { it.name }.toSortedList()
|
val declaredSubclass = B::class.declaredFunctions.map { it.name }.sorted()
|
||||||
assert(declaredSubclass.isEmpty()) { "Fail B declaredFunctions: ${B::class.declaredFunctions}" }
|
assert(declaredSubclass.isEmpty()) { "Fail B declaredFunctions: ${B::class.declaredFunctions}" }
|
||||||
|
|
||||||
return "OK"
|
return "OK"
|
||||||
|
|||||||
+2
-2
@@ -14,8 +14,8 @@ class Sub : Super() {
|
|||||||
fun box(): String {
|
fun box(): String {
|
||||||
val sub = Sub::class
|
val sub = Sub::class
|
||||||
|
|
||||||
assertEquals(listOf("a", "c"), sub.memberProperties.map { it.name }.sort())
|
assertEquals(listOf("a", "c"), sub.memberProperties.map { it.name }.sorted())
|
||||||
assertEquals(listOf("b", "d"), sub.memberExtensionProperties.map { it.name }.sort())
|
assertEquals(listOf("b", "d"), sub.memberExtensionProperties.map { it.name }.sorted())
|
||||||
assertEquals(listOf("c"), sub.declaredMemberProperties.map { it.name })
|
assertEquals(listOf("c"), sub.declaredMemberProperties.map { it.name })
|
||||||
assertEquals(listOf("d"), sub.declaredMemberExtensionProperties.map { it.name })
|
assertEquals(listOf("d"), sub.declaredMemberExtensionProperties.map { it.name })
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@ fun box(): String {
|
|||||||
|
|
||||||
val props = klass.memberProperties
|
val props = klass.memberProperties
|
||||||
|
|
||||||
val names = props.map { it.name }.toSortedList()
|
val names = props.map { it.name }.sorted()
|
||||||
assert(names == listOf("anyVar", "int", "string")) { "Fail names: $props" }
|
assert(names == listOf("anyVar", "int", "string")) { "Fail names: $props" }
|
||||||
|
|
||||||
val stringProp = props.firstOrNull { it.name == "string" } ?: return "Fail, string not found: $props"
|
val stringProp = props.firstOrNull { it.name == "string" } ?: return "Fail, string not found: $props"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
fun box(): String {
|
fun box(): String {
|
||||||
val sorted = arrayListOf("1", "3", "2").sort()
|
val sorted = arrayListOf("1", "3", "2").sorted()
|
||||||
return if (sorted != arrayListOf("1", "2", "3")) "$sorted" else "OK"
|
return if (sorted != arrayListOf("1", "2", "3")) "$sorted" else "OK"
|
||||||
}
|
}
|
||||||
@@ -23,6 +23,6 @@ class C(val nums: Map<E, Int>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
val res = C(hashMapOf(E.VALUE to 11, E.VALUE2 to 12)).normalizedNums.values().sort().joinToString()
|
val res = C(hashMapOf(E.VALUE to 11, E.VALUE2 to 12)).normalizedNums.values().sorted().joinToString()
|
||||||
return if ("0.0, 1.0" == res) "OK" else "fail $res"
|
return if ("0.0, 1.0" == res) "OK" else "fail $res"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user