diff options
Diffstat (limited to 'OpenSim/Tests/OpenSim/Region')
-rw-r--r-- | OpenSim/Tests/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGeneratorTest.cs | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/OpenSim/Tests/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGeneratorTest.cs b/OpenSim/Tests/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGeneratorTest.cs index 6e4d029..19c08ed 100644 --- a/OpenSim/Tests/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGeneratorTest.cs +++ b/OpenSim/Tests/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGeneratorTest.cs | |||
@@ -1520,6 +1520,44 @@ default | |||
1520 | } | 1520 | } |
1521 | 1521 | ||
1522 | [Test] | 1522 | [Test] |
1523 | public void TestAssignmentInIfWhileDoWhile() | ||
1524 | { | ||
1525 | string input = @"default | ||
1526 | { | ||
1527 | state_entry() | ||
1528 | { | ||
1529 | integer x; | ||
1530 | |||
1531 | while(x = 14) llOwnerSay(""x is: "" + (string) x); | ||
1532 | |||
1533 | if(x = 24) llOwnerSay(""x is: "" + (string) x); | ||
1534 | |||
1535 | do | ||
1536 | llOwnerSay(""x is: "" + (string) x); | ||
1537 | while(x = 44); | ||
1538 | } | ||
1539 | }"; | ||
1540 | |||
1541 | string expected = @" | ||
1542 | public void default_event_state_entry() | ||
1543 | { | ||
1544 | LSL_Types.LSLInteger x = 0; | ||
1545 | while (x = 14) | ||
1546 | llOwnerSay(""x is: "" + (LSL_Types.LSLString) (x)); | ||
1547 | if (x = 24) | ||
1548 | llOwnerSay(""x is: "" + (LSL_Types.LSLString) (x)); | ||
1549 | do | ||
1550 | llOwnerSay(""x is: "" + (LSL_Types.LSLString) (x)); | ||
1551 | while (x = 44); | ||
1552 | } | ||
1553 | "; | ||
1554 | |||
1555 | CSCodeGenerator cg = new CSCodeGenerator(); | ||
1556 | string output = cg.Convert(input); | ||
1557 | Assert.AreEqual(expected, output); | ||
1558 | } | ||
1559 | |||
1560 | [Test] | ||
1523 | [ExpectedException("Tools.CSToolsException")] | 1561 | [ExpectedException("Tools.CSToolsException")] |
1524 | public void TestSyntaxError() | 1562 | public void TestSyntaxError() |
1525 | { | 1563 | { |
@@ -1548,5 +1586,35 @@ default | |||
1548 | throw; | 1586 | throw; |
1549 | } | 1587 | } |
1550 | } | 1588 | } |
1589 | |||
1590 | [Test] | ||
1591 | [ExpectedException("Tools.CSToolsException")] | ||
1592 | public void TestSyntaxErrorDeclaringVariableInForLoop() | ||
1593 | { | ||
1594 | string input = @"default | ||
1595 | { | ||
1596 | state_entry() | ||
1597 | { | ||
1598 | for (integer x = 0; x < 10; x++) llOwnerSay(""x is: "" + (string) x); | ||
1599 | } | ||
1600 | } | ||
1601 | "; | ||
1602 | try | ||
1603 | { | ||
1604 | CSCodeGenerator cg = new CSCodeGenerator(); | ||
1605 | cg.Convert(input); | ||
1606 | } | ||
1607 | catch (Tools.CSToolsException e) | ||
1608 | { | ||
1609 | // The syntax error is on line 6, char 5 (expected ';', found | ||
1610 | // '}'). | ||
1611 | Regex r = new Regex("Line ([0-9]+), char ([0-9]+)"); | ||
1612 | Match m = r.Match(e.Message); | ||
1613 | Assert.AreEqual("5", m.Groups[1].Value); | ||
1614 | Assert.AreEqual("14", m.Groups[2].Value); | ||
1615 | |||
1616 | throw; | ||
1617 | } | ||
1618 | } | ||
1551 | } | 1619 | } |
1552 | } | 1620 | } |