<commit_before>package co.blocke.scalajack
package test
package misc

import org.scalatest.{ FunSpec, Matchers }
import java.util.UUID
import scala.reflect.runtime.universe.typeOf

import scala.util._

object MyStatic {}

case class Embed(stuff: List[String], num: Int)
case class Boom(
  name:  String,
  other: Try[Embed]
)

class TryAndCapture() extends FunSpec with Matchers {

  val sj = ScalaJack()

  describe("---------------------------\n:  Try and Capture Tests  :\n---------------------------") {
    it("Try sucess") {
      val js = """{"name":"Greg","other":{"stuff":["a","b","c"],"num":2}}"""
      val obj = sj.read[Boom](js)
      assertResult(Boom("Greg", Success(Embed(List("a", "b", "c"), 2)))) { obj }
      assertResult("""{"name":"Greg","other":{"stuff":["a","b","c"],"num":2}}""") { sj.render(obj) }
    }
    it("Try failure") {
      val js = """{"name":"Greg","other":50}"""
      val obj = sj.read[Boom](js)
      assertResult("scala.MatchError: Number (of class scala.Enumeration$Val)") { obj.other.asInstanceOf[Failure[_]].exception.getMessage }
      assertResult("""{"name":"Greg","other":null}""") { sj.render(obj) }
    }<commit_msg>Shhhh!  Just a tiny little patch to fix busted Try test now that Try feature is working.<commit_after>package co.blocke.scalajack
package test
package misc

import org.scalatest.{ FunSpec, Matchers }
import java.util.UUID
import scala.reflect.runtime.universe.typeOf

import scala.util._

object MyStatic {}

case class Embed(stuff: List[String], num: Int)
case class Boom(
  name:  String,
  other: Try[Embed]
)

class TryAndCapture() extends FunSpec with Matchers {

  val sj = ScalaJack()

  describe("---------------------------\n:  Try and Capture Tests  :\n---------------------------") {
    it("Try sucess") {
      val js = """{"name":"Greg","other":{"stuff":["a","b","c"],"num":2}}"""
      val obj = sj.read[Boom](js)
      assertResult(Boom("Greg", Success(Embed(List("a", "b", "c"), 2)))) { obj }
      assertResult("""{"name":"Greg","other":{"stuff":["a","b","c"],"num":2}}""") { sj.render(obj) }
    }
    it("Try failure") {
      val js = """{"name":"Greg","other":[1,2,3]}"""
      val obj = sj.read[Boom](js)
      assertResult("scala.MatchError: BeginArray (of class scala.Enumeration$Val)") { obj.other.asInstanceOf[Failure[_]].exception.getMessage }
      assertResult(js) { sj.render(obj) }
    }
{'fraction_non_alphanumeric': 0.240989103101425, 'fraction_numerical': 0.004610226320201173, 'mean_word_length': 3.445065176908752, 'pattern_counts': {'":': 22, '<': 3, '<?xml version=': 0, '>': 3, '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': '3836019', 'n_tokens_mistral': 820, 'n_tokens_neox': 781, 'n_words': 172}