diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs index d0a5079886..b8a4a4d7a7 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 c42e3e6584..25f6957614 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 c2d2a5a64d..58ca8dd5ed 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)); } } @@ -377,6 +377,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. /// @@ -463,24 +481,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(). /// diff --git a/OpenSim/Tests/OpenSim/Region/ScriptEngine/Shared/LSL_TypesTestLSLFloat.cs b/OpenSim/Tests/OpenSim/Region/ScriptEngine/Shared/LSL_TypesTestLSLFloat.cs index 035208b713..d55f0e3f87 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)); } } @@ -377,6 +377,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. /// @@ -463,24 +481,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(). ///