summaryrefslogtreecommitdiff
path: root/spec/test_luatool.lua
diff options
context:
space:
mode:
Diffstat (limited to 'spec/test_luatool.lua')
-rw-r--r--spec/test_luatool.lua13
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/test_luatool.lua b/spec/test_luatool.lua
index d002bca..62f9283 100644
--- a/spec/test_luatool.lua
+++ b/spec/test_luatool.lua
@@ -57,6 +57,19 @@ return {
assert(env.print() == nil)
end },
+ { "the guest json codec round-trips and reports bad input instead of raising", function()
+ local env = luatool.build_env()
+ local encoded = env.json.encode({ prs = { 124, 125 } })
+ has(encoded, "124")
+ local decoded = env.json.decode(encoded)
+ assert(type(decoded) == "table" and decoded.prs[2] == 125)
+ -- The sandbox has no pcall, so a raising decoder would kill a workflow
+ -- over one malformed agent line.
+ local value, message = env.json.decode("RESULT=not json")
+ assert(value == nil and type(message) == "string")
+ assert(env.json.decode(nil) == nil)
+ end },
+
{ "the string metatable stays reachable and harmless", function()
local env = luatool.build_env()
assert(type(("").dump) == "function")