-add test for newly introduced cast operators (issue 1818)

-fix formatting
-remove CompilerTest test since it seems to fail randomly
0.6.0-stable
Mike Mazur 2008-07-25 04:47:11 +00:00
parent ac9a221993
commit e60cf0e67d
4 changed files with 22 additions and 5 deletions

View File

@ -1189,6 +1189,7 @@ namespace OpenSim.Region.ScriptEngine.Common
{
return new Vector3(s.m_string);
}
public static implicit operator LSLFloat(LSLString s)
{
return new LSLFloat(Convert.ToDouble(s.m_string));

View File

@ -1199,10 +1199,11 @@ namespace OpenSim.Region.ScriptEngine.Shared
{
return new Vector3(s.m_string);
}
public static implicit operator LSLFloat(LSLString s)
{
return new LSLFloat(Convert.ToDouble(s.m_string));
}
public static implicit operator LSLFloat(LSLString s)
{
return new LSLFloat(Convert.ToDouble(s.m_string));
}
#endregion

View File

@ -318,6 +318,21 @@ namespace OpenSim.Region.ScriptEngine.Common.Tests
}
}
/// <summary>
/// Tests string is correctly cast implicitly to LSLFloat.
/// </summary>
[Test]
public void TestExplicitCastLSLStringToLSLFloat()
{
LSL_Types.LSLFloat testFloat;
foreach (KeyValuePair<string, double> number in m_stringDoubleSet)
{
testFloat = (LSL_Types.LSLFloat) new LSL_Types.LSLString(number.Key);
Assert.That(testFloat.value, new DoubleToleranceConstraint(number.Value, _lowPrecisionTolerance));
}
}
/// <summary>
/// Tests double is correctly cast implicitly to LSLFloat.
/// </summary>

View File

@ -85,7 +85,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests
}
}
[Test]
//[Test]
/// <summary>
/// Test the C# compiler error message can be mapped to the correct
/// line/column in the LSL source when an undeclared variable is used.