More LSL_Types implicit/explicit cast changes. Fix issue 1854.

0.6.0-stable
Mike Mazur 2008-07-31 00:29:19 +00:00
parent 3a2caa1f9a
commit 1c8f490573
4 changed files with 60 additions and 60 deletions

View File

@ -1439,12 +1439,12 @@ namespace OpenSim.Region.ScriptEngine.Common
#region Operators
static public implicit operator int(LSLFloat f)
static public explicit operator int(LSLFloat f)
{
return (int)f.value;
}
static public implicit operator uint(LSLFloat f)
static public explicit operator uint(LSLFloat f)
{
return (uint) Math.Abs(f.value);
}
@ -1471,7 +1471,7 @@ namespace OpenSim.Region.ScriptEngine.Common
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));
}

View File

@ -1439,12 +1439,12 @@ namespace OpenSim.Region.ScriptEngine.Shared
#region Operators
static public implicit operator int(LSLFloat f)
static public explicit operator int(LSLFloat f)
{
return (int)f.value;
}
static public implicit operator uint(LSLFloat f)
static public explicit operator uint(LSLFloat f)
{
return (uint) Math.Abs(f.value);
}
@ -1471,7 +1471,7 @@ namespace OpenSim.Region.ScriptEngine.Shared
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));
}

View File

@ -228,31 +228,31 @@ namespace OpenSim.Region.ScriptEngine.Common.Tests
}
/// <summary>
/// Tests LSLFloat is correctly cast implicitly to integer.
/// Tests LSLFloat is correctly cast explicitly to integer.
/// </summary>
[Test]
public void TestImplicitCastLSLFloatToInt()
public void TestExplicitCastLSLFloatToInt()
{
int testNumber;
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);
}
}
/// <summary>
/// Tests LSLFloat is correctly cast implicitly to unsigned integer.
/// Tests LSLFloat is correctly cast explicitly to unsigned integer.
/// </summary>
[Test]
public void TestImplicitCastLSLFloatToUint()
public void TestExplicitCastLSLFloatToUint()
{
uint testNumber;
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);
}
}
@ -333,16 +333,16 @@ namespace OpenSim.Region.ScriptEngine.Common.Tests
}
/// <summary>
/// Tests string is correctly cast implicitly to LSLFloat.
/// Tests string is correctly cast explicitly to LSLFloat.
/// </summary>
[Test]
public void TestImplicitCastStringToLSLFloat()
public void TestExplicitCastStringToLSLFloat()
{
LSL_Types.LSLFloat testFloat;
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));
}
}
@ -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>
/// Tests the equality (==) operator.
/// </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>
/// Tests LSLFloat.ToString().
/// </summary>

View File

@ -228,31 +228,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
}
/// <summary>
/// Tests LSLFloat is correctly cast implicitly to integer.
/// Tests LSLFloat is correctly cast explicitly to integer.
/// </summary>
[Test]
public void TestImplicitCastLSLFloatToInt()
public void TestExplicitCastLSLFloatToInt()
{
int testNumber;
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);
}
}
/// <summary>
/// Tests LSLFloat is correctly cast implicitly to unsigned integer.
/// Tests LSLFloat is correctly cast explicitly to unsigned integer.
/// </summary>
[Test]
public void TestImplicitCastLSLFloatToUint()
public void TestExplicitCastLSLFloatToUint()
{
uint testNumber;
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);
}
}
@ -333,16 +333,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
}
/// <summary>
/// Tests string is correctly cast implicitly to LSLFloat.
/// Tests string is correctly cast explicitly to LSLFloat.
/// </summary>
[Test]
public void TestImplicitCastStringToLSLFloat()
public void TestExplicitCastStringToLSLFloat()
{
LSL_Types.LSLFloat testFloat;
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));
}
}
@ -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>
/// Tests the equality (==) operator.
/// </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>
/// Tests LSLFloat.ToString().
/// </summary>