summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpportunityLiu <[email protected]>2019-07-25 18:31:53 +0800
committerOpportunityLiu <[email protected]>2019-07-25 18:31:53 +0800
commit5e8049c85f976305206ed2117b71168b1972704c (patch)
tree278f738b030cfeadad151c828825e692c35a0712
parentcb1283c1f4590aaa562ae9a472a027d27229ba84 (diff)
add some tests
-rw-r--r--tests/modules/string/serialize/test.lua3
-rw-r--r--xmake/core/base/serialize.lua2
2 files changed, 4 insertions, 1 deletions
diff --git a/tests/modules/string/serialize/test.lua b/tests/modules/string/serialize/test.lua
index 1e1484f98..a85868e7e 100644
--- a/tests/modules/string/serialize/test.lua
+++ b/tests/modules/string/serialize/test.lua
@@ -27,6 +27,7 @@ function test_table(t)
t:are_equal(roundtrip({1, 2, 3}), {1, 2, 3})
t:are_equal(roundtrip({1, "", 3}), {1, "", 3})
t:are_equal(roundtrip({{1, 2, 3, nil, 4}}), {{1, 2, 3, nil, 4}})
+ t:are_equal(roundtrip({{1, 2, 3, nil, 4, [100]=5}}), {{1, 2, 3, nil, 4, [100]=5}})
t:are_equal(roundtrip({{a=1, b=2, c=3, nil, 4}}), {{a=1, b=2, c=3, nil, 4}})
end
@@ -34,4 +35,6 @@ function test_function(t)
t:are_equal(roundtrip(function() return {} end)(), {})
t:are_equal(roundtrip(function() return {1, 2, 3} end)(), {1, 2, 3})
t:are_equal(roundtrip(function() return {{1, 2, 3, nil, 4}} end)(), {{1, 2, 3, nil, 4}})
+ t:are_equal(roundtrip({function() return {{1, 2, 3, nil, 4}} end})[1](), {{1, 2, 3, nil, 4}})
+ t:are_equal(roundtrip({{function() return {{1, 2, 3, nil, 4}} end}})[1][1](), {{1, 2, 3, nil, 4}})
end
diff --git a/xmake/core/base/serialize.lua b/xmake/core/base/serialize.lua
index 2582daae6..84c74cd34 100644
--- a/xmake/core/base/serialize.lua
+++ b/xmake/core/base/serialize.lua
@@ -129,7 +129,7 @@ function serialize._maketable(object, opt, level)
if type(k) == "string" and not k:match("^[%a_][%w_]*$") then
k = string.format("[%q]", k)
elseif type(k) == "number" then
- local nval, err = serialize._makenumber(v, opt, childlevel)
+ local nval, err = serialize._makenumber(k, opt, childlevel)
if err ~= nil then
return nil, err
end