diff options
author | Matt Stancliff <matt@genges.com> | 2014-04-04 14:13:14 -0400 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2014-11-14 17:08:22 +0100 |
commit | e327c8edb907606765237a614ff05997b9f8b7c7 (patch) | |
tree | 58bfb75fdd34a637c30befc6a308db2d0ae2a56c /tests | |
parent | 7ea331d60162d5469ccc2f3682f07738a480538f (diff) | |
download | redis-e327c8edb907606765237a614ff05997b9f8b7c7.tar.gz |
Lua: add cjson scripting test
Two simple decode tests added mainly to check that
the 'cjson' global gets registered and is usable.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/scripting.tcl | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/unit/scripting.tcl b/tests/unit/scripting.tcl index 07016bc04..69ce0ccbf 100644 --- a/tests/unit/scripting.tcl +++ b/tests/unit/scripting.tcl @@ -184,6 +184,23 @@ start_server {tags {"scripting"}} { set e } {*against a key*} + test {EVAL - JSON numeric decoding} { + # We must return the table as a string because otherwise + # Redis converts floats to ints and we get 0 and 1023 instead + # of 0.0003 and 1023.2 as the parsed output. + r eval {return + table.concat( + cjson.decode( + "[0.0, -5e3, -1, 0.3e-3, 1023.2, 0e10]"), " ") + } 0 + } {0 -5000 -1 0.0003 1023.2 0} + + test {EVAL - JSON string decoding} { + r eval {local decoded = cjson.decode('{"keya": "a", "keyb": "b"}') + return {decoded.keya, decoded.keyb} + } 0 + } {a b} + test {SCRIPTING FLUSH - is able to clear the scripts cache?} { r set mykey myval set v [r evalsha fd758d1589d044dd850a6f05d52f2eefd27f033f 1 mykey] |