Make several tests running on JS backend.

This commit is contained in:
Ilya Gorbunov
2016-11-17 01:58:43 +03:00
parent 0899a0fdda
commit 62fe89b536
16 changed files with 48 additions and 196 deletions
@@ -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"
}