From d77cbb5f94bb8fbaa8d589573de20ce120765055 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Wed, 14 Jun 2017 11:23:32 +0200 Subject: [PATCH 1/2] add test case for issue #12 --- spec/encode_spec.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 spec/encode_spec.lua diff --git a/spec/encode_spec.lua b/spec/encode_spec.lua new file mode 100644 index 0000000..db26834 --- /dev/null +++ b/spec/encode_spec.lua @@ -0,0 +1,11 @@ +describe("encoding", function() + setup(function() + TOML = require "toml" + end) + + it("array", function() + local obj = TOML.encode{ a = { "foo","bar" } } + local sol = "a = [\nfoo,\nbar,\n]" + assert.same(sol, obj) + end) +end) From b914f26b66856d82d11d4c9205d5ccd97ae54bb6 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Wed, 14 Jun 2017 11:44:20 +0200 Subject: [PATCH 2/2] fix encoding of plain ol borring arrays (issue #12) --- toml.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toml.lua b/toml.lua index a5655ed..b5eb2ed 100644 --- a/toml.lua +++ b/toml.lua @@ -619,7 +619,7 @@ TOML.encode = function(tbl) else -- plain ol boring array toml = toml .. k .. " = [\n" - for kk, vv in pairs(v) do + for kk, vv in pairs(first) do toml = toml .. tostring(vv) .. ",\n" end toml = toml .. "]\n"