Fix null values being treated as missing in 'put' method of a specialized string-keyed map

This commit is contained in:
Ilya Gorbunov
2017-04-17 21:03:04 +03:00
parent 8fdb611e3b
commit 2db8714fc5
2 changed files with 22 additions and 2 deletions
+15 -1
View File
@@ -45,7 +45,7 @@ class PrimitiveMapJsTest : MapJsTest() {
override fun emptyMutableMapWithNullableKeyValue(): MutableMap<String?, Int?> = HashMap()
@Test fun compareBehavior() {
val specialJsStringMap = HashMap<String, Any>()
val specialJsStringMap = stringMapOf<Any>()
specialJsStringMap.put("k1", "v1")
compare(genericHashMapOf("k1" to "v1"), specialJsStringMap) { mapBehavior() }
@@ -53,6 +53,20 @@ class PrimitiveMapJsTest : MapJsTest() {
specialJsNumberMap.put(5, "v5")
compare(genericHashMapOf(5 to "v5"), specialJsNumberMap) { mapBehavior() }
}
@Test fun putNull() {
val map = stringMapOf("k" to null)
assertEquals(1, map.size)
map.put("k", null)
assertEquals(1, map.size)
map["k"] = null
assertEquals(1, map.size)
map.remove("k")
assertEquals(0, map.size)
}
}
class LinkedHashMapJsTest : MapJsTest() {