1 local lunit
= require("lunit")
2 local json
= require("json")
5 _ENV
= lunit
.module("lunit-depth", 'seeall')
7 module("lunit-depth", lunit
.testcase
, package
.seeall
)
11 local SAFE_CALL_DEPTH
= 31
13 function test_object_current_max_depth()
15 for i
= 1, SAFE_DEPTH
do
18 local encoded
= json
.encode(root
)
22 function test_array_current_max_depth()
24 for i
= 1, SAFE_DEPTH
do
27 local encoded
= json
.encode(root
)
31 function test_function_current_max_depth()
32 local root
= json
.util
.buildCall("deep")
33 for i
= 1, SAFE_CALL_DEPTH
do
34 root
= json
.util
.buildCall("deep", root
)
36 local encoded
= json
.encode(root
)
37 json
.decode(encoded
, { calls
= { allowUndefined
= true }})
40 if os
.getenv("TEST_UNSAFE") then
41 local UNSAFE_DEPTH
= 194
42 local UNSAFE_CALL_DEPTH
= UNSAFE_DEPTH
43 function test_object_unsafe_max_depth()
45 for i
= 1, UNSAFE_DEPTH
do
48 local encoded
= json
.encode(root
)
52 function test_array_unsafe_max_depth()
54 for i
= 1, UNSAFE_DEPTH
do
57 local encoded
= json
.encode(root
)
61 function test_function_unsafe_max_depth()
62 local root
= json
.util
.buildCall("deep")
63 for i
= 1, UNSAFE_CALL_DEPTH
do
64 root
= json
.util
.buildCall("deep", root
)
66 local encoded
= json
.encode(root
)
67 json
.decode(encoded
, { calls
= { allowUndefined
= true }})