aboutsummaryrefslogtreecommitdiffstats
path: root/community/lua-toml/fix-decode-arrays-and-include-testcase.patch
blob: 0409f39ee146e34be57233be6355f21c36d01e58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
From d77cbb5f94bb8fbaa8d589573de20ce120765055 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
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 <ncopa@alpinelinux.org>
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"