More LSL_Types implicit/explicit cast changes. Fix issue 1854.
parent
3a2caa1f9a
commit
1c8f490573
|
@ -1439,12 +1439,12 @@ namespace OpenSim.Region.ScriptEngine.Common
|
||||||
|
|
||||||
#region Operators
|
#region Operators
|
||||||
|
|
||||||
static public implicit operator int(LSLFloat f)
|
static public explicit operator int(LSLFloat f)
|
||||||
{
|
{
|
||||||
return (int)f.value;
|
return (int)f.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public implicit operator uint(LSLFloat f)
|
static public explicit operator uint(LSLFloat f)
|
||||||
{
|
{
|
||||||
return (uint) Math.Abs(f.value);
|
return (uint) Math.Abs(f.value);
|
||||||
}
|
}
|
||||||
|
@ -1471,7 +1471,7 @@ namespace OpenSim.Region.ScriptEngine.Common
|
||||||
return new LSLFloat(i.value);
|
return new LSLFloat(i.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public implicit operator LSLFloat(string s)
|
static public explicit operator LSLFloat(string s)
|
||||||
{
|
{
|
||||||
return new LSLFloat(double.Parse(s));
|
return new LSLFloat(double.Parse(s));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1439,12 +1439,12 @@ namespace OpenSim.Region.ScriptEngine.Shared
|
||||||
|
|
||||||
#region Operators
|
#region Operators
|
||||||
|
|
||||||
static public implicit operator int(LSLFloat f)
|
static public explicit operator int(LSLFloat f)
|
||||||
{
|
{
|
||||||
return (int)f.value;
|
return (int)f.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public implicit operator uint(LSLFloat f)
|
static public explicit operator uint(LSLFloat f)
|
||||||
{
|
{
|
||||||
return (uint) Math.Abs(f.value);
|
return (uint) Math.Abs(f.value);
|
||||||
}
|
}
|
||||||
|
@ -1471,7 +1471,7 @@ namespace OpenSim.Region.ScriptEngine.Shared
|
||||||
return new LSLFloat(i.value);
|
return new LSLFloat(i.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public implicit operator LSLFloat(string s)
|
static public explicit operator LSLFloat(string s)
|
||||||
{
|
{
|
||||||
return new LSLFloat(double.Parse(s));
|
return new LSLFloat(double.Parse(s));
|
||||||
}
|
}
|
||||||
|
|
|
@ -228,31 +228,31 @@ namespace OpenSim.Region.ScriptEngine.Common.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests LSLFloat is correctly cast implicitly to integer.
|
/// Tests LSLFloat is correctly cast explicitly to integer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Test]
|
[Test]
|
||||||
public void TestImplicitCastLSLFloatToInt()
|
public void TestExplicitCastLSLFloatToInt()
|
||||||
{
|
{
|
||||||
int testNumber;
|
int testNumber;
|
||||||
|
|
||||||
foreach (KeyValuePair<double, int> number in m_doubleIntSet)
|
foreach (KeyValuePair<double, int> number in m_doubleIntSet)
|
||||||
{
|
{
|
||||||
testNumber = new LSL_Types.LSLFloat(number.Key);
|
testNumber = (int) new LSL_Types.LSLFloat(number.Key);
|
||||||
Assert.AreEqual(number.Value, testNumber, "Converting double " + number.Key + ", expecting int " + number.Value);
|
Assert.AreEqual(number.Value, testNumber, "Converting double " + number.Key + ", expecting int " + number.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests LSLFloat is correctly cast implicitly to unsigned integer.
|
/// Tests LSLFloat is correctly cast explicitly to unsigned integer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Test]
|
[Test]
|
||||||
public void TestImplicitCastLSLFloatToUint()
|
public void TestExplicitCastLSLFloatToUint()
|
||||||
{
|
{
|
||||||
uint testNumber;
|
uint testNumber;
|
||||||
|
|
||||||
foreach (KeyValuePair<double, int> number in m_doubleUintSet)
|
foreach (KeyValuePair<double, int> number in m_doubleUintSet)
|
||||||
{
|
{
|
||||||
testNumber = new LSL_Types.LSLFloat(number.Key);
|
testNumber = (uint) new LSL_Types.LSLFloat(number.Key);
|
||||||
Assert.AreEqual(number.Value, testNumber, "Converting double " + number.Key + ", expecting uint " + number.Value);
|
Assert.AreEqual(number.Value, testNumber, "Converting double " + number.Key + ", expecting uint " + number.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -333,16 +333,16 @@ namespace OpenSim.Region.ScriptEngine.Common.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests string is correctly cast implicitly to LSLFloat.
|
/// Tests string is correctly cast explicitly to LSLFloat.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Test]
|
[Test]
|
||||||
public void TestImplicitCastStringToLSLFloat()
|
public void TestExplicitCastStringToLSLFloat()
|
||||||
{
|
{
|
||||||
LSL_Types.LSLFloat testFloat;
|
LSL_Types.LSLFloat testFloat;
|
||||||
|
|
||||||
foreach (KeyValuePair<string, double> number in m_stringDoubleSet)
|
foreach (KeyValuePair<string, double> number in m_stringDoubleSet)
|
||||||
{
|
{
|
||||||
testFloat = number.Key;
|
testFloat = (LSL_Types.LSLFloat) number.Key;
|
||||||
Assert.That(testFloat.value, new DoubleToleranceConstraint(number.Value, _lowPrecisionTolerance));
|
Assert.That(testFloat.value, new DoubleToleranceConstraint(number.Value, _lowPrecisionTolerance));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -377,6 +377,24 @@ namespace OpenSim.Region.ScriptEngine.Common.Tests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests LSLFloat is correctly cast implicitly to double.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestImplicitCastLSLFloatToDouble()
|
||||||
|
{
|
||||||
|
double testNumber;
|
||||||
|
LSL_Types.LSLFloat testFloat;
|
||||||
|
|
||||||
|
foreach (double number in m_doubleList)
|
||||||
|
{
|
||||||
|
testFloat = new LSL_Types.LSLFloat(number);
|
||||||
|
testNumber = testFloat;
|
||||||
|
|
||||||
|
Assert.That(testNumber, new DoubleToleranceConstraint(number, _lowPrecisionTolerance));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the equality (==) operator.
|
/// Tests the equality (==) operator.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -463,24 +481,6 @@ namespace OpenSim.Region.ScriptEngine.Common.Tests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Tests LSLFloat is correctly cast implicitly to double.
|
|
||||||
/// </summary>
|
|
||||||
[Test]
|
|
||||||
public void TestImplicitCastLSLFloatToDouble()
|
|
||||||
{
|
|
||||||
double testNumber;
|
|
||||||
LSL_Types.LSLFloat testFloat;
|
|
||||||
|
|
||||||
foreach (double number in m_doubleList)
|
|
||||||
{
|
|
||||||
testFloat = new LSL_Types.LSLFloat(number);
|
|
||||||
testNumber = testFloat;
|
|
||||||
|
|
||||||
Assert.That(testNumber, new DoubleToleranceConstraint(number, _lowPrecisionTolerance));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests LSLFloat.ToString().
|
/// Tests LSLFloat.ToString().
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -228,31 +228,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests LSLFloat is correctly cast implicitly to integer.
|
/// Tests LSLFloat is correctly cast explicitly to integer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Test]
|
[Test]
|
||||||
public void TestImplicitCastLSLFloatToInt()
|
public void TestExplicitCastLSLFloatToInt()
|
||||||
{
|
{
|
||||||
int testNumber;
|
int testNumber;
|
||||||
|
|
||||||
foreach (KeyValuePair<double, int> number in m_doubleIntSet)
|
foreach (KeyValuePair<double, int> number in m_doubleIntSet)
|
||||||
{
|
{
|
||||||
testNumber = new LSL_Types.LSLFloat(number.Key);
|
testNumber = (int) new LSL_Types.LSLFloat(number.Key);
|
||||||
Assert.AreEqual(number.Value, testNumber, "Converting double " + number.Key + ", expecting int " + number.Value);
|
Assert.AreEqual(number.Value, testNumber, "Converting double " + number.Key + ", expecting int " + number.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests LSLFloat is correctly cast implicitly to unsigned integer.
|
/// Tests LSLFloat is correctly cast explicitly to unsigned integer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Test]
|
[Test]
|
||||||
public void TestImplicitCastLSLFloatToUint()
|
public void TestExplicitCastLSLFloatToUint()
|
||||||
{
|
{
|
||||||
uint testNumber;
|
uint testNumber;
|
||||||
|
|
||||||
foreach (KeyValuePair<double, int> number in m_doubleUintSet)
|
foreach (KeyValuePair<double, int> number in m_doubleUintSet)
|
||||||
{
|
{
|
||||||
testNumber = new LSL_Types.LSLFloat(number.Key);
|
testNumber = (uint) new LSL_Types.LSLFloat(number.Key);
|
||||||
Assert.AreEqual(number.Value, testNumber, "Converting double " + number.Key + ", expecting uint " + number.Value);
|
Assert.AreEqual(number.Value, testNumber, "Converting double " + number.Key + ", expecting uint " + number.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -333,16 +333,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests string is correctly cast implicitly to LSLFloat.
|
/// Tests string is correctly cast explicitly to LSLFloat.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Test]
|
[Test]
|
||||||
public void TestImplicitCastStringToLSLFloat()
|
public void TestExplicitCastStringToLSLFloat()
|
||||||
{
|
{
|
||||||
LSL_Types.LSLFloat testFloat;
|
LSL_Types.LSLFloat testFloat;
|
||||||
|
|
||||||
foreach (KeyValuePair<string, double> number in m_stringDoubleSet)
|
foreach (KeyValuePair<string, double> number in m_stringDoubleSet)
|
||||||
{
|
{
|
||||||
testFloat = number.Key;
|
testFloat = (LSL_Types.LSLFloat) number.Key;
|
||||||
Assert.That(testFloat.value, new DoubleToleranceConstraint(number.Value, _lowPrecisionTolerance));
|
Assert.That(testFloat.value, new DoubleToleranceConstraint(number.Value, _lowPrecisionTolerance));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -377,6 +377,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests LSLFloat is correctly cast implicitly to double.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestImplicitCastLSLFloatToDouble()
|
||||||
|
{
|
||||||
|
double testNumber;
|
||||||
|
LSL_Types.LSLFloat testFloat;
|
||||||
|
|
||||||
|
foreach (double number in m_doubleList)
|
||||||
|
{
|
||||||
|
testFloat = new LSL_Types.LSLFloat(number);
|
||||||
|
testNumber = testFloat;
|
||||||
|
|
||||||
|
Assert.That(testNumber, new DoubleToleranceConstraint(number, _lowPrecisionTolerance));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the equality (==) operator.
|
/// Tests the equality (==) operator.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -463,24 +481,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Tests LSLFloat is correctly cast implicitly to double.
|
|
||||||
/// </summary>
|
|
||||||
[Test]
|
|
||||||
public void TestImplicitCastLSLFloatToDouble()
|
|
||||||
{
|
|
||||||
double testNumber;
|
|
||||||
LSL_Types.LSLFloat testFloat;
|
|
||||||
|
|
||||||
foreach (double number in m_doubleList)
|
|
||||||
{
|
|
||||||
testFloat = new LSL_Types.LSLFloat(number);
|
|
||||||
testNumber = testFloat;
|
|
||||||
|
|
||||||
Assert.That(testNumber, new DoubleToleranceConstraint(number, _lowPrecisionTolerance));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests LSLFloat.ToString().
|
/// Tests LSLFloat.ToString().
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in New Issue