aboutsummaryrefslogtreecommitdiff
path: root/spec/outputs/test/table_spreading_spec.lua
blob: fd90867de883131be6bc2f3c9f9dafb97c382b89 (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
return describe("table spreading", function()
	return it("list and dict", function()
		local template = {
			foo = "Hello",
			bar = "World",
			"!"
		}
		local specialized
		do
			local _tab_0 = {
				"a",
				"b",
				"c"
			}
			local _idx_0 = 1
			for _key_0, _value_0 in pairs(template) do
				if _idx_0 == _key_0 then
					_tab_0[#_tab_0 + 1] = _value_0
					_idx_0 = _idx_0 + 1
				else
					_tab_0[_key_0] = _value_0
				end
			end
			_tab_0.bar = "Bob"
			specialized = _tab_0
		end
		return assert.same(specialized, {
			"a",
			"b",
			"c",
			"!",
			foo = "Hello",
			bar = "Bob"
		})
	end)
end)