aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-10-12 00:13:24 +0200
committerKim Alvefur <zash@zash.se>2018-10-12 00:13:24 +0200
commit92a6d6110a4998836edc1ee39041df334d8ef3a4 (patch)
tree4f5e21721be10dfd4d8f4737a132ed6ddf0dcf28 /spec
parent509aee3849892bacadb4809d7a0f03541a9cedae (diff)
downloadprosody-92a6d6110a4998836edc1ee39041df334d8ef3a4.tar.gz
prosody-92a6d6110a4998836edc1ee39041df334d8ef3a4.zip
util.serialization: Simpler metatable pre-processing
It was too difficult to describe what it did.
Diffstat (limited to 'spec')
-rw-r--r--spec/util_serialization_spec.lua8
1 files changed, 8 insertions, 0 deletions
diff --git a/spec/util_serialization_spec.lua b/spec/util_serialization_spec.lua
index 52075bc2..d22cf738 100644
--- a/spec/util_serialization_spec.lua
+++ b/spec/util_serialization_spec.lua
@@ -44,6 +44,14 @@ describe("util.serialization", function ()
test({foo={[100]={{"bar"},{baz=1}}}});
test({["goto"] = {["function"]={["do"]="keywords"}}});
end);
+
+ it("can serialize with metatables", function ()
+ local s = serialization.new({ freeze = true });
+ local t = setmetatable({ a = "hi" }, { __freeze = function (t) return { t.a } end });
+ local rt = serialization.deserialize(s(t));
+ assert.same({"hi"}, rt);
+ end);
+
end);
end);