Comparison

spec/util_serialization_spec.lua @ 9485:c667887d78ad

util.serialization: Simpler metatable pre-processing It was too difficult to describe what it did.
author Kim Alvefur <zash@zash.se>
date Fri, 12 Oct 2018 00:13:24 +0200
parent 9482:8791bfa3984a
child 9566:dad29508d0f2
comparison
equal deleted inserted replaced
9484:1d1541630c20 9485:c667887d78ad
42 test("nödåtgärd"); 42 test("nödåtgärd");
43 test({1,2,3,4}); 43 test({1,2,3,4});
44 test({foo={[100]={{"bar"},{baz=1}}}}); 44 test({foo={[100]={{"bar"},{baz=1}}}});
45 test({["goto"] = {["function"]={["do"]="keywords"}}}); 45 test({["goto"] = {["function"]={["do"]="keywords"}}});
46 end); 46 end);
47
48 it("can serialize with metatables", function ()
49 local s = serialization.new({ freeze = true });
50 local t = setmetatable({ a = "hi" }, { __freeze = function (t) return { t.a } end });
51 local rt = serialization.deserialize(s(t));
52 assert.same({"hi"}, rt);
53 end);
54
47 end); 55 end);
48 end); 56 end);
49 57