Software /
code /
prosody
File
spec/util_serialization_spec.lua @ 9518:a62fa766d8f3
mod_vcard_legacy: Create nodes with open access (fixes #1221)
Less drastic change from mod_vcard where everything is always public.
This allows users to configure nodes without needing to for the old
behaviour.
Thanks to 038446c50630 users may still override this.
Due to #1222 this may still not apply if the node has already been
created by an automatic subscription
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 18 Oct 2018 19:07:01 +0200 |
parent | 9485:c667887d78ad |
child | 9566:dad29508d0f2 |
line wrap: on
line source
local serialization = require "util.serialization"; describe("util.serialization", function () describe("serialize", function () it("makes a string", function () assert.is_string(serialization.serialize({})); assert.is_string(serialization.serialize(nil)); assert.is_string(serialization.serialize(1)); assert.is_string(serialization.serialize(true)); end); it("rejects function by default", function () assert.has_error(function () serialization.serialize(function () end) end); end); it("makes a string in debug mode", function () assert.is_string(serialization.serialize(function () end, "debug")); end); it("rejects cycles", function () assert.has_error(function () local t = {} t[t] = { t }; serialization.serialize(t) end); end); it("roundtrips", function () local function test(data) local serialized = serialization.serialize(data); assert.is_string(serialized); local deserialized, err = serialization.deserialize(serialized); assert.same(data, deserialized, err); end test({}); test({hello="world"}); test("foobar") test("\0\1\2\3"); test("nödåtgärd"); test({1,2,3,4}); 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);