From 1c8f4905735ff7653313f725fea13bf6346d1389 Mon Sep 17 00:00:00 2001
From: Mike Mazur
Date: Thu, 31 Jul 2008 00:29:19 +0000
Subject: More LSL_Types implicit/explicit cast changes. Fix issue 1854.
---
OpenSim/Region/ScriptEngine/Common/LSL_Types.cs | 6 +--
OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 6 +--
.../ScriptEngine/Common/LSL_TypesTestLSLFloat.cs | 54 +++++++++++-----------
.../ScriptEngine/Shared/LSL_TypesTestLSLFloat.cs | 54 +++++++++++-----------
4 files changed, 60 insertions(+), 60 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs
index d0a5079..b8a4a4d 100644
--- a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs
@@ -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));
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
index c42e3e6..25f6957 100644
--- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
@@ -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));
}
diff --git a/OpenSim/Tests/OpenSim/Region/ScriptEngine/Common/LSL_TypesTestLSLFloat.cs b/OpenSim/Tests/OpenSim/Region/ScriptEngine/Common/LSL_TypesTestLSLFloat.cs
index c2d2a5a..58ca8dd 100644
--- a/OpenSim/Tests/OpenSim/Region/ScriptEngine/Common/LSL_TypesTestLSLFloat.cs
+++ b/OpenSim/Tests/OpenSim/Region/ScriptEngine/Common/LSL_TypesTestLSLFloat.cs
@@ -228,31 +228,31 @@ namespace OpenSim.Region.ScriptEngine.Common.Tests
}
///
- /// Tests LSLFloat is correctly cast implicitly to integer.
+ /// Tests LSLFloat is correctly cast explicitly to integer.
///
[Test]
- public void TestImplicitCastLSLFloatToInt()
+ public void TestExplicitCastLSLFloatToInt()
{
int testNumber;
foreach (KeyValuePair 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);
}
}
///
- /// Tests LSLFloat is correctly cast implicitly to unsigned integer.
+ /// Tests LSLFloat is correctly cast explicitly to unsigned integer.
///
[Test]
- public void TestImplicitCastLSLFloatToUint()
+ public void TestExplicitCastLSLFloatToUint()
{
uint testNumber;
foreach (KeyValuePair 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
}
///
- /// Tests string is correctly cast implicitly to LSLFloat.
+ /// Tests string is correctly cast explicitly to LSLFloat.
///
[Test]
- public void TestImplicitCastStringToLSLFloat()
+ public void TestExplicitCastStringToLSLFloat()
{
LSL_Types.LSLFloat testFloat;
foreach (KeyValuePair number in m_stringDoubleSet)
{
- testFloat = number.Key;
+ testFloat = (LSL_Types.LSLFloat) number.Key;
Assert.That(testFloat.value, new DoubleToleranceConstraint(number.Value, _lowPrecisionTolerance));
}
}
@@ -378,6 +378,24 @@ namespace OpenSim.Region.ScriptEngine.Common.Tests
}
///
+ /// Tests LSLFloat is correctly cast implicitly to double.
+ ///
+ [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));
+ }
+ }
+
+ ///
/// Tests the equality (==) operator.
///
[Test]
@@ -464,24 +482,6 @@ namespace OpenSim.Region.ScriptEngine.Common.Tests
}
///
- /// Tests LSLFloat is correctly cast implicitly to double.
- ///
- [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));
- }
- }
-
- ///
/// Tests LSLFloat.ToString().
///
[Test]
diff --git a/OpenSim/Tests/OpenSim/Region/ScriptEngine/Shared/LSL_TypesTestLSLFloat.cs b/OpenSim/Tests/OpenSim/Region/ScriptEngine/Shared/LSL_TypesTestLSLFloat.cs
index 035208b..d55f0e3 100644
--- a/OpenSim/Tests/OpenSim/Region/ScriptEngine/Shared/LSL_TypesTestLSLFloat.cs
+++ b/OpenSim/Tests/OpenSim/Region/ScriptEngine/Shared/LSL_TypesTestLSLFloat.cs
@@ -228,31 +228,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
}
///
- /// Tests LSLFloat is correctly cast implicitly to integer.
+ /// Tests LSLFloat is correctly cast explicitly to integer.
///
[Test]
- public void TestImplicitCastLSLFloatToInt()
+ public void TestExplicitCastLSLFloatToInt()
{
int testNumber;
foreach (KeyValuePair 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);
}
}
///
- /// Tests LSLFloat is correctly cast implicitly to unsigned integer.
+ /// Tests LSLFloat is correctly cast explicitly to unsigned integer.
///
[Test]
- public void TestImplicitCastLSLFloatToUint()
+ public void TestExplicitCastLSLFloatToUint()
{
uint testNumber;
foreach (KeyValuePair 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
}
///
- /// Tests string is correctly cast implicitly to LSLFloat.
+ /// Tests string is correctly cast explicitly to LSLFloat.
///
[Test]
- public void TestImplicitCastStringToLSLFloat()
+ public void TestExplicitCastStringToLSLFloat()
{
LSL_Types.LSLFloat testFloat;
foreach (KeyValuePair number in m_stringDoubleSet)
{
- testFloat = number.Key;
+ testFloat = (LSL_Types.LSLFloat) number.Key;
Assert.That(testFloat.value, new DoubleToleranceConstraint(number.Value, _lowPrecisionTolerance));
}
}
@@ -378,6 +378,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
}
///
+ /// Tests LSLFloat is correctly cast implicitly to double.
+ ///
+ [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));
+ }
+ }
+
+ ///
/// Tests the equality (==) operator.
///
[Test]
@@ -464,24 +482,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
}
///
- /// Tests LSLFloat is correctly cast implicitly to double.
- ///
- [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));
- }
- }
-
- ///
/// Tests LSLFloat.ToString().
///
[Test]
--
cgit v1.1