Mercurial > prosody-hg
diff spec/util_serialization_spec.lua @ 9567:dbfa286cfa88
util.serialization: Add option for allowing multiple references to the same table (but not cycles)
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 27 Oct 2018 12:43:03 +0200 |
| parents | dad29508d0f2 |
| children |
line wrap: on
line diff
--- a/spec/util_serialization_spec.lua Sat Oct 27 12:40:47 2018 +0200 +++ b/spec/util_serialization_spec.lua Sat Oct 27 12:43:03 2018 +0200 @@ -25,13 +25,27 @@ t[t] = { t }; serialization.serialize(t) end); + -- also with multirefs allowed + assert.has_error(function () + local t = {} + t[t] = { t }; + serialization.serialize(t, { multirefs = true }) + end); end); it("rejects multiple references to same table", function () assert.has_error(function () local t1 = {}; local t2 = { t1, t1 }; - serialization.serialize(t2); + serialization.serialize(t2, { multirefs = false }); + end); + end); + + it("optionally allows multiple references to same table", function () + assert.has_error(function () + local t1 = {}; + local t2 = { t1, t1 }; + serialization.serialize(t2, { multirefs = true }); end); end);
