diff options
Diffstat (limited to 'spec/outputs/switch.lua')
-rw-r--r-- | spec/outputs/switch.lua | 362 |
1 files changed, 362 insertions, 0 deletions
diff --git a/spec/outputs/switch.lua b/spec/outputs/switch.lua index e4dedc9..7c1004b 100644 --- a/spec/outputs/switch.lua +++ b/spec/outputs/switch.lua | |||
@@ -415,4 +415,366 @@ do | |||
415 | end | 415 | end |
416 | end | 416 | end |
417 | end | 417 | end |
418 | do | ||
419 | local _exp_0 = tb | ||
420 | local _type_0 = type(_exp_0) | ||
421 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 | ||
422 | local _match_0 = false | ||
423 | if _tab_0 then | ||
424 | if 1 == _exp_0[1] and 2 == _exp_0[2] and 3 == _exp_0[3] then | ||
425 | _match_0 = true | ||
426 | print("1, 2, 3") | ||
427 | end | ||
428 | end | ||
429 | if not _match_0 then | ||
430 | local _match_1 = false | ||
431 | if _tab_0 then | ||
432 | local b = _exp_0[2] | ||
433 | if 1 == _exp_0[1] and b ~= nil and 3 == _exp_0[3] then | ||
434 | _match_1 = true | ||
435 | print("1, " .. tostring(b) .. ", 3") | ||
436 | end | ||
437 | end | ||
438 | if not _match_1 then | ||
439 | if _tab_0 then | ||
440 | local b = _exp_0[3] | ||
441 | if b == nil then | ||
442 | b = 3 | ||
443 | end | ||
444 | if 1 == _exp_0[1] and 2 == _exp_0[2] then | ||
445 | print("1, 2, " .. tostring(b)) | ||
446 | end | ||
447 | end | ||
448 | end | ||
449 | end | ||
450 | end | ||
451 | do | ||
452 | local _exp_0 = tb | ||
453 | local _type_0 = type(_exp_0) | ||
454 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 | ||
455 | local _match_0 = false | ||
456 | if _tab_0 then | ||
457 | local result = _exp_0.result | ||
458 | if true == _exp_0.success and result ~= nil then | ||
459 | _match_0 = true | ||
460 | print("success", result) | ||
461 | end | ||
462 | end | ||
463 | if not _match_0 then | ||
464 | local _match_1 = false | ||
465 | if _tab_0 then | ||
466 | if false == _exp_0.success then | ||
467 | _match_1 = true | ||
468 | print("failed", result) | ||
469 | end | ||
470 | end | ||
471 | if not _match_1 then | ||
472 | print("invalid") | ||
473 | end | ||
474 | end | ||
475 | end | ||
476 | do | ||
477 | local _exp_0 = tb | ||
478 | local _type_0 = type(_exp_0) | ||
479 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 | ||
480 | local _match_0 = false | ||
481 | if _tab_0 then | ||
482 | local content = _exp_0.content | ||
483 | if "success" == _exp_0.type and content ~= nil then | ||
484 | _match_0 = true | ||
485 | print("success", content) | ||
486 | end | ||
487 | end | ||
488 | if not _match_0 then | ||
489 | local _match_1 = false | ||
490 | if _tab_0 then | ||
491 | local content = _exp_0.content | ||
492 | if "error" == _exp_0.type and content ~= nil then | ||
493 | _match_1 = true | ||
494 | print("failed", content) | ||
495 | end | ||
496 | end | ||
497 | if not _match_1 then | ||
498 | print("invalid") | ||
499 | end | ||
500 | end | ||
501 | end | ||
502 | do | ||
503 | do | ||
504 | local _exp_0 = tb | ||
505 | local _type_0 = type(_exp_0) | ||
506 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 | ||
507 | if _tab_0 then | ||
508 | local fourth = _exp_0[4] | ||
509 | local _val_0 | ||
510 | do | ||
511 | local _obj_0 = _exp_0[1] | ||
512 | if _obj_0 ~= nil then | ||
513 | _val_0 = _obj_0.a | ||
514 | end | ||
515 | end | ||
516 | local _val_1 | ||
517 | do | ||
518 | local _obj_0 = _exp_0[1] | ||
519 | if _obj_0 ~= nil then | ||
520 | _val_1 = _obj_0.b | ||
521 | end | ||
522 | end | ||
523 | local _val_2 | ||
524 | do | ||
525 | local _obj_0 = _exp_0[2] | ||
526 | if _obj_0 ~= nil then | ||
527 | _val_2 = _obj_0.a | ||
528 | end | ||
529 | end | ||
530 | local _val_3 | ||
531 | do | ||
532 | local _obj_0 = _exp_0[2] | ||
533 | if _obj_0 ~= nil then | ||
534 | _val_3 = _obj_0.b | ||
535 | end | ||
536 | end | ||
537 | local _val_4 | ||
538 | do | ||
539 | local _obj_0 = _exp_0[3] | ||
540 | if _obj_0 ~= nil then | ||
541 | _val_4 = _obj_0.a | ||
542 | end | ||
543 | end | ||
544 | local _val_5 | ||
545 | do | ||
546 | local _obj_0 = _exp_0[3] | ||
547 | if _obj_0 ~= nil then | ||
548 | _val_5 = _obj_0.b | ||
549 | end | ||
550 | end | ||
551 | if 1 == _val_0 and 2 == _val_1 and 3 == _val_2 and 4 == _val_3 and 5 == _val_4 and 6 == _val_5 and fourth ~= nil then | ||
552 | print("matched", fourth) | ||
553 | end | ||
554 | end | ||
555 | end | ||
556 | local _exp_0 = tb | ||
557 | local _type_0 = type(_exp_0) | ||
558 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 | ||
559 | local _match_0 = false | ||
560 | if _tab_0 then | ||
561 | local _val_0 | ||
562 | do | ||
563 | local _obj_0 = _exp_0[1] | ||
564 | if _obj_0 ~= nil then | ||
565 | _val_0 = _obj_0.c | ||
566 | end | ||
567 | end | ||
568 | local _val_1 | ||
569 | do | ||
570 | local _obj_0 = _exp_0[1] | ||
571 | if _obj_0 ~= nil then | ||
572 | _val_1 = _obj_0.d | ||
573 | end | ||
574 | end | ||
575 | local _val_2 | ||
576 | do | ||
577 | local _obj_0 = _exp_0[2] | ||
578 | if _obj_0 ~= nil then | ||
579 | _val_2 = _obj_0.c | ||
580 | end | ||
581 | end | ||
582 | local _val_3 | ||
583 | do | ||
584 | local _obj_0 = _exp_0[2] | ||
585 | if _obj_0 ~= nil then | ||
586 | _val_3 = _obj_0.d | ||
587 | end | ||
588 | end | ||
589 | local _val_4 | ||
590 | do | ||
591 | local _obj_0 = _exp_0[3] | ||
592 | if _obj_0 ~= nil then | ||
593 | _val_4 = _obj_0.c | ||
594 | end | ||
595 | end | ||
596 | local _val_5 | ||
597 | do | ||
598 | local _obj_0 = _exp_0[3] | ||
599 | if _obj_0 ~= nil then | ||
600 | _val_5 = _obj_0.d | ||
601 | end | ||
602 | end | ||
603 | if 1 == _val_0 and 2 == _val_1 and 3 == _val_2 and 4 == _val_3 and 5 == _val_4 and 6 == _val_5 then | ||
604 | _match_0 = true | ||
605 | print("OK") | ||
606 | end | ||
607 | end | ||
608 | if not _match_0 then | ||
609 | if _tab_0 then | ||
610 | local sixth = _exp_0[6] | ||
611 | local _val_0 | ||
612 | do | ||
613 | local _obj_0 = _exp_0[3] | ||
614 | if _obj_0 ~= nil then | ||
615 | _val_0 = _obj_0.a | ||
616 | end | ||
617 | end | ||
618 | local _val_1 | ||
619 | do | ||
620 | local _obj_0 = _exp_0[3] | ||
621 | if _obj_0 ~= nil then | ||
622 | _val_1 = _obj_0.b | ||
623 | end | ||
624 | end | ||
625 | local _val_2 | ||
626 | do | ||
627 | local _obj_0 = _exp_0[4] | ||
628 | if _obj_0 ~= nil then | ||
629 | _val_2 = _obj_0.a | ||
630 | end | ||
631 | end | ||
632 | local _val_3 | ||
633 | do | ||
634 | local _obj_0 = _exp_0[4] | ||
635 | if _obj_0 ~= nil then | ||
636 | _val_3 = _obj_0.b | ||
637 | end | ||
638 | end | ||
639 | local _val_4 | ||
640 | do | ||
641 | local _obj_0 = _exp_0[5] | ||
642 | if _obj_0 ~= nil then | ||
643 | _val_4 = _obj_0.a | ||
644 | end | ||
645 | end | ||
646 | local _val_5 | ||
647 | do | ||
648 | local _obj_0 = _exp_0[5] | ||
649 | if _obj_0 ~= nil then | ||
650 | _val_5 = _obj_0.b | ||
651 | end | ||
652 | end | ||
653 | if 1 == _val_0 and 2 == _val_1 and 3 == _val_2 and 4 == _val_3 and 5 == _val_4 and 6 == _val_5 and sixth ~= nil then | ||
654 | print("matched", sixth) | ||
655 | end | ||
656 | end | ||
657 | end | ||
658 | end | ||
659 | do | ||
660 | local v = "hello" | ||
661 | if "hello" == v then | ||
662 | print("matched hello") | ||
663 | else | ||
664 | print("not matched") | ||
665 | end | ||
666 | end | ||
667 | do | ||
668 | local f | ||
669 | f = function() | ||
670 | return "ok" | ||
671 | end | ||
672 | local val = f() | ||
673 | if "ok" == val then | ||
674 | print("it's ok") | ||
675 | end | ||
676 | end | ||
677 | do | ||
678 | local g | ||
679 | g = function() | ||
680 | return 42 | ||
681 | end | ||
682 | local result = g() | ||
683 | if 1 == result or 2 == result then | ||
684 | print("small") | ||
685 | elseif 42 == result then | ||
686 | print("life universe everything") | ||
687 | else | ||
688 | print("other " .. tostring(result)) | ||
689 | end | ||
690 | end | ||
691 | do | ||
692 | local check | ||
693 | check = function() | ||
694 | if true then | ||
695 | return "yes" | ||
696 | else | ||
697 | return "no" | ||
698 | end | ||
699 | end | ||
700 | local x = check() | ||
701 | if "yes" == x then | ||
702 | print("affirmative") | ||
703 | else | ||
704 | print("negative") | ||
705 | end | ||
706 | end | ||
707 | do | ||
708 | local t | ||
709 | t = function() | ||
710 | local tb = { | ||
711 | a = 1 | ||
712 | } | ||
713 | tb.a = 2 | ||
714 | return tb | ||
715 | end | ||
716 | local data = t() | ||
717 | local _type_0 = type(data) | ||
718 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 | ||
719 | local _match_0 = false | ||
720 | if _tab_0 then | ||
721 | if 2 == data.a then | ||
722 | _match_0 = true | ||
723 | print("matched") | ||
724 | end | ||
725 | end | ||
726 | if not _match_0 then | ||
727 | print("not matched") | ||
728 | end | ||
729 | end | ||
730 | do | ||
731 | local clientData = { | ||
732 | "Meta", | ||
733 | "CUST_1001", | ||
734 | "CHK123" | ||
735 | } | ||
736 | local _type_0 = type(clientData) | ||
737 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 | ||
738 | if _tab_0 then | ||
739 | local metadata | ||
740 | do | ||
741 | local _accum_0 = { } | ||
742 | local _len_0 = 1 | ||
743 | local _max_0 = #clientData + -3 + 1 | ||
744 | for _index_0 = 1, _max_0 do | ||
745 | local _item_0 = clientData[_index_0] | ||
746 | _accum_0[_len_0] = _item_0 | ||
747 | _len_0 = _len_0 + 1 | ||
748 | end | ||
749 | metadata = _accum_0 | ||
750 | end | ||
751 | local customerId = clientData[#clientData - 1] | ||
752 | local checksum = clientData[#clientData] | ||
753 | if customerId ~= nil and checksum ~= nil then | ||
754 | print(metadata) | ||
755 | print(customerId) | ||
756 | print(checksum) | ||
757 | end | ||
758 | end | ||
759 | end | ||
760 | do | ||
761 | local handlePath | ||
762 | handlePath = function(segments) | ||
763 | local _type_0 = type(segments) | ||
764 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 | ||
765 | if _tab_0 then | ||
766 | local resource = segments[#segments - 1] | ||
767 | local action = segments[#segments] | ||
768 | if resource ~= nil and action ~= nil then | ||
769 | print("Resource:", resource) | ||
770 | return print("Action:", action) | ||
771 | end | ||
772 | end | ||
773 | end | ||
774 | handlePath({ | ||
775 | "admin", | ||
776 | "logs", | ||
777 | "view" | ||
778 | }) | ||
779 | end | ||
418 | return nil | 780 | return nil |