Fix bug in generating termination checks in compound statement for loop.

Add regression test for this case.
user_profiles
Justin Clark-Casey (justincc) 2013-01-22 01:23:10 +00:00
parent a558f9797d
commit c6ba27d096
2 changed files with 27 additions and 3 deletions

View File

@ -445,7 +445,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
if (previousSymbol is GlobalFunctionDefinition
|| previousSymbol is WhileStatement
|| previousSymbol is DoWhileStatement
|| previousSymbol is ForLoopStatement
|| previousSymbol is ForLoop
|| previousSymbol is StateEvent)
retstr += GenerateIndentedLine(m_coopTerminationCheck);
}

View File

@ -76,12 +76,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests
xEngineConfig.Set("AppDomainLoading", "false");
xEngineConfig.Set("ScriptStopStrategy", "co-op");
xEngineConfig.Set("WriteScriptSourceToDebugFile", true);
// This is not currently used at all for co-op termination. Bumping up to demonstrate that co-op termination
// has an effect - without it tests will fail due to a 120 second wait for the event to finish.
xEngineConfig.Set("WaitForEventCompletionOnScriptStop", 120000);
m_scene = new SceneHelpers().SetupScene("My Test", UUID.Random(), 1000, 1000, configSource);
m_scene = new SceneHelpers().SetupScene("My Test", TestHelpers.ParseTail(0x9999), 1000, 1000, configSource);
SceneHelpers.SetupSceneModules(m_scene, configSource, m_xEngine);
m_scene.StartScripts();
}
@ -113,7 +114,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests
}
[Test]
public void TestStopOnLongForLoop()
public void TestStopOnLongSingleStatementForLoop()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
@ -133,6 +134,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests
TestStop(script);
}
[Test]
public void TestStopOnLongCompoundStatementForLoop()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
string script =
@"default
{
state_entry()
{
llSay(0, ""Thin Lizzy"");
integer i = 0;
for (i = 0; i < 2147483647; i++)
{
llSay(0, ""Iter "" + (string)i);
}
}
}";
TestStop(script);
}
private void TestStop(string script)
{
UUID userId = TestHelpers.ParseTail(0x1);