KT-42589 Add listOf, setOf, mapOf overloads for a single value to common src-set

`listOf`, `setOf` and `mapOf` overloads were defined in some source-sets
but common source-set was missing it.
This change adds common definition of these methods and also add
declarations for source-sets that were previously
missing it.

^KT-42589 fixed
This commit is contained in:
Filipp Zhinkin
2023-04-19 08:48:29 +02:00
committed by Space Team
parent aa85e6d95c
commit 50841e7cb0
12 changed files with 112 additions and 36 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -184,10 +184,14 @@ class CollectionJVMTest {
@Test fun emptyMapIsSerializable() = testSingletonSerialization(emptyMap<Any, Any>())
private fun testSingletonSerialization(value: Any) {
private fun checkSerializeAndDeserialize(value: Any): Any {
val result = serializeAndDeserialize(value)
assertEquals(value, result)
return result
}
private fun testSingletonSerialization(value: Any) {
val result = checkSerializeAndDeserialize(value)
assertSame(value, result)
}
@@ -245,7 +249,6 @@ class CollectionJVMTest {
testCollectionBuilderSerialization(source)
}
private fun testCollectionBuilderSerialization(value: Any) {
val result = serializeAndDeserialize(value)
assertEquals(value, result)
@@ -260,4 +263,14 @@ class CollectionJVMTest {
}
}
@Test fun singletonListIsSerializable() = testSingletonCollectionSerialization(listOf(42))
@Test fun singletonSetIsSerializable() = testSingletonCollectionSerialization(setOf(42))
@Test fun singletonMapIsSerializable() = testSingletonCollectionSerialization(mapOf("hello" to "world"))
private fun testSingletonCollectionSerialization(value: Any) {
val deserialized = checkSerializeAndDeserialize(value)
assertReadOnly(deserialized)
}
}