Update with current status
[gnash.git] / testsuite / actionscript.all / case.as
blob6d2eae14ee2e48cd911d5ac82dc4298412cd86e4
1 //
2 // Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
3 //
4 // This program is free software; you can redistribute it and/or modchecky
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; check not, write to the Free Software
16 // Foundation, Inc., 51 Franklin St, Fcheckth Floor, Boston, MA 02110-1301 USA
20 * Zou Lunkai, zoulunkai@gmail.com
22 * Test case sensitivity
26 rcsid="case.as";
27 #include "check.as"
29 #if OUTPUT_VERSION <= 6 // {
30 aBcD = 100;
31 oBj = new Object();
32 obj.xYZ = 100;
34 check_equals(ABCD, 100);
35 check_equals(typeof(OBJ), 'object');
36 check_equals(OBJ.xyz, 100);
37 #else // OUTPUT_VERSION > 6 }{
38 //swf7 and above are case sensitive
39 check_equals(ABCD, undefined);
40 check_equals(OBJ, undefined);
41 #endif // OUTPUT_VERSION > 6 }
43 #if OUTPUT_VERSION <= 6
44 check_equals(_root, _ROOT);
45 check_equals(_level0, _LEVEL0);
46 #else // OUTPUT_VERSION >= 7
47 check(_root != _ROOT);
48 check(_level0 != _LEVEL0);
49 #endif // OUTPUT_VERSION >= 7
51 #if OUTPUT_VERSION == 6 // {
54 //
55 // create _root.mc0 and _root.mc0.mc1
56 //
57 _ROOT.createEmptyMovieClip("mC0", 3);
58 check_equals(typeof(mc0), 'movieclip');
59 mC0.createEmptyMovieClip("mC1", 3);
60 check_equals(typeof(mc0.mc1), 'movieclip');
62 #ifdef MING_SUPPORTS_ASM // {
63 asm{
64 push "/_ROOT/MC0/"
65 push 0.0
66 push 100
67 setproperty
69 // check setproperty
70 check_equals(mC0._X, 100);
71 check_equals(mC0._x, 100);
74 // check _name and _target, they still keep the case
75 //
76 check_equals(mC0._name, "mC0");
77 check_equals(mC0._target, "/mC0");
78 check_equals(mC0.mC1._name, "mC1");
79 check_equals(mC0.mC1._target, "/mC0/mC1");
80 #endif // MING_SUPPORTS_ASM }
81 #endif // OUTPUT_VERSION == 6 }
83 #if OUTPUT_VERSION >= 6 // {
86 // create two movieclips named by same letters but different cases
88 mcRef = new Array(10);
89 i = 0;
90 MovieClip.prototype.onConstruct = function ()
92 mcRef[i++] = this;
93 note("Constructed "+this+" in depth "+this.getDepth()+" and assigned to mcRef["+(i-1)+"]");
96 _root.createEmptyMovieClip("clip", 6); //this will invoke the onConstruct listener
97 _root.createEmptyMovieClip("CLIP", 7); //this will invoke the onConstruct listener
99 // support visual checks
100 with(mcRef[0])
102 beginFill(0xff0000, 100);
103 moveTo(100, 100);
104 lineTo(200,100);
105 lineTo(200,200);
106 lineTo(100,200);
107 lineTo(100,100);
108 endFill();
109 _alpha = 20;
112 // support visual checks
113 with(mcRef[1])
115 beginFill(0x00ff00, 100);
116 moveTo(100, 100);
117 lineTo(200,100);
118 lineTo(200,200);
119 lineTo(100,200);
120 lineTo(100,100);
121 endFill();
122 _alpha = 20;
124 mcRef[1]._x += 100;
126 check(mcRef[0]!= mcRef[1]);
127 check_equals(mcRef[0].getDepth(), 6);
128 check_equals(mcRef[0]._name, "clip");
129 check_equals(mcRef[0]._target, "/clip");
131 #if OUTPUT_VERSION > 6
132 check_equals(mcRef[1].getDepth(), 7);
133 check_equals(mcRef[1]._name, "CLIP");
134 check_equals(mcRef[1]._target, "/CLIP");
135 #else // OUTPUT_VERSION <= 6
136 // Gnash used to fail these due to "soft references"
137 // Basically, a MOVIECLIP as_value stores the clip
138 // target, but in SWF<7 the target is insensitive
139 // so /clip and /CLIP both resolve to the *same*
140 // character.
142 check_equals(mcRef[1].getDepth(), 7);
143 check_equals(mcRef[1]._name, "CLIP");
144 check_equals(mcRef[1]._target, "/CLIP");
145 #endif // OUTPUT_VERSION <= 6
148 #if OUTPUT_VERSION <= 6
149 //case insensitive, so they reference the same movieclip.
150 //Or both are undefined with OUTPUT_VERSION <= 5
151 check(clip == CLIP);
152 #else // OUTPUT_VERSION >= 7
153 //case sensitive, so they are different
154 check(clip != CLIP);
155 check_equals(clip.getDepth(), 6);
156 check_equals(CLIP.getDepth(), 7);
157 #endif // OUTPUT_VERSION >= 7
159 _root.createEmptyMovieClip("CLIP2", 8); //this will invoke the onConstruct listener
160 _root.createEmptyMovieClip("clip2", 9); //this will invoke the onConstruct listener
162 check_equals(clip.getDepth(), 6);
163 #if OUTPUT_VERSION < 7
164 check_equals(CLIP.getDepth(), 6);
165 check_equals(CLIP2.getDepth(), 8);
166 check_equals(clip2.getDepth(), 8);
167 #else // OUTPUT_VERSION >= 7
168 check_equals(CLIP.getDepth(), 7);
169 check_equals(clip2.getDepth(), 9);
170 check_equals(CLIP2.getDepth(), 8);
171 #endif
173 #endif // OUTPUT_VERSION >= 6 }
176 // Test function args
178 func = function (xYz)
180 check_equals(xYz, 100);
181 #if OUTPUT_VERSION < 7
182 check_equals(xyz, 100);
183 #endif
184 this.testVar = xYz;
185 check_equals(this.testVar, 100);
186 #if OUTPUT_VERSION < 7
187 check_equals(this.testvar, 100);
188 #endif
190 // call the function above,
191 // trigger tests in it.
192 func(100);
194 #if OUTPUT_VERSION > 5
195 mcRef = _root.createEmptyMovieClip("mc_XYZ", 3);
196 check_equals(typeof(_root['mc_XYZ']), 'movieclip');
197 check_equals(typeof(_root['mcRef']), 'movieclip');
198 check_equals(typeof(mcRef['gotoAndStop']), 'function');
199 #endif
202 delete obj;
203 propRecorder = new Array();
204 obj = { A: 1, b: 2 };
205 for(var prop in obj)
207 propRecorder.push(prop);
209 propRecorder.sort(); // case sensitive sort
210 check_equals(propRecorder.length, 2);
211 #if OUTPUT_VERSION < 7
212 check_equals(propRecorder[0], 'A')
213 #else
214 check_equals(propRecorder[0], 'A')
215 #endif
216 check_equals(propRecorder[1], 'b')
218 propRecorder = new Array();
219 obj.a = 3;
220 for(var prop in obj)
222 propRecorder.push(prop);
224 propRecorder.sort(); //case sensitive sort
225 #if OUTPUT_VERSION < 7
226 check_equals(propRecorder.length, 2);
227 check_equals(propRecorder[0], 'A')
228 check_equals(propRecorder[1], 'b')
229 #else
230 check_equals(propRecorder.length, 3);
231 check_equals(propRecorder[0], 'A')
232 check_equals(propRecorder[1], 'a')
233 check_equals(propRecorder[2], 'b')
234 #endif
236 propRecorder = new Array();
237 obj.B = 4;
238 for(var prop in obj)
240 propRecorder.push(prop);
242 propRecorder.sort(); //case sensitive sort
243 #if OUTPUT_VERSION < 7
244 check_equals(propRecorder.length, 2);
245 check_equals(propRecorder[0], 'A')
246 check_equals(propRecorder[1], 'b')
247 #else
248 check_equals(propRecorder.length, 4);
249 check_equals(propRecorder[0], 'A')
250 check_equals(propRecorder[1], 'B')
251 check_equals(propRecorder[2], 'a')
252 check_equals(propRecorder[3], 'b')
253 #endif
255 propRecorder = new Array();
256 delete obj.a;
257 for(var prop in obj)
259 propRecorder.push(prop);
261 propRecorder.sort(); //case sensitive sort
262 #if OUTPUT_VERSION < 7
263 check_equals(propRecorder.length, 1);
264 check_equals(propRecorder[0], 'b')
265 #else
266 check_equals(propRecorder.length, 3);
267 check_equals(propRecorder[0], 'A')
268 check_equals(propRecorder[1], 'B')
269 check_equals(propRecorder[2], 'b')
270 #endif
272 // Now create a new object, with lowercase A and uppercase B
273 // Gnash will fail as long as it uses a single string_table
274 // for the whole objects set
275 obj = { a: 1, B: 2 };
276 #if OUTPUT_VERSION > 5
277 check(obj.hasOwnProperty('a'));
278 #if OUTPUT_VERSION == 6
279 check(obj.hasOwnProperty('A'));
280 #else
281 check(!obj.hasOwnProperty('A'));
282 #endif
283 #endif
284 propRecorder = new Array();
285 for(var prop in obj)
287 propRecorder.push(prop);
289 propRecorder.sort();
290 check_equals(propRecorder.length, 2);
291 #if OUTPUT_VERSION < 7
292 // gnash fails here because 'B' will point to a previously used 'b'
293 // and 'a' will point to a previously used 'A'
294 // in the global string_table
295 check_equals(propRecorder[0], 'B');
296 check_equals(propRecorder[1], 'a');
297 #else
298 // The problem above is a non-issue in SWF7 or higher, as 'b' and
299 // 'B' will be separate entries in the string_table
300 check_equals(propRecorder[0], 'B');
301 check_equals(propRecorder[1], 'a');
302 #endif
305 #if OUTPUT_VERSION > 5
306 // Check that properties are not overridden by
307 // variable names.
308 _global.hasOwnProperty = ASnative(101, 5);
310 check(_global.hasOwnProperty("Date"));
311 # if OUTPUT_VERSION == 6
312 check(_global.hasOwnProperty("date"));
313 # endif
314 Color = 5;
315 color = 8;
317 check(_global.hasOwnProperty("Color"));
318 # if OUTPUT_VERSION == 6
319 check(_global.hasOwnProperty("color"));
320 # endif
322 #endif
324 // Case sensitivity
325 // These DisplayObject properties are case-insensitive in all versions
327 check_equals(_root._x, _root._X);
328 check_equals(_root._y, _root._Y);
329 check_equals(_root._width, _root._wIDth);
330 check_equals(_root._height, _root._HEIGHT);
331 check_equals(_root._xmouse, _root._XmousE);
332 check_equals(_root._ymouse, _root._yMouse);
333 check_equals(_root._soundbuftime, _root._soundBufTIME);
334 check_equals(_root._focusrect, _root._FOCUSRECT);
335 check_equals(_root._quality, _root._QUALITY);
336 check_equals(_root._highquality, _root._highQUALITY);
339 #if OUTPUT_VERSION <= 5
340 check_totals(33);
341 #endif
342 #if OUTPUT_VERSION == 6
343 check_totals(62);
344 #endif
345 #if OUTPUT_VERSION >= 7
346 check_totals(56);
347 #endif