2 // Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
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.
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
29 #if OUTPUT_VERSION
<= 6 // {
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 // {
55 // create _root.mc0 and _root.mc0.mc1
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
// {
70 check_equals
(mC0
._X
, 100);
71 check_equals
(mC0
._x
, 100);
74 // check _name and _target, they still keep the case
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);
90 MovieClip.prototype
.onConstruct
= function ()
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
102 beginFill
(0xff0000, 100);
112 // support visual checks
115 beginFill
(0x00ff00, 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*
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
152 #else // OUTPUT_VERSION >= 7
153 //case sensitive, so they are different
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);
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);
185 check_equals
(this.testVar
, 100);
186 #if OUTPUT_VERSION
< 7
187 check_equals
(this.testvar
, 100);
190 // call the function above,
191 // trigger tests in it.
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');
203 propRecorder
= new Array();
204 obj
= { A
: 1, b
: 2 };
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')
214 check_equals
(propRecorder
[0], 'A')
216 check_equals
(propRecorder
[1], 'b')
218 propRecorder
= new Array();
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')
230 check_equals
(propRecorder
.length
, 3);
231 check_equals
(propRecorder
[0], 'A')
232 check_equals
(propRecorder
[1], 'a')
233 check_equals
(propRecorder
[2], 'b')
236 propRecorder
= new Array();
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')
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')
255 propRecorder
= new Array();
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')
266 check_equals
(propRecorder
.length
, 3);
267 check_equals
(propRecorder
[0], 'A')
268 check_equals
(propRecorder
[1], 'B')
269 check_equals
(propRecorder
[2], 'b')
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'));
281 check
(!obj
.hasOwnProperty
('A'));
284 propRecorder
= new Array();
287 propRecorder
.push
(prop
);
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');
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');
305 #if OUTPUT_VERSION
> 5
306 // Check that properties are not overridden by
308 _global
.hasOwnProperty
= ASnative
(101, 5);
310 check
(_global
.hasOwnProperty
("Date"));
311 # if OUTPUT_VERSION
== 6
312 check
(_global
.hasOwnProperty
("date"));
317 check
(_global
.hasOwnProperty
("Color"));
318 # if OUTPUT_VERSION
== 6
319 check
(_global
.hasOwnProperty
("color"));
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
342 #if OUTPUT_VERSION
== 6
345 #if OUTPUT_VERSION
>= 7