diff options
author | flaviut <tamasflaviu@gmail.com> | 2014-04-13 17:19:59 -0400 |
---|---|---|
committer | flaviut <tamasflaviu@gmail.com> | 2014-04-13 17:19:59 -0400 |
commit | db7fee6303652572812a57ae70e3f2ca28e8829d (patch) | |
tree | 838181659e5c0987f526cc2630c9eb17f4aec973 /lib | |
parent | 4ff511280301d53ebac3a473f988d93ba9c065e2 (diff) | |
download | Nim-db7fee6303652572812a57ae70e3f2ca28e8829d.tar.gz |
Add tests for the nil passthrough
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pure/json.nim | 8 |
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() |