Add casts from integer to float. Fix issue 1822.
							parent
							
								
									84cc69573b
								
							
						
					
					
						commit
						19ad7db5e1
					
				|  | @ -1454,6 +1454,11 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
|                 return new LSLFloat(i); | ||||
|             } | ||||
| 
 | ||||
|             static public implicit operator LSLFloat(LSLInteger i) | ||||
|             { | ||||
|                 return new LSLFloat(i.value); | ||||
|             } | ||||
| 
 | ||||
|             static public implicit operator LSLFloat(string s) | ||||
|             { | ||||
|                 return new LSLFloat(double.Parse(s)); | ||||
|  |  | |||
|  | @ -1509,6 +1509,11 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
|                 return new LSLFloat(i); | ||||
|             } | ||||
| 
 | ||||
|             static public implicit operator LSLFloat(LSLInteger i) | ||||
|             { | ||||
|                 return new LSLFloat(i.value); | ||||
|             } | ||||
| 
 | ||||
|             static public implicit operator LSLFloat(string s) | ||||
|             { | ||||
|                 return new LSLFloat(double.Parse(s)); | ||||
|  |  | |||
|  | @ -303,6 +303,36 @@ namespace OpenSim.Region.ScriptEngine.Common.Tests | |||
|             } | ||||
|         } | ||||
| 
 | ||||
|         /// <summary> | ||||
|         /// Tests LSLInteger is correctly cast implicitly to LSLFloat. | ||||
|         /// </summary> | ||||
|         [Test] | ||||
|         public void TestImplicitCastLSLIntegerToLSLFloat() | ||||
|         { | ||||
|             LSL_Types.LSLFloat testFloat; | ||||
| 
 | ||||
|             foreach (int number in m_intList) | ||||
|             { | ||||
|                 testFloat = new LSL_Types.LSLInteger(number); | ||||
|                 Assert.That(testFloat.value, new DoubleToleranceConstraint(number, _lowPrecisionTolerance)); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         /// <summary> | ||||
|         /// Tests LSLInteger is correctly cast explicitly to LSLFloat. | ||||
|         /// </summary> | ||||
|         [Test] | ||||
|         public void TestExplicitCastLSLIntegerToLSLFloat() | ||||
|         { | ||||
|             LSL_Types.LSLFloat testFloat; | ||||
| 
 | ||||
|             foreach (int number in m_intList) | ||||
|             { | ||||
|                 testFloat = (LSL_Types.LSLFloat) new LSL_Types.LSLInteger(number); | ||||
|                 Assert.That(testFloat.value, new DoubleToleranceConstraint(number, _lowPrecisionTolerance)); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         /// <summary> | ||||
|         /// Tests string is correctly cast implicitly to LSLFloat. | ||||
|         /// </summary> | ||||
|  | @ -319,7 +349,7 @@ namespace OpenSim.Region.ScriptEngine.Common.Tests | |||
|         } | ||||
| 
 | ||||
|         /// <summary> | ||||
|         /// Tests string is correctly cast implicitly to LSLFloat. | ||||
|         /// Tests LSLString is correctly cast implicitly to LSLFloat. | ||||
|         /// </summary> | ||||
|         [Test] | ||||
|         public void TestExplicitCastLSLStringToLSLFloat() | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Mike Mazur
						Mike Mazur