2 * Copyright 2008 Jacek Caban for CodeWeavers
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.
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.
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
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");
36 ok(1E0 === 1, "1E0 === 1 is false");
37 ok(1000000*1000000 === 1000000000000, "1000000*1000000 === 1000000000000 is false");
38 ok(8.64e15 === 8640000000000000, "8.64e15 !== 8640000000000000");
39 ok(1e2147483648 === Infinity, "1e2147483648 !== Infinity");
41 ok(1 !== 2, "1 !== 2 is false");
42 ok(null !== undefined, "null !== undefined is false");
44 ok(1 == 1, "1 == 1 is false");
45 ok(!(1 == 2), "!(1 == 2) is false");
46 ok(1.0 == 1, "1.0 == 1 is false");
47 ok("abc" == "abc", "\"abc\" == \"abc\" is false");
48 ok(true == true, "true == true is false");
49 ok(null == null, "null == null is false");
50 ok(undefined == undefined, "undefined == undefined is false");
51 ok(undefined == null, "undefined == null is false");
52 ok(true == 1, "true == 1 is false");
53 ok(!(true == 2), "true == 2");
54 ok(0 == false, "0 == false is false");
56 ok(1 != 2, "1 != 2 is false");
57 ok(false != 1, "false != 1 is false");
60 ok(trueVar, "trueVar is not true");
62 ok(ScriptEngine.length === 0, "ScriptEngine.length is not 0");
64 function testFunc1(x, y) {
65 ok(this !== undefined, "this is undefined");
66 ok(x === true, "x is not true");
67 ok(y === "test", "y is not \"test\"");
68 ok(arguments.length === 2, "arguments.length is not 2");
69 ok(arguments["0"] === true, "arguments[0] is not true");
70 ok(arguments["1"] === "test", "arguments[1] is not \"test\"");
71 ok(arguments.callee === testFunc1, "arguments.calee !== testFunc1");
76 ok(testFunc1.length === 2, "testFunc1.length is not 2");
78 ok(Object.prototype !== undefined, "Object.prototype is undefined");
79 ok(Object.prototype.prototype === undefined, "Object.prototype is not undefined");
80 ok(String.prototype !== undefined, "String.prototype is undefined");
81 ok(Array.prototype !== undefined, "Array.prototype is undefined");
82 ok(Boolean.prototype !== undefined, "Boolean.prototype is undefined");
83 ok(Number.prototype !== undefined, "Number.prototype is undefined");
84 ok(RegExp.prototype !== undefined, "RegExp.prototype is undefined");
85 ok(Math !== undefined, "Math is undefined");
86 ok(Math.prototype === undefined, "Math.prototype is not undefined");
87 ok(Function.prototype !== undefined, "Function.prototype is undefined");
88 ok(Function.prototype.prototype === undefined, "Function.prototype.prototype is not undefined");
89 ok(Date.prototype !== undefined, "Date.prototype is undefined");
90 ok(Date.prototype.prototype === undefined, "Date.prototype is not undefined");
92 Function.prototype.test = true;
93 ok(testFunc1.test === true, "testFunc1.test !== true");
94 ok(Function.test === true, "Function.test !== true");
96 ok(typeof(0) === "number", "typeof(0) is not number");
97 ok(typeof(1.5) === "number", "typeof(1.5) is not number");
98 ok(typeof("abc") === "string", "typeof(\"abc\") is not string");
99 ok(typeof("") === "string", "typeof(\"\") is not string");
100 ok(typeof(true) === "boolean", "typeof(true) is not boolean");
101 ok(typeof(null) === "object", "typeof(null) is not object");
102 ok(typeof(undefined) === "undefined", "typeof(undefined) is not undefined");
103 ok(typeof(Math) === "object", "typeof(Math) is not object");
104 ok(typeof(String.prototype) === "object", "typeof(String.prototype) is not object");
105 ok(typeof(testFunc1) === "function", "typeof(testFunc1) is not function");
106 ok(typeof(String) === "function", "typeof(String) is not function");
107 ok(typeof(ScriptEngine) === "function", "typeof(ScriptEngine) is not function");
108 ok(typeof(this) === "object", "typeof(this) is not object");
110 ok(testFunc1(true, "test") === true, "testFunc1 not returned true");
112 tmp = (function() {1;})();
113 ok(tmp === undefined, "tmp = " + tmp);
115 ok(tmp === 1, "tmp = " + tmp);
117 var obj1 = new Object();
118 ok(typeof(obj1) === "object", "typeof(obj1) is not object");
120 obj1.func = function () {
121 ok(this === obj1, "this is not obj1");
122 ok(this.test === true, "this.test is not true");
123 ok(arguments.length === 1, "arguments.length is not 1");
124 ok(arguments["0"] === true, "arguments[0] is not true");
125 ok(typeof(arguments.callee) === "function", "typeof(arguments.calee) = " + typeof(arguments.calee));
130 ok(obj1.func(true) === "test", "obj1.func(true) is not \"test\"");
132 function testConstr1() {
135 ok(this !== undefined, "this is undefined");
136 ok(arguments.length === 1, "arguments.length is not 1");
137 ok(arguments["0"] === true, "arguments[0] is not 1");
138 ok(arguments.callee === testConstr1, "arguments.calee !== testConstr1");
143 testConstr1.prototype.pvar = 1;
145 var obj2 = new testConstr1(true);
146 ok(typeof(obj2) === "object", "typeof(obj2) is not object");
147 ok(obj2.pvar === 1, "obj2.pvar is not 1");
149 testConstr1.prototype.pvar = 2;
150 ok(obj2.pvar === 2, "obj2.pvar is not 2");
153 testConstr1.prototype.pvar = 1;
154 ok(obj2.pvar === 3, "obj2.pvar is not 3");
157 function testConstr3() {
161 obj2 = new testConstr3();
162 ok(obj1 === obj2, "obj1 != obj2");
164 function testConstr4() {
168 obj2 = new testConstr3();
169 ok(typeof(obj2) === "object", "typeof(obj2) = " + typeof(obj2));
171 var obj3 = new Object;
172 ok(typeof(obj3) === "object", "typeof(obj3) is not object");
174 for(var iter in "test")
175 ok(false, "unexpected forin call, test = " + iter);
177 for(var iter in null)
178 ok(false, "unexpected forin call, test = " + iter);
180 for(var iter in false)
181 ok(false, "unexpected forin call, test = " + iter);
187 ok(false, "else evaluated");
188 ok(tmp === 1, "tmp !== 1, if not evaluated?");
192 ok(false, "if evaluated");
195 ok(tmp === 1, "tmp !== 1, if not evaluated?");
198 ok(false, "if(false) evaluated");
203 ok(tmp === 1, "tmp !== 1, if(true) not evaluated?");
209 var obj3 = { prop1: 1, prop2: typeof(false) };
210 ok(obj3.prop1 === 1, "obj3.prop1 is not 1");
211 ok(obj3.prop2 === "boolean", "obj3.prop2 is not \"boolean\"");
217 ok(blockVar === 2, "blockVar !== 2");
219 ok((true ? 1 : 2) === 1, "conditional expression true is not 1");
220 ok((0 === 2 ? 1 : 2) === 2, "conditional expression true is not 2");
222 ok(getVT(undefined) === "VT_EMPTY", "getVT(undefined) is not VT_EMPTY");
223 ok(getVT(null) === "VT_NULL", "getVT(null) is not VT_NULL");
224 ok(getVT(0) === "VT_I4", "getVT(0) is not VT_I4");
225 ok(getVT(0.5) === "VT_R8", "getVT(1.5) is not VT_R8");
226 ok(getVT("test") === "VT_BSTR", "getVT(\"test\") is not VT_BSTR");
227 ok(getVT(Math) === "VT_DISPATCH", "getVT(Math) is not VT_DISPATCH");
228 ok(getVT(false) === "VT_BOOL", "getVT(false) is not VT_BOOL");
231 ok(tmp === 4, "2+2 !== 4");
232 ok(getVT(tmp) === "VT_I4", "getVT(2+2) !== VT_I4");
235 ok(tmp === 4.5, "2+2.5 !== 4.5");
236 ok(getVT(tmp) === "VT_R8", "getVT(2+2.5) !== VT_R8");
239 ok(tmp === 4, "1.4+2.5 !== 4");
240 ok(getVT(tmp) === "VT_I4", "getVT(1.5+2.5) !== VT_I4");
243 ok(tmp === 2, "4-2 !== 2");
244 ok(getVT(tmp) === "VT_I4", "getVT(4-2) !== VT_I4");
247 ok(tmp === 2.5, "4.5-2 !== 2.5");
248 ok(getVT(tmp) === "VT_R8", "getVT(4-2) !== VT_R8");
251 ok(tmp === 0-2, "-2 !== 0-2");
252 ok(getVT(tmp) === "VT_I4", "getVT(-2) !== VT_I4");
255 ok(tmp === 6, "2*3 !== 6");
256 ok(getVT(tmp) === "VT_I4", "getVT(2*3) !== VT_I4");
259 ok(tmp === 7, "2*3.5 !== 7");
260 ok(getVT(tmp) === "VT_I4", "getVT(2*3.5) !== VT_I4");
263 ok(tmp === 8.75, "2.5*3.5 !== 8.75");
264 ok(getVT(tmp) === "VT_R8", "getVT(2.5*3.5) !== VT_R8");
267 ok(tmp === 2, "4/2 !== 2");
268 ok(getVT(tmp) === "VT_I4", "getVT(4/2) !== VT_I4");
271 ok(tmp === 3, "4.5/1.5 !== 3");
272 ok(getVT(tmp) === "VT_I4", "getVT(4.5/1.5) !== VT_I4");
275 ok(tmp === 1.5, "3/2 !== 1.5");
276 ok(getVT(tmp) === "VT_R8", "getVT(3/2) !== VT_R8");
279 ok(tmp === 1, "3%2 = " + tmp);
282 ok(tmp ===0, "4%2 = " + tmp);
285 ok(tmp === 0.5, "3.5%1.5 = " + tmp);
288 ok(tmp === 0, "3%true = " + tmp);
291 ok(tmp === "abcd", "\"ab\" + \"cd\" !== \"abcd\"");
294 ok((tmp += 1) === 2, "tmp += 1 !== 2");
295 ok(tmp === 2, "tmp !== 2");
298 ok((tmp -= 1) === 1, "tmp -= 1 !== 1");
299 ok(tmp === 1, "tmp !=== 1");
302 ok((tmp *= 1.5) === 3, "tmp *= 1.5 !== 3");
303 ok(tmp === 3, "tmp !=== 3");
306 ok((tmp /= 2) === 2.5, "tmp /= 2 !== 2.5");
307 ok(tmp === 2.5, "tmp !=== 2.5");
310 ok((tmp %= 2) === 1, "tmp %= 2 !== 1");
311 ok(tmp === 1, "tmp !== 1");
314 ok((tmp <<= 1) === 16, "tmp <<= 1 !== 16");
317 ok((tmp >>= 1) === 4, "tmp >>= 1 !== 4");
320 ok((tmp >>>= 1) === 4, "tmp >>>= 1 !== 4");
322 tmp = 3 || ok(false, "second or expression called");
323 ok(tmp === 3, "3 || (...) is not 3");
326 ok(tmp === 2, "false || 2 is not 2");
328 tmp = 0 && ok(false, "second and expression called");
329 ok(tmp === 0, "0 && (...) is not 0");
331 tmp = true && "test";
332 ok(tmp === "test", "true && \"test\" is not \"test\"");
335 ok(tmp === 0, "true && 0 is not 0");
338 ok(tmp === 7, "3 | 4 !== 7");
339 ok(getVT(tmp) === "VT_I4", "getVT(3|4) = " + getVT(tmp));
342 ok(tmp === 3, "3.5 | 0 !== 3");
343 ok(getVT(tmp) === "VT_I4", "getVT(3.5|0) = " + getVT(tmp));
346 ok(tmp === -3, "-3.5 | 0 !== -3");
347 ok(getVT(tmp) === "VT_I4", "getVT(3.5|0) = " + getVT(tmp));
350 ok((tmp |= 0x10) === 26, "tmp(10) |= 0x10 !== 26");
351 ok(getVT(tmp) === "VT_I4", "getVT(tmp |= 10) = " + getVT(tmp));
354 ok(tmp === 1, "3 & 5 !== 1");
355 ok(getVT(tmp) === "VT_I4", "getVT(3|5) = " + getVT(tmp));
358 ok(tmp === 3, "3.5 & 0xffff !== 3 ");
359 ok(getVT(tmp) === "VT_I4", "getVT(3.5&0xffff) = " + getVT(tmp));
361 tmp = (-3.5) & 0xffffffff;
362 ok(tmp === -3, "-3.5 & 0xffff !== -3");
363 ok(getVT(tmp) === "VT_I4", "getVT(3.5&0xffff) = " + getVT(tmp));
366 ok(tmp === 16, "2 << 3 = " + tmp);
369 ok(tmp === 16, "2 << 35 = " + tmp);
372 ok(tmp === 2, "8 >> 2 = " + tmp);
375 ok(tmp === -4, "-64 >> 4 = " + tmp);
378 ok(tmp === 2, "8 >> 2 = " + tmp);
381 ok(tmp === 0x0ffffffc, "-64 >>> 4 = " + tmp);
384 ok((tmp &= 8) === 8, "tmp(10) &= 8 !== 8");
385 ok(getVT(tmp) === "VT_I4", "getVT(tmp &= 8) = " + getVT(tmp));
388 ok(tmp === 0x0ff0, "0xf0f0^0xff00 !== 0x0ff0");
389 ok(getVT(tmp) === "VT_I4", "getVT(0xf0f0^0xff00) = " + getVT(tmp));
392 ok((tmp ^= 3) === 6, "tmp(5) ^= 3 !== 6");
393 ok(getVT(tmp) === "VT_I4", "getVT(tmp ^= 3) = " + getVT(tmp));
396 ok(tmp === -2, "~1 !== -2");
397 ok(getVT(tmp) === "VT_I4", "getVT(~1) = " + getVT(tmp));
399 ok((3,4) === 4, "(3,4) !== 4");
401 ok(+3 === 3, "+3 !== 3");
402 ok(+true === 1, "+true !== 1");
403 ok(+false === 0, "+false !== 0");
404 ok(+null === 0, "+null !== 0");
405 ok(+"0" === 0, "+'0' !== 0");
406 ok(+"3" === 3, "+'3' !== 3");
407 ok(+"-3" === -3, "+'-3' !== -3");
408 ok(+"0xff" === 255, "+'0xff' !== 255");
409 ok(+"3e3" === 3000, "+'3e3' !== 3000");
412 ok(+tmp === 1, "+(new Number(1)) = " + (+tmp));
413 tmp = new String("1");
414 ok(+tmp === 1, "+(new String('1')) = " + (+tmp));
416 ok("" + 0 === "0", "\"\" + 0 !== \"0\"");
417 ok("" + 123 === "123", "\"\" + 123 !== \"123\"");
418 ok("" + (-5) === "-5", "\"\" + (-5) !== \"-5\"");
419 ok("" + null === "null", "\"\" + null !== \"null\"");
420 ok("" + undefined === "undefined", "\"\" + undefined !== \"undefined\"");
421 ok("" + true === "true", "\"\" + true !== \"true\"");
422 ok("" + false === "false", "\"\" + false !== \"false\"");
423 ok("" + 0.5 === "0.5", "'' + 0.5 = " + 0.5);
424 ok("" + (-0.5432) === "-0.5432", "'' + (-0.5432) = " + (-0.5432));
426 ok(1 < 3.4, "1 < 3.4 failed");
427 ok(!(3.4 < 1), "3.4 < 1");
428 ok("abc" < "abcd", "abc < abcd failed");
429 ok("abcd" < "abce", "abce < abce failed");
430 ok("" < "x", "\"\" < \"x\" failed");
431 ok(!(0 < 0), "0 < 0");
433 ok(1 <= 3.4, "1 <= 3.4 failed");
434 ok(!(3.4 <= 1), "3.4 <= 1");
435 ok("abc" <= "abcd", "abc <= abcd failed");
436 ok("abcd" <= "abce", "abce <= abce failed");
437 ok("" <= "x", "\"\" <= \"x\" failed");
438 ok(0 <= 0, "0 <= 0 failed");
440 ok(3.4 > 1, "3.4 > 1 failed");
441 ok(!(1 > 3.4), "1 > 3.4");
442 ok("abcd" > "abc", "abc > abcd failed");
443 ok("abce" > "abcd", "abce > abce failed");
444 ok("x" > "", "\"x\" > \"\" failed");
445 ok(!(0 > 0), "0 > 0");
447 ok(3.4 >= 1, "3.4 >= 1 failed");
448 ok(!(1 >= 3.4), "1 >= 3.4");
449 ok("abcd" >= "abc", "abc >= abcd failed");
450 ok("abce" >= "abcd", "abce >= abce failed");
451 ok("x" >= "", "\"x\" >= \"\" failed");
452 ok(0 >= 0, "0 >= 0");
455 ok(++tmp === 2, "++tmp (1) is not 2");
456 ok(tmp === 2, "incremented tmp is not 2");
457 ok(--tmp === 1, "--tmp (2) is not 1");
458 ok(tmp === 1, "decremented tmp is not 1");
459 ok(tmp++ === 1, "tmp++ (1) is not 1");
460 ok(tmp === 2, "incremented tmp(1) is not 2");
461 ok(tmp-- === 2, "tmp-- (2) is not 2");
462 ok(tmp === 1, "decremented tmp is not 1");
464 String.prototype.test = true;
465 ok("".test === true, "\"\".test is not true");
467 Boolean.prototype.test = true;
468 ok(true.test === true, "true.test is not true");
470 Number.prototype.test = true;
471 ok((0).test === true, "(0).test is not true");
472 ok((0.5).test === true, "(0.5).test is not true");
476 ok(state === "", "try: state = " + state);
479 ok(false, "unexpected catch");
481 ok(state === "try", "state = " + state + " expected try");
485 ok(state === "", "try: state = " + state);
488 ok(state === "try", "finally: state = " + state);
491 ok(state === "finally", "state = " + state + " expected finally");
495 ok(state === "", "try: state = " + state);
498 ok(false, "unexpected catch");
500 ok(state === "try", "finally: state = " + state);
503 ok(state === "finally", "state = " + state + " expected finally");
507 ok(state === "", "try: state = " + state);
511 ok(state === "try", "catch: state = " + state);
512 ok(ex === "except", "ex is not \"except\"");
515 ok(state === "catch", "state = " + state + " expected catch");
519 ok(state === "", "try: state = " + state);
523 ok(state === "try", "catch: state = " + state);
524 ok(ex === true, "ex is not true");
527 ok(state === "catch", "finally: state = " + state);
530 ok(state === "finally", "state = " + state + " expected finally");
534 ok(state === "", "try: state = " + state);
536 try { throw true; } finally {}
538 ok(state === "try", "catch: state = " + state);
539 ok(ex === true, "ex is not true");
542 ok(state === "catch", "finally: state = " + state);
545 ok(state === "finally", "state = " + state + " expected finally");
549 ok(state === "", "try: state = " + state);
551 try { throw "except"; } catch(ex) { throw true; }
553 ok(state === "try", "catch: state = " + state);
554 ok(ex === true, "ex is not true");
557 ok(state === "catch", "finally: state = " + state);
560 ok(state === "finally", "state = " + state + " expected finally");
562 function throwFunc(x) {
568 ok(state === "", "try: state = " + state);
572 ok(state === "try", "catch: state = " + state);
573 ok(ex === true, "ex is not true");
576 ok(state === "catch", "finally: state = " + state);
579 ok(state === "finally", "state = " + state + " expected finally");
584 ok(false, "unexpected case \"1\"");
586 ok(state === "", "case 1: state = " + state);
589 ok(state === "1", "default: state = " + state);
592 ok(state === "default", "case false: state = " + state);
595 ok(state === "false", "state = " + state);
601 ok(false, "unexpected case 1");
603 ok(state === "", "default: state = " + state);
606 ok(state === "default", "case false: state = " + state);
609 ok(state === "false", "state = " + state);
614 ok(false, "unexpected case \"1\"");
616 ok(state === "", "case 1: state = " + state);
619 ok(state === "1", "default: state = " + state);
623 ok(false, "unexpected case false");
625 ok(state === "default", "state = " + state);
628 ok(tmp === 1, "eval(\"1\") !== 1");
629 eval("{ ok(tmp === 1, 'eval: tmp !== 1'); } tmp = 2;");
630 ok(tmp === 2, "tmp !== 2");
632 ok(eval(false) === false, "eval(false) !== false");
633 ok(eval() === undefined, "eval() !== undefined");
635 tmp = eval("1", "2");
636 ok(tmp === 1, "eval(\"1\", \"2\") !== 1");
640 ok(state === "", "try: state = " + state);
642 eval("throwFunc(true);");
644 ok(state === "try", "catch: state = " + state);
645 ok(ex === true, "ex is not true");
648 ok(state === "catch", "finally: state = " + state);
651 ok(state === "finally", "state = " + state + " expected finally");
653 tmp = [,,1,2,,,true];
654 ok(tmp.length === 7, "tmp.length !== 7");
655 ok(tmp["0"] === undefined, "tmp[0] is not undefined");
656 ok(tmp["3"] === 2, "tmp[3] !== 2");
657 ok(tmp["6"] === true, "tmp[6] !== true");
658 ok(tmp[2] === 1, "tmp[2] !== 1");
660 ok([1,].length === 2, "[1,].length !== 2");
661 ok([,,].length === 3, "[,,].length !== 3");
662 ok([,].length === 2, "[].length != 2");
663 ok([].length === 0, "[].length != 0");
667 ok(tmp < 4, "tmp >= 4");
670 ok(tmp === 4, "tmp !== 4");
674 ok(tmp < 4, "tmp >= 4");
678 ok(false, "break did not break");
681 ok(tmp === 4, "tmp !== 4");
685 ok(tmp < 4, "tmp >= 4");
688 ok(tmp === 4, "tmp !== 4");
692 ok(tmp === 0, "tmp !=== 0");
695 ok(tmp === 1, "tmp !== 1");
699 ok(tmp < 4, "tmp >= 4");
702 ok(tmp === 4, "tmp !== 4")
709 ok(false, "break did not break");
711 ok(tmp <= 4 && tmp != 2, "tmp = " + tmp);
713 ok(tmp === 4, "tmp !== 4");
715 for(tmp=0; tmp < 4; tmp++)
716 ok(tmp < 4, "tmp = " + tmp);
717 ok(tmp === 4, "tmp !== 4");
719 for(tmp=0; tmp < 4; tmp++) {
722 ok(tmp < 2, "tmp = " + tmp);
724 ok(tmp === 2, "tmp !== 2");
726 for(tmp=0; tmp < 4; tmp++) {
729 ok(tmp < 4 && tmp != 2, "tmp = " + tmp);
731 ok(tmp === 4, "tmp !== 4");
733 for(var fi=0; fi < 4; fi++)
734 ok(fi < 4, "fi = " + fi);
735 ok(fi === 4, "fi !== 4");
737 ok((void 1) === undefined, "(void 1) !== undefined");
739 var inobj = new Object();
741 for(var iter in inobj)
742 ok(false, "unexpected iter = " + iter);
747 ok(iter == "test", "unexpected iter = " + iter);
750 ok(tmp === 1, "for..in tmp = " + tmp);
752 function forinTestObj() {}
754 forinTestObj.prototype.test3 = true;
756 var arr = new Array();
757 inobj = new forinTestObj();
767 ok(tmp === 3, "for..in tmp = " + tmp);
768 ok(arr["test1"] === true, "arr[test1] !== true");
769 ok(arr["test2"] === true, "arr[test2] !== true");
770 ok(arr["test3"] === true, "arr[test3] !== true");
774 ok((delete tmp.test) === true, "delete returned false");
775 ok(typeof(tmp.test) === "undefined", "tmp.test type = " + typeof(tmp.test));
777 ok(false, "tmp has prop " + iter);
781 ok(testWith === true, "testWith !== true");
787 ok(varTest1 === undefined, "varTest1 = " + varTest1);
788 ok(varTest2 === undefined, "varTest2 = " + varTest1);
792 function varTestFunc(varTest3) {
795 ok(varTest3 === 3, "varTest3 = " + varTest3);
796 ok(varTest4 === undefined, "varTest4 = " + varTest4);
807 ok(false, "deleteTest not throwed exception?");
812 ok(false, "if evaluated");
814 ok(false, "else should be associated with nearest if statement");
818 ok(false, "if evaluated");
820 ok(true, "else should be associated with nearest if statement");
822 function instanceOfTest() {}
823 tmp = new instanceOfTest();
825 ok((tmp instanceof instanceOfTest) === true, "tmp is not instance of instanceOfTest");
826 ok((tmp instanceof Object) === true, "tmp is not instance of Object");
827 ok((tmp instanceof String) === false, "tmp is instance of String");
829 instanceOfTest.prototype = new Object();
830 ok((tmp instanceof instanceOfTest) === false, "tmp is instance of instanceOfTest");
831 ok((tmp instanceof Object) === true, "tmp is not instance of Object");
833 ok((1 instanceof Object) === false, "1 is instance of Object");
834 ok((false instanceof Boolean) === false, "false is instance of Boolean");
835 ok(("" instanceof Object) === false, "'' is instance of Object");
838 ok((arguments instanceof Object) === true, "argument is not instance of Object");
839 ok((arguments instanceof Array) === false, "argument is not instance of Array");
840 ok(arguments.toString() === "[object Object]", "arguments.toString() = " + arguments.toString());
844 ok(("length" in obj) === true, "length is not in obj");
845 ok(("isPrototypeOf" in obj) === true, "isPrototypeOf is not in obj");
846 ok(("abc" in obj) === false, "test is in obj");
848 ok(("abc" in obj) === true, "test is not in obj");
849 ok(("1" in obj) === false, "1 is in obj");
852 ok((1 in obj) === true, "1 is not in obj");
854 ok(isNaN(NaN) === true, "isNaN(NaN) !== true");
855 ok(isNaN(0.5) === false, "isNaN(0.5) !== false");
856 ok(isNaN(Infinity) === false, "isNaN(Infinity) !== false");
857 ok(isNaN() === true, "isNaN() !== true");
858 ok(isNaN(NaN, 0) === true, "isNaN(NaN, 0) !== true");
859 ok(isNaN(0.5, NaN) === false, "isNaN(0.5, NaN) !== false");
860 ok(isNaN(+undefined) === true, "isNaN(+undefined) !== true");
862 ok(isFinite(0.5) === true, "isFinite(0.5) !== true");
863 ok(isFinite(Infinity) === false, "isFinite(Infinity) !== false");
864 ok(isFinite(-Infinity) === false, "isFinite(Infinity) !== false");
865 ok(isFinite(NaN) === false, "isFinite(NaN) !== false");
866 ok(isFinite(0.5, NaN) === true, "isFinite(0.5, NaN) !== true");
867 ok(isFinite(NaN, 0.5) === false, "isFinite(NaN, 0.5) !== false");
868 ok(isFinite() === false, "isFinite() !== false");
870 ok((1 < NaN) === false, "(1 < NaN) !== false");
871 ok((1 > NaN) === false, "(1 > NaN) !== false");
872 ok((1 <= NaN) === false, "(1 <= NaN) !== false");
873 ok((1 >= NaN) === false, "(1 >= NaN) !== false");
874 ok((NaN < 1) === false, "(NaN < 1) !== false");
875 ok((NaN > 1) === false, "(NaN > 1) !== false");
876 ok((NaN <= 1) === false, "(NaN <= 1) !== false");
877 ok((NaN >= 1) === false, "(NaN >= 1) !== false");
878 ok((Infinity < 2) === false, "(Infinity < 2) !== false");
879 ok((Infinity > 2) === true, "(Infinity > 2) !== true");
880 ok((-Infinity < 2) === true, "(-Infinity < 2) !== true");
882 ok(isNaN(+"test") === true, "isNaN(+'test') !== true");
883 ok(isNaN(+"123t") === true, "isNaN(+'123t') !== true");
884 ok(isNaN(+"Infinity x") === true, "isNaN(+'Infinity x') !== true");
885 ok(+"Infinity" === Infinity, "+'Infinity' !== Infinity");
886 ok(+" Infinity " === Infinity, "+' Infinity ' !== Infinity");
887 ok(+"-Infinity" === -Infinity, "+'-Infinity' !== -Infinity");
889 ok((NaN !== NaN) === true, "(NaN !== NaN) !== true");
890 ok((NaN === NaN) === false, "(NaN === NaN) !== false");
891 ok((Infinity !== NaN) === true, "(Infinity !== NaN) !== true");
892 ok((Infinity !== NaN) === true, "(Infinity !== NaN) !== true");
893 ok((0 === NaN) === false, "(0 === NaN) !== false");
895 ok((NaN != NaN) === true, "(NaN !== NaN) != true");
896 ok((NaN == NaN) === false, "(NaN === NaN) != false");
897 ok((Infinity != NaN) === true, "(Infinity != NaN) !== true");
898 ok((Infinity != NaN) === true, "(Infinity != NaN) !== true");
899 ok((0 == NaN) === false, "(0 === NaN) != false");
902 ok(typeof(testFunc2) === "function", "typeof(testFunc2) = " + typeof(testFunc2));
904 ok(tmp === 2, "testFunc2(1) = " + tmp);
905 function testFunc2(x) { return x+1; }
907 ok(typeof(testFunc3) === "function", "typeof(testFunc3) = " + typeof(testFunc3));
909 ok(tmp === 3, "testFunc3(1) = " + tmp);
910 tmp = function testFunc3(x) { return x+2; };
913 ok(tmp === 5, "testFunc4(1) = " + tmp);
914 tmp = function testFunc4(x) { return x+3; };
917 ok(testFunc4 === 1, "testFunc4 = " + testFunc4);
918 ok(tmp === 5, "testFunc4(1) = " + tmp);
919 tmp = function testFunc4(x) { return x+4; };
920 ok(testFunc4 === 1, "testFunc4 = " + testFunc4);
922 function testEmbededFunctions() {
923 ok(typeof(testFunc5) === "function", "typeof(testFunc5) = " + typeof(testFunc5));
925 ok(tmp === 3, "testFunc5(1) = " + tmp);
926 tmp = function testFunc5(x) { return x+2; };
929 ok(tmp === 5, "testFunc6(1) = " + tmp);
930 tmp = function testFunc6(x) { return x+3; };
932 ok(tmp === 5, "testFunc6(1) = " + tmp);
933 tmp = function testFunc6(x) { return x+4; };
935 ok(testFunc6 === 1, "testFunc4 = " + testFunc6);
938 testEmbededFunctions();
941 date.toString = function() { return "toString"; }
942 ok(""+date === "toString", "''+date = " + date);
943 date.toString = function() { return this; }
944 ok(""+date === ""+date.valueOf(), "''+date = " + date);
946 str = new String("test");
947 str.valueOf = function() { return "valueOf"; }
948 ok(""+str === "valueOf", "''+str = " + str);
949 str.valueOf = function() { return new Date(); }
950 ok(""+str === "test", "''+str = " + str);
952 ok((function (){return 1;})() === 1, "(function (){return 1;})() = " + (function (){return 1;})());
954 var re = /=(\?|%3F)/g;
955 ok(re.source === "=(\\?|%3F)", "re.source = " + re.source);
958 for(var i=0; i<2; i++)
960 ok(tmp[0] != tmp[1], "tmp[0] == tmp [1]");
962 ok(createNullBSTR() === '', "createNullBSTR() !== ''");
964 ok(getVT(nullDisp) === "VT_DISPATCH", "getVT(nullDisp) = " + getVT(nullDisp));
965 ok(typeof(nullDisp) === "object", "typeof(nullDisp) = " + typeof(nullDisp));
966 ok(nullDisp === nullDisp, "nullDisp !== nullDisp");
967 ok(nullDisp !== re, "nullDisp === re");
968 ok(nullDisp === null, "nullDisp === null");
969 ok(nullDisp == null, "nullDisp == null");
970 ok(getVT(true && nullDisp) === "VT_DISPATCH",
971 "getVT(0 && nullDisp) = " + getVT(true && nullDisp));
972 ok(!nullDisp === true, "!nullDisp = " + !nullDisp);
973 ok(String(nullDisp) === "null", "String(nullDisp) = " + String(nullDisp));
974 ok(nullDisp != new Object(), "nullDisp == new Object()");
975 ok(new Object() != nullDisp, "new Object() == nullDisp");
976 ok((typeof Object(nullDisp)) === "object", "typeof Object(nullDisp) !== 'object'");
977 tmp = getVT(Object(nullDisp));
978 ok(tmp === "VT_DISPATCH", "getVT(Object(nullDisp) = " + tmp);
979 tmp = Object(nullDisp).toString();
980 ok(tmp === "[object Object]", "Object(nullDisp).toString() = " + tmp);
982 function do_test() {}
983 function nosemicolon() {} nosemicolon();
984 function () {} nosemicolon();
987 function in_if_false() { return true; } ok(false, "!?");
990 ok(in_if_false(), "in_if_false failed");
992 ok(typeof(doesnotexist) === "undefined", "typeof(doesnotexist) = " + typeof(doesnotexist));
994 (function() { newValue = 1; })();
995 ok(newValue === 1, "newValue = " + newValue);