push 15b96ea46b12fa9aa8d3d4072be1bf1f7af34661
[wine/hacks.git] / dlls / jscript / tests / lang.js
blob82e865f4159ca6bcca806df1242d0845a984d663
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 = "ab" + "cd";
252 ok(tmp === "abcd", "\"ab\" + \"cd\" !== \"abcd\"");
254 tmp = 1;
255 ok((tmp += 1) === 2, "tmp += 1 !== 2");
256 ok(tmp === 2, "tmp !== 2");
258 tmp = 2;
259 ok((tmp -= 1) === 1, "tmp -= 1 !== 1");
260 ok(tmp === 1, "tmp !=== 1");
262 tmp = 2;
263 ok((tmp *= 1.5) === 3, "tmp *= 1.5 !== 3");
264 ok(tmp === 3, "tmp !=== 3");
266 tmp = 5;
267 ok((tmp /= 2) === 2.5, "tmp /= 2 !== 2.5");
268 ok(tmp === 2.5, "tmp !=== 2.5");
270 tmp = 8;
271 ok((tmp <<= 1) === 16, "tmp <<= 1 !== 16");
273 tmp = 8;
274 ok((tmp >>= 1) === 4, "tmp >>= 1 !== 4");
276 tmp = 8;
277 ok((tmp >>>= 1) === 4, "tmp >>>= 1 !== 4");
279 tmp = 3 || ok(false, "second or expression called");
280 ok(tmp === 3, "3 || (...) is not 3");
282 tmp = false || 2;
283 ok(tmp === 2, "false || 2 is not 2");
285 tmp = 0 && ok(false, "second and expression called");
286 ok(tmp === 0, "0 && (...) is not 0");
288 tmp = true && "test";
289 ok(tmp === "test", "true && \"test\" is not \"test\"");
291 tmp = true && 0;
292 ok(tmp === 0, "true && 0 is not 0");
294 tmp = 3 | 4;
295 ok(tmp === 7, "3 | 4 !== 7");
296 ok(getVT(tmp) === "VT_I4", "getVT(3|4) = " + getVT(tmp));
298 tmp = 3.5 | 0;
299 ok(tmp === 3, "3.5 | 0 !== 3");
300 ok(getVT(tmp) === "VT_I4", "getVT(3.5|0) = " + getVT(tmp));
302 tmp = -3.5 | 0;
303 ok(tmp === -3, "-3.5 | 0 !== -3");
304 ok(getVT(tmp) === "VT_I4", "getVT(3.5|0) = " + getVT(tmp));
306 tmp = 10;
307 ok((tmp |= 0x10) === 26, "tmp(10) |= 0x10 !== 26");
308 ok(getVT(tmp) === "VT_I4", "getVT(tmp |= 10) = " + getVT(tmp));
310 tmp = 3 & 5;
311 ok(tmp === 1, "3 & 5 !== 1");
312 ok(getVT(tmp) === "VT_I4", "getVT(3|5) = " + getVT(tmp));
314 tmp = 3.5 & 0xffff;
315 ok(tmp === 3, "3.5 & 0xffff !== 3 ");
316 ok(getVT(tmp) === "VT_I4", "getVT(3.5&0xffff) = " + getVT(tmp));
318 tmp = (-3.5) & 0xffffffff;
319 ok(tmp === -3, "-3.5 & 0xffff !== -3");
320 ok(getVT(tmp) === "VT_I4", "getVT(3.5&0xffff) = " + getVT(tmp));
322 tmp = 2 << 3;
323 ok(tmp === 16, "2 << 3 = " + tmp);
325 tmp = 2 << 35;
326 ok(tmp === 16, "2 << 35 = " + tmp);
328 tmp = 8 >> 2;
329 ok(tmp === 2, "8 >> 2 = " + tmp);
331 tmp = -64 >> 4;
332 ok(tmp === -4, "-64 >> 4 = " + tmp);
334 tmp = 8 >>> 2;
335 ok(tmp === 2, "8 >> 2 = " + tmp);
337 tmp = -64 >>> 4;
338 ok(tmp === 0x0ffffffc, "-64 >>> 4 = " + tmp);
340 tmp = 10;
341 ok((tmp &= 8) === 8, "tmp(10) &= 8 !== 8");
342 ok(getVT(tmp) === "VT_I4", "getVT(tmp &= 8) = " + getVT(tmp));
344 tmp = 0xf0f0^0xff00;
345 ok(tmp === 0x0ff0, "0xf0f0^0xff00 !== 0x0ff0");
346 ok(getVT(tmp) === "VT_I4", "getVT(0xf0f0^0xff00) = " + getVT(tmp));
348 tmp = 5;
349 ok((tmp ^= 3) === 6, "tmp(5) ^= 3 !== 6");
350 ok(getVT(tmp) === "VT_I4", "getVT(tmp ^= 3) = " + getVT(tmp));
352 tmp = ~1;
353 ok(tmp === -2, "~1 !== -2");
354 ok(getVT(tmp) === "VT_I4", "getVT(~1) = " + getVT(tmp));
356 ok((3,4) === 4, "(3,4) !== 4");
358 ok(+3 === 3, "+3 !== 3");
359 ok(+true === 1, "+true !== 1");
360 ok(+false === 0, "+false !== 0");
361 ok(+null === 0, "+null !== 0");
362 ok(+"0" === 0, "+'0' !== 0");
363 ok(+"3" === 3, "+'3' !== 3");
364 ok(+"-3" === -3, "+'-3' !== -3");
365 ok(+"0xff" === 255, "+'0xff' !== 255");
366 ok(+"3e3" === 3000, "+'3e3' !== 3000");
368 tmp = new Number(1);
369 ok(+tmp === 1, "ToNumber(new Number(1)) = " + (+tmp));
370 tmp = new String("1");
371 ok(+tmp === 1, "ToNumber(new String('1')) = " + (+tmp));
373 ok("" + 0 === "0", "\"\" + 0 !== \"0\"");
374 ok("" + 123 === "123", "\"\" + 123 !== \"123\"");
375 ok("" + (-5) === "-5", "\"\" + (-5) !== \"-5\"");
376 ok("" + null === "null", "\"\" + null !== \"null\"");
377 ok("" + undefined === "undefined", "\"\" + undefined !== \"undefined\"");
378 ok("" + true === "true", "\"\" + true !== \"true\"");
379 ok("" + false === "false", "\"\" + false !== \"false\"");
380 ok("" + 0.5 === "0.5", "'' + 0.5 = " + 0.5);
381 ok("" + (-0.5432) === "-0.5432", "'' + (-0.5432) = " + (-0.5432));
383 ok(1 < 3.4, "1 < 3.4 failed");
384 ok(!(3.4 < 1), "3.4 < 1");
385 ok("abc" < "abcd", "abc < abcd failed");
386 ok("abcd" < "abce", "abce < abce failed");
387 ok("" < "x", "\"\" < \"x\" failed");
388 ok(!(0 < 0), "0 < 0");
390 ok(1 <= 3.4, "1 <= 3.4 failed");
391 ok(!(3.4 <= 1), "3.4 <= 1");
392 ok("abc" <= "abcd", "abc <= abcd failed");
393 ok("abcd" <= "abce", "abce <= abce failed");
394 ok("" <= "x", "\"\" <= \"x\" failed");
395 ok(0 <= 0, "0 <= 0 failed");
397 ok(3.4 > 1, "3.4 > 1 failed");
398 ok(!(1 > 3.4), "1 > 3.4");
399 ok("abcd" > "abc", "abc > abcd failed");
400 ok("abce" > "abcd", "abce > abce failed");
401 ok("x" > "", "\"x\" > \"\" failed");
402 ok(!(0 > 0), "0 > 0");
404 ok(3.4 >= 1, "3.4 >= 1 failed");
405 ok(!(1 >= 3.4), "1 >= 3.4");
406 ok("abcd" >= "abc", "abc >= abcd failed");
407 ok("abce" >= "abcd", "abce >= abce failed");
408 ok("x" >= "", "\"x\" >= \"\" failed");
409 ok(0 >= 0, "0 >= 0");
411 tmp = 1;
412 ok(++tmp === 2, "++tmp (1) is not 2");
413 ok(tmp === 2, "incremented tmp is not 2");
414 ok(--tmp === 1, "--tmp (2) is not 1");
415 ok(tmp === 1, "decremented tmp is not 1");
416 ok(tmp++ === 1, "tmp++ (1) is not 1");
417 ok(tmp === 2, "incremented tmp(1) is not 2");
418 ok(tmp-- === 2, "tmp-- (2) is not 2");
419 ok(tmp === 1, "decremented tmp is not 1");
421 String.prototype.test = true;
422 ok("".test === true, "\"\".test is not true");
424 Boolean.prototype.test = true;
425 ok(true.test === true, "true.test is not true");
427 Number.prototype.test = true;
428 ok((0).test === true, "(0).test is not true");
429 ok((0.5).test === true, "(0.5).test is not true");
431 var state = "";
432 try {
433     ok(state === "", "try: state = " + state);
434     state = "try";
435 }catch(ex) {
436     ok(false, "unexpected catch");
438 ok(state === "try", "state = " + state + " expected try");
440 state = "";
441 try {
442     ok(state === "", "try: state = " + state);
443     state = "try";
444 }finally {
445     ok(state === "try", "funally: state = " + state);
446     state = "finally";
448 ok(state === "finally", "state = " + state + " expected finally");
450 state = "";
451 try {
452     ok(state === "", "try: state = " + state);
453     state = "try";
454 }catch(ex) {
455     ok(false, "unexpected catch");
456 }finally {
457     ok(state === "try", "funally: state = " + state);
458     state = "finally";
460 ok(state === "finally", "state = " + state + " expected finally");
462 var state = "";
463 try {
464     ok(state === "", "try: state = " + state);
465     state = "try";
466     throw "except";
467 }catch(ex) {
468     ok(state === "try", "catch: state = " + state);
469     ok(ex === "except", "ex is not \"except\"");
470     state = "catch";
472 ok(state === "catch", "state = " + state + " expected catch");
474 var state = "";
475 try {
476     ok(state === "", "try: state = " + state);
477     state = "try";
478     throw true;
479 }catch(ex) {
480     ok(state === "try", "catch: state = " + state);
481     ok(ex === true, "ex is not true");
482     state = "catch";
483 }finally {
484     ok(state === "catch", "funally: state = " + state);
485     state = "finally";
487 ok(state === "finally", "state = " + state + " expected finally");
489 var state = "";
490 try {
491     ok(state === "", "try: state = " + state);
492     state = "try";
493     try { throw true; } finally {}
494 }catch(ex) {
495     ok(state === "try", "catch: state = " + state);
496     ok(ex === true, "ex is not true");
497     state = "catch";
498 }finally {
499     ok(state === "catch", "funally: state = " + state);
500     state = "finally";
502 ok(state === "finally", "state = " + state + " expected finally");
504 var state = "";
505 try {
506     ok(state === "", "try: state = " + state);
507     state = "try";
508     try { throw "except"; } catch(ex) { throw true; }
509 }catch(ex) {
510     ok(state === "try", "catch: state = " + state);
511     ok(ex === true, "ex is not true");
512     state = "catch";
513 }finally {
514     ok(state === "catch", "funally: state = " + state);
515     state = "finally";
517 ok(state === "finally", "state = " + state + " expected finally");
519 function throwFunc(x) {
520     throw x;
523 var state = "";
524 try {
525     ok(state === "", "try: state = " + state);
526     state = "try";
527     throwFunc(true);
528 }catch(ex) {
529     ok(state === "try", "catch: state = " + state);
530     ok(ex === true, "ex is not true");
531     state = "catch";
532 }finally {
533     ok(state === "catch", "funally: state = " + state);
534     state = "finally";
536 ok(state === "finally", "state = " + state + " expected finally");
538 state = "";
539 switch(1) {
540 case "1":
541     ok(false, "unexpected case \"1\"");
542 case 1:
543     ok(state === "", "case 1: state = " + state);
544     state = "1";
545 default:
546     ok(state === "1", "default: state = " + state);
547     state = "default";
548 case false:
549     ok(state === "default", "case false: state = " + state);
550     state = "false";
552 ok(state === "false", "state = " + state);
554 state = "";
555 switch("") {
556 case "1":
557 case 1:
558     ok(false, "unexpected case 1");
559 default:
560     ok(state === "", "default: state = " + state);
561     state = "default";
562 case false:
563     ok(state === "default", "case false: state = " + state);
564     state = "false";
566 ok(state === "false", "state = " + state);
568 state = "";
569 switch(1) {
570 case "1":
571     ok(false, "unexpected case \"1\"");
572 case 1:
573     ok(state === "", "case 1: state = " + state);
574     state = "1";
575 default:
576     ok(state === "1", "default: state = " + state);
577     state = "default";
578     break;
579 case false:
580     ok(false, "unexpected case false");
582 ok(state === "default", "state = " + state);
584 tmp = eval("1");
585 ok(tmp === 1, "eval(\"1\") !== 1");
586 eval("{ ok(tmp === 1, 'eval: tmp !== 1'); } tmp = 2;");
587 ok(tmp === 2, "tmp !== 2");
589 ok(eval(false) === false, "eval(false) !== false");
590 ok(eval() === undefined, "eval() !== undefined");
592 tmp = eval("1", "2");
593 ok(tmp === 1, "eval(\"1\", \"2\") !== 1");
595 var state = "";
596 try {
597     ok(state === "", "try: state = " + state);
598     state = "try";
599     eval("throwFunc(true);");
600 }catch(ex) {
601     ok(state === "try", "catch: state = " + state);
602     ok(ex === true, "ex is not true");
603     state = "catch";
604 }finally {
605     ok(state === "catch", "funally: state = " + state);
606     state = "finally";
608 ok(state === "finally", "state = " + state + " expected finally");
610 tmp = [,,1,2,,,true];
611 ok(tmp.length === 7, "tmp.length !== 7");
612 ok(tmp["0"] === undefined, "tmp[0] is not undefined");
613 ok(tmp["3"] === 2, "tmp[3] !== 2");
614 ok(tmp["6"] === true, "tmp[6] !== true");
615 ok(tmp[2] === 1, "tmp[2] !== 1");
617 ok([1,].length === 2, "[1,].length !== 2");
618 ok([,,].length === 3, "[,,].length !== 3");
619 ok([,].length === 2, "[].length != 2");
620 ok([].length === 0, "[].length != 0");
622 tmp = 0;
623 while(tmp < 4) {
624     ok(tmp < 4, "tmp >= 4");
625     tmp++;
627 ok(tmp === 4, "tmp !== 4");
629 tmp = 0;
630 while(true) {
631     ok(tmp < 4, "tmp >= 4");
632     tmp++;
633     if(tmp === 4) {
634         break;
635         ok(false, "break did not break");
636     }
638 ok(tmp === 4, "tmp !== 4");
640 tmp = 0;
641 do {
642     ok(tmp < 4, "tmp >= 4");
643     tmp++;
644 } while(tmp < 4);
645 ok(tmp === 4, "tmp !== 4");
647 tmp = 0;
648 do {
649     ok(tmp === 0, "tmp !=== 0");
650     tmp++;
651 } while(false);
652 ok(tmp === 1, "tmp !== 1");
654 tmp = 0;
655 while(tmp < 4) {
656     tmp++;
657     if(tmp === 2) {
658         continue;
659         ok(false, "break did not break");
660     }
661     ok(tmp <= 4 && tmp != 2, "tmp = " + tmp);
663 ok(tmp === 4, "tmp !== 4");
665 for(tmp=0; tmp < 4; tmp++)
666     ok(tmp < 4, "tmp = " + tmp);
667 ok(tmp === 4, "tmp !== 4");
669 for(tmp=0; tmp < 4; tmp++) {
670     if(tmp === 2)
671         break;
672     ok(tmp < 2, "tmp = " + tmp);
674 ok(tmp === 2, "tmp !== 2");
676 for(tmp=0; tmp < 4; tmp++) {
677     if(tmp === 2)
678         continue;
679     ok(tmp < 4 && tmp != 2, "tmp = " + tmp);
681 ok(tmp === 4, "tmp !== 4");
683 for(var fi=0; fi < 4; fi++)
684     ok(fi < 4, "fi = " + fi);
685 ok(fi === 4, "fi !== 4");
687 ok((void 1) === undefined, "(void 1) !== undefined");
689 var inobj = new Object();
691 for(var iter in inobj)
692     ok(false, "unexpected iter = " + iter);
694 inobj.test = true;
695 tmp = 0;
696 for(iter in inobj) {
697     ok(iter == "test", "unexpected iter = " + iter);
698     tmp++;
700 ok(tmp === 1, "for..in tmp = " + tmp);
702 function forinTestObj() {}
704 forinTestObj.prototype.test3 = true;
706 var arr = new Array();
707 inobj = new forinTestObj();
708 inobj.test1 = true;
709 inobj.test2 = true;
711 tmp = 0;
712 for(iter in inobj) {
713     arr[iter] = true;
714     tmp++;
717 ok(tmp === 3, "for..in tmp = " + tmp);
718 ok(arr["test1"] === true, "arr[test1] !== true");
719 ok(arr["test2"] === true, "arr[test2] !== true");
720 ok(arr["test3"] === true, "arr[test3] !== true");
722 tmp = new Object();
723 tmp.test = false;
724 ok((delete tmp.test) === true, "delete returned false");
725 ok(typeof(tmp.test) === "undefined", "tmp.test type = " + typeof(tmp.test));
726 for(iter in tmp)
727     ok(false, "tmp has prop " + iter);
729 tmp.testWith = true;
730 with(tmp)
731     ok(testWith === true, "testWith !== true");
733 if(false) {
734     var varTest1 = true;
737 ok(varTest1 === undefined, "varTest1 = " + varTest1);
738 ok(varTest2 === undefined, "varTest2 = " + varTest1);
740 var varTest2;
742 function varTestFunc(varTest3) {
743     var varTest3;
745     ok(varTest3 === 3, "varTest3 = " + varTest3);
746     ok(varTest4 === undefined, "varTest4 = " + varTest4);
748     var varTest4;
751 varTestFunc(3);
753 deleteTest = 1;
754 delete deleteTest;
755 try {
756     tmp = deleteTest;
757     ok(false, "deleteTest not throwed exception?");
758 }catch(ex) {}
760 reportSuccess();