diff options
| author | Li Jin <dragon-fly@qq.com> | 2026-01-28 18:43:14 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2026-01-28 18:43:14 +0800 |
| commit | dd64edd58fe25ec74ae5958128cf3f74b0692f3b (patch) | |
| tree | 0f2de1df55897e2713977c5a53936757e14b477a /spec/outputs/test/table_append_spec.lua | |
| parent | 7c2a92b82e9808d3c5ea29b47d1c59d663fe984a (diff) | |
| download | yuescript-dd64edd58fe25ec74ae5958128cf3f74b0692f3b.tar.gz yuescript-dd64edd58fe25ec74ae5958128cf3f74b0692f3b.tar.bz2 yuescript-dd64edd58fe25ec74ae5958128cf3f74b0692f3b.zip | |
Fixed compiler issues and added 800+ test cases.
Diffstat (limited to 'spec/outputs/test/table_append_spec.lua')
| -rw-r--r-- | spec/outputs/test/table_append_spec.lua | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/spec/outputs/test/table_append_spec.lua b/spec/outputs/test/table_append_spec.lua index 5ce1156..4705161 100644 --- a/spec/outputs/test/table_append_spec.lua +++ b/spec/outputs/test/table_append_spec.lua | |||
| @@ -72,12 +72,12 @@ return describe("table append", function() | |||
| 72 | 2 | 72 | 2 |
| 73 | }) | 73 | }) |
| 74 | end) | 74 | end) |
| 75 | it("should append nil values", function() | 75 | it("should not append nil values", function() |
| 76 | local tab = { } | 76 | local tab = { } |
| 77 | tab[#tab + 1] = nil | 77 | tab[#tab + 1] = nil |
| 78 | tab[#tab + 1] = "value" | 78 | tab[#tab + 1] = "value" |
| 79 | assert.same(tab[1], nil) | 79 | assert.same(tab[2], nil) |
| 80 | return assert.same(tab[2], "value") | 80 | return assert.same(tab[1], "value") |
| 81 | end) | 81 | end) |
| 82 | it("should work in loop", function() | 82 | it("should work in loop", function() |
| 83 | local tab = { } | 83 | local tab = { } |
| @@ -150,7 +150,14 @@ return describe("table append", function() | |||
| 150 | return 1, 2, 3 | 150 | return 1, 2, 3 |
| 151 | end | 151 | end |
| 152 | local tab = { } | 152 | local tab = { } |
| 153 | tab[#tab + 1] = fn() | 153 | local _len_0 = #tab + 1 |
| 154 | local _list_0 = { | ||
| 155 | fn() | ||
| 156 | } | ||
| 157 | for _index_0 = 1, #_list_0 do | ||
| 158 | local _elm_0 = _list_0[_index_0] | ||
| 159 | tab[_len_0], _len_0 = _elm_0, _len_0 + 1 | ||
| 160 | end | ||
| 154 | return assert.same(tab, { | 161 | return assert.same(tab, { |
| 155 | 1, | 162 | 1, |
| 156 | 2, | 163 | 2, |
