Implement LSLFloat {+,-,*,/} LSLFloat operations. Fix issues 1532, 1701, 1824 &
1832.0.6.0-stable
parent
290f942858
commit
6267db0c4c
|
@ -1511,6 +1511,26 @@ namespace OpenSim.Region.ScriptEngine.Common
|
|||
return new LSLFloat(f.value / (double)i);
|
||||
}
|
||||
|
||||
static public LSLFloat operator +(LSLFloat lhs, LSLFloat rhs)
|
||||
{
|
||||
return new LSLFloat(lhs.value + rhs.value);
|
||||
}
|
||||
|
||||
static public LSLFloat operator -(LSLFloat lhs, LSLFloat rhs)
|
||||
{
|
||||
return new LSLFloat(lhs.value - rhs.value);
|
||||
}
|
||||
|
||||
static public LSLFloat operator *(LSLFloat lhs, LSLFloat rhs)
|
||||
{
|
||||
return new LSLFloat(lhs.value * rhs.value);
|
||||
}
|
||||
|
||||
static public LSLFloat operator /(LSLFloat lhs, LSLFloat rhs)
|
||||
{
|
||||
return new LSLFloat(lhs.value / rhs.value);
|
||||
}
|
||||
|
||||
static public LSLFloat operator -(LSLFloat f)
|
||||
{
|
||||
return new LSLFloat(-f.value);
|
||||
|
|
|
@ -1579,6 +1579,26 @@ namespace OpenSim.Region.ScriptEngine.Shared
|
|||
return new LSLFloat(f.value / (double)i);
|
||||
}
|
||||
|
||||
static public LSLFloat operator +(LSLFloat lhs, LSLFloat rhs)
|
||||
{
|
||||
return new LSLFloat(lhs.value + rhs.value);
|
||||
}
|
||||
|
||||
static public LSLFloat operator -(LSLFloat lhs, LSLFloat rhs)
|
||||
{
|
||||
return new LSLFloat(lhs.value - rhs.value);
|
||||
}
|
||||
|
||||
static public LSLFloat operator *(LSLFloat lhs, LSLFloat rhs)
|
||||
{
|
||||
return new LSLFloat(lhs.value * rhs.value);
|
||||
}
|
||||
|
||||
static public LSLFloat operator /(LSLFloat lhs, LSLFloat rhs)
|
||||
{
|
||||
return new LSLFloat(lhs.value / rhs.value);
|
||||
}
|
||||
|
||||
static public LSLFloat operator -(LSLFloat f)
|
||||
{
|
||||
return new LSLFloat(-f.value);
|
||||
|
|
|
@ -496,5 +496,68 @@ namespace OpenSim.Region.ScriptEngine.Common.Tests
|
|||
Assert.AreEqual(number.Value, testFloat.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests addition of two LSLFloats.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestAddTwoLSLFloats()
|
||||
{
|
||||
LSL_Types.LSLFloat testResult;
|
||||
|
||||
foreach (KeyValuePair<double, double> number in m_doubleDoubleSet)
|
||||
{
|
||||
testResult = new LSL_Types.LSLFloat(number.Key) + new LSL_Types.LSLFloat(number.Value);
|
||||
Assert.That(testResult.value, new DoubleToleranceConstraint(number.Key + number.Value, _lowPrecisionTolerance));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests subtraction of two LSLFloats.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestSubtractTwoLSLFloats()
|
||||
{
|
||||
LSL_Types.LSLFloat testResult;
|
||||
|
||||
foreach (KeyValuePair<double, double> number in m_doubleDoubleSet)
|
||||
{
|
||||
testResult = new LSL_Types.LSLFloat(number.Key) - new LSL_Types.LSLFloat(number.Value);
|
||||
Assert.That(testResult.value, new DoubleToleranceConstraint(number.Key - number.Value, _lowPrecisionTolerance));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests multiplication of two LSLFloats.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestMultiplyTwoLSLFloats()
|
||||
{
|
||||
LSL_Types.LSLFloat testResult;
|
||||
|
||||
foreach (KeyValuePair<double, double> number in m_doubleDoubleSet)
|
||||
{
|
||||
testResult = new LSL_Types.LSLFloat(number.Key) * new LSL_Types.LSLFloat(number.Value);
|
||||
Assert.That(testResult.value, new DoubleToleranceConstraint(number.Key * number.Value, _lowPrecisionTolerance));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests division of two LSLFloats.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestDivideTwoLSLFloats()
|
||||
{
|
||||
LSL_Types.LSLFloat testResult;
|
||||
|
||||
foreach (KeyValuePair<double, double> number in m_doubleDoubleSet)
|
||||
{
|
||||
if (number.Value != 0.0) // Let's avoid divide by zero.
|
||||
{
|
||||
testResult = new LSL_Types.LSLFloat(number.Key) / new LSL_Types.LSLFloat(number.Value);
|
||||
Assert.That(testResult.value, new DoubleToleranceConstraint(number.Key / number.Value, _lowPrecisionTolerance));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue