diff options
author | Kim Alvefur <zash@zash.se> | 2018-10-27 12:43:03 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2018-10-27 12:43:03 +0200 |
commit | 669ab61ecdd06056995fbac2fbf7e5cc2ab5ee0e (patch) | |
tree | b949b814294559492811672e610d7e8f75954a84 /spec/util_serialization_spec.lua | |
parent | f08a141337780d659564781bcbf7ff8ef381c209 (diff) | |
download | prosody-669ab61ecdd06056995fbac2fbf7e5cc2ab5ee0e.tar.gz prosody-669ab61ecdd06056995fbac2fbf7e5cc2ab5ee0e.zip |
util.serialization: Add option for allowing multiple references to the same table (but not cycles)
Diffstat (limited to 'spec/util_serialization_spec.lua')
-rw-r--r-- | spec/util_serialization_spec.lua | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/spec/util_serialization_spec.lua b/spec/util_serialization_spec.lua index e73ca826..2af5d803 100644 --- a/spec/util_serialization_spec.lua +++ b/spec/util_serialization_spec.lua @@ -25,13 +25,27 @@ describe("util.serialization", function () 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); |