diff options
author | kenji yoshida <6b656e6a69@gmail.com> | 2018-08-07 19:07:58 +0900 |
---|---|---|
committer | Johannes Rudolph <johannes.rudolph@gmail.com> | 2018-08-07 12:07:58 +0200 |
commit | 0131537d5635f0af53314d87eb6ed1fb42ae0c4b (patch) | |
tree | f0a36b3369f7ddb189374fdf112675d0022b6488 /src/test/scala | |
parent | 3e4d7da9b35abde4e110d0c61ea251da2697667c (diff) | |
download | spray-json-0131537d5635f0af53314d87eb6ed1fb42ae0c4b.tar.gz spray-json-0131537d5635f0af53314d87eb6ed1fb42ae0c4b.tar.bz2 spray-json-0131537d5635f0af53314d87eb6ed1fb42ae0c4b.zip |
Add support for Scala 2.13.0-M4 (#263)v1.3.4-2.13.0-M4
Diffstat (limited to 'src/test/scala')
4 files changed, 19 insertions, 12 deletions
diff --git a/src/test/scala/spray/json/AdditionalFormatsSpec.scala b/src/test/scala/spray/json/AdditionalFormatsSpec.scala index eafceb2..01127e6 100644 --- a/src/test/scala/spray/json/AdditionalFormatsSpec.scala +++ b/src/test/scala/spray/json/AdditionalFormatsSpec.scala @@ -64,8 +64,10 @@ class AdditionalFormatsSpec extends Specification { "The lazyFormat wrapper" should { "enable recursive format definitions" in { import FooProtocol._ - Foo(1, "a", Some(Foo(2, "b", Some(Foo(3, "c") :: Nil)) :: Foo(4, "d") :: Nil)).toJson.toString mustEqual - """{"id":1,"name":"a","foos":[{"id":2,"name":"b","foos":[{"id":3,"name":"c"}]},{"id":4,"name":"d"}]}""" + val json = Foo(1, "a", Some(Foo(2, "b", Some(Foo(3, "c") :: Nil)) :: Foo(4, "d") :: Nil)).toJson + + json mustEqual + """{"id":1,"name":"a","foos":[{"id":2,"name":"b","foos":[{"id":3,"name":"c"}]},{"id":4,"name":"d"}]}""".parseJson } } }
\ No newline at end of file diff --git a/src/test/scala/spray/json/CollectionFormatsSpec.scala b/src/test/scala/spray/json/CollectionFormatsSpec.scala index 3d953bb..9d6970b 100644 --- a/src/test/scala/spray/json/CollectionFormatsSpec.scala +++ b/src/test/scala/spray/json/CollectionFormatsSpec.scala @@ -59,12 +59,12 @@ class CollectionFormatsSpec extends Specification with DefaultJsonProtocol { "The immutableSetFormat" should { val set = Set(1, 2, 3) - val json = JsArray(JsNumber(1), JsNumber(2), JsNumber(3)) + val numbers = Set(JsNumber(1), JsNumber(2), JsNumber(3)) "convert a Set[Int] to a JsArray of JsNumbers" in { - set.toJson mustEqual json + set.toJson.asInstanceOf[JsArray].elements.toSet mustEqual numbers } "convert a JsArray of JsNumbers to a Set[Int]" in { - json.convertTo[Set[Int]] mustEqual set + JsArray(numbers.toVector).convertTo[Set[Int]] mustEqual set } } diff --git a/src/test/scala/spray/json/JsonParserSpec.scala b/src/test/scala/spray/json/JsonParserSpec.scala index a97f021..e5645a4 100644 --- a/src/test/scala/spray/json/JsonParserSpec.scala +++ b/src/test/scala/spray/json/JsonParserSpec.scala @@ -73,11 +73,16 @@ class JsonParserSpec extends Specification { JsonParser(json.prettyPrint.getBytes("UTF-8")) === json } "be reentrant" in { + import scala.concurrent.{Await, Future} + import scala.concurrent.duration._ + import scala.concurrent.ExecutionContext.Implicits.global + val largeJsonSource = scala.io.Source.fromInputStream(getClass.getResourceAsStream("/test.json")).mkString - import scala.collection.parallel.immutable.ParSeq - ParSeq.fill(20)(largeJsonSource).map(JsonParser(_)).toList.map { - _.asInstanceOf[JsObject].fields("questions").asInstanceOf[JsArray].elements.size - } === List.fill(20)(100) + val list = Await.result( + Future.traverse(List.fill(20)(largeJsonSource))(src => Future(JsonParser(src))), + 5.seconds + ) + list.map(_.asInstanceOf[JsObject].fields("questions").asInstanceOf[JsArray].elements.size) === List.fill(20)(100) } "produce proper error messages" in { diff --git a/src/test/scala/spray/json/ProductFormatsSpec.scala b/src/test/scala/spray/json/ProductFormatsSpec.scala index 30582a8..9eabc50 100644 --- a/src/test/scala/spray/json/ProductFormatsSpec.scala +++ b/src/test/scala/spray/json/ProductFormatsSpec.scala @@ -198,12 +198,12 @@ class ProductFormatsSpec extends Specification { "A JsonFormat created with `jsonFormat`, for a case class with mangled-name members," should { import TestProtocol1._ - val json = """{"ü$bavf$u56ú$":true,"=><+-*/!@#%^&~?|":1.0,"foo-bar!":42,"-x-":26,"User ID":"Karl"}""" + val json = """{"ü$bavf$u56ú$":true,"=><+-*/!@#%^&~?|":1.0,"foo-bar!":42,"-x-":26,"User ID":"Karl"}""".parseJson "produce the correct JSON" in { - TestMangled(42, "Karl", true, 26, 1.0f).toJson.compactPrint === json + TestMangled(42, "Karl", true, 26, 1.0f).toJson === json } "convert a JsObject to the respective case class instance" in { - json.parseJson.convertTo[TestMangled] === TestMangled(42, "Karl", true, 26, 1.0f) + json.convertTo[TestMangled] === TestMangled(42, "Karl", true, 26, 1.0f) } } } |