diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/LSL_EventTests.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/LSL_EventTests.cs | 211 |
1 files changed, 197 insertions, 14 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/LSL_EventTests.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/LSL_EventTests.cs index 2a1c19c..53ce405 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/LSL_EventTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/LSL_EventTests.cs | |||
@@ -36,29 +36,212 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
36 | { | 36 | { |
37 | public class LSL_EventTests : OpenSimTestCase | 37 | public class LSL_EventTests : OpenSimTestCase |
38 | { | 38 | { |
39 | CSCodeGenerator m_cg = new CSCodeGenerator(); | ||
40 | |||
41 | [Test] | ||
42 | public void TestBadEvent() | ||
43 | { | ||
44 | TestHelpers.InMethod(); | ||
45 | // TestHelpers.EnableLogging(); | ||
46 | |||
47 | TestCompile("default { bad() {} }", true); | ||
48 | } | ||
49 | |||
50 | [Test] | ||
51 | public void TestMovingEndEvent() | ||
52 | { | ||
53 | TestHelpers.InMethod(); | ||
54 | // TestHelpers.EnableLogging(); | ||
55 | |||
56 | TestVoidArgEvent("moving_end"); | ||
57 | } | ||
58 | |||
59 | [Test] | ||
60 | public void TestMovingStartEvent() | ||
61 | { | ||
62 | TestHelpers.InMethod(); | ||
63 | // TestHelpers.EnableLogging(); | ||
64 | |||
65 | TestVoidArgEvent("moving_start"); | ||
66 | } | ||
67 | |||
68 | [Test] | ||
69 | public void TestNoSensorEvent() | ||
70 | { | ||
71 | TestHelpers.InMethod(); | ||
72 | // TestHelpers.EnableLogging(); | ||
73 | |||
74 | TestVoidArgEvent("no_sensor"); | ||
75 | } | ||
76 | |||
77 | [Test] | ||
78 | public void TestNotAtRotTargetEvent() | ||
79 | { | ||
80 | TestHelpers.InMethod(); | ||
81 | // TestHelpers.EnableLogging(); | ||
82 | |||
83 | TestVoidArgEvent("not_at_rot_target"); | ||
84 | } | ||
85 | |||
86 | [Test] | ||
87 | public void TestNotAtTargetEvent() | ||
88 | { | ||
89 | TestHelpers.InMethod(); | ||
90 | // TestHelpers.EnableLogging(); | ||
91 | |||
92 | TestVoidArgEvent("not_at_target"); | ||
93 | } | ||
94 | |||
39 | [Test] | 95 | [Test] |
40 | public void TestStateEntryEvent() | 96 | public void TestStateEntryEvent() |
41 | { | 97 | { |
42 | TestHelpers.InMethod(); | 98 | TestHelpers.InMethod(); |
43 | // TestHelpers.EnableLogging(); | 99 | // TestHelpers.EnableLogging(); |
44 | 100 | ||
45 | CSCodeGenerator cg = new CSCodeGenerator(); | 101 | TestVoidArgEvent("state_entry"); |
46 | cg.Convert("default { state_entry() {} }"); | 102 | } |
103 | |||
104 | [Test] | ||
105 | public void TestStateExitEvent() | ||
106 | { | ||
107 | TestHelpers.InMethod(); | ||
108 | // TestHelpers.EnableLogging(); | ||
109 | |||
110 | TestVoidArgEvent("state_exit"); | ||
111 | } | ||
112 | |||
113 | [Test] | ||
114 | public void TestTimerEvent() | ||
115 | { | ||
116 | TestHelpers.InMethod(); | ||
117 | // TestHelpers.EnableLogging(); | ||
118 | |||
119 | TestVoidArgEvent("timer"); | ||
120 | } | ||
121 | |||
122 | private void TestVoidArgEvent(string eventName) | ||
123 | { | ||
124 | TestCompile("default { " + eventName + "() {} }", false); | ||
125 | TestCompile("default { " + eventName + "(integer n) {} }", true); | ||
126 | } | ||
47 | 127 | ||
128 | [Test] | ||
129 | public void TestChangedEvent() | ||
130 | { | ||
131 | TestHelpers.InMethod(); | ||
132 | // TestHelpers.EnableLogging(); | ||
133 | |||
134 | TestIntArgEvent("changed"); | ||
135 | } | ||
136 | |||
137 | [Test] | ||
138 | public void TestCollisionEvent() | ||
139 | { | ||
140 | TestHelpers.InMethod(); | ||
141 | // TestHelpers.EnableLogging(); | ||
142 | |||
143 | TestIntArgEvent("collision"); | ||
144 | } | ||
145 | |||
146 | [Test] | ||
147 | public void TestCollisionStartEvent() | ||
148 | { | ||
149 | TestHelpers.InMethod(); | ||
150 | // TestHelpers.EnableLogging(); | ||
151 | |||
152 | TestIntArgEvent("collision_start"); | ||
153 | } | ||
154 | |||
155 | [Test] | ||
156 | public void TestCollisionEndEvent() | ||
157 | { | ||
158 | TestHelpers.InMethod(); | ||
159 | // TestHelpers.EnableLogging(); | ||
160 | |||
161 | TestIntArgEvent("collision_end"); | ||
162 | } | ||
163 | |||
164 | [Test] | ||
165 | public void TestOnRezEvent() | ||
166 | { | ||
167 | TestHelpers.InMethod(); | ||
168 | // TestHelpers.EnableLogging(); | ||
169 | |||
170 | TestIntArgEvent("on_rez"); | ||
171 | } | ||
172 | |||
173 | [Test] | ||
174 | public void TestRunTimePermissionsEvent() | ||
175 | { | ||
176 | TestHelpers.InMethod(); | ||
177 | // TestHelpers.EnableLogging(); | ||
178 | |||
179 | TestIntArgEvent("run_time_permissions"); | ||
180 | } | ||
181 | |||
182 | [Test] | ||
183 | public void TestSensorEvent() | ||
184 | { | ||
185 | TestHelpers.InMethod(); | ||
186 | // TestHelpers.EnableLogging(); | ||
187 | |||
188 | TestIntArgEvent("sensor"); | ||
189 | } | ||
190 | |||
191 | [Test] | ||
192 | public void TestTouchEvent() | ||
193 | { | ||
194 | TestHelpers.InMethod(); | ||
195 | // TestHelpers.EnableLogging(); | ||
196 | |||
197 | TestIntArgEvent("touch"); | ||
198 | } | ||
199 | |||
200 | [Test] | ||
201 | public void TestTouchStartEvent() | ||
202 | { | ||
203 | TestHelpers.InMethod(); | ||
204 | // TestHelpers.EnableLogging(); | ||
205 | |||
206 | TestIntArgEvent("touch_start"); | ||
207 | } | ||
208 | |||
209 | [Test] | ||
210 | public void TestTouchEndEvent() | ||
211 | { | ||
212 | TestHelpers.InMethod(); | ||
213 | // TestHelpers.EnableLogging(); | ||
214 | |||
215 | TestIntArgEvent("touch_end"); | ||
216 | } | ||
217 | |||
218 | private void TestIntArgEvent(string eventName) | ||
219 | { | ||
220 | TestCompile("default { " + eventName + "(integer n) {} }", false); | ||
221 | TestCompile("default { " + eventName + "{{}} }", true); | ||
222 | TestCompile("default { " + eventName + "(string s) {{}} }", true); | ||
223 | TestCompile("default { " + eventName + "(integer n, integer o) {{}} }", true); | ||
224 | } | ||
225 | |||
226 | private void TestCompile(string script, bool expectException) | ||
227 | { | ||
228 | bool gotException = false; | ||
229 | Exception ge = null; | ||
230 | |||
231 | try | ||
232 | { | ||
233 | m_cg.Convert(script); | ||
234 | } | ||
235 | catch (Exception e) | ||
48 | { | 236 | { |
49 | bool gotException = false; | 237 | gotException = true; |
50 | 238 | ge = e; | |
51 | try | ||
52 | { | ||
53 | cg.Convert("default { state_entry(integer n) {} }"); | ||
54 | } | ||
55 | catch (Exception ) | ||
56 | { | ||
57 | gotException = true; | ||
58 | } | ||
59 | |||
60 | Assert.That(gotException, Is.True); | ||
61 | } | 239 | } |
240 | |||
241 | Assert.That( | ||
242 | gotException, | ||
243 | Is.EqualTo(expectException), | ||
244 | "Failed on {0}, exception {1}", script, ge != null ? ge.ToString() : "n/a"); | ||
62 | } | 245 | } |
63 | } | 246 | } |
64 | } \ No newline at end of file | 247 | } \ No newline at end of file |