aboutsummaryrefslogtreecommitdiff
path: root/builtin/common/tests
diff options
context:
space:
mode:
authorHybridDog <3192173+HybridDog@users.noreply.github.com>2020-04-22 16:43:48 +0200
committerGitHub <noreply@github.com>2020-04-22 16:43:48 +0200
commit5355cb1d87f60bc5548a8a9311e597b9c6046013 (patch)
treec5aabae94525edead5e5ae8ee854bde2520e6ee1 /builtin/common/tests
parent4361bfcb4da0b6f9de74c7de9f2d08084877713e (diff)
downloadminetest-5355cb1d87f60bc5548a8a9311e597b9c6046013.tar.gz
minetest-5355cb1d87f60bc5548a8a9311e597b9c6046013.tar.bz2
minetest-5355cb1d87f60bc5548a8a9311e597b9c6046013.zip
minetest.serialize: Reversible number serialization (#9722)
* minetest.serialize: Reversible number to string conversion The %a format is not supported in Lua 5.1. This commit also adds two tests for number serialization.
Diffstat (limited to 'builtin/common/tests')
-rw-r--r--builtin/common/tests/serialize_spec.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/builtin/common/tests/serialize_spec.lua b/builtin/common/tests/serialize_spec.lua
index c41b0a372..17c6a60f7 100644
--- a/builtin/common/tests/serialize_spec.lua
+++ b/builtin/common/tests/serialize_spec.lua
@@ -18,6 +18,18 @@ describe("serialize", function()
assert.same(test_in, test_out)
end)
+ it("handles precise numbers", function()
+ local test_in = 0.2695949158945771
+ local test_out = core.deserialize(core.serialize(test_in))
+ assert.same(test_in, test_out)
+ end)
+
+ it("handles big integers", function()
+ local test_in = 269594915894577
+ 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