If anything other than a single integer is specified for events that only take a single integer, generate a syntax error on LSL script compile rather than an exception later on.

This applies to events changed, collision, collision_start, collision_end, on_rez, run_time_permissions, sensor, touch, touch_start, touch_end
link-sitting
Justin Clark-Casey (justincc) 2013-11-16 02:50:14 +00:00
parent 62006baaef
commit edd7e19463
2 changed files with 9416 additions and 8970 deletions

View File

@ -108,20 +108,123 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
TestCompile("default { timer(integer n) {} }", true); TestCompile("default { timer(integer n) {} }", true);
} }
[Test]
public void TestChangedEvent()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
TestIntArgEvent("changed");
}
[Test]
public void TestCollisionEvent()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
TestIntArgEvent("collision");
}
[Test]
public void TestCollisionStartEvent()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
TestIntArgEvent("collision_start");
}
[Test]
public void TestCollisionEndEvent()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
TestIntArgEvent("collision_end");
}
[Test]
public void TestOnRezEvent()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
TestIntArgEvent("on_rez");
}
[Test]
public void TestRunTimePermissionsEvent()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
TestIntArgEvent("run_time_permissions");
}
[Test]
public void TestSensorEvent()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
TestIntArgEvent("sensor");
}
[Test]
public void TestTouchEvent()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
TestIntArgEvent("touch");
}
[Test]
public void TestTouchStartEvent()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
TestIntArgEvent("touch_start");
}
[Test]
public void TestTouchEndEvent()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
TestIntArgEvent("touch_end");
}
private void TestIntArgEvent(string eventName)
{
TestCompile("default { " + eventName + "(integer n) {} }", false);
TestCompile("default { " + eventName + "{{}} }", true);
TestCompile("default { " + eventName + "(string s) {{}} }", true);
TestCompile("default { " + eventName + "(integer n, integer o) {{}} }", true);
}
private void TestCompile(string script, bool expectException) private void TestCompile(string script, bool expectException)
{ {
bool gotException = false; bool gotException = false;
Exception ge = null;
try try
{ {
m_cg.Convert(script); m_cg.Convert(script);
} }
catch (Exception) catch (Exception e)
{ {
gotException = true; gotException = true;
ge = e;
} }
Assert.That(gotException, Is.EqualTo(expectException)); Assert.That(
gotException,
Is.EqualTo(expectException),
"Failed on {0}, exception {1}", script, ge != null ? ge.ToString() : "n/a");
} }
} }
} }

File diff suppressed because it is too large Load Diff