summaryrefslogtreecommitdiff
path: root/src/test/scala
diff options
context:
space:
mode:
authorMathias <mathias@spray.io>2014-09-19 15:13:01 +0200
committerMathias <mathias@spray.io>2014-09-19 15:13:01 +0200
commit37af0d4ca639ccea44efcb22d10a1e07abc4c04b (patch)
tree34e983e7d3b70e7c095a71d8645f612862a8c038 /src/test/scala
parentc4a92c096ee223e680ea1bba80c4633ed9f64344 (diff)
downloadspray-json-37af0d4ca639ccea44efcb22d10a1e07abc4c04b.tar.gz
spray-json-37af0d4ca639ccea44efcb22d10a1e07abc4c04b.tar.bz2
spray-json-37af0d4ca639ccea44efcb22d10a1e07abc4c04b.zip
Switch JsArray(List) to JsArray(Vector), make parser produce JsObject(HashMap) rather than JsObject(ListMap)
Diffstat (limited to 'src/test/scala')
-rw-r--r--src/test/scala/spray/json/PrettyPrinterSpec.scala74
-rw-r--r--src/test/scala/spray/json/ReadmeSpec.scala2
-rw-r--r--src/test/scala/spray/json/RoundTripSpecs.scala4
3 files changed, 40 insertions, 40 deletions
diff --git a/src/test/scala/spray/json/PrettyPrinterSpec.scala b/src/test/scala/spray/json/PrettyPrinterSpec.scala
index 27137a8..6354ef0 100644
--- a/src/test/scala/spray/json/PrettyPrinterSpec.scala
+++ b/src/test/scala/spray/json/PrettyPrinterSpec.scala
@@ -16,49 +16,49 @@
package spray.json
+import scala.collection.immutable.ListMap
import org.specs2.mutable._
class PrettyPrinterSpec extends Specification {
"The PrettyPrinter" should {
"print a more complicated JsObject nicely aligned" in {
- PrettyPrinter {
- JsonParser {
- """|{
- | "simpleKey" : "some value",
- | "key with spaces": null,
- | "zero": 0,
- | "number": -1.2323424E-5,
- | "Boolean yes":true,
- | "Boolean no": false,
- | "Unic\u00f8de" : "Long string with newline\nescape",
- | "key with \"quotes\"" : "string",
- | "sub object" : {
- | "sub key": 26.5,
- | "a": "b",
- | "array": [1, 2, { "yes":1, "no":0 }, ["a", "b", null], false]
- | }
- |}""".stripMargin
- }
- } mustEqual {
- """|{
- | "simpleKey": "some value",
- | "key with spaces": null,
- | "zero": 0,
- | "number": -0.000012323424,
- | "Boolean yes": true,
- | "Boolean no": false,
- | "Unic\u00f8de": "Long string with newline\nescape",
- | "key with \"quotes\"": "string",
- | "sub object": {
- | "sub key": 26.5,
- | "a": "b",
- | "array": [1, 2, {
- | "yes": 1,
- | "no": 0
- | }, ["a", "b", null], false]
- | }
- |}""".stripMargin
+ val JsObject(fields) = JsonParser {
+ """{
+ | "Boolean no": false,
+ | "Boolean yes":true,
+ | "Unic\u00f8de" : "Long string with newline\nescape",
+ | "key with \"quotes\"" : "string",
+ | "key with spaces": null,
+ | "number": -1.2323424E-5,
+ | "simpleKey" : "some value",
+ | "sub object" : {
+ | "sub key": 26.5,
+ | "a": "b",
+ | "array": [1, 2, { "yes":1, "no":0 }, ["a", "b", null], false]
+ | },
+ | "zero": 0
+ |}""".stripMargin
+ }
+ PrettyPrinter(JsObject(ListMap(fields.toSeq.sortBy(_._1):_*))) mustEqual {
+ """{
+ | "Boolean no": false,
+ | "Boolean yes": true,
+ | "Unic\u00f8de": "Long string with newline\nescape",
+ | "key with \"quotes\"": "string",
+ | "key with spaces": null,
+ | "number": -0.000012323424,
+ | "simpleKey": "some value",
+ | "sub object": {
+ | "sub key": 26.5,
+ | "a": "b",
+ | "array": [1, 2, {
+ | "yes": 1,
+ | "no": 0
+ | }, ["a", "b", null], false]
+ | },
+ | "zero": 0
+ |}""".stripMargin
}
}
}
diff --git a/src/test/scala/spray/json/ReadmeSpec.scala b/src/test/scala/spray/json/ReadmeSpec.scala
index 51a1ec5..306b656 100644
--- a/src/test/scala/spray/json/ReadmeSpec.scala
+++ b/src/test/scala/spray/json/ReadmeSpec.scala
@@ -60,7 +60,7 @@ class ReadmeSpec extends Specification {
JsArray(JsString(c.name), JsNumber(c.red), JsNumber(c.green), JsNumber(c.blue))
def read(value: JsValue) = value match {
- case JsArray(JsString(name) :: JsNumber(red) :: JsNumber(green) :: JsNumber(blue) :: Nil) =>
+ case JsArray(Seq(JsString(name), JsNumber(red), JsNumber(green), JsNumber(blue))) =>
new Color(name, red.toInt, green.toInt, blue.toInt)
case _ => deserializationError("Color expected")
}
diff --git a/src/test/scala/spray/json/RoundTripSpecs.scala b/src/test/scala/spray/json/RoundTripSpecs.scala
index d9e16c1..7609a53 100644
--- a/src/test/scala/spray/json/RoundTripSpecs.scala
+++ b/src/test/scala/spray/json/RoundTripSpecs.scala
@@ -20,7 +20,7 @@ object JsValueGenerators {
for {
n <- choose(0, 15)
els <- Gen.containerOfN[List, JsValue](n, genValue(depth - 1))
- } yield JsArray(els)
+ } yield JsArray(els.toVector)
def genField(depth: Int): Gen[(String, JsValue)] =
for {
key <- parseableString
@@ -32,7 +32,7 @@ object JsValueGenerators {
for {
n <- choose(0, 15)
fields <- Gen.containerOfN[List, (String, JsValue)](n, genField(depth - 1))
- } yield JsObject(fields)
+ } yield JsObject(fields: _*)
def genValue(depth: Int): Gen[JsValue] =
oneOf(