From 447d9b62f61a3bd20349783835e01fa73d8d5747 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Fri, 26 Jul 2019 14:05:49 +0800 Subject: support ref loop --- tests/modules/string/serialize/test.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests/modules/string/serialize/test.lua') 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 -- cgit v1.3.1