summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorflaviut <tamasflaviu@gmail.com>2014-04-13 17:19:59 -0400
committerflaviut <tamasflaviu@gmail.com>2014-04-13 17:19:59 -0400
commitdb7fee6303652572812a57ae70e3f2ca28e8829d (patch)
tree838181659e5c0987f526cc2630c9eb17f4aec973 /lib
parent4ff511280301d53ebac3a473f988d93ba9c065e2 (diff)
downloadNim-db7fee6303652572812a57ae70e3f2ca28e8829d.tar.gz
Add tests for the nil passthrough
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/json.nim8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/pure/json.nim b/lib/pure/json.nim
index 3e8840e47..7b2a0eed6 100644
--- a/lib/pure/json.nim
+++ b/lib/pure/json.nim
@@ -936,6 +936,14 @@ when isMainModule:
     raise newException(EInvalidValue, "That line was expected to fail")
   except EInvalidIndex: echo()
 
+  let passthroughTest = parseJson"""{ "a": [1, 2, 3, 4], "b": "asd" }"""
+  # nil passthrough
+  assert(passthroughTest["doesnt_exist"][1] == nil)
+  assert(passthroughTest["doesnt_exist"]["anything"] == nil)
+  # default param
+  assert(passthroughTest["doesnt_exist",%true].bval)
+  assert(passthroughTest["doesnt_exist"][1,%true].bval)
+
   discard """
   while true:
     var json = stdin.readLine()