Make several tests running on JS backend.
This commit is contained in:
+4
-12
@@ -1,22 +1,14 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
import java.util.ArrayList
|
||||
import java.util.Arrays
|
||||
import java.util.Collections
|
||||
import java.util.Comparator
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun sort(list: MutableList<String>, comparator: (String, String) -> Int) {
|
||||
Collections.sort(list, object : Comparator<String> {
|
||||
override fun compare(p0: String, p1: String) = comparator(p0, p1)
|
||||
})
|
||||
list.sortWith(Comparator(comparator))
|
||||
}
|
||||
|
||||
fun compare(s1: String, s2: String) = s1.compareTo(s2)
|
||||
|
||||
fun box(): String {
|
||||
val l = ArrayList(Arrays.asList("d", "b", "c", "e", "a"))
|
||||
val l = mutableListOf("d", "b", "c", "e", "a")
|
||||
sort(l, ::compare)
|
||||
if (l != Arrays.asList("a", "b", "c", "d", "e")) return "Fail: $l"
|
||||
if (l != listOf("a", "b", "c", "d", "e")) return "Fail: $l"
|
||||
return "OK"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user