Skip to content

Commit

Permalink
use Map.apply in test. revert workaround for Scala 2.13.0-M5
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwei-k committed Jun 27, 2019
1 parent 864d22b commit 08a5a7f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ class MapSerializationExamples extends Specification {
"Map with Timestamp key" in {
val t2013 = new Timestamp(1356998400)
val t2014 = new Timestamp(1388534400)
// TODO use Map.apply instead of "new Map.Map2" when 2.13.0-M5 released
// https://github.com/scala/scala/commit/6a570b6f1f59222cae4f55aa25d48e3d4c22ea59
val pw: Map[Timestamp, String] = new Map.Map2(t2013, "hello", t2014, "world")
val pw: Map[Timestamp, String] = Map(t2013 -> "hello", t2014 -> "world")
val ser = swrite(pw)

val f2013 = formats.dateFormat.format(t2013)
Expand Down Expand Up @@ -80,9 +78,7 @@ class MapSerializationExamples extends Specification {
}

"case class with custom map" in {
// TODO use Map.apply instead of "new Map.Map2" when 2.13.0-M5 released
// https://github.com/scala/scala/commit/6a570b6f1f59222cae4f55aa25d48e3d4c22ea59
val pw = PlayerWithCustomMap("zortan", new Map.Map2("2013", "zortan13", "2014", "zortan14"))
val pw = PlayerWithCustomMap("zortan", Map("2013" -> "zortan13", "2014" -> "zortan14"))
val ser = swrite(pw)
val s: String = """{"name":"zortan","aliasByYear":{"2013":"zortan13","2014":"zortan14"}}"""
ser must_== s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,19 +170,15 @@ object SerializationExamples extends Specification {
}

"Generic Map with simple values example" in {
// TODO use Map.apply instead of "new Map.Map2" when 2.13.0-M5 released
// https://github.com/scala/scala/commit/6a570b6f1f59222cae4f55aa25d48e3d4c22ea59
val pw = PlayerWithGenericMap("zortan", new Map.Map2("1", "asd", "a", 3))
val pw = PlayerWithGenericMap("zortan", Map("1" -> "asd", "a" -> 3))
val ser = swrite(pw)
ser must_== """{"name":"zortan","infomap":{"1":"asd","a":3}}"""
read[PlayerWithGenericMap](ser) must_== pw
}

"Generic Map with case class and type hint example" in {
implicit val formats = native.Serialization.formats(ShortTypeHints(List(classOf[Player])))
// TODO use Map.apply instead of "new Map.Map3" when 2.13.0-M5 released
// https://github.com/scala/scala/commit/6a570b6f1f59222cae4f55aa25d48e3d4c22ea59
val pw = PlayerWithGenericMap("zortan", new Map.Map3("1", "asd", "a", 3, "friend", Player("joe")))
val pw = PlayerWithGenericMap("zortan", Map("1" -> "asd", "a" -> 3, "friend" -> Player("joe")))
val ser = swrite(pw)
ser must_== """{"name":"zortan","infomap":{"1":"asd","a":3,"friend":{"jsonClass":"Player","name":"joe"}}}"""
read[PlayerWithGenericMap](ser) must_== pw
Expand Down

0 comments on commit 08a5a7f

Please sign in to comment.