jscript: Added object to number conversion implementation.
[wine] / dlls / jscript / tests / lang.js
1 /*
2  * Copyright 2008 Jacek Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library 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 GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 var tmp;
20
21 ok(true, "true is not true?");
22 ok(!false, "!false is not true");
23 ok(!undefined, "!undefined is not true");
24 ok(!null, "!null is not true");
25 ok(!0, "!0 is not true");
26 ok(!0.0, "!0.0 is not true");
27
28 ok(1 === 1, "1 === 1 is false");
29 ok(!(1 === 2), "!(1 === 2) is false");
30 ok(1.0 === 1, "1.0 === 1 is false");
31 ok("abc" === "abc", "\"abc\" === \"abc\" is false");
32 ok(true === true, "true === true is false");
33 ok(null === null, "null === null is false");
34 ok(undefined === undefined, "undefined === undefined is false");
35 ok(!(undefined === null), "!(undefined === null) is false");
36
37 ok(1 !== 2, "1 !== 2 is false");
38 ok(null !== undefined, "null !== undefined is false");
39
40 ok(1 == 1, "1 == 1 is false");
41 ok(!(1 == 2), "!(1 == 2) is false");
42 ok(1.0 == 1, "1.0 == 1 is false");
43 ok("abc" == "abc", "\"abc\" == \"abc\" is false");
44 ok(true == true, "true == true is false");
45 ok(null == null, "null == null is false");
46 ok(undefined == undefined, "undefined == undefined is false");
47 ok(undefined == null, "undefined == null is false");
48 ok(true == 1, "true == 1 is false");
49 ok(!(true == 2), "true == 2");
50 ok(0 == false, "0 == false is false");
51
52 ok(1 != 2, "1 != 2 is false");
53 ok(false != 1, "false != 1 is false");
54
55 var trueVar = true;
56 ok(trueVar, "trueVar is not true");
57
58 ok(ScriptEngine.length === 0, "ScriptEngine.length is not 0");
59
60 function testFunc1(x, y) {
61     ok(this !== undefined, "this is undefined");
62     ok(x === true, "x is not 1");
63     ok(y === "test", "y is not \"test\"");
64     ok(arguments.length === 2, "arguments.length is not 2");
65     ok(arguments["0"] === true, "arguments[0] is not true");
66     ok(arguments["1"] === "test", "arguments[1] is not \"test\"");
67
68     return true;
69 }
70
71 ok(testFunc1.length === 2, "testFunc1.length is not 2");
72
73 ok(Object.prototype !== undefined, "Object.prototype is undefined");
74 ok(Object.prototype.prototype === undefined, "Object.prototype is not undefined");
75 ok(String.prototype !== undefined, "String.prototype is undefined");
76 ok(Array.prototype !== undefined, "Array.prototype is undefined");
77 ok(Boolean.prototype !== undefined, "Boolean.prototype is undefined");
78 ok(Number.prototype !== undefined, "Number.prototype is undefined");
79 ok(RegExp.prototype !== undefined, "RegExp.prototype is undefined");
80 ok(Math !== undefined, "Math is undefined");
81 ok(Math.prototype === undefined, "Math.prototype is not undefined");
82 ok(Function.prototype !== undefined, "Function.prototype is undefined");
83 ok(Function.prototype.prototype === undefined, "Function.prototype is not undefined");
84
85 Function.prototype.test = true;
86 ok(testFunc1.test === true, "testFunc1.test !== true");
87 ok(Function.test === true, "Function.test !== true");
88
89 ok(typeof(0) === "number", "typeof(0) is not number");
90 ok(typeof(1.5) === "number", "typeof(1.5) is not number");
91 ok(typeof("abc") === "string", "typeof(\"abc\") is not string");
92 ok(typeof("") === "string", "typeof(\"\") is not string");
93 ok(typeof(true) === "boolean", "typeof(true) is not boolean");
94 ok(typeof(null) === "object", "typeof(null) is not object");
95 ok(typeof(undefined) === "undefined", "typeof(undefined) is not undefined");
96 ok(typeof(Math) === "object", "typeof(Math) is not object");
97 ok(typeof(String.prototype) === "object", "typeof(String.prototype) is not object");
98 ok(typeof(testFunc1) === "function", "typeof(testFunc1) is not function");
99 ok(typeof(String) === "function", "typeof(String) is not function");
100 ok(typeof(ScriptEngine) === "function", "typeof(ScriptEngine) is not function");
101 ok(typeof(this) === "object", "typeof(this) is not object");
102
103 ok(testFunc1(true, "test") === true, "testFunc1 not returned true");
104
105 var obj1 = new Object();
106 ok(typeof(obj1) === "object", "typeof(obj1) is not object");
107 obj1.test = true;
108 obj1.func = function () {
109     ok(this === obj1, "this is not obj1");
110     ok(this.test === true, "this.test is not true");
111     ok(arguments.length === 1, "arguments.length is not 1");
112     ok(arguments["0"] === true, "arguments[0] is not true");
113
114     return "test";
115 };
116
117 ok(obj1.func(true) === "test", "obj1.func(true) is not \"test\"");
118
119 function testConstr1() {
120     this.var1 = 1;
121
122     ok(this !== undefined, "this is undefined");
123     ok(arguments.length === 1, "arguments.length is not 1");
124     ok(arguments["0"] === true, "arguments[0] is not 1");
125
126     return false;
127 }
128
129 testConstr1.prototype.pvar = 1;
130
131 var obj2 = new testConstr1(true);
132 ok(typeof(obj2) === "object", "typeof(obj2) is not object");
133 ok(obj2.pvar === 1, "obj2.pvar is not 1");
134
135 testConstr1.prototype.pvar = 2;
136 ok(obj2.pvar === 2, "obj2.pvar is not 2");
137
138 obj2.pvar = 3;
139 testConstr1.prototype.pvar = 1;
140 ok(obj2.pvar === 3, "obj2.pvar is not 3");
141
142 var obj3 = new Object;
143 ok(typeof(obj3) === "object", "typeof(obj3) is not object");
144
145 for(var iter in "test")
146     ok(false, "unexpected forin call, test = " + iter);
147
148 for(var iter in null)
149     ok(false, "unexpected forin call, test = " + iter);
150
151 for(var iter in false)
152     ok(false, "unexpected forin call, test = " + iter);
153
154 tmp = 0;
155 if(true)
156     tmp = 1;
157 else
158     ok(false, "else evaluated");
159 ok(tmp === 1, "tmp !== 1, if not evaluated?");
160
161 tmp = 0;
162 if(1 === 0)
163     ok(false, "if evaluated");
164 else
165     tmp = 1;
166 ok(tmp === 1, "tmp !== 1, if not evaluated?");
167
168 if(false)
169     ok(false, "if(false) evaluated");
170
171 tmp = 0;
172 if(true)
173     tmp = 1;
174 ok(tmp === 1, "tmp !== 1, if(true) not evaluated?");
175
176 var obj3 = { prop1: 1,  prop2: typeof(false) };
177 ok(obj3.prop1 === 1, "obj3.prop1 is not 1");
178 ok(obj3.prop2 === "boolean", "obj3.prop2 is not \"boolean\"");
179
180 {
181     var blockVar = 1;
182     blockVar = 2;
183 }
184 ok(blockVar === 2, "blockVar !== 2");
185
186 ok((true ? 1 : 2) === 1, "conditional expression true is not 1");
187 ok((0 === 2 ? 1 : 2) === 2, "conditional expression true is not 2");
188
189 ok(getVT(undefined) === "VT_EMPTY", "getVT(undefined) is not VT_EMPTY");
190 ok(getVT(null) === "VT_NULL", "getVT(null) is not VT_NULL");
191 ok(getVT(0) === "VT_I4", "getVT(0) is not VT_I4");
192 ok(getVT(0.5) === "VT_R8", "getVT(1.5) is not VT_R8");
193 ok(getVT("test") === "VT_BSTR", "getVT(\"test\") is not VT_BSTR");
194 ok(getVT(Math) === "VT_DISPATCH", "getVT(Math) is not VT_DISPATCH");
195 ok(getVT(false) === "VT_BOOL", "getVT(false) is not VT_BOOL");
196
197 tmp = 2+2;
198 ok(tmp === 4, "2+2 !== 4");
199 ok(getVT(tmp) === "VT_I4", "getVT(2+2) !== VT_I4");
200
201 tmp = 2+2.5;
202 ok(tmp === 4.5, "2+2.5 !== 4.5");
203 ok(getVT(tmp) === "VT_R8", "getVT(2+2.5) !== VT_R8");
204
205 tmp = 1.5+2.5;
206 ok(tmp === 4, "1.4+2.5 !== 4");
207 ok(getVT(tmp) === "VT_I4", "getVT(1.5+2.5) !== VT_I4");
208
209 tmp = 4-2;
210 ok(tmp === 2, "4-2 !== 2");
211 ok(getVT(tmp) === "VT_I4", "getVT(4-2) !== VT_I4");
212
213 tmp = 4.5-2;
214 ok(tmp === 2.5, "4.5-2 !== 2.5");
215 ok(getVT(tmp) === "VT_R8", "getVT(4-2) !== VT_R8");
216
217 tmp = -2;
218 ok(tmp === 0-2, "-2 !== 0-2");
219 ok(getVT(tmp) === "VT_I4", "getVT(-2) !== VT_I4");
220
221 tmp = 2*3;
222 ok(tmp === 6, "2*3 !== 6");
223 ok(getVT(tmp) === "VT_I4", "getVT(2*3) !== VT_I4");
224
225 tmp = 2*3.5;
226 ok(tmp === 7, "2*3.5 !== 7");
227 ok(getVT(tmp) === "VT_I4", "getVT(2*3.5) !== VT_I4");
228
229 tmp = 2.5*3.5;
230 ok(tmp === 8.75, "2.5*3.5 !== 8.75");
231 ok(getVT(tmp) === "VT_R8", "getVT(2.5*3.5) !== VT_R8");
232
233 tmp = 4/2;
234 ok(tmp === 2, "4/2 !== 2");
235 ok(getVT(tmp) === "VT_I4", "getVT(4/2) !== VT_I4");
236
237 tmp = 4.5/1.5;
238 ok(tmp === 3, "4.5/1.5 !== 3");
239 ok(getVT(tmp) === "VT_I4", "getVT(4.5/1.5) !== VT_I4");
240
241 tmp = 3/2;
242 ok(tmp === 1.5, "3/2 !== 1.5");
243 ok(getVT(tmp) === "VT_R8", "getVT(3/2) !== VT_R8");
244
245 tmp = "ab" + "cd";
246 ok(tmp === "abcd", "\"ab\" + \"cd\" !== \"abcd\"");
247
248 tmp = 1;
249 ok((tmp += 1) === 2, "tmp += 1 !== 2");
250 ok(tmp === 2, "tmp !== 2");
251
252 tmp = 2;
253 ok((tmp -= 1) === 1, "tmp -= 1 !== 1");
254 ok(tmp === 1, "tmp !=== 1");
255
256 tmp = 2;
257 ok((tmp *= 1.5) === 3, "tmp *= 1.5 !== 3");
258 ok(tmp === 3, "tmp !=== 3");
259
260 tmp = 5;
261 ok((tmp /= 2) === 2.5, "tmp /= 2 !== 2.5");
262 ok(tmp === 2.5, "tmp !=== 2.5");
263
264 tmp = 8;
265 ok((tmp <<= 1) === 16, "tmp <<= 1 !== 16");
266
267 tmp = 8;
268 ok((tmp >>= 1) === 4, "tmp >>= 1 !== 4");
269
270 tmp = 8;
271 ok((tmp >>>= 1) === 4, "tmp >>>= 1 !== 4");
272
273 tmp = 3 || ok(false, "second or expression called");
274 ok(tmp === 3, "3 || (...) is not 3");
275
276 tmp = false || 2;
277 ok(tmp === 2, "false || 2 is not 2");
278
279 tmp = 0 && ok(false, "second and expression called");
280 ok(tmp === 0, "0 && (...) is not 0");
281
282 tmp = true && "test";
283 ok(tmp === "test", "true && \"test\" is not \"test\"");
284
285 tmp = true && 0;
286 ok(tmp === 0, "true && 0 is not 0");
287
288 tmp = 3 | 4;
289 ok(tmp === 7, "3 | 4 !== 7");
290 ok(getVT(tmp) === "VT_I4", "getVT(3|4) = " + getVT(tmp));
291
292 tmp = 3.5 | 0;
293 ok(tmp === 3, "3.5 | 0 !== 3");
294 ok(getVT(tmp) === "VT_I4", "getVT(3.5|0) = " + getVT(tmp));
295
296 tmp = -3.5 | 0;
297 ok(tmp === -3, "-3.5 | 0 !== -3");
298 ok(getVT(tmp) === "VT_I4", "getVT(3.5|0) = " + getVT(tmp));
299
300 tmp = 10;
301 ok((tmp |= 0x10) === 26, "tmp(10) |= 0x10 !== 26");
302 ok(getVT(tmp) === "VT_I4", "getVT(tmp |= 10) = " + getVT(tmp));
303
304 tmp = 3 & 5;
305 ok(tmp === 1, "3 & 5 !== 1");
306 ok(getVT(tmp) === "VT_I4", "getVT(3|5) = " + getVT(tmp));
307
308 tmp = 3.5 & 0xffff;
309 ok(tmp === 3, "3.5 & 0xffff !== 3 ");
310 ok(getVT(tmp) === "VT_I4", "getVT(3.5&0xffff) = " + getVT(tmp));
311
312 tmp = (-3.5) & 0xffffffff;
313 ok(tmp === -3, "-3.5 & 0xffff !== -3");
314 ok(getVT(tmp) === "VT_I4", "getVT(3.5&0xffff) = " + getVT(tmp));
315
316 tmp = 2 << 3;
317 ok(tmp === 16, "2 << 3 = " + tmp);
318
319 tmp = 2 << 35;
320 ok(tmp === 16, "2 << 35 = " + tmp);
321
322 tmp = 8 >> 2;
323 ok(tmp === 2, "8 >> 2 = " + tmp);
324
325 tmp = -64 >> 4;
326 ok(tmp === -4, "-64 >> 4 = " + tmp);
327
328 tmp = 8 >>> 2;
329 ok(tmp === 2, "8 >> 2 = " + tmp);
330
331 tmp = -64 >>> 4;
332 ok(tmp === 0x0ffffffc, "-64 >>> 4 = " + tmp);
333
334 tmp = 10;
335 ok((tmp &= 8) === 8, "tmp(10) &= 8 !== 8");
336 ok(getVT(tmp) === "VT_I4", "getVT(tmp &= 8) = " + getVT(tmp));
337
338 tmp = 0xf0f0^0xff00;
339 ok(tmp === 0x0ff0, "0xf0f0^0xff00 !== 0x0ff0");
340 ok(getVT(tmp) === "VT_I4", "getVT(0xf0f0^0xff00) = " + getVT(tmp));
341
342 tmp = 5;
343 ok((tmp ^= 3) === 6, "tmp(5) ^= 3 !== 6");
344 ok(getVT(tmp) === "VT_I4", "getVT(tmp ^= 3) = " + getVT(tmp));
345
346 tmp = ~1;
347 ok(tmp === -2, "~1 !== -2");
348 ok(getVT(tmp) === "VT_I4", "getVT(~1) = " + getVT(tmp));
349
350 ok((3,4) === 4, "(3,4) !== 4");
351
352 ok(+3 === 3, "+3 !== 3");
353 ok(+true === 1, "+true !== 1");
354 ok(+false === 0, "+false !== 0");
355 ok(+null === 0, "+null !== 0");
356 ok(+"0" === 0, "+'0' !== 0");
357 ok(+"3" === 3, "+'3' !== 3");
358 ok(+"-3" === -3, "+'-3' !== -3");
359 ok(+"0xff" === 255, "+'0xff' !== 255");
360 ok(+"3e3" === 3000, "+'3e3' !== 3000");
361
362 tmp = new Number(1);
363 ok(+tmp === 1, "ToNumber(new Number(1)) = " + (+tmp));
364 tmp = new String("1");
365 ok(+tmp === 1, "ToNumber(new String('1')) = " + (+tmp));
366
367 ok("" + 0 === "0", "\"\" + 0 !== \"0\"");
368 ok("" + 123 === "123", "\"\" + 123 !== \"123\"");
369 ok("" + (-5) === "-5", "\"\" + (-5) !== \"-5\"");
370 ok("" + null === "null", "\"\" + null !== \"null\"");
371 ok("" + undefined === "undefined", "\"\" + undefined !== \"undefined\"");
372 ok("" + true === "true", "\"\" + true !== \"true\"");
373 ok("" + false === "false", "\"\" + false !== \"false\"");
374 ok("" + 0.5 === "0.5", "'' + 0.5 = " + 0.5);
375 ok("" + (-0.5432) === "-0.5432", "'' + (-0.5432) = " + (-0.5432));
376
377 ok(1 < 3.4, "1 < 3.4 failed");
378 ok(!(3.4 < 1), "3.4 < 1");
379 ok("abc" < "abcd", "abc < abcd failed");
380 ok("abcd" < "abce", "abce < abce failed");
381 ok("" < "x", "\"\" < \"x\" failed");
382 ok(!(0 < 0), "0 < 0");
383
384 ok(1 <= 3.4, "1 <= 3.4 failed");
385 ok(!(3.4 <= 1), "3.4 <= 1");
386 ok("abc" <= "abcd", "abc <= abcd failed");
387 ok("abcd" <= "abce", "abce <= abce failed");
388 ok("" <= "x", "\"\" <= \"x\" failed");
389 ok(0 <= 0, "0 <= 0 failed");
390
391 ok(3.4 > 1, "3.4 > 1 failed");
392 ok(!(1 > 3.4), "1 > 3.4");
393 ok("abcd" > "abc", "abc > abcd failed");
394 ok("abce" > "abcd", "abce > abce failed");
395 ok("x" > "", "\"x\" > \"\" failed");
396 ok(!(0 > 0), "0 > 0");
397
398 ok(3.4 >= 1, "3.4 >= 1 failed");
399 ok(!(1 >= 3.4), "1 >= 3.4");
400 ok("abcd" >= "abc", "abc >= abcd failed");
401 ok("abce" >= "abcd", "abce >= abce failed");
402 ok("x" >= "", "\"x\" >= \"\" failed");
403 ok(0 >= 0, "0 >= 0");
404
405 tmp = 1;
406 ok(++tmp === 2, "++tmp (1) is not 2");
407 ok(tmp === 2, "incremented tmp is not 2");
408 ok(--tmp === 1, "--tmp (2) is not 1");
409 ok(tmp === 1, "decremented tmp is not 1");
410 ok(tmp++ === 1, "tmp++ (1) is not 1");
411 ok(tmp === 2, "incremented tmp(1) is not 2");
412 ok(tmp-- === 2, "tmp-- (2) is not 2");
413 ok(tmp === 1, "decremented tmp is not 1");
414
415 String.prototype.test = true;
416 ok("".test === true, "\"\".test is not true");
417
418 Boolean.prototype.test = true;
419 ok(true.test === true, "true.test is not true");
420
421 Number.prototype.test = true;
422 ok((0).test === true, "(0).test is not true");
423 ok((0.5).test === true, "(0.5).test is not true");
424
425 var state = "";
426 try {
427     ok(state === "", "try: state = " + state);
428     state = "try";
429 }catch(ex) {
430     ok(false, "unexpected catch");
431 }
432 ok(state === "try", "state = " + state + " expected try");
433
434 state = "";
435 try {
436     ok(state === "", "try: state = " + state);
437     state = "try";
438 }finally {
439     ok(state === "try", "funally: state = " + state);
440     state = "finally";
441 }
442 ok(state === "finally", "state = " + state + " expected finally");
443
444 state = "";
445 try {
446     ok(state === "", "try: state = " + state);
447     state = "try";
448 }catch(ex) {
449     ok(false, "unexpected catch");
450 }finally {
451     ok(state === "try", "funally: state = " + state);
452     state = "finally";
453 }
454 ok(state === "finally", "state = " + state + " expected finally");
455
456 var state = "";
457 try {
458     ok(state === "", "try: state = " + state);
459     state = "try";
460     throw "except";
461 }catch(ex) {
462     ok(state === "try", "catch: state = " + state);
463     ok(ex === "except", "ex is not \"except\"");
464     state = "catch";
465 }
466 ok(state === "catch", "state = " + state + " expected catch");
467
468 var state = "";
469 try {
470     ok(state === "", "try: state = " + state);
471     state = "try";
472     throw true;
473 }catch(ex) {
474     ok(state === "try", "catch: state = " + state);
475     ok(ex === true, "ex is not true");
476     state = "catch";
477 }finally {
478     ok(state === "catch", "funally: state = " + state);
479     state = "finally";
480 }
481 ok(state === "finally", "state = " + state + " expected finally");
482
483 var state = "";
484 try {
485     ok(state === "", "try: state = " + state);
486     state = "try";
487     try { throw true; } finally {}
488 }catch(ex) {
489     ok(state === "try", "catch: state = " + state);
490     ok(ex === true, "ex is not true");
491     state = "catch";
492 }finally {
493     ok(state === "catch", "funally: state = " + state);
494     state = "finally";
495 }
496 ok(state === "finally", "state = " + state + " expected finally");
497
498 var state = "";
499 try {
500     ok(state === "", "try: state = " + state);
501     state = "try";
502     try { throw "except"; } catch(ex) { throw true; }
503 }catch(ex) {
504     ok(state === "try", "catch: state = " + state);
505     ok(ex === true, "ex is not true");
506     state = "catch";
507 }finally {
508     ok(state === "catch", "funally: state = " + state);
509     state = "finally";
510 }
511 ok(state === "finally", "state = " + state + " expected finally");
512
513 function throwFunc(x) {
514     throw x;
515 }
516
517 var state = "";
518 try {
519     ok(state === "", "try: state = " + state);
520     state = "try";
521     throwFunc(true);
522 }catch(ex) {
523     ok(state === "try", "catch: state = " + state);
524     ok(ex === true, "ex is not true");
525     state = "catch";
526 }finally {
527     ok(state === "catch", "funally: state = " + state);
528     state = "finally";
529 }
530 ok(state === "finally", "state = " + state + " expected finally");
531
532 state = "";
533 switch(1) {
534 case "1":
535     ok(false, "unexpected case \"1\"");
536 case 1:
537     ok(state === "", "case 1: state = " + state);
538     state = "1";
539 default:
540     ok(state === "1", "default: state = " + state);
541     state = "default";
542 case false:
543     ok(state === "default", "case false: state = " + state);
544     state = "false";
545 }
546 ok(state === "false", "state = " + state);
547
548 state = "";
549 switch("") {
550 case "1":
551 case 1:
552     ok(false, "unexpected case 1");
553 default:
554     ok(state === "", "default: state = " + state);
555     state = "default";
556 case false:
557     ok(state === "default", "case false: state = " + state);
558     state = "false";
559 }
560 ok(state === "false", "state = " + state);
561
562 state = "";
563 switch(1) {
564 case "1":
565     ok(false, "unexpected case \"1\"");
566 case 1:
567     ok(state === "", "case 1: state = " + state);
568     state = "1";
569 default:
570     ok(state === "1", "default: state = " + state);
571     state = "default";
572     break;
573 case false:
574     ok(false, "unexpected case false");
575 }
576 ok(state === "default", "state = " + state);
577
578 tmp = eval("1");
579 ok(tmp === 1, "eval(\"1\") !== 1");
580 eval("{ ok(tmp === 1, 'eval: tmp !== 1'); } tmp = 2;");
581 ok(tmp === 2, "tmp !== 2");
582
583 ok(eval(false) === false, "eval(false) !== false");
584 ok(eval() === undefined, "eval() !== undefined");
585
586 tmp = eval("1", "2");
587 ok(tmp === 1, "eval(\"1\", \"2\") !== 1");
588
589 var state = "";
590 try {
591     ok(state === "", "try: state = " + state);
592     state = "try";
593     eval("throwFunc(true);");
594 }catch(ex) {
595     ok(state === "try", "catch: state = " + state);
596     ok(ex === true, "ex is not true");
597     state = "catch";
598 }finally {
599     ok(state === "catch", "funally: state = " + state);
600     state = "finally";
601 }
602 ok(state === "finally", "state = " + state + " expected finally");
603
604 tmp = [,,1,2,,,true];
605 ok(tmp.length === 7, "tmp.length !== 7");
606 ok(tmp["0"] === undefined, "tmp[0] is not undefined");
607 ok(tmp["3"] === 2, "tmp[3] !== 2");
608 ok(tmp["6"] === true, "tmp[6] !== true");
609 ok(tmp[2] === 1, "tmp[2] !== 1");
610
611 ok([1,].length === 2, "[1,].length !== 2");
612
613 tmp = 0;
614 while(tmp < 4) {
615     ok(tmp < 4, "tmp >= 4");
616     tmp++;
617 }
618 ok(tmp === 4, "tmp !== 4");
619
620 tmp = 0;
621 while(true) {
622     ok(tmp < 4, "tmp >= 4");
623     tmp++;
624     if(tmp === 4) {
625         break;
626         ok(false, "break did not break");
627     }
628 }
629 ok(tmp === 4, "tmp !== 4");
630
631 tmp = 0;
632 do {
633     ok(tmp < 4, "tmp >= 4");
634     tmp++;
635 } while(tmp < 4);
636 ok(tmp === 4, "tmp !== 4");
637
638 tmp = 0;
639 do {
640     ok(tmp === 0, "tmp !=== 0");
641     tmp++;
642 } while(false);
643 ok(tmp === 1, "tmp !== 1");
644
645 tmp = 0;
646 while(tmp < 4) {
647     tmp++;
648     if(tmp === 2) {
649         continue;
650         ok(false, "break did not break");
651     }
652     ok(tmp <= 4 && tmp != 2, "tmp = " + tmp);
653 }
654 ok(tmp === 4, "tmp !== 4");
655
656 for(tmp=0; tmp < 4; tmp++)
657     ok(tmp < 4, "tmp = " + tmp);
658 ok(tmp === 4, "tmp !== 4");
659
660 for(tmp=0; tmp < 4; tmp++) {
661     if(tmp === 2)
662         break;
663     ok(tmp < 2, "tmp = " + tmp);
664 }
665 ok(tmp === 2, "tmp !== 2");
666
667 for(tmp=0; tmp < 4; tmp++) {
668     if(tmp === 2)
669         continue;
670     ok(tmp < 4 && tmp != 2, "tmp = " + tmp);
671 }
672 ok(tmp === 4, "tmp !== 4");
673
674 for(var fi=0; fi < 4; fi++)
675     ok(fi < 4, "fi = " + fi);
676 ok(fi === 4, "fi !== 4");
677
678 ok((void 1) === undefined, "(void 1) !== undefined");
679
680 var inobj = new Object();
681
682 for(var iter in inobj)
683     ok(false, "unexpected iter = " + iter);
684
685 inobj.test = true;
686 tmp = 0;
687 for(iter in inobj) {
688     ok(iter == "test", "unexpected iter = " + iter);
689     tmp++;
690 }
691 ok(tmp === 1, "for..in tmp = " + tmp);
692
693 function forinTestObj() {}
694
695 forinTestObj.prototype.test3 = true;
696
697 var arr = new Array();
698 inobj = new forinTestObj();
699 inobj.test1 = true;
700 inobj.test2 = true;
701
702 tmp = 0;
703 for(iter in inobj) {
704     arr[iter] = true;
705     tmp++;
706 }
707
708 ok(tmp === 3, "for..in tmp = " + tmp);
709 ok(arr["test1"] === true, "arr[test1] !== true");
710 ok(arr["test2"] === true, "arr[test2] !== true");
711 ok(arr["test3"] === true, "arr[test3] !== true");
712
713 tmp = new Object();
714 tmp.test = false;
715 ok((delete tmp.test) === true, "delete returned false");
716 ok(typeof(tmp.test) === "undefined", "tmp.test type = " + typeof(tmp.test));
717 for(iter in tmp)
718     ok(false, "tmp has prop " + iter);
719
720 tmp.testWith = true;
721 with(tmp)
722     ok(testWith === true, "testWith !== true");
723
724 reportSuccess();