diff options
Diffstat (limited to 'spec/outputs')
| -rw-r--r-- | spec/outputs/test/table_spreading_spec.lua | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/outputs/test/table_spreading_spec.lua b/spec/outputs/test/table_spreading_spec.lua new file mode 100644 index 0000000..fd90867 --- /dev/null +++ b/spec/outputs/test/table_spreading_spec.lua | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | return describe("table spreading", function() | ||
| 2 | return it("list and dict", function() | ||
| 3 | local template = { | ||
| 4 | foo = "Hello", | ||
| 5 | bar = "World", | ||
| 6 | "!" | ||
| 7 | } | ||
| 8 | local specialized | ||
| 9 | do | ||
| 10 | local _tab_0 = { | ||
| 11 | "a", | ||
| 12 | "b", | ||
| 13 | "c" | ||
| 14 | } | ||
| 15 | local _idx_0 = 1 | ||
| 16 | for _key_0, _value_0 in pairs(template) do | ||
| 17 | if _idx_0 == _key_0 then | ||
| 18 | _tab_0[#_tab_0 + 1] = _value_0 | ||
| 19 | _idx_0 = _idx_0 + 1 | ||
| 20 | else | ||
| 21 | _tab_0[_key_0] = _value_0 | ||
| 22 | end | ||
| 23 | end | ||
| 24 | _tab_0.bar = "Bob" | ||
| 25 | specialized = _tab_0 | ||
| 26 | end | ||
| 27 | return assert.same(specialized, { | ||
| 28 | "a", | ||
| 29 | "b", | ||
| 30 | "c", | ||
| 31 | "!", | ||
| 32 | foo = "Hello", | ||
| 33 | bar = "Bob" | ||
| 34 | }) | ||
| 35 | end) | ||
| 36 | end) | ||
