diff options
Diffstat (limited to 'builtin/common/tests/serialize_spec.lua')
-rw-r--r-- | builtin/common/tests/serialize_spec.lua | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/builtin/common/tests/serialize_spec.lua b/builtin/common/tests/serialize_spec.lua new file mode 100644 index 000000000..321d2766a --- /dev/null +++ b/builtin/common/tests/serialize_spec.lua @@ -0,0 +1,28 @@ +_G.core = {} + +_G.setfenv = function() end + +dofile("builtin/common/serialize.lua") + +describe("serialize", function() + it("works", function() + local test_in = {cat={sound="nyan", speed=400}, dog={sound="woof"}} + local test_out = core.deserialize(core.serialize(test_in)) + + assert.same(test_in, test_out) + end) + + it("handles characters", function() + local test_in = {escape_chars="\n\r\t\v\\\"\'", non_european="θשׁ٩∂"} + local test_out = core.deserialize(core.serialize(test_in)) + assert.same(test_in, test_out) + end) + + it("handles recursive structures", function() + local test_in = { hello = "world" } + test_in.foo = test_in + + local test_out = core.deserialize(core.serialize(test_in)) + assert.same(test_in, test_out) + end) +end) |