<commit_before>package akka.viz.serialization

import org.scalatest.{FlatSpec, Matchers}
import upickle.Js
import upickle.json.FastRenderer

class ReflectiveSerializersTest extends FlatSpec with Matchers {

  "ReflectiveSerializer" should "use default serializers recursively" in {

    val keys = MessageSerialization.serialize(new {
      val X = 123
      val y = "Test"
    }).value.asInstanceOf[Seq[(String, Js.Value)]]

    keys.find(_._1 == "X") shouldBe Some("X" -> Js.Num(123))
    keys.find(_._1 == "y") shouldBe Some("y" -> Js.Str("Test"))

  }

  it should "work with nested objects" in {
    val serialized = MessageSerialization.serialize(new {
      val obj = new {
        val X = 1
      }
    })

    val json = FastRenderer.render(serialized)
    json should include("\"X\":1")

  }


}
<commit_msg>Serialization cycles need to be handled<commit_after>package akka.viz.serialization

import org.scalatest.{FlatSpec, Matchers}
import upickle.Js
import upickle.json.FastRenderer

class ReflectiveSerializersTest extends FlatSpec with Matchers {

  "ReflectiveSerializer" should "use default serializers recursively" in {

    val keys = MessageSerialization.serialize(new {
      val X = 123
      val y = "Test"
    }).value.asInstanceOf[Seq[(String, Js.Value)]]

    keys.find(_._1 == "X") shouldBe Some("X" -> Js.Num(123))
    keys.find(_._1 == "y") shouldBe Some("y" -> Js.Str("Test"))

  }

  it should "work with nested objects" in {
    val serialized = MessageSerialization.serialize(new {
      val obj = new {
        val X = 1
      }
    })

    val json = FastRenderer.render(serialized)
    json should include("\"X\":1")

  }

  it should "handle cycles" in {
    pending
  }

}

{'fraction_non_alphanumeric': 0.12390414962010521, 'fraction_numerical': 0.011689070718877849, 'mean_word_length': 3.196078431372549, 'pattern_counts': {'":': 2, '<': 3, '<?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': '6274951', 'n_tokens_mistral': 572, 'n_tokens_neox': 546, 'n_words': 141}