EindbaasExpress / handsonscala-issuemigrator

Part of the HandsOnScala Course
0 stars 0 forks source link

Writing Scala 3 enums is broken #117

Open EindbaasExpress opened 2 years ago

EindbaasExpress commented 2 years ago

Trying to write Scala 3 enum values actually writes always the first one.

Test reproducing the problem

package upickle

import scala.language.implicitConversions
import utest._

import upickle.default._

object EnumTests extends TestSuite {

  enum SimpleEnum {
    case A, B
  }

  val tests = Tests {
    test("simple") {
      given ReadWriter[SimpleEnum] = macroRW[SimpleEnum]
      test("enum write") {
        val parsed = write(SimpleEnum.B)
        val expected = """{"$type":"upickle.EnumTests.SimpleEnum.B"}"""
        assert(parsed == expected)
      }
    }
  }
}

Fails with:

X upickle.EnumTests.simple.enum write 71ms 
  utest.AssertionError: parsed == expected
  parsed: String = {"$type":"upickle.EnumTests.SimpleEnum.A"}
  expected: String = {"$type":"upickle.EnumTests.SimpleEnum.B"}

ID: 356 Original Author: lolgab