push cea036dc4aae50c232dc1391dcc459ff0b060bcf
[wine/hacks.git] / dlls / jscript / tests / lang.js
blob720c1660546d1f63b6a6035881d94d26df18968b
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  */
19 var tmp;
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");
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");
37 ok(1 !== 2, "1 !== 2 is false");
38 ok(null !== undefined, "null !== undefined is false");
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");
52 ok(1 != 2, "1 != 2 is false");
53 ok(false != 1, "false != 1 is false");
55 var trueVar = true;
56 ok(trueVar, "trueVar is not true");
58 ok(ScriptEngine.length === 0, "ScriptEngine.length is not 0");
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\"");
68     return true;
71 ok(testFunc1.length === 2, "testFunc1.length is not 2");
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 ok(Date.prototype !== undefined, "Date.prototype is undefined");
85 ok(Date.prototype.prototype === undefined, "Date.prototype is not undefined");
87 Function.prototype.test = true;
88 ok(testFunc1.test === true, "testFunc1.test !== true");
89 ok(Function.test === true, "Function.test !== true");
91 ok(typeof(0) === "number", "typeof(0) is not number");
92 ok(typeof(1.5) === "number", "typeof(1.5) is not number");
93 ok(typeof("abc") === "string", "typeof(\"abc\") is not string");
94 ok(typeof("") === "string", "typeof(\"\") is not string");
95 ok(typeof(true) === "boolean", "typeof(true) is not boolean");
96 ok(typeof(null) === "object", "typeof(null) is not object");
97 ok(typeof(undefined) === "undefined", "typeof(undefined) is not undefined");
98 ok(typeof(Math) === "object", "typeof(Math) is not object");
99 ok(typeof(String.prototype) === "object", "typeof(String.prototype) is not object");
100 ok(typeof(testFunc1) === "function", "typeof(testFunc1) is not function");
101 ok(typeof(String) === "function", "typeof(String) is not function");
102 ok(typeof(ScriptEngine) === "function", "typeof(ScriptEngine) is not function");
103 ok(typeof(this) === "object", "typeof(this) is not object");
105 ok(testFunc1(true, "test") === true, "testFunc1 not returned true");
107 var obj1 = new Object();
108 ok(typeof(obj1) === "object", "typeof(obj1) is not object");
109 obj1.test = true;
110 obj1.func = function () {
111     ok(this === obj1, "this is not obj1");
112     ok(this.test === true, "this.test is not true");
113     ok(arguments.length === 1, "arguments.length is not 1");
114     ok(arguments["0"] === true, "arguments[0] is not true");
116     return "test";
119 ok(obj1.func(true) === "test", "obj1.func(true) is not \"test\"");
121 function testConstr1() {
122     this.var1 = 1;
124     ok(this !== undefined, "this is undefined");
125     ok(arguments.length === 1, "arguments.length is not 1");
126     ok(arguments["0"] === true, "arguments[0] is not 1");
128     return false;
131 testConstr1.prototype.pvar = 1;
133 var obj2 = new testConstr1(true);
134 ok(typeof(obj2) === "object", "typeof(obj2) is not object");
135 ok(obj2.pvar === 1, "obj2.pvar is not 1");
137 testConstr1.prototype.pvar = 2;
138 ok(obj2.pvar === 2, "obj2.pvar is not 2");
140 obj2.pvar = 3;
141 testConstr1.prototype.pvar = 1;
142 ok(obj2.pvar === 3, "obj2.pvar is not 3");
144 var obj3 = new Object;
145 ok(typeof(obj3) === "object", "typeof(obj3) is not object");
147 for(var iter in "test")
148     ok(false, "unexpected forin call, test = " + iter);
150 for(var iter in null)
151     ok(false, "unexpected forin call, test = " + iter);
153 for(var iter in false)
154     ok(false, "unexpected forin call, test = " + iter);
156 tmp = 0;
157 if(true)
158     tmp = 1;
159 else
160     ok(false, "else evaluated");
161 ok(tmp === 1, "tmp !== 1, if not evaluated?");
163 tmp = 0;
164 if(1 === 0)
165     ok(false, "if evaluated");
166 else
167     tmp = 1;
168 ok(tmp === 1, "tmp !== 1, if not evaluated?");
170 if(false)
171     ok(false, "if(false) evaluated");
173 tmp = 0;
174 if(true)
175     tmp = 1;
176 ok(tmp === 1, "tmp !== 1, if(true) not evaluated?");
178 if(false) {
179 }else {
182 var obj3 = { prop1: 1,  prop2: typeof(false) };
183 ok(obj3.prop1 === 1, "obj3.prop1 is not 1");
184 ok(obj3.prop2 === "boolean", "obj3.prop2 is not \"boolean\"");
187     var blockVar = 1;
188     blockVar = 2;
190 ok(blockVar === 2, "blockVar !== 2");
192 ok((true ? 1 : 2) === 1, "conditional expression true is not 1");
193 ok((0 === 2 ? 1 : 2) === 2, "conditional expression true is not 2");
195 ok(getVT(undefined) === "VT_EMPTY", "getVT(undefined) is not VT_EMPTY");
196 ok(getVT(null) === "VT_NULL", "getVT(null) is not VT_NULL");
197 ok(getVT(0) === "VT_I4", "getVT(0) is not VT_I4");
198 ok(getVT(0.5) === "VT_R8", "getVT(1.5) is not VT_R8");
199 ok(getVT("test") === "VT_BSTR", "getVT(\"test\") is not VT_BSTR");
200 ok(getVT(Math) === "VT_DISPATCH", "getVT(Math) is not VT_DISPATCH");
201 ok(getVT(false) === "VT_BOOL", "getVT(false) is not VT_BOOL");
203 tmp = 2+2;
204 ok(tmp === 4, "2+2 !== 4");
205 ok(getVT(tmp) === "VT_I4", "getVT(2+2) !== VT_I4");
207 tmp = 2+2.5;
208 ok(tmp === 4.5, "2+2.5 !== 4.5");
209 ok(getVT(tmp) === "VT_R8", "getVT(2+2.5) !== VT_R8");
211 tmp = 1.5+2.5;
212 ok(tmp === 4, "1.4+2.5 !== 4");
213 ok(getVT(tmp) === "VT_I4", "getVT(1.5+2.5) !== VT_I4");
215 tmp = 4-2;
216 ok(tmp === 2, "4-2 !== 2");
217 ok(getVT(tmp) === "VT_I4", "getVT(4-2) !== VT_I4");
219 tmp = 4.5-2;
220 ok(tmp === 2.5, "4.5-2 !== 2.5");
221 ok(getVT(tmp) === "VT_R8", "getVT(4-2) !== VT_R8");
223 tmp = -2;
224 ok(tmp === 0-2, "-2 !== 0-2");
225 ok(getVT(tmp) === "VT_I4", "getVT(-2) !== VT_I4");
227 tmp = 2*3;
228 ok(tmp === 6, "2*3 !== 6");
229 ok(getVT(tmp) === "VT_I4", "getVT(2*3) !== VT_I4");
231 tmp = 2*3.5;
232 ok(tmp === 7, "2*3.5 !== 7");
233 ok(getVT(tmp) === "VT_I4", "getVT(2*3.5) !== VT_I4");
235 tmp = 2.5*3.5;
236 ok(tmp === 8.75, "2.5*3.5 !== 8.75");
237 ok(getVT(tmp) === "VT_R8", "getVT(2.5*3.5) !== VT_R8");
239 tmp = 4/2;
240 ok(tmp === 2, "4/2 !== 2");
241 ok(getVT(tmp) === "VT_I4", "getVT(4/2) !== VT_I4");
243 tmp = 4.5/1.5;
244 ok(tmp === 3, "4.5/1.5 !== 3");
245 ok(getVT(tmp) === "VT_I4", "getVT(4.5/1.5) !== VT_I4");
247 tmp = 3/2;
248 ok(tmp === 1.5, "3/2 !== 1.5");
249 ok(getVT(tmp) === "VT_R8", "getVT(3/2) !== VT_R8");
251 tmp = 3%2;
252 ok(tmp === 1, "3%2 = " + tmp);
254 tmp = 4%2;
255 ok(tmp ===0, "4%2 = " + tmp);
257 tmp = 3.5%1.5;
258 ok(tmp === 0.5, "3.5%1.5 = " + tmp);
260 tmp = 3%true;
261 ok(tmp === 0, "3%true = " + tmp);
263 tmp = "ab" + "cd";
264 ok(tmp === "abcd", "\"ab\" + \"cd\" !== \"abcd\"");
266 tmp = 1;
267 ok((tmp += 1) === 2, "tmp += 1 !== 2");
268 ok(tmp === 2, "tmp !== 2");
270 tmp = 2;
271 ok((tmp -= 1) === 1, "tmp -= 1 !== 1");
272 ok(tmp === 1, "tmp !=== 1");
274 tmp = 2;
275 ok((tmp *= 1.5) === 3, "tmp *= 1.5 !== 3");
276 ok(tmp === 3, "tmp !=== 3");
278 tmp = 5;
279 ok((tmp /= 2) === 2.5, "tmp /= 2 !== 2.5");
280 ok(tmp === 2.5, "tmp !=== 2.5");
282 tmp = 3;
283 ok((tmp %= 2) === 1, "tmp %= 2 !== 1");
284 ok(tmp === 1, "tmp !== 1");
286 tmp = 8;
287 ok((tmp <<= 1) === 16, "tmp <<= 1 !== 16");
289 tmp = 8;
290 ok((tmp >>= 1) === 4, "tmp >>= 1 !== 4");
292 tmp = 8;
293 ok((tmp >>>= 1) === 4, "tmp >>>= 1 !== 4");
295 tmp = 3 || ok(false, "second or expression called");
296 ok(tmp === 3, "3 || (...) is not 3");
298 tmp = false || 2;
299 ok(tmp === 2, "false || 2 is not 2");
301 tmp = 0 && ok(false, "second and expression called");
302 ok(tmp === 0, "0 && (...) is not 0");
304 tmp = true && "test";
305 ok(tmp === "test", "true && \"test\" is not \"test\"");
307 tmp = true && 0;
308 ok(tmp === 0, "true && 0 is not 0");
310 tmp = 3 | 4;
311 ok(tmp === 7, "3 | 4 !== 7");
312 ok(getVT(tmp) === "VT_I4", "getVT(3|4) = " + getVT(tmp));
314 tmp = 3.5 | 0;
315 ok(tmp === 3, "3.5 | 0 !== 3");
316 ok(getVT(tmp) === "VT_I4", "getVT(3.5|0) = " + getVT(tmp));
318 tmp = -3.5 | 0;
319 ok(tmp === -3, "-3.5 | 0 !== -3");
320 ok(getVT(tmp) === "VT_I4", "getVT(3.5|0) = " + getVT(tmp));
322 tmp = 10;
323 ok((tmp |= 0x10) === 26, "tmp(10) |= 0x10 !== 26");
324 ok(getVT(tmp) === "VT_I4", "getVT(tmp |= 10) = " + getVT(tmp));
326 tmp = 3 & 5;
327 ok(tmp === 1, "3 & 5 !== 1");
328 ok(getVT(tmp) === "VT_I4", "getVT(3|5) = " + getVT(tmp));
330 tmp = 3.5 & 0xffff;
331 ok(tmp === 3, "3.5 & 0xffff !== 3 ");
332 ok(getVT(tmp) === "VT_I4", "getVT(3.5&0xffff) = " + getVT(tmp));
334 tmp = (-3.5) & 0xffffffff;
335 ok(tmp === -3, "-3.5 & 0xffff !== -3");
336 ok(getVT(tmp) === "VT_I4", "getVT(3.5&0xffff) = " + getVT(tmp));
338 tmp = 2 << 3;
339 ok(tmp === 16, "2 << 3 = " + tmp);
341 tmp = 2 << 35;
342 ok(tmp === 16, "2 << 35 = " + tmp);
344 tmp = 8 >> 2;
345 ok(tmp === 2, "8 >> 2 = " + tmp);
347 tmp = -64 >> 4;
348 ok(tmp === -4, "-64 >> 4 = " + tmp);
350 tmp = 8 >>> 2;
351 ok(tmp === 2, "8 >> 2 = " + tmp);
353 tmp = -64 >>> 4;
354 ok(tmp === 0x0ffffffc, "-64 >>> 4 = " + tmp);
356 tmp = 10;
357 ok((tmp &= 8) === 8, "tmp(10) &= 8 !== 8");
358 ok(getVT(tmp) === "VT_I4", "getVT(tmp &= 8) = " + getVT(tmp));
360 tmp = 0xf0f0^0xff00;
361 ok(tmp === 0x0ff0, "0xf0f0^0xff00 !== 0x0ff0");
362 ok(getVT(tmp) === "VT_I4", "getVT(0xf0f0^0xff00) = " + getVT(tmp));
364 tmp = 5;
365 ok((tmp ^= 3) === 6, "tmp(5) ^= 3 !== 6");
366 ok(getVT(tmp) === "VT_I4", "getVT(tmp ^= 3) = " + getVT(tmp));
368 tmp = ~1;
369 ok(tmp === -2, "~1 !== -2");
370 ok(getVT(tmp) === "VT_I4", "getVT(~1) = " + getVT(tmp));
372 ok((3,4) === 4, "(3,4) !== 4");
374 ok(+3 === 3, "+3 !== 3");
375 ok(+true === 1, "+true !== 1");
376 ok(+false === 0, "+false !== 0");
377 ok(+null === 0, "+null !== 0");
378 ok(+"0" === 0, "+'0' !== 0");
379 ok(+"3" === 3, "+'3' !== 3");
380 ok(+"-3" === -3, "+'-3' !== -3");
381 ok(+"0xff" === 255, "+'0xff' !== 255");
382 ok(+"3e3" === 3000, "+'3e3' !== 3000");
384 tmp = new Number(1);
385 ok(+tmp === 1, "ToNumber(new Number(1)) = " + (+tmp));
386 tmp = new String("1");
387 ok(+tmp === 1, "ToNumber(new String('1')) = " + (+tmp));
389 ok("" + 0 === "0", "\"\" + 0 !== \"0\"");
390 ok("" + 123 === "123", "\"\" + 123 !== \"123\"");
391 ok("" + (-5) === "-5", "\"\" + (-5) !== \"-5\"");
392 ok("" + null === "null", "\"\" + null !== \"null\"");
393 ok("" + undefined === "undefined", "\"\" + undefined !== \"undefined\"");
394 ok("" + true === "true", "\"\" + true !== \"true\"");
395 ok("" + false === "false", "\"\" + false !== \"false\"");
396 ok("" + 0.5 === "0.5", "'' + 0.5 = " + 0.5);
397 ok("" + (-0.5432) === "-0.5432", "'' + (-0.5432) = " + (-0.5432));
399 ok(1 < 3.4, "1 < 3.4 failed");
400 ok(!(3.4 < 1), "3.4 < 1");
401 ok("abc" < "abcd", "abc < abcd failed");
402 ok("abcd" < "abce", "abce < abce failed");
403 ok("" < "x", "\"\" < \"x\" failed");
404 ok(!(0 < 0), "0 < 0");
406 ok(1 <= 3.4, "1 <= 3.4 failed");
407 ok(!(3.4 <= 1), "3.4 <= 1");
408 ok("abc" <= "abcd", "abc <= abcd failed");
409 ok("abcd" <= "abce", "abce <= abce failed");
410 ok("" <= "x", "\"\" <= \"x\" failed");
411 ok(0 <= 0, "0 <= 0 failed");
413 ok(3.4 > 1, "3.4 > 1 failed");
414 ok(!(1 > 3.4), "1 > 3.4");
415 ok("abcd" > "abc", "abc > abcd failed");
416 ok("abce" > "abcd", "abce > abce failed");
417 ok("x" > "", "\"x\" > \"\" failed");
418 ok(!(0 > 0), "0 > 0");
420 ok(3.4 >= 1, "3.4 >= 1 failed");
421 ok(!(1 >= 3.4), "1 >= 3.4");
422 ok("abcd" >= "abc", "abc >= abcd failed");
423 ok("abce" >= "abcd", "abce >= abce failed");
424 ok("x" >= "", "\"x\" >= \"\" failed");
425 ok(0 >= 0, "0 >= 0");
427 tmp = 1;
428 ok(++tmp === 2, "++tmp (1) is not 2");
429 ok(tmp === 2, "incremented tmp is not 2");
430 ok(--tmp === 1, "--tmp (2) is not 1");
431 ok(tmp === 1, "decremented tmp is not 1");
432 ok(tmp++ === 1, "tmp++ (1) is not 1");
433 ok(tmp === 2, "incremented tmp(1) is not 2");
434 ok(tmp-- === 2, "tmp-- (2) is not 2");
435 ok(tmp === 1, "decremented tmp is not 1");
437 String.prototype.test = true;
438 ok("".test === true, "\"\".test is not true");
440 Boolean.prototype.test = true;
441 ok(true.test === true, "true.test is not true");
443 Number.prototype.test = true;
444 ok((0).test === true, "(0).test is not true");
445 ok((0.5).test === true, "(0.5).test is not true");
447 var state = "";
448 try {
449     ok(state === "", "try: state = " + state);
450     state = "try";
451 }catch(ex) {
452     ok(false, "unexpected catch");
454 ok(state === "try", "state = " + state + " expected try");
456 state = "";
457 try {
458     ok(state === "", "try: state = " + state);
459     state = "try";
460 }finally {
461     ok(state === "try", "funally: state = " + state);
462     state = "finally";
464 ok(state === "finally", "state = " + state + " expected finally");
466 state = "";
467 try {
468     ok(state === "", "try: state = " + state);
469     state = "try";
470 }catch(ex) {
471     ok(false, "unexpected catch");
472 }finally {
473     ok(state === "try", "funally: state = " + state);
474     state = "finally";
476 ok(state === "finally", "state = " + state + " expected finally");
478 var state = "";
479 try {
480     ok(state === "", "try: state = " + state);
481     state = "try";
482     throw "except";
483 }catch(ex) {
484     ok(state === "try", "catch: state = " + state);
485     ok(ex === "except", "ex is not \"except\"");
486     state = "catch";
488 ok(state === "catch", "state = " + state + " expected catch");
490 var state = "";
491 try {
492     ok(state === "", "try: state = " + state);
493     state = "try";
494     throw true;
495 }catch(ex) {
496     ok(state === "try", "catch: state = " + state);
497     ok(ex === true, "ex is not true");
498     state = "catch";
499 }finally {
500     ok(state === "catch", "funally: state = " + state);
501     state = "finally";
503 ok(state === "finally", "state = " + state + " expected finally");
505 var state = "";
506 try {
507     ok(state === "", "try: state = " + state);
508     state = "try";
509     try { throw true; } finally {}
510 }catch(ex) {
511     ok(state === "try", "catch: state = " + state);
512     ok(ex === true, "ex is not true");
513     state = "catch";
514 }finally {
515     ok(state === "catch", "funally: state = " + state);
516     state = "finally";
518 ok(state === "finally", "state = " + state + " expected finally");
520 var state = "";
521 try {
522     ok(state === "", "try: state = " + state);
523     state = "try";
524     try { throw "except"; } catch(ex) { throw true; }
525 }catch(ex) {
526     ok(state === "try", "catch: state = " + state);
527     ok(ex === true, "ex is not true");
528     state = "catch";
529 }finally {
530     ok(state === "catch", "funally: state = " + state);
531     state = "finally";
533 ok(state === "finally", "state = " + state + " expected finally");
535 function throwFunc(x) {
536     throw x;
539 var state = "";
540 try {
541     ok(state === "", "try: state = " + state);
542     state = "try";
543     throwFunc(true);
544 }catch(ex) {
545     ok(state === "try", "catch: state = " + state);
546     ok(ex === true, "ex is not true");
547     state = "catch";
548 }finally {
549     ok(state === "catch", "funally: state = " + state);
550     state = "finally";
552 ok(state === "finally", "state = " + state + " expected finally");
554 state = "";
555 switch(1) {
556 case "1":
557     ok(false, "unexpected case \"1\"");
558 case 1:
559     ok(state === "", "case 1: state = " + state);
560     state = "1";
561 default:
562     ok(state === "1", "default: state = " + state);
563     state = "default";
564 case false:
565     ok(state === "default", "case false: state = " + state);
566     state = "false";
568 ok(state === "false", "state = " + state);
570 state = "";
571 switch("") {
572 case "1":
573 case 1:
574     ok(false, "unexpected case 1");
575 default:
576     ok(state === "", "default: state = " + state);
577     state = "default";
578 case false:
579     ok(state === "default", "case false: state = " + state);
580     state = "false";
582 ok(state === "false", "state = " + state);
584 state = "";
585 switch(1) {
586 case "1":
587     ok(false, "unexpected case \"1\"");
588 case 1:
589     ok(state === "", "case 1: state = " + state);
590     state = "1";
591 default:
592     ok(state === "1", "default: state = " + state);
593     state = "default";
594     break;
595 case false:
596     ok(false, "unexpected case false");
598 ok(state === "default", "state = " + state);
600 tmp = eval("1");
601 ok(tmp === 1, "eval(\"1\") !== 1");
602 eval("{ ok(tmp === 1, 'eval: tmp !== 1'); } tmp = 2;");
603 ok(tmp === 2, "tmp !== 2");
605 ok(eval(false) === false, "eval(false) !== false");
606 ok(eval() === undefined, "eval() !== undefined");
608 tmp = eval("1", "2");
609 ok(tmp === 1, "eval(\"1\", \"2\") !== 1");
611 var state = "";
612 try {
613     ok(state === "", "try: state = " + state);
614     state = "try";
615     eval("throwFunc(true);");
616 }catch(ex) {
617     ok(state === "try", "catch: state = " + state);
618     ok(ex === true, "ex is not true");
619     state = "catch";
620 }finally {
621     ok(state === "catch", "funally: state = " + state);
622     state = "finally";
624 ok(state === "finally", "state = " + state + " expected finally");
626 tmp = [,,1,2,,,true];
627 ok(tmp.length === 7, "tmp.length !== 7");
628 ok(tmp["0"] === undefined, "tmp[0] is not undefined");
629 ok(tmp["3"] === 2, "tmp[3] !== 2");
630 ok(tmp["6"] === true, "tmp[6] !== true");
631 ok(tmp[2] === 1, "tmp[2] !== 1");
633 ok([1,].length === 2, "[1,].length !== 2");
634 ok([,,].length === 3, "[,,].length !== 3");
635 ok([,].length === 2, "[].length != 2");
636 ok([].length === 0, "[].length != 0");
638 tmp = 0;
639 while(tmp < 4) {
640     ok(tmp < 4, "tmp >= 4");
641     tmp++;
643 ok(tmp === 4, "tmp !== 4");
645 tmp = 0;
646 while(true) {
647     ok(tmp < 4, "tmp >= 4");
648     tmp++;
649     if(tmp === 4) {
650         break;
651         ok(false, "break did not break");
652     }
654 ok(tmp === 4, "tmp !== 4");
656 tmp = 0;
657 do {
658     ok(tmp < 4, "tmp >= 4");
659     tmp++;
660 } while(tmp < 4);
661 ok(tmp === 4, "tmp !== 4");
663 tmp = 0;
664 do {
665     ok(tmp === 0, "tmp !=== 0");
666     tmp++;
667 } while(false);
668 ok(tmp === 1, "tmp !== 1");
670 tmp = 0;
671 while(tmp < 4) {
672     tmp++;
673     if(tmp === 2) {
674         continue;
675         ok(false, "break did not break");
676     }
677     ok(tmp <= 4 && tmp != 2, "tmp = " + tmp);
679 ok(tmp === 4, "tmp !== 4");
681 for(tmp=0; tmp < 4; tmp++)
682     ok(tmp < 4, "tmp = " + tmp);
683 ok(tmp === 4, "tmp !== 4");
685 for(tmp=0; tmp < 4; tmp++) {
686     if(tmp === 2)
687         break;
688     ok(tmp < 2, "tmp = " + tmp);
690 ok(tmp === 2, "tmp !== 2");
692 for(tmp=0; tmp < 4; tmp++) {
693     if(tmp === 2)
694         continue;
695     ok(tmp < 4 && tmp != 2, "tmp = " + tmp);
697 ok(tmp === 4, "tmp !== 4");
699 for(var fi=0; fi < 4; fi++)
700     ok(fi < 4, "fi = " + fi);
701 ok(fi === 4, "fi !== 4");
703 ok((void 1) === undefined, "(void 1) !== undefined");
705 var inobj = new Object();
707 for(var iter in inobj)
708     ok(false, "unexpected iter = " + iter);
710 inobj.test = true;
711 tmp = 0;
712 for(iter in inobj) {
713     ok(iter == "test", "unexpected iter = " + iter);
714     tmp++;
716 ok(tmp === 1, "for..in tmp = " + tmp);
718 function forinTestObj() {}
720 forinTestObj.prototype.test3 = true;
722 var arr = new Array();
723 inobj = new forinTestObj();
724 inobj.test1 = true;
725 inobj.test2 = true;
727 tmp = 0;
728 for(iter in inobj) {
729     arr[iter] = true;
730     tmp++;
733 ok(tmp === 3, "for..in tmp = " + tmp);
734 ok(arr["test1"] === true, "arr[test1] !== true");
735 ok(arr["test2"] === true, "arr[test2] !== true");
736 ok(arr["test3"] === true, "arr[test3] !== true");
738 tmp = new Object();
739 tmp.test = false;
740 ok((delete tmp.test) === true, "delete returned false");
741 ok(typeof(tmp.test) === "undefined", "tmp.test type = " + typeof(tmp.test));
742 for(iter in tmp)
743     ok(false, "tmp has prop " + iter);
745 tmp.testWith = true;
746 with(tmp)
747     ok(testWith === true, "testWith !== true");
749 if(false) {
750     var varTest1 = true;
753 ok(varTest1 === undefined, "varTest1 = " + varTest1);
754 ok(varTest2 === undefined, "varTest2 = " + varTest1);
756 var varTest2;
758 function varTestFunc(varTest3) {
759     var varTest3;
761     ok(varTest3 === 3, "varTest3 = " + varTest3);
762     ok(varTest4 === undefined, "varTest4 = " + varTest4);
764     var varTest4;
767 varTestFunc(3);
769 deleteTest = 1;
770 delete deleteTest;
771 try {
772     tmp = deleteTest;
773     ok(false, "deleteTest not throwed exception?");
774 }catch(ex) {}
776 reportSuccess();