Skip to content

Commit 1f4a9e5

Browse files
authored
Uncomment all stale tests that depended on Kotlin upgrade (#2147)
1 parent 15eaee9 commit 1f4a9e5

File tree

4 files changed

+55
-59
lines changed

4 files changed

+55
-59
lines changed

core/commonTest/src/kotlinx/serialization/CachedSerializersTest.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
package kotlinx.serialization
66

77
import kotlinx.serialization.modules.*
8-
import kotlinx.serialization.test.noJsLegacy
8+
import kotlinx.serialization.test.*
99
import kotlin.test.*
1010
import kotlin.time.*
1111

@@ -65,8 +65,7 @@ class CachedSerializersTest {
6565

6666
@OptIn(ExperimentalTime::class)
6767
@Test
68-
@Ignore // TODO: Unignore after 1.8.0 update
69-
fun testSerializersAreIntrinsified() {
68+
fun testSerializersAreIntrinsified() = jvmOnly {
7069
val m = SerializersModule { }
7170
val direct = measureTime {
7271
Object.serializer()

formats/json-tests/commonTest/src/kotlinx/serialization/features/DurationTest.kt

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,15 @@ import kotlin.time.Duration
1111
import kotlin.time.DurationUnit
1212
import kotlin.time.toDuration
1313

14-
1514
class DurationTest : JsonTestBase() {
16-
// TODO uncomment when Kotlin 1.7.20 is released
17-
// @Serializable
18-
// data class DurationHolder(val duration: Duration)
19-
// @Test
20-
// fun testDuration() {
21-
// assertJsonFormAndRestored(
22-
// DurationHolder.serializer(),
23-
// DurationHolder(1000.toDuration(DurationUnit.SECONDS)),
24-
// """{"duration":"PT16M40S"}"""
25-
// )
26-
// }
15+
@Serializable
16+
data class DurationHolder(val duration: Duration)
17+
@Test
18+
fun testDuration() {
19+
assertJsonFormAndRestored(
20+
DurationHolder.serializer(),
21+
DurationHolder(1000.toDuration(DurationUnit.SECONDS)),
22+
"""{"duration":"PT16M40S"}"""
23+
)
24+
}
2725
}

formats/json-tests/commonTest/src/kotlinx/serialization/features/inline/UnsignedIntegersTest.kt

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -21,36 +21,36 @@ class UnsignedIntegersTest : JsonTestBase() {
2121
val double: Double
2222
)
2323

24-
// TODO uncomment when Kotlin 1.8.0 is released
25-
// @Serializable
26-
// data class UnsignedArrays(
27-
// val uByte: UByteArray,
28-
// val uShort: UShortArray,
29-
// val uInt: UIntArray,
30-
// val uLong: ULongArray
31-
// ) {
32-
// override fun equals(other: Any?): Boolean {
33-
// if (this === other) return true
34-
// if (other == null || this::class != other::class) return false
35-
//
36-
// other as UnsignedArrays
37-
//
38-
// if (!uByte.contentEquals(other.uByte)) return false
39-
// if (!uShort.contentEquals(other.uShort)) return false
40-
// if (!uInt.contentEquals(other.uInt)) return false
41-
// if (!uLong.contentEquals(other.uLong)) return false
42-
//
43-
// return true
44-
// }
45-
//
46-
// override fun hashCode(): Int {
47-
// var result = uByte.contentHashCode()
48-
// result = 31 * result + uShort.contentHashCode()
49-
// result = 31 * result + uInt.contentHashCode()
50-
// result = 31 * result + uLong.contentHashCode()
51-
// return result
52-
// }
53-
// }
24+
@ExperimentalUnsignedTypes
25+
@Serializable
26+
data class UnsignedArrays(
27+
val uByte: UByteArray,
28+
val uShort: UShortArray,
29+
val uInt: UIntArray,
30+
val uLong: ULongArray
31+
) {
32+
override fun equals(other: Any?): Boolean {
33+
if (this === other) return true
34+
if (other == null || this::class != other::class) return false
35+
36+
other as UnsignedArrays
37+
38+
if (!uByte.contentEquals(other.uByte)) return false
39+
if (!uShort.contentEquals(other.uShort)) return false
40+
if (!uInt.contentEquals(other.uInt)) return false
41+
if (!uLong.contentEquals(other.uLong)) return false
42+
43+
return true
44+
}
45+
46+
override fun hashCode(): Int {
47+
var result = uByte.contentHashCode()
48+
result = 31 * result + uShort.contentHashCode()
49+
result = 31 * result + uInt.contentHashCode()
50+
result = 31 * result + uLong.contentHashCode()
51+
return result
52+
}
53+
}
5454

5555
@Serializable
5656
data class UnsignedWithoutLong(val uInt: UInt, val uByte: UByte, val uShort: UShort)
@@ -123,18 +123,18 @@ class UnsignedIntegersTest : JsonTestBase() {
123123
) { l, r -> l.contentEquals(r) }
124124
}
125125

126-
// TODO uncomment when Kotlin 1.8.0 is released
127-
// @OptIn(ExperimentalUnsignedTypes::class)
128-
// fun testArrays() {
129-
// val data = UnsignedArrays(
130-
// ubyteArrayOf(1U, 220U),
131-
// ushortArrayOf(1U, 65000U),
132-
// uintArrayOf(1U, 2147483657U),
133-
// ulongArrayOf(1U, 9223372036854775817U)
134-
// )
135-
// val json = """{"uByte":[1,220],uShort:[1,65000],uInt:[1,2147483657],uLong:[1,9223372036854775817]}"""
136-
//
137-
// assertJsonFormAndRestored(UnsignedArrays.serializer(), data, json)
138-
// }
126+
@OptIn(ExperimentalUnsignedTypes::class)
127+
@Test
128+
fun testArrays() {
129+
val data = UnsignedArrays(
130+
ubyteArrayOf(1U, 220U),
131+
ushortArrayOf(1U, 65000U),
132+
uintArrayOf(1U, 2147483657U),
133+
ulongArrayOf(1U, 9223372036854775817U)
134+
)
135+
val json = """{"uByte":[1,220],"uShort":[1,65000],"uInt":[1,2147483657],"uLong":[1,9223372036854775817]}"""
136+
137+
assertJsonFormAndRestored(UnsignedArrays.serializer(), data, json)
138+
}
139139

140140
}

formats/json-tests/jvmTest/src/kotlinx/serialization/features/SerializerByTypeTest.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ class SerializerByTypeTest {
287287

288288
@OptIn(ExperimentalTime::class)
289289
@Test
290-
@Ignore // TODO: Unignore after 1.8.0 update
291290
fun testSerializersAreIntrinsified() {
292291
val direct = measureTime {
293292
Json.encodeToString(IntData.serializer(), IntData(10))

0 commit comments

Comments
 (0)