Get regression test TestUseUndeclaredVariable() functional again, though not yet enabled.

This reveals the position map problems and will make the fix (and subsequent continual checking) easier.
bullet-2.82
Justin Clark-Casey (justincc) 2014-05-23 22:29:47 +01:00
parent 250ea09328
commit cf95b65c10
1 changed files with 19 additions and 8 deletions

View File

@ -108,19 +108,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests
}";
CSCodeGenerator cg = new CSCodeGenerator();
string output = "using OpenSim.Region.ScriptEngine.Shared; using System.Collections.Generic;\n" +
"namespace SecondLife { " +
"public class Script : OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass {\n" +
"public Script() { } " +
cg.Convert(input) +
"} }\n";
string output = cg.Convert(input);
output = Compiler.CreateCSCompilerScript(output, "script1", typeof(ScriptBaseClass).FullName, null);
System.Console.WriteLine(output);
Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> positionMap = cg.PositionMap;
m_compilerResults = m_CSCodeProvider.CompileAssemblyFromSource(m_compilerParameters, output);
Assert.AreEqual(new KeyValuePair<int, int>(5, 21),
positionMap[new KeyValuePair<int, int>(m_compilerResults.Errors[0].Line, m_compilerResults.Errors[0].Column)]);
foreach (KeyValuePair<int, int> key in positionMap.Keys)
{
KeyValuePair<int, int> val = positionMap[key];
System.Console.WriteLine("{0},{1} => {2},{3}", key.Key, key.Value, val.Key, val.Value);
}
foreach (CompilerError compErr in m_compilerResults.Errors)
{
System.Console.WriteLine("Error: {0},{1} => {2}", compErr.Line, compErr.Column, compErr);
}
Assert.AreEqual(
new KeyValuePair<int, int>(5, 21),
positionMap[new KeyValuePair<int, int>(m_compilerResults.Errors[0].Line, m_compilerResults.Errors[0].Column)]);
}
/// <summary>