diff options
3 files changed, 103 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs index 7ac7a65..d5211f5 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs | |||
@@ -1511,6 +1511,26 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
1511 | return new LSLFloat(f.value / (double)i); | 1511 | return new LSLFloat(f.value / (double)i); |
1512 | } | 1512 | } |
1513 | 1513 | ||
1514 | static public LSLFloat operator +(LSLFloat lhs, LSLFloat rhs) | ||
1515 | { | ||
1516 | return new LSLFloat(lhs.value + rhs.value); | ||
1517 | } | ||
1518 | |||
1519 | static public LSLFloat operator -(LSLFloat lhs, LSLFloat rhs) | ||
1520 | { | ||
1521 | return new LSLFloat(lhs.value - rhs.value); | ||
1522 | } | ||
1523 | |||
1524 | static public LSLFloat operator *(LSLFloat lhs, LSLFloat rhs) | ||
1525 | { | ||
1526 | return new LSLFloat(lhs.value * rhs.value); | ||
1527 | } | ||
1528 | |||
1529 | static public LSLFloat operator /(LSLFloat lhs, LSLFloat rhs) | ||
1530 | { | ||
1531 | return new LSLFloat(lhs.value / rhs.value); | ||
1532 | } | ||
1533 | |||
1514 | static public LSLFloat operator -(LSLFloat f) | 1534 | static public LSLFloat operator -(LSLFloat f) |
1515 | { | 1535 | { |
1516 | return new LSLFloat(-f.value); | 1536 | return new LSLFloat(-f.value); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index 7eb5e77..77bb426 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | |||
@@ -1579,6 +1579,26 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
1579 | return new LSLFloat(f.value / (double)i); | 1579 | return new LSLFloat(f.value / (double)i); |
1580 | } | 1580 | } |
1581 | 1581 | ||
1582 | static public LSLFloat operator +(LSLFloat lhs, LSLFloat rhs) | ||
1583 | { | ||
1584 | return new LSLFloat(lhs.value + rhs.value); | ||
1585 | } | ||
1586 | |||
1587 | static public LSLFloat operator -(LSLFloat lhs, LSLFloat rhs) | ||
1588 | { | ||
1589 | return new LSLFloat(lhs.value - rhs.value); | ||
1590 | } | ||
1591 | |||
1592 | static public LSLFloat operator *(LSLFloat lhs, LSLFloat rhs) | ||
1593 | { | ||
1594 | return new LSLFloat(lhs.value * rhs.value); | ||
1595 | } | ||
1596 | |||
1597 | static public LSLFloat operator /(LSLFloat lhs, LSLFloat rhs) | ||
1598 | { | ||
1599 | return new LSLFloat(lhs.value / rhs.value); | ||
1600 | } | ||
1601 | |||
1582 | static public LSLFloat operator -(LSLFloat f) | 1602 | static public LSLFloat operator -(LSLFloat f) |
1583 | { | 1603 | { |
1584 | return new LSLFloat(-f.value); | 1604 | return new LSLFloat(-f.value); |
diff --git a/OpenSim/Tests/OpenSim/Region/ScriptEngine/Common/LSL_TypesTestLSLFloat.cs b/OpenSim/Tests/OpenSim/Region/ScriptEngine/Common/LSL_TypesTestLSLFloat.cs index 2d553a7..2a26031 100644 --- a/OpenSim/Tests/OpenSim/Region/ScriptEngine/Common/LSL_TypesTestLSLFloat.cs +++ b/OpenSim/Tests/OpenSim/Region/ScriptEngine/Common/LSL_TypesTestLSLFloat.cs | |||
@@ -496,5 +496,68 @@ namespace OpenSim.Region.ScriptEngine.Common.Tests | |||
496 | Assert.AreEqual(number.Value, testFloat.ToString()); | 496 | Assert.AreEqual(number.Value, testFloat.ToString()); |
497 | } | 497 | } |
498 | } | 498 | } |
499 | |||
500 | /// <summary> | ||
501 | /// Tests addition of two LSLFloats. | ||
502 | /// </summary> | ||
503 | [Test] | ||
504 | public void TestAddTwoLSLFloats() | ||
505 | { | ||
506 | LSL_Types.LSLFloat testResult; | ||
507 | |||
508 | foreach (KeyValuePair<double, double> number in m_doubleDoubleSet) | ||
509 | { | ||
510 | testResult = new LSL_Types.LSLFloat(number.Key) + new LSL_Types.LSLFloat(number.Value); | ||
511 | Assert.That(testResult.value, new DoubleToleranceConstraint(number.Key + number.Value, _lowPrecisionTolerance)); | ||
512 | } | ||
513 | } | ||
514 | |||
515 | /// <summary> | ||
516 | /// Tests subtraction of two LSLFloats. | ||
517 | /// </summary> | ||
518 | [Test] | ||
519 | public void TestSubtractTwoLSLFloats() | ||
520 | { | ||
521 | LSL_Types.LSLFloat testResult; | ||
522 | |||
523 | foreach (KeyValuePair<double, double> number in m_doubleDoubleSet) | ||
524 | { | ||
525 | testResult = new LSL_Types.LSLFloat(number.Key) - new LSL_Types.LSLFloat(number.Value); | ||
526 | Assert.That(testResult.value, new DoubleToleranceConstraint(number.Key - number.Value, _lowPrecisionTolerance)); | ||
527 | } | ||
528 | } | ||
529 | |||
530 | /// <summary> | ||
531 | /// Tests multiplication of two LSLFloats. | ||
532 | /// </summary> | ||
533 | [Test] | ||
534 | public void TestMultiplyTwoLSLFloats() | ||
535 | { | ||
536 | LSL_Types.LSLFloat testResult; | ||
537 | |||
538 | foreach (KeyValuePair<double, double> number in m_doubleDoubleSet) | ||
539 | { | ||
540 | testResult = new LSL_Types.LSLFloat(number.Key) * new LSL_Types.LSLFloat(number.Value); | ||
541 | Assert.That(testResult.value, new DoubleToleranceConstraint(number.Key * number.Value, _lowPrecisionTolerance)); | ||
542 | } | ||
543 | } | ||
544 | |||
545 | /// <summary> | ||
546 | /// Tests division of two LSLFloats. | ||
547 | /// </summary> | ||
548 | [Test] | ||
549 | public void TestDivideTwoLSLFloats() | ||
550 | { | ||
551 | LSL_Types.LSLFloat testResult; | ||
552 | |||
553 | foreach (KeyValuePair<double, double> number in m_doubleDoubleSet) | ||
554 | { | ||
555 | if (number.Value != 0.0) // Let's avoid divide by zero. | ||
556 | { | ||
557 | testResult = new LSL_Types.LSLFloat(number.Key) / new LSL_Types.LSLFloat(number.Value); | ||
558 | Assert.That(testResult.value, new DoubleToleranceConstraint(number.Key / number.Value, _lowPrecisionTolerance)); | ||
559 | } | ||
560 | } | ||
561 | } | ||
499 | } | 562 | } |
500 | } | 563 | } |