Libraries written in Kotlin are factored out into a separate project

This commit is contained in:
Andrey Breslav
2012-03-06 18:48:49 +04:00
parent 7c6f1657d2
commit 0a08ac5fe8
253 changed files with 252 additions and 2703 deletions
+53
View File
@@ -0,0 +1,53 @@
package test.collections
import kotlin.test.*
// TODO can we avoid importing all this stuff by default I wonder?
// e.g. making println and the collection builder methods public by default?
import kotlin.*
import kotlin.io.*
import kotlin.util.*
import java.util.*
import junit.framework.TestCase
class MapTest() : TestCase() {
val data: java.util.Map<String, Int> = java.util.HashMap<String, Int>()
fun testGetOrElse() {
val a = data.getOrElse("foo"){2}
assertEquals(2, a)
val b = data.getOrElse("foo"){3}
assertEquals(3, b)
assertEquals(0, data.size())
}
fun testGetOrPut() {
val a = data.getOrPut("foo"){2}
assertEquals(2, a)
val b = data.getOrPut("foo"){3}
assertEquals(2, b)
assertEquals(1, data.size())
}
fun testSizeAndEmpty() {
assertTrue{ data.empty }
// TODO using size breaks a test case
assertEquals(data.size(), 0)
}
fun testSetViaIndexOperators() {
val map = java.util.HashMap<String, String>()
assertTrue{ map.empty }
// TODO using size breaks a test case
assertEquals(map.size(), 0)
map["name"] = "James"
assertTrue{ !map.empty }
assertEquals(map.size(), 1)
assertEquals("James", map["name"])
}
}