29 using System.Collections.Generic;
30 using System.Text.RegularExpressions;
31 using NUnit.Framework;
32 using OpenSim.Region.ScriptEngine.Shared.CodeTools;
33 using OpenSim.Tests.Common;
35 namespace OpenSim.Region.ScriptEngine.Shared.Tests
44 TestHelpers.InMethod();
47 TestCompile(
"default { bad() {} }",
true);
53 TestHelpers.InMethod();
56 TestKeyArgEvent(
"attach");
62 TestHelpers.InMethod();
65 TestKeyArgEvent(
"object_rez");
71 TestHelpers.InMethod();
74 TestVoidArgEvent(
"moving_end");
80 TestHelpers.InMethod();
83 TestVoidArgEvent(
"moving_start");
89 TestHelpers.InMethod();
92 TestVoidArgEvent(
"no_sensor");
98 TestHelpers.InMethod();
101 TestVoidArgEvent(
"not_at_rot_target");
107 TestHelpers.InMethod();
110 TestVoidArgEvent(
"not_at_target");
116 TestHelpers.InMethod();
119 TestVoidArgEvent(
"state_entry");
125 TestHelpers.InMethod();
128 TestVoidArgEvent(
"state_exit");
134 TestHelpers.InMethod();
137 TestVoidArgEvent(
"timer");
140 private void TestVoidArgEvent(
string eventName)
142 TestCompile(
"default { " + eventName +
"() {} }",
false);
143 TestCompile(
"default { " + eventName +
"(integer n) {} }",
true);
149 TestHelpers.InMethod();
152 TestIntArgEvent(
"changed");
158 TestHelpers.InMethod();
161 TestIntArgEvent(
"collision");
167 TestHelpers.InMethod();
170 TestIntArgEvent(
"collision_start");
176 TestHelpers.InMethod();
179 TestIntArgEvent(
"collision_end");
185 TestHelpers.InMethod();
188 TestIntArgEvent(
"on_rez");
194 TestHelpers.InMethod();
197 TestIntArgEvent(
"run_time_permissions");
203 TestHelpers.InMethod();
206 TestIntArgEvent(
"sensor");
212 TestHelpers.InMethod();
215 TestIntArgEvent(
"touch");
221 TestHelpers.InMethod();
224 TestIntArgEvent(
"touch_start");
230 TestHelpers.InMethod();
233 TestIntArgEvent(
"touch_end");
239 TestHelpers.InMethod();
242 TestVectorArgEvent(
"land_collision");
248 TestHelpers.InMethod();
251 TestVectorArgEvent(
"land_collision_start");
257 TestHelpers.InMethod();
260 TestVectorArgEvent(
"land_collision_end");
266 TestHelpers.InMethod();
269 TestIntRotRotArgEvent(
"at_rot_target");
275 TestHelpers.InMethod();
278 TestIntVecVecArgEvent(
"at_target");
284 TestHelpers.InMethod();
287 TestKeyIntIntArgEvent(
"control");
290 private void TestIntArgEvent(
string eventName)
292 TestCompile(
"default { " + eventName +
"(integer n) {} }",
false);
293 TestCompile(
"default { " + eventName +
"{{}} }",
true);
294 TestCompile(
"default { " + eventName +
"(string s) {{}} }",
true);
295 TestCompile(
"default { " + eventName +
"(integer n, integer o) {{}} }",
true);
298 private void TestKeyArgEvent(
string eventName)
300 TestCompile(
"default { " + eventName +
"(key k) {} }",
false);
301 TestCompile(
"default { " + eventName +
"{{}} }",
true);
302 TestCompile(
"default { " + eventName +
"(string s) {{}} }",
true);
303 TestCompile(
"default { " + eventName +
"(key k, key l) {{}} }",
true);
306 private void TestVectorArgEvent(
string eventName)
308 TestCompile(
"default { " + eventName +
"(vector v) {} }",
false);
309 TestCompile(
"default { " + eventName +
"{{}} }",
true);
310 TestCompile(
"default { " + eventName +
"(string s) {{}} }",
true);
311 TestCompile(
"default { " + eventName +
"(vector v, vector w) {{}} }",
true);
314 private void TestIntRotRotArgEvent(
string eventName)
316 TestCompile(
"default { " + eventName +
"(integer n, rotation r, rotation s) {} }",
false);
317 TestCompile(
"default { " + eventName +
"{{}} }",
true);
318 TestCompile(
"default { " + eventName +
"(string s) {{}} }",
true);
319 TestCompile(
"default { " + eventName +
"(integer n, rotation r, rotation s, rotation t) {{}} }",
true);
322 private void TestIntVecVecArgEvent(
string eventName)
324 TestCompile(
"default { " + eventName +
"(integer n, vector v, vector w) {} }",
false);
325 TestCompile(
"default { " + eventName +
"{{}} }",
true);
326 TestCompile(
"default { " + eventName +
"(string s) {{}} }",
true);
327 TestCompile(
"default { " + eventName +
"(integer n, vector v, vector w, vector x) {{}} }",
true);
330 private void TestKeyIntIntArgEvent(
string eventName)
332 TestCompile(
"default { " + eventName +
"(key k, integer n, integer o) {} }",
false);
333 TestCompile(
"default { " + eventName +
"{{}} }",
true);
334 TestCompile(
"default { " + eventName +
"(string s) {{}} }",
true);
335 TestCompile(
"default { " + eventName +
"(key k, integer n, integer o, integer p) {{}} }",
true);
338 private void TestCompile(
string script,
bool expectException)
340 bool gotException =
false;
345 m_cg.Convert(script);
355 Is.EqualTo(expectException),
356 "Failed on {0}, exception {1}", script, ge != null ? ge.ToString() :
"n/a");
void TestStateEntryEvent()
void TestLandCollisionEvent()
void TestCollisionStartEvent()
void TestMovingStartEvent()
void TestObjectRezEvent()
void TestCollisionEvent()
void TestTouchStartEvent()
void TestStateExitEvent()
void TestRunTimePermissionsEvent()
void TestNotAtTargetEvent()
void TestLandCollisionStartEvent()
void TestMovingEndEvent()
void TestAtRotTargetEvent()
Interactive OpenSim region server
void TestLandCollisionEndEvent()
void TestCollisionEndEvent()
void TestNotAtRotTargetEvent()