Adapt the unit tests to the new list rules, change some casts to

new method for testing
0.6.0-stable
Melanie Thielker 2008-09-08 19:29:16 +00:00
parent e7abde70a2
commit 6447d7132f
3 changed files with 35 additions and 29 deletions

View File

@ -5614,12 +5614,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (remain < 6) if (remain < 6)
return; return;
face = Convert.ToInt32(rules.Data[idx++].ToString()); // holeshape face = (int)rules.GetLSLIntegerItem(idx++);
v = new LSL_Types.Vector3(rules.Data[idx++].ToString()); // cut v = rules.GetVector3Item(idx++); // cut
hollow = (float)Convert.ToDouble(rules.Data[idx++].ToString()); hollow = (float)rules.GetLSLFloatItem(idx++);
twist = new LSL_Types.Vector3(rules.Data[idx++].ToString()); twist = rules.GetVector3Item(idx++);
taper_b = new LSL_Types.Vector3(rules.Data[idx++].ToString()); taper_b = rules.GetVector3Item(idx++);
topshear = new LSL_Types.Vector3(rules.Data[idx++].ToString()); topshear = rules.GetVector3Item(idx++);
part.Shape.PathCurve = (byte)Extrusion.Straight; part.Shape.PathCurve = (byte)Extrusion.Straight;
SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, 1); SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, 1);
break; break;

View File

@ -454,7 +454,12 @@ namespace OpenSim.Region.ScriptEngine.Shared
public LSL_Types.LSLInteger GetLSLIntegerItem(int itemIndex) public LSL_Types.LSLInteger GetLSLIntegerItem(int itemIndex)
{ {
return (LSL_Types.LSLInteger)m_data[itemIndex]; if (m_data[itemIndex] is LSL_Types.LSLInteger)
return (LSL_Types.LSLInteger)m_data[itemIndex];
else if (m_data[itemIndex] is Int32)
return new LSLInteger((int)m_data[itemIndex]);
else
throw new InvalidCastException();
} }
public LSL_Types.Vector3 GetVector3Item(int itemIndex) public LSL_Types.Vector3 GetVector3Item(int itemIndex)

View File

@ -44,18 +44,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
[Test] [Test]
public void TestConcatenateString() public void TestConcatenateString()
{ {
LSL_Types.list testList = new LSL_Types.list(1, 'a', "test"); LSL_Types.list testList = new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger('a'), new LSL_Types.LSLString("test"));
testList += "addition"; testList += new LSL_Types.LSLString("addition");
Assert.AreEqual(4, testList.Length); Assert.AreEqual(4, testList.Length);
Assert.AreEqual("addition", testList.Data[3]); Assert.AreEqual(new LSL_Types.LSLString("addition"), testList.Data[3]);
Assert.AreEqual(typeof(System.String), testList.Data[3].GetType()); Assert.AreEqual(typeof(LSL_Types.LSLString), testList.Data[3].GetType());
LSL_Types.list secondTestList = testList + "more"; LSL_Types.list secondTestList = testList + new LSL_Types.LSLString("more");
Assert.AreEqual(5, secondTestList.Length); Assert.AreEqual(5, secondTestList.Length);
Assert.AreEqual("more", secondTestList.Data[4]); Assert.AreEqual(new LSL_Types.LSLString("more"), secondTestList.Data[4]);
Assert.AreEqual(typeof(System.String), secondTestList.Data[4].GetType()); Assert.AreEqual(typeof(LSL_Types.LSLString), secondTestList.Data[4].GetType());
} }
/// <summary> /// <summary>
@ -64,38 +64,38 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
[Test] [Test]
public void TestConcatenateInteger() public void TestConcatenateInteger()
{ {
LSL_Types.list testList = new LSL_Types.list(1, 'a', "test"); LSL_Types.list testList = new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger('a'), new LSL_Types.LSLString("test"));
testList += 20; testList += new LSL_Types.LSLInteger(20);
Assert.AreEqual(4, testList.Length); Assert.AreEqual(4, testList.Length);
Assert.AreEqual(20, testList.Data[3]); Assert.AreEqual(new LSL_Types.LSLInteger(20), testList.Data[3]);
Assert.AreEqual(typeof(int), testList.Data[3].GetType()); Assert.AreEqual(typeof(LSL_Types.LSLInteger), testList.Data[3].GetType());
LSL_Types.list secondTestList = testList + 2; LSL_Types.list secondTestList = testList + new LSL_Types.LSLInteger(2);
Assert.AreEqual(5, secondTestList.Length); Assert.AreEqual(5, secondTestList.Length);
Assert.AreEqual(2, secondTestList.Data[4]); Assert.AreEqual(new LSL_Types.LSLInteger(2), secondTestList.Data[4]);
Assert.AreEqual(typeof(int), secondTestList.Data[4].GetType()); Assert.AreEqual(typeof(LSL_Types.LSLInteger), secondTestList.Data[4].GetType());
} }
/// <summary> /// <summary>
/// Tests concatenating a double to a list. /// Tests concatenating a float to a list.
/// </summary> /// </summary>
[Test] [Test]
public void TestConcatenateDouble() public void TestConcatenateDouble()
{ {
LSL_Types.list testList = new LSL_Types.list(1, 'a', "test"); LSL_Types.list testList = new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger('a'), new LSL_Types.LSLString("test"));
testList += 2.0; testList += new LSL_Types.LSLFloat(2.0f);
Assert.AreEqual(4, testList.Length); Assert.AreEqual(4, testList.Length);
Assert.AreEqual(2.0, testList.Data[3]); Assert.AreEqual(new LSL_Types.LSLFloat(2.0f), testList.Data[3]);
Assert.AreEqual(typeof(double), testList.Data[3].GetType()); Assert.AreEqual(typeof(LSL_Types.LSLFloat), testList.Data[3].GetType());
LSL_Types.list secondTestList = testList + 0.04; LSL_Types.list secondTestList = testList + new LSL_Types.LSLFloat(0.04f);
Assert.AreEqual(5, secondTestList.Length); Assert.AreEqual(5, secondTestList.Length);
Assert.AreEqual(0.04, secondTestList.Data[4]); Assert.AreEqual(new LSL_Types.LSLFloat(0.04f), secondTestList.Data[4]);
Assert.AreEqual(typeof(double), secondTestList.Data[4].GetType()); Assert.AreEqual(typeof(LSL_Types.LSLFloat), secondTestList.Data[4].GetType());
} }
/// <summary> /// <summary>