<commit_before>/*
 * Copyright 2017-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
 */

package kotlinx.serialization

import kotlinx.io.*
import kotlinx.serialization.internal.*
import kotlinx.serialization.cbor.Cbor
import kotlinx.serialization.json.Json
import kotlinx.serialization.protobuf.ProtoBuf
import kotlin.test.*

class CommonTest {
    @Test
    fun canSerialize() {
        val serializer = Shop.serializer()
        val jsonShop = Json.stringify(serializer, shop)
        assertTrue(jsonShop.isNotBlank())
    }

    @Test
    fun basicJson() {
        val serializer = SimpleData.serializer()
        val data = SimpleData("foo", 42)
        val json = Json.stringify(serializer, data)
        assertEquals("""{"foo":"foo","bar":42}""", json)
    }

    @Test
    fun isomorphicCbor() {
        val zoo = shop
        val serial = Shop.serializer()
        val zoo2 = Cbor.load(serial, Cbor.dump(serial, zoo))
        assertTrue(zoo !== zoo2)
        assertEquals(zoo, zoo2)
    }

    @Test
    fun isomorphicProtobuf() {
        val country = russia
        val serial = CountryData.serializer()
        val country2 = ProtoBuf.load(serial, ProtoBuf.dump(serial, country))
        assertTrue(country !== country2)
        assertEquals(country, country2)
    }

    @Test
    fun nativeSupportSerialIds() {
        val country = CountryData.serializer()
        val id1 = country.descriptor.findAnnotation<SerialId>(0)?.id ?: 0
        val id2 = getSerialId(country.descriptor, 0)
        assertEquals(10, id1)
        assertEquals(10, id2)
    }

    @Test
    @Ignore // todo: unignore on 1.3.50-eap-2
    @UseExperimental(ImplicitReflectionSerializer::class)
    fun nativeSupportsSimpleReflectionSerializer() {
        val s = Json.stringify(shop)
        println(s)
        val shop2 = Json.parse<Shop>(s)
        assertEquals(shop, shop2)
    }
}<commit_msg>Unignore forgotten test<commit_after>/*
 * Copyright 2017-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
 */

package kotlinx.serialization

import kotlinx.io.*
import kotlinx.serialization.internal.*
import kotlinx.serialization.cbor.Cbor
import kotlinx.serialization.json.Json
import kotlinx.serialization.protobuf.ProtoBuf
import kotlin.test.*

class CommonTest {
    @Test
    fun canSerialize() {
        val serializer = Shop.serializer()
        val jsonShop = Json.stringify(serializer, shop)
        assertTrue(jsonShop.isNotBlank())
    }

    @Test
    fun basicJson() {
        val serializer = SimpleData.serializer()
        val data = SimpleData("foo", 42)
        val json = Json.stringify(serializer, data)
        assertEquals("""{"foo":"foo","bar":42}""", json)
    }

    @Test
    fun isomorphicCbor() {
        val zoo = shop
        val serial = Shop.serializer()
        val zoo2 = Cbor.load(serial, Cbor.dump(serial, zoo))
        assertTrue(zoo !== zoo2)
        assertEquals(zoo, zoo2)
    }

    @Test
    fun isomorphicProtobuf() {
        val country = russia
        val serial = CountryData.serializer()
        val country2 = ProtoBuf.load(serial, ProtoBuf.dump(serial, country))
        assertTrue(country !== country2)
        assertEquals(country, country2)
    }

    @Test
    fun nativeSupportSerialIds() {
        val country = CountryData.serializer()
        val id1 = country.descriptor.findAnnotation<SerialId>(0)?.id ?: 0
        val id2 = getSerialId(country.descriptor, 0)
        assertEquals(10, id1)
        assertEquals(10, id2)
    }

    @Test
    @UseExperimental(ImplicitReflectionSerializer::class)
    fun nativeSupportsSimpleReflectionSerializer() {
        val s = Json.stringify(shop)
        println(s)
        val shop2 = Json.parse<Shop>(s)
        assertEquals(shop, shop2)
    }
}
{'fraction_non_alphanumeric': 0.10994213571804314, 'fraction_numerical': 0.018674381904260916, 'mean_word_length': 2.74679802955665, 'pattern_counts': {'":': 4, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4624756', 'n_tokens_mistral': 1196, 'n_tokens_neox': 1144, 'n_words': 261}