Thanks Mike for another LSL compiler patch which fixes a bug where 'vector v=<0, 0, -0.5>' caused a syntax error, and implements multiple assignments in one line (x = y = 3;)

0.6.0-stable
Johan Berntsson 2008-07-11 08:33:53 +00:00
parent cda5269391
commit 130d8047a2
3 changed files with 15565 additions and 14979 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1301,6 +1301,64 @@ default
Assert.AreEqual(expected, output);
}
[Test]
public void TestMultipleEqualsExpression()
{
string input = @"// let's test x = y = 5 type expressions
default
{
touch_start(integer num_detected)
{
integer x;
integer y;
x = y = 5;
x += y -= 5;
llOwnerSay(""x is: "" + (string) x + "", y is: "" + (string) y);
}
}
";
string expected = @"
public void default_event_touch_start(LSL_Types.LSLInteger num_detected)
{
LSL_Types.LSLInteger x = 0;
LSL_Types.LSLInteger y = 0;
x = y = 5;
x += y -= 5;
llOwnerSay(""x is: "" + (LSL_Types.LSLString) (x) + "", y is: "" + (LSL_Types.LSLString) (y));
}
";
CSCodeGenerator cg = new CSCodeGenerator(input);
string output = cg.Generate();
Assert.AreEqual(expected, output);
}
[Test]
public void TestUnaryExpressionLastInVectorConstant()
{
string input = @"// let's test unary expressions some more
default
{
state_entry()
{
vector v = <x,y,-0.5>;
}
}
";
string expected = @"
public void default_event_state_entry()
{
LSL_Types.Vector3 v = new LSL_Types.Vector3(x, y, -0.5);
}
";
CSCodeGenerator cg = new CSCodeGenerator(input);
string output = cg.Generate();
Assert.AreEqual(expected, output);
}
[Test]
[ExpectedException("Tools.CSToolsException")]
public void TestSyntaxError()
@ -1316,7 +1374,7 @@ default
try
{
CSCodeGenerator cg = new CSCodeGenerator(input);
string output = cg.Generate();
cg.Generate();
}
catch (Tools.CSToolsException e)
{