diff options
| author | Li Jin <dragon-fly@qq.com> | 2025-06-04 16:07:06 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2025-06-04 16:07:06 +0800 |
| commit | 0e72454a11f65d9ac800dedb698ddfcc15933785 (patch) | |
| tree | 6cded6335c22c4dd204f7d3bc66efa0f76a41ef0 /spec/outputs/lists.lua | |
| parent | 548ab1d9ff5b831050f14f1355a3314a41163ad6 (diff) | |
| download | yuescript-0e72454a11f65d9ac800dedb698ddfcc15933785.tar.gz yuescript-0e72454a11f65d9ac800dedb698ddfcc15933785.tar.bz2 yuescript-0e72454a11f65d9ac800dedb698ddfcc15933785.zip | |
Added more reversed index support for slice. [skip CI]
Diffstat (limited to 'spec/outputs/lists.lua')
| -rw-r--r-- | spec/outputs/lists.lua | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/spec/outputs/lists.lua b/spec/outputs/lists.lua index 1bdfa3e..2ed7b95 100644 --- a/spec/outputs/lists.lua +++ b/spec/outputs/lists.lua | |||
| @@ -230,31 +230,36 @@ x = { | |||
| 230 | 6, | 230 | 6, |
| 231 | 7 | 231 | 7 |
| 232 | } | 232 | } |
| 233 | local _max_0 = -5 | 233 | local _max_0 = #x + -5 + 1 |
| 234 | for _index_0 = 2, _max_0 < 0 and #x + _max_0 + 1 or _max_0, 2 do | 234 | for _index_0 = 2, _max_0, 2 do |
| 235 | local y = x[_index_0] | 235 | local y = x[_index_0] |
| 236 | print(y) | 236 | print(y) |
| 237 | end | 237 | end |
| 238 | local _max_1 = 3 | 238 | for _index_0 = 1, 3 do |
| 239 | for _index_0 = 1, _max_1 < 0 and #x + _max_1 + 1 or _max_1 do | ||
| 240 | local y = x[_index_0] | 239 | local y = x[_index_0] |
| 241 | print(y) | 240 | print(y) |
| 242 | end | 241 | end |
| 243 | for _index_0 = 2, #x do | 242 | local _max_1 = #x |
| 243 | for _index_0 = 2, _max_1 do | ||
| 244 | local y = x[_index_0] | 244 | local y = x[_index_0] |
| 245 | print(y) | 245 | print(y) |
| 246 | end | 246 | end |
| 247 | for _index_0 = 1, #x, 2 do | 247 | local _max_2 = #x |
| 248 | for _index_0 = 1, _max_2, 2 do | ||
| 248 | local y = x[_index_0] | 249 | local y = x[_index_0] |
| 249 | print(y) | 250 | print(y) |
| 250 | end | 251 | end |
| 251 | for _index_0 = 2, #x, 2 do | 252 | local _max_3 = #x |
| 253 | for _index_0 = 2, _max_3, 2 do | ||
| 252 | local y = x[_index_0] | 254 | local y = x[_index_0] |
| 253 | print(y) | 255 | print(y) |
| 254 | end | 256 | end |
| 255 | local a, b, c = 1, 5, 2 | 257 | local a, b, c = 1, 5, 2 |
| 256 | local _max_2 = b | 258 | local _min_0 = a |
| 257 | for _index_0 = a, _max_2 < 0 and #x + _max_2 + 1 or _max_2, c do | 259 | local _max_4 = b |
| 260 | _min_0 = _min_0 < 0 and #x + _min_0 + 1 or _min_0 | ||
| 261 | _max_4 = _max_4 < 0 and #x + _max_4 + 1 or _max_4 | ||
| 262 | for _index_0 = _min_0, _max_4, c do | ||
| 258 | local y = x[_index_0] | 263 | local y = x[_index_0] |
| 259 | print(y) | 264 | print(y) |
| 260 | end | 265 | end |
| @@ -287,7 +292,10 @@ do | |||
| 287 | a | 292 | a |
| 288 | }) | 293 | }) |
| 289 | local _list_0 = f | 294 | local _list_0 = f |
| 290 | for _index_0 = a, #_list_0 do | 295 | local _min_1 = a |
| 296 | local _max_5 = #_list_0 | ||
| 297 | _min_1 = _min_1 < 0 and #_list_0 + _min_1 + 1 or _min_1 | ||
| 298 | for _index_0 = _min_1, _max_5 do | ||
| 291 | local v = _list_0[_index_0] | 299 | local v = _list_0[_index_0] |
| 292 | print(v) | 300 | print(v) |
| 293 | end | 301 | end |
| @@ -339,8 +347,8 @@ do | |||
| 339 | do | 347 | do |
| 340 | local _accum_0 = { } | 348 | local _accum_0 = { } |
| 341 | local _len_0 = 1 | 349 | local _len_0 = 1 |
| 342 | local _max_3 = -2 | 350 | local _max_5 = #transactions + -2 + 1 |
| 343 | for _index_0 = 2, _max_3 < 0 and #transactions + _max_3 + 1 or _max_3 do | 351 | for _index_0 = 2, _max_5 do |
| 344 | local _item_0 = transactions[_index_0] | 352 | local _item_0 = transactions[_index_0] |
| 345 | _accum_0[_len_0] = _item_0 | 353 | _accum_0[_len_0] = _item_0 |
| 346 | _len_0 = _len_0 + 1 | 354 | _len_0 = _len_0 + 1 |
| @@ -405,7 +413,8 @@ do | |||
| 405 | cloneList1 = function(list) | 413 | cloneList1 = function(list) |
| 406 | local _accum_0 = { } | 414 | local _accum_0 = { } |
| 407 | local _len_0 = 1 | 415 | local _len_0 = 1 |
| 408 | for _index_0 = 1, #list do | 416 | local _max_5 = #list |
| 417 | for _index_0 = 1, _max_5 do | ||
| 409 | local _item_0 = list[_index_0] | 418 | local _item_0 = list[_index_0] |
| 410 | _accum_0[_len_0] = _item_0 | 419 | _accum_0[_len_0] = _item_0 |
| 411 | _len_0 = _len_0 + 1 | 420 | _len_0 = _len_0 + 1 |
| @@ -471,8 +480,8 @@ local _anon_func_1 = function(a) | |||
| 471 | local _accum_0 = { } | 480 | local _accum_0 = { } |
| 472 | local _len_0 = 1 | 481 | local _len_0 = 1 |
| 473 | local _list_0 = a.b.c | 482 | local _list_0 = a.b.c |
| 474 | local _max_3 = -5 | 483 | local _max_5 = #_list_0 + -5 + 1 |
| 475 | for _index_0 = 5, _max_3 < 0 and #_list_0 + _max_3 + 1 or _max_3 do | 484 | for _index_0 = 5, _max_5 do |
| 476 | local _item_1 = _list_0[_index_0] | 485 | local _item_1 = _list_0[_index_0] |
| 477 | _accum_0[_len_0] = _item_1 | 486 | _accum_0[_len_0] = _item_1 |
| 478 | _len_0 = _len_0 + 1 | 487 | _len_0 = _len_0 + 1 |
| @@ -491,8 +500,8 @@ local _anon_func_2 = function(x) | |||
| 491 | if _obj_2 ~= nil then | 500 | if _obj_2 ~= nil then |
| 492 | local _accum_0 = { } | 501 | local _accum_0 = { } |
| 493 | local _len_0 = 1 | 502 | local _len_0 = 1 |
| 494 | local _max_3 = -3 | 503 | local _max_5 = #_obj_2 + -3 + 1 |
| 495 | for _index_0 = 1, _max_3 < 0 and #_obj_2 + _max_3 + 1 or _max_3 do | 504 | for _index_0 = 1, _max_5 do |
| 496 | local _item_0 = _obj_2[_index_0] | 505 | local _item_0 = _obj_2[_index_0] |
| 497 | _accum_0[_len_0] = _item_0 | 506 | _accum_0[_len_0] = _item_0 |
| 498 | _len_0 = _len_0 + 1 | 507 | _len_0 = _len_0 + 1 |
