LSL-PyOptimizer/unit_tests/regression.suite/if-stmt.lsl
Sei Lisa 1867dc78e7 Add the new test suite.
This test suite has been in use for a long time now, in place of the obsolete and unmanageable testparser.py and testfuncs.py. It verifies the complete optimizer output to stdout and stderr, to ensure that the output matches the expectations.

See unit_tests/README.txt for more info.
2019-01-04 20:27:36 +01:00

37 lines
931 B
Text

default{timer(){
integer a = (integer)llFrand(100);
// Check optimization of if
if (a) ;
if (a) a;
if (a) a; else a;
if (a) {@b;} else {@c;}
//if (a) @d;
if (a) llDie();
if (a) ; else llDie();
if ((float)a) ; else llDie();
if ((string)a) ; else llDie();
if ((key)((string)a)) ; else llDie();
if (<a,0,0>) ; else llDie();
if (<a,0,0,1>) ; else llDie();
if ((list)a) ; else llDie();
if (!a) llDie(); else llOwnerSay("ok");
if (a == 3) llDie(); else llOwnerSay("ok");
if (a > 5) if (a == 12) ; else llDie(); else llOwnerSay("ok");
if (a == 12) llOwnerSay("1"); else if (a > 5) llOwnerSay("2");
if (a > 5) if (a == 12) ; else /*@f1*/; else llDie();
if (a == 12) llDie(); else if (a > 5) /*@f4*/;
// Fixed: Regression: this produces if (!(a == 3)) and no optimization kicks in
if (a != 3) llOwnerSay("fixed");
// Regression
if (a == 2)
llOwnerSay("a");
else if (a)
llOwnerSay("b");
else if (a == 3)
llOwnerSay("c");
}}