diff --git a/formats/json-tests/commonTest/src/kotlinx/serialization/SerializersLookupTest.kt b/formats/json-tests/commonTest/src/kotlinx/serialization/SerializersLookupTest.kt index f335d0d582..a4c8d35656 100644 --- a/formats/json-tests/commonTest/src/kotlinx/serialization/SerializersLookupTest.kt +++ b/formats/json-tests/commonTest/src/kotlinx/serialization/SerializersLookupTest.kt @@ -146,8 +146,7 @@ class SerializersLookupTest : JsonTestBase() { @OptIn(ExperimentalUuidApi::class) fun testLookupUuid() { assertSame?>(Uuid.serializer(), serializerOrNull(typeOf())) - // TODO: uncomment in 2.1 release -// assertSame?>(Uuid.serializer(), serializer()) + assertSame?>(Uuid.serializer(), serializer()) } @Test diff --git a/formats/json-tests/commonTest/src/kotlinx/serialization/features/UuidTest.kt b/formats/json-tests/commonTest/src/kotlinx/serialization/features/UuidTest.kt index 52f3b13d96..a70e110f16 100644 --- a/formats/json-tests/commonTest/src/kotlinx/serialization/features/UuidTest.kt +++ b/formats/json-tests/commonTest/src/kotlinx/serialization/features/UuidTest.kt @@ -18,19 +18,32 @@ class UuidTest : JsonTestBase() { assertJsonFormAndRestored(Uuid.serializer(), uuid, "\"$uuid\"") } - // TODO: write a test without @Contextual after 2.1.0 release @Serializable - data class Holder(@Contextual val uuid: Uuid) + data class Holder(val uuid: Uuid) + + @Serializable + data class HolderContextual(@Contextual val uuid: Uuid) val json = Json { serializersModule = serializersModuleOf(Uuid.serializer()) } @Test - fun testNested() { + fun testCompiled() { val fixed = Uuid.parse("bc501c76-d806-4578-b45e-97a264e280f1") assertJsonFormAndRestored( Holder.serializer(), Holder(fixed), """{"uuid":"bc501c76-d806-4578-b45e-97a264e280f1"}""", + Json + ) + } + + @Test + fun testContextual() { + val fixed = Uuid.parse("bc501c76-d806-4578-b45e-97a264e280f1") + assertJsonFormAndRestored( + HolderContextual.serializer(), + HolderContextual(fixed), + """{"uuid":"bc501c76-d806-4578-b45e-97a264e280f1"}""", json ) }