1 local lunit
= require("lunit")
2 local json
= require("json")
4 module("lunit-depth", lunit
.testcase
, package
.seeall
)
7 local SAFE_CALL_DEPTH
= 31
9 function test_object_current_max_depth()
11 for i
= 1, SAFE_DEPTH
do
14 local encoded
= json
.encode(root
)
18 function test_array_current_max_depth()
20 for i
= 1, SAFE_DEPTH
do
23 local encoded
= json
.encode(root
)
27 function test_function_current_max_depth()
28 local root
= json
.util
.buildCall("deep")
29 for i
= 1, SAFE_CALL_DEPTH
do
30 root
= json
.util
.buildCall("deep", root
)
32 local encoded
= json
.encode(root
)
33 json
.decode(encoded
, { calls
= { allowUndefined
= true }})
36 if os
.getenv("TEST_UNSAFE") then
37 local UNSAFE_DEPTH
= 194
38 local UNSAFE_CALL_DEPTH
= UNSAFE_DEPTH
39 function test_object_unsafe_max_depth()
41 for i
= 1, UNSAFE_DEPTH
do
44 local encoded
= json
.encode(root
)
48 function test_array_unsafe_max_depth()
50 for i
= 1, UNSAFE_DEPTH
do
53 local encoded
= json
.encode(root
)
57 function test_function_unsafe_max_depth()
58 local root
= json
.util
.buildCall("deep")
59 for i
= 1, UNSAFE_CALL_DEPTH
do
60 root
= json
.util
.buildCall("deep", root
)
62 local encoded
= json
.encode(root
)
63 json
.decode(encoded
, { calls
= { allowUndefined
= true }})