diff options
author | Mike Mazur | 2008-07-31 00:29:19 +0000 |
---|---|---|
committer | Mike Mazur | 2008-07-31 00:29:19 +0000 |
commit | 1c8f4905735ff7653313f725fea13bf6346d1389 (patch) | |
tree | 4fb37932b1dc8da15adc1d13ea802f0396f3a513 /OpenSim | |
parent | Thank you, HomerHorwitz, for a patch that (diff) | |
download | opensim-SC_OLD-1c8f4905735ff7653313f725fea13bf6346d1389.zip opensim-SC_OLD-1c8f4905735ff7653313f725fea13bf6346d1389.tar.gz opensim-SC_OLD-1c8f4905735ff7653313f725fea13bf6346d1389.tar.bz2 opensim-SC_OLD-1c8f4905735ff7653313f725fea13bf6346d1389.tar.xz |
More LSL_Types implicit/explicit cast changes. Fix issue 1854.
Diffstat (limited to '')
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 | |||
1439 | 1439 | ||
1440 | #region Operators | 1440 | #region Operators |
1441 | 1441 | ||
1442 | static public implicit operator int(LSLFloat f) | 1442 | static public explicit operator int(LSLFloat f) |
1443 | { | 1443 | { |
1444 | return (int)f.value; | 1444 | return (int)f.value; |
1445 | } | 1445 | } |
1446 | 1446 | ||
1447 | static public implicit operator uint(LSLFloat f) | 1447 | static public explicit operator uint(LSLFloat f) |
1448 | { | 1448 | { |
1449 | return (uint) Math.Abs(f.value); | 1449 | return (uint) Math.Abs(f.value); |
1450 | } | 1450 | } |
@@ -1471,7 +1471,7 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
1471 | return new LSLFloat(i.value); | 1471 | return new LSLFloat(i.value); |
1472 | } | 1472 | } |
1473 | 1473 | ||
1474 | static public implicit operator LSLFloat(string s) | 1474 | static public explicit operator LSLFloat(string s) |
1475 | { | 1475 | { |
1476 | return new LSLFloat(double.Parse(s)); | 1476 | return new LSLFloat(double.Parse(s)); |
1477 | } | 1477 | } |
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 | |||
1439 | 1439 | ||
1440 | #region Operators | 1440 | #region Operators |
1441 | 1441 | ||
1442 | static public implicit operator int(LSLFloat f) | 1442 | static public explicit operator int(LSLFloat f) |
1443 | { | 1443 | { |
1444 | return (int)f.value; | 1444 | return (int)f.value; |
1445 | } | 1445 | } |
1446 | 1446 | ||
1447 | static public implicit operator uint(LSLFloat f) | 1447 | static public explicit operator uint(LSLFloat f) |
1448 | { | 1448 | { |
1449 | return (uint) Math.Abs(f.value); | 1449 | return (uint) Math.Abs(f.value); |
1450 | } | 1450 | } |
@@ -1471,7 +1471,7 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
1471 | return new LSLFloat(i.value); | 1471 | return new LSLFloat(i.value); |
1472 | } | 1472 | } |
1473 | 1473 | ||
1474 | static public implicit operator LSLFloat(string s) | 1474 | static public explicit operator LSLFloat(string s) |
1475 | { | 1475 | { |
1476 | return new LSLFloat(double.Parse(s)); | 1476 | return new LSLFloat(double.Parse(s)); |
1477 | } | 1477 | } |
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 | |||
228 | } | 228 | } |
229 | 229 | ||
230 | /// <summary> | 230 | /// <summary> |
231 | /// Tests LSLFloat is correctly cast implicitly to integer. | 231 | /// Tests LSLFloat is correctly cast explicitly to integer. |
232 | /// </summary> | 232 | /// </summary> |
233 | [Test] | 233 | [Test] |
234 | public void TestImplicitCastLSLFloatToInt() | 234 | public void TestExplicitCastLSLFloatToInt() |
235 | { | 235 | { |
236 | int testNumber; | 236 | int testNumber; |
237 | 237 | ||
238 | foreach (KeyValuePair<double, int> number in m_doubleIntSet) | 238 | foreach (KeyValuePair<double, int> number in m_doubleIntSet) |
239 | { | 239 | { |
240 | testNumber = new LSL_Types.LSLFloat(number.Key); | 240 | testNumber = (int) new LSL_Types.LSLFloat(number.Key); |
241 | Assert.AreEqual(number.Value, testNumber, "Converting double " + number.Key + ", expecting int " + number.Value); | 241 | Assert.AreEqual(number.Value, testNumber, "Converting double " + number.Key + ", expecting int " + number.Value); |
242 | } | 242 | } |
243 | } | 243 | } |
244 | 244 | ||
245 | /// <summary> | 245 | /// <summary> |
246 | /// Tests LSLFloat is correctly cast implicitly to unsigned integer. | 246 | /// Tests LSLFloat is correctly cast explicitly to unsigned integer. |
247 | /// </summary> | 247 | /// </summary> |
248 | [Test] | 248 | [Test] |
249 | public void TestImplicitCastLSLFloatToUint() | 249 | public void TestExplicitCastLSLFloatToUint() |
250 | { | 250 | { |
251 | uint testNumber; | 251 | uint testNumber; |
252 | 252 | ||
253 | foreach (KeyValuePair<double, int> number in m_doubleUintSet) | 253 | foreach (KeyValuePair<double, int> number in m_doubleUintSet) |
254 | { | 254 | { |
255 | testNumber = new LSL_Types.LSLFloat(number.Key); | 255 | testNumber = (uint) new LSL_Types.LSLFloat(number.Key); |
256 | Assert.AreEqual(number.Value, testNumber, "Converting double " + number.Key + ", expecting uint " + number.Value); | 256 | Assert.AreEqual(number.Value, testNumber, "Converting double " + number.Key + ", expecting uint " + number.Value); |
257 | } | 257 | } |
258 | } | 258 | } |
@@ -333,16 +333,16 @@ namespace OpenSim.Region.ScriptEngine.Common.Tests | |||
333 | } | 333 | } |
334 | 334 | ||
335 | /// <summary> | 335 | /// <summary> |
336 | /// Tests string is correctly cast implicitly to LSLFloat. | 336 | /// Tests string is correctly cast explicitly to LSLFloat. |
337 | /// </summary> | 337 | /// </summary> |
338 | [Test] | 338 | [Test] |
339 | public void TestImplicitCastStringToLSLFloat() | 339 | public void TestExplicitCastStringToLSLFloat() |
340 | { | 340 | { |
341 | LSL_Types.LSLFloat testFloat; | 341 | LSL_Types.LSLFloat testFloat; |
342 | 342 | ||
343 | foreach (KeyValuePair<string, double> number in m_stringDoubleSet) | 343 | foreach (KeyValuePair<string, double> number in m_stringDoubleSet) |
344 | { | 344 | { |
345 | testFloat = number.Key; | 345 | testFloat = (LSL_Types.LSLFloat) number.Key; |
346 | Assert.That(testFloat.value, new DoubleToleranceConstraint(number.Value, _lowPrecisionTolerance)); | 346 | Assert.That(testFloat.value, new DoubleToleranceConstraint(number.Value, _lowPrecisionTolerance)); |
347 | } | 347 | } |
348 | } | 348 | } |
@@ -378,6 +378,24 @@ namespace OpenSim.Region.ScriptEngine.Common.Tests | |||
378 | } | 378 | } |
379 | 379 | ||
380 | /// <summary> | 380 | /// <summary> |
381 | /// Tests LSLFloat is correctly cast implicitly to double. | ||
382 | /// </summary> | ||
383 | [Test] | ||
384 | public void TestImplicitCastLSLFloatToDouble() | ||
385 | { | ||
386 | double testNumber; | ||
387 | LSL_Types.LSLFloat testFloat; | ||
388 | |||
389 | foreach (double number in m_doubleList) | ||
390 | { | ||
391 | testFloat = new LSL_Types.LSLFloat(number); | ||
392 | testNumber = testFloat; | ||
393 | |||
394 | Assert.That(testNumber, new DoubleToleranceConstraint(number, _lowPrecisionTolerance)); | ||
395 | } | ||
396 | } | ||
397 | |||
398 | /// <summary> | ||
381 | /// Tests the equality (==) operator. | 399 | /// Tests the equality (==) operator. |
382 | /// </summary> | 400 | /// </summary> |
383 | [Test] | 401 | [Test] |
@@ -464,24 +482,6 @@ namespace OpenSim.Region.ScriptEngine.Common.Tests | |||
464 | } | 482 | } |
465 | 483 | ||
466 | /// <summary> | 484 | /// <summary> |
467 | /// Tests LSLFloat is correctly cast implicitly to double. | ||
468 | /// </summary> | ||
469 | [Test] | ||
470 | public void TestImplicitCastLSLFloatToDouble() | ||
471 | { | ||
472 | double testNumber; | ||
473 | LSL_Types.LSLFloat testFloat; | ||
474 | |||
475 | foreach (double number in m_doubleList) | ||
476 | { | ||
477 | testFloat = new LSL_Types.LSLFloat(number); | ||
478 | testNumber = testFloat; | ||
479 | |||
480 | Assert.That(testNumber, new DoubleToleranceConstraint(number, _lowPrecisionTolerance)); | ||
481 | } | ||
482 | } | ||
483 | |||
484 | /// <summary> | ||
485 | /// Tests LSLFloat.ToString(). | 485 | /// Tests LSLFloat.ToString(). |
486 | /// </summary> | 486 | /// </summary> |
487 | [Test] | 487 | [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 | |||
228 | } | 228 | } |
229 | 229 | ||
230 | /// <summary> | 230 | /// <summary> |
231 | /// Tests LSLFloat is correctly cast implicitly to integer. | 231 | /// Tests LSLFloat is correctly cast explicitly to integer. |
232 | /// </summary> | 232 | /// </summary> |
233 | [Test] | 233 | [Test] |
234 | public void TestImplicitCastLSLFloatToInt() | 234 | public void TestExplicitCastLSLFloatToInt() |
235 | { | 235 | { |
236 | int testNumber; | 236 | int testNumber; |
237 | 237 | ||
238 | foreach (KeyValuePair<double, int> number in m_doubleIntSet) | 238 | foreach (KeyValuePair<double, int> number in m_doubleIntSet) |
239 | { | 239 | { |
240 | testNumber = new LSL_Types.LSLFloat(number.Key); | 240 | testNumber = (int) new LSL_Types.LSLFloat(number.Key); |
241 | Assert.AreEqual(number.Value, testNumber, "Converting double " + number.Key + ", expecting int " + number.Value); | 241 | Assert.AreEqual(number.Value, testNumber, "Converting double " + number.Key + ", expecting int " + number.Value); |
242 | } | 242 | } |
243 | } | 243 | } |
244 | 244 | ||
245 | /// <summary> | 245 | /// <summary> |
246 | /// Tests LSLFloat is correctly cast implicitly to unsigned integer. | 246 | /// Tests LSLFloat is correctly cast explicitly to unsigned integer. |
247 | /// </summary> | 247 | /// </summary> |
248 | [Test] | 248 | [Test] |
249 | public void TestImplicitCastLSLFloatToUint() | 249 | public void TestExplicitCastLSLFloatToUint() |
250 | { | 250 | { |
251 | uint testNumber; | 251 | uint testNumber; |
252 | 252 | ||
253 | foreach (KeyValuePair<double, int> number in m_doubleUintSet) | 253 | foreach (KeyValuePair<double, int> number in m_doubleUintSet) |
254 | { | 254 | { |
255 | testNumber = new LSL_Types.LSLFloat(number.Key); | 255 | testNumber = (uint) new LSL_Types.LSLFloat(number.Key); |
256 | Assert.AreEqual(number.Value, testNumber, "Converting double " + number.Key + ", expecting uint " + number.Value); | 256 | Assert.AreEqual(number.Value, testNumber, "Converting double " + number.Key + ", expecting uint " + number.Value); |
257 | } | 257 | } |
258 | } | 258 | } |
@@ -333,16 +333,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
333 | } | 333 | } |
334 | 334 | ||
335 | /// <summary> | 335 | /// <summary> |
336 | /// Tests string is correctly cast implicitly to LSLFloat. | 336 | /// Tests string is correctly cast explicitly to LSLFloat. |
337 | /// </summary> | 337 | /// </summary> |
338 | [Test] | 338 | [Test] |
339 | public void TestImplicitCastStringToLSLFloat() | 339 | public void TestExplicitCastStringToLSLFloat() |
340 | { | 340 | { |
341 | LSL_Types.LSLFloat testFloat; | 341 | LSL_Types.LSLFloat testFloat; |
342 | 342 | ||
343 | foreach (KeyValuePair<string, double> number in m_stringDoubleSet) | 343 | foreach (KeyValuePair<string, double> number in m_stringDoubleSet) |
344 | { | 344 | { |
345 | testFloat = number.Key; | 345 | testFloat = (LSL_Types.LSLFloat) number.Key; |
346 | Assert.That(testFloat.value, new DoubleToleranceConstraint(number.Value, _lowPrecisionTolerance)); | 346 | Assert.That(testFloat.value, new DoubleToleranceConstraint(number.Value, _lowPrecisionTolerance)); |
347 | } | 347 | } |
348 | } | 348 | } |
@@ -378,6 +378,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
378 | } | 378 | } |
379 | 379 | ||
380 | /// <summary> | 380 | /// <summary> |
381 | /// Tests LSLFloat is correctly cast implicitly to double. | ||
382 | /// </summary> | ||
383 | [Test] | ||
384 | public void TestImplicitCastLSLFloatToDouble() | ||
385 | { | ||
386 | double testNumber; | ||
387 | LSL_Types.LSLFloat testFloat; | ||
388 | |||
389 | foreach (double number in m_doubleList) | ||
390 | { | ||
391 | testFloat = new LSL_Types.LSLFloat(number); | ||
392 | testNumber = testFloat; | ||
393 | |||
394 | Assert.That(testNumber, new DoubleToleranceConstraint(number, _lowPrecisionTolerance)); | ||
395 | } | ||
396 | } | ||
397 | |||
398 | /// <summary> | ||
381 | /// Tests the equality (==) operator. | 399 | /// Tests the equality (==) operator. |
382 | /// </summary> | 400 | /// </summary> |
383 | [Test] | 401 | [Test] |
@@ -464,24 +482,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
464 | } | 482 | } |
465 | 483 | ||
466 | /// <summary> | 484 | /// <summary> |
467 | /// Tests LSLFloat is correctly cast implicitly to double. | ||
468 | /// </summary> | ||
469 | [Test] | ||
470 | public void TestImplicitCastLSLFloatToDouble() | ||
471 | { | ||
472 | double testNumber; | ||
473 | LSL_Types.LSLFloat testFloat; | ||
474 | |||
475 | foreach (double number in m_doubleList) | ||
476 | { | ||
477 | testFloat = new LSL_Types.LSLFloat(number); | ||
478 | testNumber = testFloat; | ||
479 | |||
480 | Assert.That(testNumber, new DoubleToleranceConstraint(number, _lowPrecisionTolerance)); | ||
481 | } | ||
482 | } | ||
483 | |||
484 | /// <summary> | ||
485 | /// Tests LSLFloat.ToString(). | 485 | /// Tests LSLFloat.ToString(). |
486 | /// </summary> | 486 | /// </summary> |
487 | [Test] | 487 | [Test] |