From c95ba4da8e1fd72178f6be3855fa3ce95ed65dc0 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Wed, 20 May 2015 19:25:07 +0300 Subject: [PATCH] Tests for specialized primitive implementations of sets and maps in JS. --- .../stdlib/test/collections/CollectionTest.kt | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/libraries/stdlib/test/collections/CollectionTest.kt b/libraries/stdlib/test/collections/CollectionTest.kt index e274a83956b..77e40a42ac6 100644 --- a/libraries/stdlib/test/collections/CollectionTest.kt +++ b/libraries/stdlib/test/collections/CollectionTest.kt @@ -534,12 +534,32 @@ class CollectionTest { compare(listOf("value").toMutableSet(), setOf("value")) { setBehavior() } } + test fun specialJsSets() { + val specialJsStringSet = HashSet() + specialJsStringSet.add("kotlin") + compare(hashSetOf("kotlin"), specialJsStringSet) { setBehavior() } + + val specialJsNumberSet = HashSet() + specialJsNumberSet.add(3.14) + compare(hashSetOf(3.14), specialJsNumberSet) { setBehavior() } + } + test fun specialMaps() { compare(hashMapOf(), mapOf()) { mapBehavior() } compare(linkedMapOf(), emptyMap()) { mapBehavior() } compare(linkedMapOf(2 to 3), mapOf(2 to 3)) { mapBehavior() } } + test fun specialJsMaps() { + val specialJsStringMap = HashMap() + specialJsStringMap.put("k1", "v1") + compare(hashMapOf("k1" to "v1"), specialJsStringMap) { mapBehavior() } + + val specialJsNumberMap = HashMap(4) + specialJsNumberMap.put(5, "v5") + compare(hashMapOf(5 to "v5"), specialJsNumberMap) { mapBehavior() } + } + private fun CompareContext>.listBehavior() { equalityBehavior() collectionBehavior()