Adapt the unit tests to the new list rules, change some casts to
new method for testing0.6.0-stable
parent
e7abde70a2
commit
6447d7132f
|
@ -5614,12 +5614,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
if (remain < 6)
|
||||
return;
|
||||
|
||||
face = Convert.ToInt32(rules.Data[idx++].ToString()); // holeshape
|
||||
v = new LSL_Types.Vector3(rules.Data[idx++].ToString()); // cut
|
||||
hollow = (float)Convert.ToDouble(rules.Data[idx++].ToString());
|
||||
twist = new LSL_Types.Vector3(rules.Data[idx++].ToString());
|
||||
taper_b = new LSL_Types.Vector3(rules.Data[idx++].ToString());
|
||||
topshear = new LSL_Types.Vector3(rules.Data[idx++].ToString());
|
||||
face = (int)rules.GetLSLIntegerItem(idx++);
|
||||
v = rules.GetVector3Item(idx++); // cut
|
||||
hollow = (float)rules.GetLSLFloatItem(idx++);
|
||||
twist = rules.GetVector3Item(idx++);
|
||||
taper_b = rules.GetVector3Item(idx++);
|
||||
topshear = rules.GetVector3Item(idx++);
|
||||
|
||||
part.Shape.PathCurve = (byte)Extrusion.Straight;
|
||||
SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, 1);
|
||||
break;
|
||||
|
|
|
@ -454,7 +454,12 @@ namespace OpenSim.Region.ScriptEngine.Shared
|
|||
|
||||
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)
|
||||
|
|
|
@ -44,18 +44,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
|
|||
[Test]
|
||||
public void TestConcatenateString()
|
||||
{
|
||||
LSL_Types.list testList = new LSL_Types.list(1, 'a', "test");
|
||||
testList += "addition";
|
||||
LSL_Types.list testList = new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger('a'), new LSL_Types.LSLString("test"));
|
||||
testList += new LSL_Types.LSLString("addition");
|
||||
|
||||
Assert.AreEqual(4, testList.Length);
|
||||
Assert.AreEqual("addition", testList.Data[3]);
|
||||
Assert.AreEqual(typeof(System.String), testList.Data[3].GetType());
|
||||
Assert.AreEqual(new LSL_Types.LSLString("addition"), testList.Data[3]);
|
||||
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("more", secondTestList.Data[4]);
|
||||
Assert.AreEqual(typeof(System.String), secondTestList.Data[4].GetType());
|
||||
Assert.AreEqual(new LSL_Types.LSLString("more"), secondTestList.Data[4]);
|
||||
Assert.AreEqual(typeof(LSL_Types.LSLString), secondTestList.Data[4].GetType());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -64,38 +64,38 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
|
|||
[Test]
|
||||
public void TestConcatenateInteger()
|
||||
{
|
||||
LSL_Types.list testList = new LSL_Types.list(1, 'a', "test");
|
||||
testList += 20;
|
||||
LSL_Types.list testList = new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger('a'), new LSL_Types.LSLString("test"));
|
||||
testList += new LSL_Types.LSLInteger(20);
|
||||
|
||||
Assert.AreEqual(4, testList.Length);
|
||||
Assert.AreEqual(20, testList.Data[3]);
|
||||
Assert.AreEqual(typeof(int), testList.Data[3].GetType());
|
||||
Assert.AreEqual(new LSL_Types.LSLInteger(20), testList.Data[3]);
|
||||
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(2, secondTestList.Data[4]);
|
||||
Assert.AreEqual(typeof(int), secondTestList.Data[4].GetType());
|
||||
Assert.AreEqual(new LSL_Types.LSLInteger(2), secondTestList.Data[4]);
|
||||
Assert.AreEqual(typeof(LSL_Types.LSLInteger), secondTestList.Data[4].GetType());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests concatenating a double to a list.
|
||||
/// Tests concatenating a float to a list.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestConcatenateDouble()
|
||||
{
|
||||
LSL_Types.list testList = new LSL_Types.list(1, 'a', "test");
|
||||
testList += 2.0;
|
||||
LSL_Types.list testList = new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger('a'), new LSL_Types.LSLString("test"));
|
||||
testList += new LSL_Types.LSLFloat(2.0f);
|
||||
|
||||
Assert.AreEqual(4, testList.Length);
|
||||
Assert.AreEqual(2.0, testList.Data[3]);
|
||||
Assert.AreEqual(typeof(double), testList.Data[3].GetType());
|
||||
Assert.AreEqual(new LSL_Types.LSLFloat(2.0f), testList.Data[3]);
|
||||
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(0.04, secondTestList.Data[4]);
|
||||
Assert.AreEqual(typeof(double), secondTestList.Data[4].GetType());
|
||||
Assert.AreEqual(new LSL_Types.LSLFloat(0.04f), secondTestList.Data[4]);
|
||||
Assert.AreEqual(typeof(LSL_Types.LSLFloat), secondTestList.Data[4].GetType());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in New Issue