aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests
diff options
context:
space:
mode:
authorMike Mazur2009-06-07 10:22:55 +0000
committerMike Mazur2009-06-07 10:22:55 +0000
commitcda6b2466868cc74367da1b17d676f7168b84f6d (patch)
treef7dd014e4a9544fcf76687fb537163344cef8a3f /OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests
parentAllow empty assignment in for-loop (diff)
downloadopensim-SC_OLD-cda6b2466868cc74367da1b17d676f7168b84f6d.zip
opensim-SC_OLD-cda6b2466868cc74367da1b17d676f7168b84f6d.tar.gz
opensim-SC_OLD-cda6b2466868cc74367da1b17d676f7168b84f6d.tar.bz2
opensim-SC_OLD-cda6b2466868cc74367da1b17d676f7168b84f6d.tar.xz
Skip lone ident statments or for-loop assignments
SL's LSL supports lone idents: integer x; x; as well as lone idents in for-loop assignments: for (x; x < 10; x++) { ... } while those are errors in C# (MONO at least). This patch skips lone idents in such places. Fixes Mantis #3042.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs51
1 files changed, 51 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs
index a7d4fa9..5dfbdbc 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs
@@ -133,6 +133,32 @@ state another_state
133 } 133 }
134 134
135 [Test] 135 [Test]
136 public void TestLoneIdent()
137 {
138 // A lone ident should be removed completely as it's an error in C#
139 // (MONO at least).
140 string input = @"default
141{
142 touch_start(integer num_detected)
143 {
144 integer x;
145 x;
146 }
147}
148";
149 string expected =
150 "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" +
151 "\n {" +
152 "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(0);" +
153 "\n ;" +
154 "\n }\n";
155
156 CSCodeGenerator cg = new CSCodeGenerator();
157 string output = cg.Convert(input);
158 Assert.AreEqual(expected, output);
159 }
160
161 [Test]
136 public void TestAssignments() 162 public void TestAssignments()
137 { 163 {
138 string input = @"default 164 string input = @"default
@@ -1541,6 +1567,31 @@ default
1541 } 1567 }
1542 1568
1543 [Test] 1569 [Test]
1570 public void TestForLoopWithOnlyIdentInAssignment()
1571 {
1572 string input = @"default
1573{
1574 state_entry()
1575 {
1576 integer x = 4;
1577 for (x; 1<0; x += 2);
1578 }
1579}";
1580
1581 string expected =
1582 "\n public void default_event_state_entry()" +
1583 "\n {" +
1584 "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(4);" +
1585 "\n for (; new LSL_Types.LSLInteger(1) < new LSL_Types.LSLInteger(0); x += new LSL_Types.LSLInteger(2))" +
1586 "\n ;" +
1587 "\n }\n";
1588
1589 CSCodeGenerator cg = new CSCodeGenerator();
1590 string output = cg.Convert(input);
1591 Assert.AreEqual(expected, output);
1592 }
1593
1594 [Test]
1544 public void TestAssignmentInIfWhileDoWhile() 1595 public void TestAssignmentInIfWhileDoWhile()
1545 { 1596 {
1546 string input = @"default 1597 string input = @"default