diff options
Diffstat (limited to 'spec/outputs/lists.lua')
-rw-r--r-- | spec/outputs/lists.lua | 215 |
1 files changed, 205 insertions, 10 deletions
diff --git a/spec/outputs/lists.lua b/spec/outputs/lists.lua index 48ec9c8..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 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 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 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 |
@@ -327,4 +335,191 @@ do | |||
327 | job = "jobless" | 335 | job = "jobless" |
328 | end | 336 | end |
329 | end | 337 | end |
338 | do | ||
339 | local transactions = { | ||
340 | "T001", | ||
341 | "T002", | ||
342 | "T003", | ||
343 | "T004", | ||
344 | "T005" | ||
345 | } | ||
346 | local middleTransactions | ||
347 | do | ||
348 | local _accum_0 = { } | ||
349 | local _len_0 = 1 | ||
350 | local _max_5 = #transactions + -2 + 1 | ||
351 | for _index_0 = 2, _max_5 do | ||
352 | local _item_0 = transactions[_index_0] | ||
353 | _accum_0[_len_0] = _item_0 | ||
354 | _len_0 = _len_0 + 1 | ||
355 | end | ||
356 | middleTransactions = _accum_0 | ||
357 | end | ||
358 | print(middleTransactions) | ||
359 | end | ||
360 | do | ||
361 | local logs = { | ||
362 | { | ||
363 | start = 0, | ||
364 | ["end"] = 100 | ||
365 | }, | ||
366 | { | ||
367 | start = 100, | ||
368 | ["end"] = 200 | ||
369 | }, | ||
370 | { | ||
371 | start = 200, | ||
372 | ["end"] = 123 | ||
373 | } | ||
374 | } | ||
375 | print(logs[#logs]["end"]) | ||
376 | end | ||
377 | do | ||
378 | local pendingOrders = { | ||
379 | "O001", | ||
380 | "O002", | ||
381 | "O003", | ||
382 | "O004" | ||
383 | } | ||
384 | print(pendingOrders[#pendingOrders - 1]) | ||
385 | end | ||
386 | do | ||
387 | local getOrders | ||
388 | getOrders = function() | ||
389 | return { | ||
390 | { | ||
391 | id = "O1001", | ||
392 | status = "pending" | ||
393 | }, | ||
394 | { | ||
395 | id = "O1002", | ||
396 | status = "processing" | ||
397 | }, | ||
398 | { | ||
399 | id = "O1003", | ||
400 | status = "done" | ||
401 | } | ||
402 | } | ||
403 | end | ||
404 | local lastStatus | ||
405 | do | ||
406 | local _item_0 = getOrders() | ||
407 | lastStatus = _item_0[#_item_0].status | ||
408 | end | ||
409 | assert(lastStatus == "done") | ||
410 | end | ||
411 | do | ||
412 | local cloneList1 | ||
413 | cloneList1 = function(list) | ||
414 | local _accum_0 = { } | ||
415 | local _len_0 = 1 | ||
416 | local _max_5 = #list | ||
417 | for _index_0 = 1, _max_5 do | ||
418 | local _item_0 = list[_index_0] | ||
419 | _accum_0[_len_0] = _item_0 | ||
420 | _len_0 = _len_0 + 1 | ||
421 | end | ||
422 | return _accum_0 | ||
423 | end | ||
424 | local cloneList2 | ||
425 | cloneList2 = function(list) | ||
426 | local _tab_0 = { } | ||
427 | local _idx_0 = #_tab_0 + 1 | ||
428 | for _index_0 = 1, #list do | ||
429 | local _value_0 = list[_index_0] | ||
430 | _tab_0[_idx_0] = _value_0 | ||
431 | _idx_0 = _idx_0 + 1 | ||
432 | end | ||
433 | return _tab_0 | ||
434 | end | ||
435 | local cloneTable | ||
436 | cloneTable = function(tb) | ||
437 | local _tab_0 = { } | ||
438 | local _idx_0 = 1 | ||
439 | for _key_0, _value_0 in pairs(tb) do | ||
440 | if _idx_0 == _key_0 then | ||
441 | _tab_0[#_tab_0 + 1] = _value_0 | ||
442 | _idx_0 = _idx_0 + 1 | ||
443 | else | ||
444 | _tab_0[_key_0] = _value_0 | ||
445 | end | ||
446 | end | ||
447 | return _tab_0 | ||
448 | end | ||
449 | end | ||
450 | do | ||
451 | print((function() | ||
452 | local _item_0 = globalTB | ||
453 | return _item_0[#_item_0] | ||
454 | end)(), (function() | ||
455 | local _item_0 = a.b.c | ||
456 | return _item_0[#_item_0 - 2] | ||
457 | end)(), (function() | ||
458 | if x ~= nil then | ||
459 | local _obj_0 = x.y | ||
460 | if _obj_0 ~= nil then | ||
461 | local _obj_1 = _obj_0(x).z | ||
462 | if _obj_1 ~= nil then | ||
463 | return _obj_1[#_obj_1 - 3] | ||
464 | end | ||
465 | return nil | ||
466 | end | ||
467 | return nil | ||
468 | end | ||
469 | return nil | ||
470 | end)()) | ||
471 | end | ||
472 | local _anon_func_0 = function(globalTB) | ||
473 | local _item_0 = globalTB | ||
474 | local _call_0 = _item_0[#_item_0] | ||
475 | return _call_0["end"](_call_0, 123) | ||
476 | end | ||
477 | local _anon_func_1 = function(a) | ||
478 | local _item_0 | ||
479 | do | ||
480 | local _accum_0 = { } | ||
481 | local _len_0 = 1 | ||
482 | local _list_0 = a.b.c | ||
483 | local _max_5 = #_list_0 + -5 + 1 | ||
484 | for _index_0 = 5, _max_5 do | ||
485 | local _item_1 = _list_0[_index_0] | ||
486 | _accum_0[_len_0] = _item_1 | ||
487 | _len_0 = _len_0 + 1 | ||
488 | end | ||
489 | _item_0 = _accum_0 | ||
490 | end | ||
491 | return _item_0[#_item_0 - 2] | ||
492 | end | ||
493 | local _anon_func_2 = function(x) | ||
494 | if x ~= nil then | ||
495 | local _obj_0 = x.y | ||
496 | if _obj_0 ~= nil then | ||
497 | local _obj_1 = _obj_0(x).z | ||
498 | if _obj_1 ~= nil then | ||
499 | local _obj_2 = _obj_1[#_obj_1 - 3] | ||
500 | if _obj_2 ~= nil then | ||
501 | local _accum_0 = { } | ||
502 | local _len_0 = 1 | ||
503 | local _max_5 = #_obj_2 + -3 + 1 | ||
504 | for _index_0 = 1, _max_5 do | ||
505 | local _item_0 = _obj_2[_index_0] | ||
506 | _accum_0[_len_0] = _item_0 | ||
507 | _len_0 = _len_0 + 1 | ||
508 | end | ||
509 | return _accum_0 | ||
510 | end | ||
511 | return nil | ||
512 | end | ||
513 | return nil | ||
514 | end | ||
515 | return nil | ||
516 | end | ||
517 | return nil | ||
518 | end | ||
519 | do | ||
520 | local f | ||
521 | f = function() | ||
522 | return print(_anon_func_0(globalTB), _anon_func_1(a), _anon_func_2(x)) | ||
523 | end | ||
524 | end | ||
330 | return nil | 525 | return nil |