summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorJohannes Rudolph <johannes.rudolph@gmail.com>2013-05-29 14:43:35 +0200
committerJohannes Rudolph <johannes.rudolph@gmail.com>2013-05-29 14:43:35 +0200
commit64e2e332fa962a90185025ea3788cf4c56a65647 (patch)
tree843be95bbb8b79760c94b84f5838b99ad67cdcf5 /src/test
parent74230b67f21ee366827267de9b3c4d5fae8530c4 (diff)
downloadspray-json-64e2e332fa962a90185025ea3788cf4c56a65647.tar.gz
spray-json-64e2e332fa962a90185025ea3788cf4c56a65647.tar.bz2
spray-json-64e2e332fa962a90185025ea3788cf4c56a65647.zip
add test examining the current behavior when `optionalField` are nested and `set` is applied
Current result: One could think that nested `optionalField`s and `set` would create intermediate objects as well. However, this is currently not possible, since 1. the signature of UpdateLens.updated doesn't allow to operate on missing parents, which would be necessary to let child lenses control the creation of parents. 2. the combine lens would then have to support it This test remains here as witness to the current behavior.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/scala/cc/spray/json/lenses/JsonLensesSpec.scala13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/test/scala/cc/spray/json/lenses/JsonLensesSpec.scala b/src/test/scala/cc/spray/json/lenses/JsonLensesSpec.scala
index b115afd..a6a7697 100644
--- a/src/test/scala/cc/spray/json/lenses/JsonLensesSpec.scala
+++ b/src/test/scala/cc/spray/json/lenses/JsonLensesSpec.scala
@@ -124,6 +124,19 @@ class JsonLensesSpec extends Specification with SpecHelpers {
"create" in {
"""[{"b": 4}, {"c": 5}]""".update((* / 'b.?) ! set(38)) must be_json("""[{"b": 38}, {"c": 5, "b": 38}]""")
}
+ "create nested (current behavior)" in {
+ // One could think that nested `optionalField`s and `set` would create intermediate
+ // objects as well. However, this is currently not possible, since
+ // 1. the signature of UpdateLens.updated doesn't allow to operate on
+ // missing parents, which would be necessary to let child lenses
+ // control the creation of parents.
+ // 2. the combine lens would then have to support it
+ //
+ // This test remains here as witness to the current behavior.
+
+ """[{"b": {}}, {"c": 5}]""".update((* / 'b.? / 'd.?) ! set(38)) must be_json(
+ """[{"b":{"d":38}},{"c":5}]""")
+ }
"delete some" in {
def f(i: Int): Option[Int] =
Some(i).filter(_ % 2 == 0)