[JS IR] Add linkedHashMap tests

^KT-59001
This commit is contained in:
Alexander Korepanov
2023-06-26 19:44:03 +02:00
committed by Space Team
parent 2fdb605a03
commit bfb7f74e47
4 changed files with 161 additions and 116 deletions
@@ -8,6 +8,10 @@ package test.collections
import test.*
import kotlin.test.*
import test.collections.behaviors.*
import test.collections.js.linkedStringMapOf
import test.collections.js.linkedStringSetOf
import test.collections.js.stringMapOf
import test.collections.js.stringSetOf
import test.comparisons.STRING_CASE_INSENSITIVE_ORDER
import kotlin.math.pow
import kotlin.random.Random
@@ -1209,12 +1213,16 @@ class CollectionTest {
compare(linkedSetOf<Int>(), setOf<Int>()) { setBehavior() }
compare(hashSetOf<Double>(), emptySet<Double>()) { setBehavior() }
compare(listOf("value").toMutableSet(), setOf("value")) { setBehavior() }
compare(stringSetOf("value"), setOf("value")) { setBehavior() }
compare(linkedStringSetOf("value"), setOf("value")) { setBehavior() }
}
@Test fun specialMaps() {
compare(hashMapOf<String, Int>(), mapOf<String, Int>()) { mapBehavior() }
compare(linkedMapOf<Int, String>(), emptyMap<Int, String>()) { mapBehavior() }
compare(linkedMapOf(2 to 3), mapOf(2 to 3)) { mapBehavior() }
compare(stringMapOf("2" to 3), mapOf("2" to 3)) { mapBehavior() }
compare(linkedStringMapOf("2" to 3), mapOf("2" to 3)) { mapBehavior() }
}
@Test fun toStringTest() {
@@ -6,6 +6,7 @@
package test.collections
import test.*
import test.collections.js.linkedStringSetOf
import kotlin.test.*
fun <T> iterableOf(vararg items: T): Iterable<T> = Iterable { items.iterator() }
@@ -14,6 +15,7 @@ fun <T> Iterable<T>.toIterable(): Iterable<T> = Iterable { this.iterator() }
class IterableTest : OrderedIterableTests<Iterable<String>>({ iterableOf(*it) }, iterableOf<String>())
class SetTest : IterableTests<Set<String>>({ setOf(*it) }, setOf())
class LinkedSetTest : OrderedIterableTests<LinkedHashSet<String>>({ linkedSetOf(*it) }, linkedSetOf())
class LinkedStringSetTest : OrderedIterableTests<LinkedHashSet<String>>({ linkedStringSetOf(*it) }, linkedStringSetOf())
class ListTest : OrderedIterableTests<List<String>>({ listOf(*it) }, listOf<String>())
class ArrayListTest : OrderedIterableTests<ArrayList<String>>({ arrayListOf(*it) }, arrayListOf<String>())
@@ -7,6 +7,8 @@ package test.collections
import kotlin.test.*
import test.*
import test.collections.js.linkedStringMapOf
import test.collections.js.stringMapOf
import kotlin.math.pow
class MapTest {
@@ -438,6 +440,9 @@ class MapTest {
doTest("MapBuilder", this, "z", 25)
}
doTest("built Map", builtMap, "y", 24)
doTest("stringMapOf", mapLetterToIndex.toMap(stringMapOf()), "x", 23)
doTest("linkedStringMapOf", mapLetterToIndex.toMap(linkedStringMapOf()), "w", 22)
}
@Test
@@ -468,6 +473,9 @@ class MapTest {
putAll(mapLetterToIndex)
doTest("MapBuilder", this, "z", 25)
}
doTest("stringMapOf", mapLetterToIndex.toMap(stringMapOf()), "x", 23)
doTest("linkedStringMapOf", mapLetterToIndex.toMap(linkedStringMapOf()), "w", 22)
}
@Test