diff options
Diffstat (limited to 'spec/outputs/destructure.lua')
| -rw-r--r-- | spec/outputs/destructure.lua | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/spec/outputs/destructure.lua b/spec/outputs/destructure.lua index 44da58b..4e19aca 100644 --- a/spec/outputs/destructure.lua +++ b/spec/outputs/destructure.lua | |||
| @@ -621,4 +621,114 @@ do | |||
| 621 | print(meta_field, abc, def) | 621 | print(meta_field, abc, def) |
| 622 | end | 622 | end |
| 623 | end | 623 | end |
| 624 | do | ||
| 625 | local clients = { | ||
| 626 | "VIP_Alice", | ||
| 627 | "User_Bob", | ||
| 628 | "User_Clara", | ||
| 629 | "VIP_Eva" | ||
| 630 | } | ||
| 631 | local vipStart, regulars, vipEnd = clients[1], (function() | ||
| 632 | local _accum_0 = { } | ||
| 633 | local _len_0 = 1 | ||
| 634 | local _max_0 = #clients + -2 + 1 | ||
| 635 | for _index_0 = 2, _max_0 do | ||
| 636 | local _item_0 = clients[_index_0] | ||
| 637 | _accum_0[_len_0] = _item_0 | ||
| 638 | _len_0 = _len_0 + 1 | ||
| 639 | end | ||
| 640 | return _accum_0 | ||
| 641 | end)(), clients[#clients] | ||
| 642 | print(vipStart) | ||
| 643 | print(regulars) | ||
| 644 | print(vipEnd) | ||
| 645 | end | ||
| 646 | do | ||
| 647 | local setupMeeting | ||
| 648 | setupMeeting = function(participants) | ||
| 649 | local chair, secretary = participants[1], participants[#participants] | ||
| 650 | return print(chair, secretary) | ||
| 651 | end | ||
| 652 | setupMeeting({ | ||
| 653 | "Alice", | ||
| 654 | "Bob", | ||
| 655 | "Charlie", | ||
| 656 | "David" | ||
| 657 | }) | ||
| 658 | end | ||
| 659 | do | ||
| 660 | local getTransactions | ||
| 661 | getTransactions = function() | ||
| 662 | return { | ||
| 663 | { | ||
| 664 | id = "T1", | ||
| 665 | amount = 100 | ||
| 666 | }, | ||
| 667 | { | ||
| 668 | id = "T2", | ||
| 669 | amount = 200 | ||
| 670 | }, | ||
| 671 | { | ||
| 672 | id = "T3", | ||
| 673 | amount = 300 | ||
| 674 | } | ||
| 675 | } | ||
| 676 | end | ||
| 677 | local id, amount | ||
| 678 | do | ||
| 679 | local _item_0 = getTransactions() | ||
| 680 | local _obj_0 = _item_0[#_item_0] | ||
| 681 | id, amount = _obj_0.id, _obj_0.amount | ||
| 682 | end | ||
| 683 | assert(id == "T3") | ||
| 684 | assert(amount == 300) | ||
| 685 | end | ||
| 686 | do | ||
| 687 | local middle | ||
| 688 | local _accum_0 = { } | ||
| 689 | local _len_0 = 1 | ||
| 690 | local _list_0 = tb | ||
| 691 | local _max_0 = #_list_0 + -2 + 1 | ||
| 692 | for _index_0 = 2, _max_0 do | ||
| 693 | local _item_0 = _list_0[_index_0] | ||
| 694 | _accum_0[_len_0] = _item_0 | ||
| 695 | _len_0 = _len_0 + 1 | ||
| 696 | end | ||
| 697 | middle = _accum_0 | ||
| 698 | end | ||
| 699 | do | ||
| 700 | local a, abc, b, def, sub, d, e | ||
| 701 | local _obj_0 = tb | ||
| 702 | a, abc, b, def, sub, d, e = _obj_0[1], _obj_0.abc, _obj_0[2], _obj_0.def, (function() | ||
| 703 | local _accum_0 = { } | ||
| 704 | local _len_0 = 1 | ||
| 705 | local _max_0 = #_obj_0 + -3 + 1 | ||
| 706 | for _index_0 = 3, _max_0 do | ||
| 707 | local _item_0 = _obj_0[_index_0] | ||
| 708 | _accum_0[_len_0] = _item_0 | ||
| 709 | _len_0 = _len_0 + 1 | ||
| 710 | end | ||
| 711 | return _accum_0 | ||
| 712 | end)(), _obj_0[#_obj_0 - 1], _obj_0[#_obj_0] | ||
| 713 | end | ||
| 714 | do | ||
| 715 | local _list_0 = items | ||
| 716 | for _index_0 = 1, #_list_0 do | ||
| 717 | local _des_0 = _list_0[_index_0] | ||
| 718 | local a, b = _des_0.a, _des_0.b | ||
| 719 | print(a, b) | ||
| 720 | end | ||
| 721 | local _list_1 = items | ||
| 722 | for _index_0 = 1, #_list_1 do | ||
| 723 | local _des_0 = _list_1[_index_0] | ||
| 724 | local a, b = _des_0.a, _des_0.b | ||
| 725 | print(a, b) | ||
| 726 | end | ||
| 727 | for _des_0 in pairs(data) do | ||
| 728 | local body = _des_0.body | ||
| 729 | if body then | ||
| 730 | print(body) | ||
| 731 | end | ||
| 732 | end | ||
| 733 | end | ||
| 624 | return nil | 734 | return nil |
