aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMelanie Thielker2008-09-08 19:29:16 +0000
committerMelanie Thielker2008-09-08 19:29:16 +0000
commit6447d7132f0f443205e719a00e595f79444eea25 (patch)
treed28bbcc81e3ba99085ff679f29116111327b8c49
parentMantis #2147 (diff)
downloadopensim-SC_OLD-6447d7132f0f443205e719a00e595f79444eea25.zip
opensim-SC_OLD-6447d7132f0f443205e719a00e595f79444eea25.tar.gz
opensim-SC_OLD-6447d7132f0f443205e719a00e595f79444eea25.tar.bz2
opensim-SC_OLD-6447d7132f0f443205e719a00e595f79444eea25.tar.xz
Adapt the unit tests to the new list rules, change some casts to
new method for testing
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs13
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs7
-rw-r--r--OpenSim/Tests/Region/ScriptEngine/Shared/LSL_TypesTestList.cs44
3 files changed, 35 insertions, 29 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index bc58a8a..4b92739 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -5614,12 +5614,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5614 if (remain < 6) 5614 if (remain < 6)
5615 return; 5615 return;
5616 5616
5617 face = Convert.ToInt32(rules.Data[idx++].ToString()); // holeshape 5617 face = (int)rules.GetLSLIntegerItem(idx++);
5618 v = new LSL_Types.Vector3(rules.Data[idx++].ToString()); // cut 5618 v = rules.GetVector3Item(idx++); // cut
5619 hollow = (float)Convert.ToDouble(rules.Data[idx++].ToString()); 5619 hollow = (float)rules.GetLSLFloatItem(idx++);
5620 twist = new LSL_Types.Vector3(rules.Data[idx++].ToString()); 5620 twist = rules.GetVector3Item(idx++);
5621 taper_b = new LSL_Types.Vector3(rules.Data[idx++].ToString()); 5621 taper_b = rules.GetVector3Item(idx++);
5622 topshear = new LSL_Types.Vector3(rules.Data[idx++].ToString()); 5622 topshear = rules.GetVector3Item(idx++);
5623
5623 part.Shape.PathCurve = (byte)Extrusion.Straight; 5624 part.Shape.PathCurve = (byte)Extrusion.Straight;
5624 SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, 1); 5625 SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, 1);
5625 break; 5626 break;
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
index 4554b0c..f149f60 100644
--- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
@@ -454,7 +454,12 @@ namespace OpenSim.Region.ScriptEngine.Shared
454 454
455 public LSL_Types.LSLInteger GetLSLIntegerItem(int itemIndex) 455 public LSL_Types.LSLInteger GetLSLIntegerItem(int itemIndex)
456 { 456 {
457 return (LSL_Types.LSLInteger)m_data[itemIndex]; 457 if (m_data[itemIndex] is LSL_Types.LSLInteger)
458 return (LSL_Types.LSLInteger)m_data[itemIndex];
459 else if (m_data[itemIndex] is Int32)
460 return new LSLInteger((int)m_data[itemIndex]);
461 else
462 throw new InvalidCastException();
458 } 463 }
459 464
460 public LSL_Types.Vector3 GetVector3Item(int itemIndex) 465 public LSL_Types.Vector3 GetVector3Item(int itemIndex)
diff --git a/OpenSim/Tests/Region/ScriptEngine/Shared/LSL_TypesTestList.cs b/OpenSim/Tests/Region/ScriptEngine/Shared/LSL_TypesTestList.cs
index ca59c97..7da28dd 100644
--- a/OpenSim/Tests/Region/ScriptEngine/Shared/LSL_TypesTestList.cs
+++ b/OpenSim/Tests/Region/ScriptEngine/Shared/LSL_TypesTestList.cs
@@ -44,18 +44,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
44 [Test] 44 [Test]
45 public void TestConcatenateString() 45 public void TestConcatenateString()
46 { 46 {
47 LSL_Types.list testList = new LSL_Types.list(1, 'a', "test"); 47 LSL_Types.list testList = new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger('a'), new LSL_Types.LSLString("test"));
48 testList += "addition"; 48 testList += new LSL_Types.LSLString("addition");
49 49
50 Assert.AreEqual(4, testList.Length); 50 Assert.AreEqual(4, testList.Length);
51 Assert.AreEqual("addition", testList.Data[3]); 51 Assert.AreEqual(new LSL_Types.LSLString("addition"), testList.Data[3]);
52 Assert.AreEqual(typeof(System.String), testList.Data[3].GetType()); 52 Assert.AreEqual(typeof(LSL_Types.LSLString), testList.Data[3].GetType());
53 53
54 LSL_Types.list secondTestList = testList + "more"; 54 LSL_Types.list secondTestList = testList + new LSL_Types.LSLString("more");
55 55
56 Assert.AreEqual(5, secondTestList.Length); 56 Assert.AreEqual(5, secondTestList.Length);
57 Assert.AreEqual("more", secondTestList.Data[4]); 57 Assert.AreEqual(new LSL_Types.LSLString("more"), secondTestList.Data[4]);
58 Assert.AreEqual(typeof(System.String), secondTestList.Data[4].GetType()); 58 Assert.AreEqual(typeof(LSL_Types.LSLString), secondTestList.Data[4].GetType());
59 } 59 }
60 60
61 /// <summary> 61 /// <summary>
@@ -64,38 +64,38 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
64 [Test] 64 [Test]
65 public void TestConcatenateInteger() 65 public void TestConcatenateInteger()
66 { 66 {
67 LSL_Types.list testList = new LSL_Types.list(1, 'a', "test"); 67 LSL_Types.list testList = new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger('a'), new LSL_Types.LSLString("test"));
68 testList += 20; 68 testList += new LSL_Types.LSLInteger(20);
69 69
70 Assert.AreEqual(4, testList.Length); 70 Assert.AreEqual(4, testList.Length);
71 Assert.AreEqual(20, testList.Data[3]); 71 Assert.AreEqual(new LSL_Types.LSLInteger(20), testList.Data[3]);
72 Assert.AreEqual(typeof(int), testList.Data[3].GetType()); 72 Assert.AreEqual(typeof(LSL_Types.LSLInteger), testList.Data[3].GetType());
73 73
74 LSL_Types.list secondTestList = testList + 2; 74 LSL_Types.list secondTestList = testList + new LSL_Types.LSLInteger(2);
75 75
76 Assert.AreEqual(5, secondTestList.Length); 76 Assert.AreEqual(5, secondTestList.Length);
77 Assert.AreEqual(2, secondTestList.Data[4]); 77 Assert.AreEqual(new LSL_Types.LSLInteger(2), secondTestList.Data[4]);
78 Assert.AreEqual(typeof(int), secondTestList.Data[4].GetType()); 78 Assert.AreEqual(typeof(LSL_Types.LSLInteger), secondTestList.Data[4].GetType());
79 } 79 }
80 80
81 /// <summary> 81 /// <summary>
82 /// Tests concatenating a double to a list. 82 /// Tests concatenating a float to a list.
83 /// </summary> 83 /// </summary>
84 [Test] 84 [Test]
85 public void TestConcatenateDouble() 85 public void TestConcatenateDouble()
86 { 86 {
87 LSL_Types.list testList = new LSL_Types.list(1, 'a', "test"); 87 LSL_Types.list testList = new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger('a'), new LSL_Types.LSLString("test"));
88 testList += 2.0; 88 testList += new LSL_Types.LSLFloat(2.0f);
89 89
90 Assert.AreEqual(4, testList.Length); 90 Assert.AreEqual(4, testList.Length);
91 Assert.AreEqual(2.0, testList.Data[3]); 91 Assert.AreEqual(new LSL_Types.LSLFloat(2.0f), testList.Data[3]);
92 Assert.AreEqual(typeof(double), testList.Data[3].GetType()); 92 Assert.AreEqual(typeof(LSL_Types.LSLFloat), testList.Data[3].GetType());
93 93
94 LSL_Types.list secondTestList = testList + 0.04; 94 LSL_Types.list secondTestList = testList + new LSL_Types.LSLFloat(0.04f);
95 95
96 Assert.AreEqual(5, secondTestList.Length); 96 Assert.AreEqual(5, secondTestList.Length);
97 Assert.AreEqual(0.04, secondTestList.Data[4]); 97 Assert.AreEqual(new LSL_Types.LSLFloat(0.04f), secondTestList.Data[4]);
98 Assert.AreEqual(typeof(double), secondTestList.Data[4].GetType()); 98 Assert.AreEqual(typeof(LSL_Types.LSLFloat), secondTestList.Data[4].GetType());
99 } 99 }
100 100
101 /// <summary> 101 /// <summary>