aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Tests/Region/ScriptEngine/Shared/CodeTools/CSCodeGeneratorTest.cs280
1 files changed, 137 insertions, 143 deletions
diff --git a/OpenSim/Tests/Region/ScriptEngine/Shared/CodeTools/CSCodeGeneratorTest.cs b/OpenSim/Tests/Region/ScriptEngine/Shared/CodeTools/CSCodeGeneratorTest.cs
index 310418c..beecdcf 100644
--- a/OpenSim/Tests/Region/ScriptEngine/Shared/CodeTools/CSCodeGeneratorTest.cs
+++ b/OpenSim/Tests/Region/ScriptEngine/Shared/CodeTools/CSCodeGeneratorTest.cs
@@ -569,14 +569,13 @@ default
569 } 569 }
570} 570}
571"; 571";
572 string expected = @" 572 string expected =
573 public void default_event_touch_start(LSL_Types.LSLInteger num_detected) 573 "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" +
574 { 574 "\n {" +
575 LSL_Types.Vector3 y = new LSL_Types.Vector3(new LSL_Types.LSLFloat(1.2), llGetMeAFloat(), new LSL_Types.LSLFloat(4.4)); 575 "\n LSL_Types.Vector3 y = new LSL_Types.Vector3(new LSL_Types.LSLFloat(1.2), llGetMeAFloat(), new LSL_Types.LSLFloat(4.4));" +
576 x = y.x + new LSL_Types.LSLFloat(1.1); 576 "\n x = y.x + new LSL_Types.LSLFloat(1.1);" +
577 y.x = new LSL_Types.LSLFloat(1.1); 577 "\n y.x = new LSL_Types.LSLFloat(1.1);" +
578 } 578 "\n }\n";
579";
580 579
581 CSCodeGenerator cg = new CSCodeGenerator(); 580 CSCodeGenerator cg = new CSCodeGenerator();
582 string output = cg.Convert(input); 581 string output = cg.Convert(input);
@@ -597,15 +596,14 @@ default
597 } 596 }
598} 597}
599"; 598";
600 string expected = @" 599 string expected =
601 public void default_event_touch_start(LSL_Types.LSLInteger num_detected) 600 "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" +
602 { 601 "\n {" +
603 LSL_Types.LSLInteger y = -new LSL_Types.LSLInteger(3); 602 "\n LSL_Types.LSLInteger y = -new LSL_Types.LSLInteger(3);" +
604 LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(14) + new LSL_Types.LSLInteger(6); 603 "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(14) + new LSL_Types.LSLInteger(6);" +
605 y = new LSL_Types.LSLInteger(12) + new LSL_Types.LSLInteger(45) + new LSL_Types.LSLInteger(20) + x + (new LSL_Types.LSLInteger(23) + new LSL_Types.LSLInteger(1)) + x + y; 604 "\n y = new LSL_Types.LSLInteger(12) + new LSL_Types.LSLInteger(45) + new LSL_Types.LSLInteger(20) + x + (new LSL_Types.LSLInteger(23) + new LSL_Types.LSLInteger(1)) + x + y;" +
606 y = (new LSL_Types.LSLInteger(12) + -new LSL_Types.LSLInteger(45) + -new LSL_Types.LSLInteger(20) + x + new LSL_Types.LSLInteger(23)) + -new LSL_Types.LSLInteger(1) + x + y; 605 "\n y = (new LSL_Types.LSLInteger(12) + -new LSL_Types.LSLInteger(45) + -new LSL_Types.LSLInteger(20) + x + new LSL_Types.LSLInteger(23)) + -new LSL_Types.LSLInteger(1) + x + y;" +
607 } 606 "\n }\n";
608";
609 607
610 CSCodeGenerator cg = new CSCodeGenerator(); 608 CSCodeGenerator cg = new CSCodeGenerator();
611 string output = cg.Convert(input); 609 string output = cg.Convert(input);
@@ -628,15 +626,14 @@ default
628 } 626 }
629} 627}
630"; 628";
631 string expected = @" 629 string expected =
632 public void default_event_touch_start(LSL_Types.LSLInteger num_detected) 630 "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" +
633 { 631 "\n {" +
634 LSL_Types.LSLInteger y = -new LSL_Types.LSLInteger(3); 632 "\n LSL_Types.LSLInteger y = -new LSL_Types.LSLInteger(3);" +
635 LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(14) + new LSL_Types.LSLInteger(6); 633 "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(14) + new LSL_Types.LSLInteger(6);" +
636 y = new LSL_Types.LSLInteger(12) + new LSL_Types.LSLInteger(45) + new LSL_Types.LSLInteger(20) + x++ + (new LSL_Types.LSLInteger(23) + new LSL_Types.LSLInteger(1)) + ++x + --y; 634 "\n y = new LSL_Types.LSLInteger(12) + new LSL_Types.LSLInteger(45) + new LSL_Types.LSLInteger(20) + x++ + (new LSL_Types.LSLInteger(23) + new LSL_Types.LSLInteger(1)) + ++x + --y;" +
637 y = (new LSL_Types.LSLInteger(12) + -new LSL_Types.LSLInteger(45) + -new LSL_Types.LSLInteger(20) + x-- + new LSL_Types.LSLInteger(23)) + -new LSL_Types.LSLInteger(1) + x-- + ++y; 635 "\n y = (new LSL_Types.LSLInteger(12) + -new LSL_Types.LSLInteger(45) + -new LSL_Types.LSLInteger(20) + x-- + new LSL_Types.LSLInteger(23)) + -new LSL_Types.LSLInteger(1) + x-- + ++y;" +
638 } 636 "\n }\n";
639";
640 637
641 CSCodeGenerator cg = new CSCodeGenerator(); 638 CSCodeGenerator cg = new CSCodeGenerator();
642 string output = cg.Convert(input); 639 string output = cg.Convert(input);
@@ -658,14 +655,13 @@ default
658 } 655 }
659} 656}
660"; 657";
661 string expected = @" 658 string expected =
662 public void default_event_touch_start(LSL_Types.LSLInteger num_detected) 659 "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" +
663 { 660 "\n {" +
664 LSL_Types.list l = new LSL_Types.list(); 661 "\n LSL_Types.list l = new LSL_Types.list();" +
665 LSL_Types.list m = new LSL_Types.list(new LSL_Types.LSLInteger(1), two, new LSL_Types.LSLString(""three""), new LSL_Types.Vector3(new LSL_Types.LSLFloat(4.0), new LSL_Types.LSLFloat(4.0), new LSL_Types.LSLFloat(4.0)), new LSL_Types.LSLInteger(5) + new LSL_Types.LSLInteger(5)); 662 "\n LSL_Types.list m = new LSL_Types.list(new LSL_Types.LSLInteger(1), two, new LSL_Types.LSLString(\"three\"), new LSL_Types.Vector3(new LSL_Types.LSLFloat(4.0), new LSL_Types.LSLFloat(4.0), new LSL_Types.LSLFloat(4.0)), new LSL_Types.LSLInteger(5) + new LSL_Types.LSLInteger(5));" +
666 llCallSomeFunc(new LSL_Types.LSLInteger(1), llAnotherFunc(), new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger(2), new LSL_Types.LSLInteger(3))); 663 "\n llCallSomeFunc(new LSL_Types.LSLInteger(1), llAnotherFunc(), new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger(2), new LSL_Types.LSLInteger(3)));" +
667 } 664 "\n }\n";
668";
669 665
670 CSCodeGenerator cg = new CSCodeGenerator(); 666 CSCodeGenerator cg = new CSCodeGenerator();
671 string output = cg.Convert(input); 667 string output = cg.Convert(input);
@@ -717,60 +713,59 @@ default
717 } 713 }
718} 714}
719"; 715";
720 string expected = @" 716 string expected =
721 public void default_event_touch_start(LSL_Types.LSLInteger num_detected) 717 "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" +
722 { 718 "\n {" +
723 LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(1); 719 "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(1);" +
724 if (x) 720 "\n if (x)" +
725 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""Hello"")); 721 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"Hello\"));" +
726 if (new LSL_Types.LSLInteger(1)) 722 "\n if (new LSL_Types.LSLInteger(1))" +
727 { 723 "\n {" +
728 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""Hi"")); 724 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"Hi\"));" +
729 LSL_Types.LSLInteger r = new LSL_Types.LSLInteger(3); 725 "\n LSL_Types.LSLInteger r = new LSL_Types.LSLInteger(3);" +
730 return ; 726 "\n return ;" +
731 } 727 "\n }" +
732 if (f(x)) 728 "\n if (f(x))" +
733 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""f(x) is true"")); 729 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"f(x) is true\"));" +
734 else 730 "\n else" +
735 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""f(x) is false"")); 731 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"f(x) is false\"));" +
736 if (x + y) 732 "\n if (x + y)" +
737 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""x + y is true"")); 733 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"x + y is true\"));" +
738 else 734 "\n else" +
739 if (y - x) 735 "\n if (y - x)" +
740 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""y - x is true"")); 736 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"y - x is true\"));" +
741 else 737 "\n else" +
742 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""Who needs x and y anyway?"")); 738 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"Who needs x and y anyway?\"));" +
743 if (x * y) 739 "\n if (x * y)" +
744 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""x * y is true"")); 740 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"x * y is true\"));" +
745 else 741 "\n else" +
746 if (y / x) 742 "\n if (y / x)" +
747 { 743 "\n {" +
748 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""uh-oh, y / x is true, exiting"")); 744 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"uh-oh, y / x is true, exiting\"));" +
749 return ; 745 "\n return ;" +
750 } 746 "\n }" +
751 else 747 "\n else" +
752 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""Who needs x and y anyway?"")); 748 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"Who needs x and y anyway?\"));" +
753 if (x % y) 749 "\n if (x % y)" +
754 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""x is true"")); 750 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"x is true\"));" +
755 else 751 "\n else" +
756 if (y & x) 752 "\n if (y & x)" +
757 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""y is true"")); 753 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"y is true\"));" +
758 else 754 "\n else" +
759 if (z | x) 755 "\n if (z | x)" +
760 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""z is true"")); 756 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"z is true\"));" +
761 else 757 "\n else" +
762 if (a * (b + x)) 758 "\n if (a * (b + x))" +
763 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""a is true"")); 759 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"a is true\"));" +
764 else 760 "\n else" +
765 if (b) 761 "\n if (b)" +
766 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""b is true"")); 762 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"b is true\"));" +
767 else 763 "\n else" +
768 if (v) 764 "\n if (v)" +
769 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""v is true"")); 765 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"v is true\"));" +
770 else 766 "\n else" +
771 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""Everything is lies!"")); 767 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"Everything is lies!\"));" +
772 } 768 "\n }\n";
773";
774 769
775 CSCodeGenerator cg = new CSCodeGenerator(); 770 CSCodeGenerator cg = new CSCodeGenerator();
776 string output = cg.Convert(input); 771 string output = cg.Convert(input);
@@ -823,61 +818,60 @@ default
823 } 818 }
824} 819}
825"; 820";
826 string expected = @" 821 string expected =
827 public void default_event_touch_start(LSL_Types.LSLInteger num_detected) 822 "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" +
828 { 823 "\n {" +
829 LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(1); 824 "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(1);" +
830 LSL_Types.LSLInteger y = new LSL_Types.LSLInteger(0); 825 "\n LSL_Types.LSLInteger y = new LSL_Types.LSLInteger(0);" +
831 if (x && y) 826 "\n if (x && y)" +
832 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""Hello"")); 827 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"Hello\"));" +
833 if (x || y) 828 "\n if (x || y)" +
834 { 829 "\n {" +
835 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""Hi"")); 830 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"Hi\"));" +
836 LSL_Types.LSLInteger r = new LSL_Types.LSLInteger(3); 831 "\n LSL_Types.LSLInteger r = new LSL_Types.LSLInteger(3);" +
837 return ; 832 "\n return ;" +
838 } 833 "\n }" +
839 if (x && y || z) 834 "\n if (x && y || z)" +
840 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""x is true"")); 835 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"x is true\"));" +
841 else 836 "\n else" +
842 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""x is false"")); 837 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"x is false\"));" +
843 if (x == y) 838 "\n if (x == y)" +
844 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""x is true"")); 839 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"x is true\"));" +
845 else 840 "\n else" +
846 if (y < x) 841 "\n if (y < x)" +
847 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""y is true"")); 842 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"y is true\"));" +
848 else 843 "\n else" +
849 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""Who needs x and y anyway?"")); 844 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"Who needs x and y anyway?\"));" +
850 if (x > y) 845 "\n if (x > y)" +
851 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""x is true"")); 846 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"x is true\"));" +
852 else 847 "\n else" +
853 if (y <= x) 848 "\n if (y <= x)" +
854 { 849 "\n {" +
855 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""uh-oh, y is true, exiting"")); 850 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"uh-oh, y is true, exiting\"));" +
856 return ; 851 "\n return ;" +
857 } 852 "\n }" +
858 else 853 "\n else" +
859 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""Who needs x and y anyway?"")); 854 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"Who needs x and y anyway?\"));" +
860 if (x >= y) 855 "\n if (x >= y)" +
861 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""x is true"")); 856 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"x is true\"));" +
862 else 857 "\n else" +
863 if (y != x) 858 "\n if (y != x)" +
864 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""y is true"")); 859 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"y is true\"));" +
865 else 860 "\n else" +
866 if (!z) 861 "\n if (!z)" +
867 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""z is true"")); 862 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"z is true\"));" +
868 else 863 "\n else" +
869 if (!(a && b)) 864 "\n if (!(a && b))" +
870 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""a is true"")); 865 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"a is true\"));" +
871 else 866 "\n else" +
872 if (b) 867 "\n if (b)" +
873 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""b is true"")); 868 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"b is true\"));" +
874 else 869 "\n else" +
875 if (v) 870 "\n if (v)" +
876 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""v is true"")); 871 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"v is true\"));" +
877 else 872 "\n else" +
878 llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(""Everything is lies!"")); 873 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"Everything is lies!\"));" +
879 } 874 "\n }\n";
880";
881 875
882 CSCodeGenerator cg = new CSCodeGenerator(); 876 CSCodeGenerator cg = new CSCodeGenerator();
883 string output = cg.Convert(input); 877 string output = cg.Convert(input);