diff options
| author | OpportunityLiu <[email protected]> | 2019-07-26 14:05:49 +0800 |
|---|---|---|
| committer | OpportunityLiu <[email protected]> | 2019-07-28 14:45:01 +0800 |
| commit | 447d9b62f61a3bd20349783835e01fa73d8d5747 (patch) | |
| tree | fd83d0c46deaadcf973df8ae3db9e06aae353361 /tests/modules/string/serialize/test.lua | |
| parent | d0216ee6b330bfa8fe894210f8d6bc1517d7e42d (diff) | |
support ref loop
Diffstat (limited to 'tests/modules/string/serialize/test.lua')
| -rw-r--r-- | tests/modules/string/serialize/test.lua | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/modules/string/serialize/test.lua b/tests/modules/string/serialize/test.lua index 567bee87f..ab8986867 100644 --- a/tests/modules/string/serialize/test.lua +++ b/tests/modules/string/serialize/test.lua @@ -43,3 +43,18 @@ function test_function(t) t:are_equal(roundtrip({function() return {{1, 2, 3, nil, 4}} end})[1](), {{1, 2, 3, nil, 4}}) t:are_equal(roundtrip({{function() return {{1, 2, 3, nil, 4}} end}})[1][1](), {{1, 2, 3, nil, 4}}) end + +function test_refloop(t) + local l1 = {} + l1.l = l1 + local r1 = roundtrip(l1) + t:are_same(r1.l, r1) + + local l2 = {{1}, {2}, {3}} + l2[1].l = { root = l2, a = l2[1], b = l2[2], c = l2[3] } + local r2 = roundtrip(l2) + t:are_same(r2[1].l.root, r2) + t:are_same(r2[1].l.a, r2[1]) + t:are_same(r2[1].l.b, r2[2]) + t:are_same(r2[1].l.c, r2[3]) +end |
