diff options
| author | Li Jin <dragon-fly@qq.com> | 2022-07-27 11:39:50 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2022-07-27 11:39:50 +0800 |
| commit | 8df3b854939a63b14aab3fd4688b0caea3daf1dc (patch) | |
| tree | 5c142c53bd1f60ede9603f9ba05be731bad61b60 /spec/outputs/test | |
| parent | 0f5bdeaeba0f04e49c47f4a2be55b14185a7dfdd (diff) | |
| download | yuescript-8df3b854939a63b14aab3fd4688b0caea3daf1dc.tar.gz yuescript-8df3b854939a63b14aab3fd4688b0caea3daf1dc.tar.bz2 yuescript-8df3b854939a63b14aab3fd4688b0caea3daf1dc.zip | |
adding test cases.
Diffstat (limited to 'spec/outputs/test')
| -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) | ||
