diff options
author | Justin Clark-Casey (justincc) | 2013-11-16 02:50:14 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-11-16 02:50:14 +0000 |
commit | edd7e1946372bc57bb49d0b6b65c546795ea896a (patch) | |
tree | e902b526782fac80fa1cb83e30896f7b707d1265 /OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests | |
parent | Make state_exit, moving_end, moving_start, not_at_rot_target, not_at_target a... (diff) | |
download | opensim-SC-edd7e1946372bc57bb49d0b6b65c546795ea896a.zip opensim-SC-edd7e1946372bc57bb49d0b6b65c546795ea896a.tar.gz opensim-SC-edd7e1946372bc57bb49d0b6b65c546795ea896a.tar.bz2 opensim-SC-edd7e1946372bc57bb49d0b6b65c546795ea896a.tar.xz |
If anything other than a single integer is specified for events that only take a single integer, generate a syntax error on LSL script compile rather than an exception later on.
This applies to events changed, collision, collision_start, collision_end, on_rez, run_time_permissions, sensor, touch, touch_start, touch_end
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/LSL_EventTests.cs | 107 |
1 files changed, 105 insertions, 2 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/LSL_EventTests.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/LSL_EventTests.cs index 6c51060..42d2d7b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/LSL_EventTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/LSL_EventTests.cs | |||
@@ -108,20 +108,123 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
108 | TestCompile("default { timer(integer n) {} }", true); | 108 | TestCompile("default { timer(integer n) {} }", true); |
109 | } | 109 | } |
110 | 110 | ||
111 | [Test] | ||
112 | public void TestChangedEvent() | ||
113 | { | ||
114 | TestHelpers.InMethod(); | ||
115 | // TestHelpers.EnableLogging(); | ||
116 | |||
117 | TestIntArgEvent("changed"); | ||
118 | } | ||
119 | |||
120 | [Test] | ||
121 | public void TestCollisionEvent() | ||
122 | { | ||
123 | TestHelpers.InMethod(); | ||
124 | // TestHelpers.EnableLogging(); | ||
125 | |||
126 | TestIntArgEvent("collision"); | ||
127 | } | ||
128 | |||
129 | [Test] | ||
130 | public void TestCollisionStartEvent() | ||
131 | { | ||
132 | TestHelpers.InMethod(); | ||
133 | // TestHelpers.EnableLogging(); | ||
134 | |||
135 | TestIntArgEvent("collision_start"); | ||
136 | } | ||
137 | |||
138 | [Test] | ||
139 | public void TestCollisionEndEvent() | ||
140 | { | ||
141 | TestHelpers.InMethod(); | ||
142 | // TestHelpers.EnableLogging(); | ||
143 | |||
144 | TestIntArgEvent("collision_end"); | ||
145 | } | ||
146 | |||
147 | [Test] | ||
148 | public void TestOnRezEvent() | ||
149 | { | ||
150 | TestHelpers.InMethod(); | ||
151 | // TestHelpers.EnableLogging(); | ||
152 | |||
153 | TestIntArgEvent("on_rez"); | ||
154 | } | ||
155 | |||
156 | [Test] | ||
157 | public void TestRunTimePermissionsEvent() | ||
158 | { | ||
159 | TestHelpers.InMethod(); | ||
160 | // TestHelpers.EnableLogging(); | ||
161 | |||
162 | TestIntArgEvent("run_time_permissions"); | ||
163 | } | ||
164 | |||
165 | [Test] | ||
166 | public void TestSensorEvent() | ||
167 | { | ||
168 | TestHelpers.InMethod(); | ||
169 | // TestHelpers.EnableLogging(); | ||
170 | |||
171 | TestIntArgEvent("sensor"); | ||
172 | } | ||
173 | |||
174 | [Test] | ||
175 | public void TestTouchEvent() | ||
176 | { | ||
177 | TestHelpers.InMethod(); | ||
178 | // TestHelpers.EnableLogging(); | ||
179 | |||
180 | TestIntArgEvent("touch"); | ||
181 | } | ||
182 | |||
183 | [Test] | ||
184 | public void TestTouchStartEvent() | ||
185 | { | ||
186 | TestHelpers.InMethod(); | ||
187 | // TestHelpers.EnableLogging(); | ||
188 | |||
189 | TestIntArgEvent("touch_start"); | ||
190 | } | ||
191 | |||
192 | [Test] | ||
193 | public void TestTouchEndEvent() | ||
194 | { | ||
195 | TestHelpers.InMethod(); | ||
196 | // TestHelpers.EnableLogging(); | ||
197 | |||
198 | TestIntArgEvent("touch_end"); | ||
199 | } | ||
200 | |||
201 | private void TestIntArgEvent(string eventName) | ||
202 | { | ||
203 | TestCompile("default { " + eventName + "(integer n) {} }", false); | ||
204 | TestCompile("default { " + eventName + "{{}} }", true); | ||
205 | TestCompile("default { " + eventName + "(string s) {{}} }", true); | ||
206 | TestCompile("default { " + eventName + "(integer n, integer o) {{}} }", true); | ||
207 | } | ||
208 | |||
111 | private void TestCompile(string script, bool expectException) | 209 | private void TestCompile(string script, bool expectException) |
112 | { | 210 | { |
113 | bool gotException = false; | 211 | bool gotException = false; |
212 | Exception ge = null; | ||
114 | 213 | ||
115 | try | 214 | try |
116 | { | 215 | { |
117 | m_cg.Convert(script); | 216 | m_cg.Convert(script); |
118 | } | 217 | } |
119 | catch (Exception) | 218 | catch (Exception e) |
120 | { | 219 | { |
121 | gotException = true; | 220 | gotException = true; |
221 | ge = e; | ||
122 | } | 222 | } |
123 | 223 | ||
124 | Assert.That(gotException, Is.EqualTo(expectException)); | 224 | Assert.That( |
225 | gotException, | ||
226 | Is.EqualTo(expectException), | ||
227 | "Failed on {0}, exception {1}", script, ge != null ? ge.ToString() : "n/a"); | ||
125 | } | 228 | } |
126 | } | 229 | } |
127 | } \ No newline at end of file | 230 | } \ No newline at end of file |