Refactor Map-InternalMap to provide specialized linked string map and set

This commit is contained in:
Ilya Gorbunov
2016-08-26 22:25:56 +03:00
parent e342593d2e
commit 23d2654afd
9 changed files with 67 additions and 32 deletions
+14 -1
View File
@@ -55,7 +55,7 @@ class PrimitiveMapJsTest : MapJsTest() {
}
}
class LinkedHashMapTest : MapJsTest() {
class LinkedHashMapJsTest : MapJsTest() {
@test override fun constructors() {
LinkedHashMap<String, Int>()
LinkedHashMap<String, Int>(3)
@@ -72,6 +72,19 @@ class LinkedHashMapTest : MapJsTest() {
override fun emptyMutableMapWithNullableKeyValue(): MutableMap<String?, Int?> = LinkedHashMap()
}
class LinkedPrimitiveMapJsTest : MapJsTest() {
@test override fun constructors() {
val map = createTestMap()
assertEquals(KEYS.toNormalizedList(), map.keys.toNormalizedList())
assertEquals(VALUES.toNormalizedList(), map.values.toNormalizedList())
}
override fun <T : kotlin.Comparable<T>> Collection<T>.toNormalizedList(): List<T> = this.toList()
override fun emptyMutableMap(): MutableMap<String, Int> = linkedStringMapOf()
override fun emptyMutableMapWithNullableKeyValue(): MutableMap<String?, Int?> = LinkedHashMap()
}
abstract class MapJsTest {
val KEYS = listOf("zero", "one", "two", "three")
val VALUES = arrayOf(0, 1, 2, 3).toList()