Stdlib: run all stdlib tests with JS backend(as possible).

This commit is contained in:
Zalim Bashorov
2014-10-10 17:10:17 +04:00
parent f20ee6df4b
commit f202ad9f98
18 changed files with 252 additions and 208 deletions
@@ -70,6 +70,10 @@ class CollectionJVMTest {
}
}
test fun first() {
assertEquals(19, TreeSet(arrayListOf(90, 47, 19)).first())
}
test fun last() {
val data = arrayListOf("foo", "bar")
assertEquals("bar", data.last())
@@ -85,28 +89,19 @@ class CollectionJVMTest {
assertTrue(linkedListOf(15, 19, 20).contains(15))
}
test fun sortBy() {
expect(arrayListOf("two" to 2, "three" to 3)) {
arrayListOf("three" to 3, "two" to 2).sortBy { it.second }
}
expect(arrayListOf("three" to 3, "two" to 2)) {
arrayListOf("three" to 3, "two" to 2).sortBy { it.first }
}
expect(arrayListOf("two" to 2, "three" to 3)) {
arrayListOf("three" to 3, "two" to 2).sortBy { it.first.length }
test fun toArray() {
val data = arrayListOf("foo", "bar")
val arr = data.toArray()
println("Got array ${arr}")
assertEquals(2, arr.size)
todo {
assertTrue {
arr is Array<String>
}
}
}
test fun sortFunctionShouldReturnSortedCopyForList() {
val list: List<Int> = arrayListOf(2, 3, 1)
expect(arrayListOf(1, 2, 3)) { list.sort() }
expect(arrayListOf(2, 3, 1)) { list }
}
test fun sortFunctionShouldReturnSortedCopyForIterable() {
val list: Iterable<Int> = arrayListOf(2, 3, 1)
expect(arrayListOf(1, 2, 3)) { list.sort() }
expect(arrayListOf(2, 3, 1)) { list }
test fun takeReturnsFirstNElements() {
expect(setOf(1, 2)) { sortedSetOf(1, 2, 3, 4, 5).take(2).toSet() }
}
}