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");
119 ok(obj1
.constructor === Object
, "unexpected obj1.constructor");
121 obj1
.func = function () {
122 ok(this === obj1
, "this is not obj1");
123 ok(this.test
=== true, "this.test is not true");
124 ok(arguments
.length
=== 1, "arguments.length is not 1");
125 ok(arguments
["0"] === true, "arguments[0] is not true");
126 ok(typeof(arguments
.callee
) === "function", "typeof(arguments.calee) = " + typeof(arguments
.calee
));
131 ok(obj1
.func(true) === "test", "obj1.func(true) is not \"test\"");
133 function testConstr1() {
136 ok(this !== undefined, "this is undefined");
137 ok(arguments
.length
=== 1, "arguments.length is not 1");
138 ok(arguments
["0"] === true, "arguments[0] is not 1");
139 ok(arguments
.callee
=== testConstr1
, "arguments.calee !== testConstr1");
144 testConstr1
.prototype.pvar
= 1;
146 var obj2
= new testConstr1(true);
147 ok(typeof(obj2
) === "object", "typeof(obj2) is not object");
148 ok(obj2
.constructor === testConstr1
, "unexpected obj2.constructor");
149 ok(obj2
.pvar
=== 1, "obj2.pvar is not 1");
151 testConstr1
.prototype.pvar
= 2;
152 ok(obj2
.pvar
=== 2, "obj2.pvar is not 2");
155 testConstr1
.prototype.pvar
= 1;
156 ok(obj2
.pvar
=== 3, "obj2.pvar is not 3");
159 function testConstr3() {
163 obj2
= new testConstr3();
164 ok(obj1
=== obj2
, "obj1 != obj2");
166 function testConstr4() {
170 obj2
= new testConstr3();
171 ok(typeof(obj2
) === "object", "typeof(obj2) = " + typeof(obj2
));
173 var obj3
= new Object
;
174 ok(typeof(obj3
) === "object", "typeof(obj3) is not object");
176 for(var iter
in "test")
177 ok(false, "unexpected forin call, test = " + iter
);
179 for(var iter
in null)
180 ok(false, "unexpected forin call, test = " + iter
);
182 for(var iter
in false)
183 ok(false, "unexpected forin call, test = " + iter
);
189 ok(false, "else evaluated");
190 ok(tmp
=== 1, "tmp !== 1, if not evaluated?");
194 ok(false, "if evaluated");
197 ok(tmp
=== 1, "tmp !== 1, if not evaluated?");
200 ok(false, "if(false) evaluated");
205 ok(tmp
=== 1, "tmp !== 1, if(true) not evaluated?");
211 var obj3
= { prop1
: 1, prop2
: typeof(false) };
212 ok(obj3
.prop1
=== 1, "obj3.prop1 is not 1");
213 ok(obj3
.prop2
=== "boolean", "obj3.prop2 is not \"boolean\"");
214 ok(obj3
.constructor === Object
, "unexpected obj3.constructor");
220 ok(blockVar
=== 2, "blockVar !== 2");
222 ok((true ? 1 : 2) === 1, "conditional expression true is not 1");
223 ok((0 === 2 ? 1 : 2) === 2, "conditional expression true is not 2");
225 ok(getVT(undefined) === "VT_EMPTY", "getVT(undefined) is not VT_EMPTY");
226 ok(getVT(null) === "VT_NULL", "getVT(null) is not VT_NULL");
227 ok(getVT(0) === "VT_I4", "getVT(0) is not VT_I4");
228 ok(getVT(0.5) === "VT_R8", "getVT(1.5) is not VT_R8");
229 ok(getVT("test") === "VT_BSTR", "getVT(\"test\") is not VT_BSTR");
230 ok(getVT(Math
) === "VT_DISPATCH", "getVT(Math) is not VT_DISPATCH");
231 ok(getVT(false) === "VT_BOOL", "getVT(false) is not VT_BOOL");
234 ok(tmp
=== 4, "2+2 !== 4");
235 ok(getVT(tmp
) === "VT_I4", "getVT(2+2) !== VT_I4");
238 ok(tmp
=== 4.5, "2+2.5 !== 4.5");
239 ok(getVT(tmp
) === "VT_R8", "getVT(2+2.5) !== VT_R8");
242 ok(tmp
=== 4, "1.4+2.5 !== 4");
243 ok(getVT(tmp
) === "VT_I4", "getVT(1.5+2.5) !== VT_I4");
246 ok(tmp
=== 2, "4-2 !== 2");
247 ok(getVT(tmp
) === "VT_I4", "getVT(4-2) !== VT_I4");
250 ok(tmp
=== 2.5, "4.5-2 !== 2.5");
251 ok(getVT(tmp
) === "VT_R8", "getVT(4-2) !== VT_R8");
254 ok(tmp
=== 0-2, "-2 !== 0-2");
255 ok(getVT(tmp
) === "VT_I4", "getVT(-2) !== VT_I4");
258 ok(tmp
=== 6, "2*3 !== 6");
259 ok(getVT(tmp
) === "VT_I4", "getVT(2*3) !== VT_I4");
262 ok(tmp
=== 7, "2*3.5 !== 7");
263 ok(getVT(tmp
) === "VT_I4", "getVT(2*3.5) !== VT_I4");
266 ok(tmp
=== 8.75, "2.5*3.5 !== 8.75");
267 ok(getVT(tmp
) === "VT_R8", "getVT(2.5*3.5) !== VT_R8");
270 ok(tmp
=== 2, "4/2 !== 2");
271 ok(getVT(tmp
) === "VT_I4", "getVT(4/2) !== VT_I4");
274 ok(tmp
=== 3, "4.5/1.5 !== 3");
275 ok(getVT(tmp
) === "VT_I4", "getVT(4.5/1.5) !== VT_I4");
278 ok(tmp
=== 1.5, "3/2 !== 1.5");
279 ok(getVT(tmp
) === "VT_R8", "getVT(3/2) !== VT_R8");
282 ok(tmp
=== 1, "3%2 = " + tmp
);
285 ok(tmp
===0, "4%2 = " + tmp
);
288 ok(tmp
=== 0.5, "3.5%1.5 = " + tmp
);
291 ok(tmp
=== 0, "3%true = " + tmp
);
294 ok(tmp
=== "abcd", "\"ab\" + \"cd\" !== \"abcd\"");
297 ok((tmp
+= 1) === 2, "tmp += 1 !== 2");
298 ok(tmp
=== 2, "tmp !== 2");
301 ok((tmp
-= 1) === 1, "tmp -= 1 !== 1");
302 ok(tmp
=== 1, "tmp !=== 1");
305 ok((tmp
*= 1.5) === 3, "tmp *= 1.5 !== 3");
306 ok(tmp
=== 3, "tmp !=== 3");
309 ok((tmp
/= 2) === 2.5, "tmp /= 2 !== 2.5");
310 ok(tmp === 2.5, "tmp
!=== 2.5");
313 ok((tmp %= 2) === 1, "tmp
%= 2 !== 1");
314 ok(tmp === 1, "tmp
!== 1");
317 ok((tmp <<= 1) === 16, "tmp
<<= 1 !== 16");
320 ok((tmp >>= 1) === 4, "tmp
>>= 1 !== 4");
323 ok((tmp >>>= 1) === 4, "tmp
>>>= 1 !== 4");
325 tmp = 3 || ok(false, "second or expression called
");
326 ok(tmp === 3, "3 || (...) is not
3");
329 ok(tmp === 2, "false || 2 is not
2");
331 tmp = 0 && ok(false, "second and expression called
");
332 ok(tmp === 0, "0 && (...) is not
0");
334 tmp = true && "test
";
335 ok(tmp === "test
", "true && \"test
\" is not
\"test
\"");
338 ok(tmp === 0, "true && 0 is not
0");
341 ok(tmp === 7, "3 | 4 !== 7");
342 ok(getVT(tmp) === "VT_I4
", "getVT(3|4) = " + getVT(tmp));
345 ok(tmp === 3, "3.5 | 0 !== 3");
346 ok(getVT(tmp) === "VT_I4
", "getVT(3.5|0) = " + getVT(tmp));
349 ok(tmp === -3, "-3.5 | 0 !== -3");
350 ok(getVT(tmp) === "VT_I4
", "getVT(3.5|0) = " + getVT(tmp));
353 ok(tmp === 0, "0 | NaN
= " + tmp);
356 ok(tmp === 0, "0 | NaN
= " + tmp);
358 tmp = 0 | (-Infinity);
359 ok(tmp === 0, "0 | NaN
= " + tmp);
362 ok((tmp |= 0x10) === 26, "tmp(10) |= 0x10 !== 26");
363 ok(getVT(tmp) === "VT_I4
", "getVT(tmp
|= 10) = " + getVT(tmp));
366 ok(tmp === 1, "3 & 5 !== 1");
367 ok(getVT(tmp) === "VT_I4
", "getVT(3|5) = " + getVT(tmp));
370 ok(tmp === 3, "3.5 & 0xffff !== 3 ");
371 ok(getVT(tmp) === "VT_I4
", "getVT(3.5&0xffff) = " + getVT(tmp));
373 tmp = (-3.5) & 0xffffffff;
374 ok(tmp === -3, "-3.5 & 0xffff !== -3");
375 ok(getVT(tmp) === "VT_I4
", "getVT(3.5&0xffff) = " + getVT(tmp));
378 ok(tmp === 16, "2 << 3 = " + tmp);
381 ok(tmp === 16, "2 << 35 = " + tmp);
384 ok(tmp === 2, "8 >> 2 = " + tmp);
387 ok(tmp === -4, "-64 >> 4 = " + tmp);
390 ok(tmp === 2, "8 >> 2 = " + tmp);
393 ok(tmp === 0x0ffffffc, "-64 >>> 4 = " + tmp);
396 ok(tmp === 4, "4 >>> NaN
= " + tmp);
399 ok((tmp &= 8) === 8, "tmp(10) &= 8 !== 8");
400 ok(getVT(tmp) === "VT_I4
", "getVT(tmp
&= 8) = " + getVT(tmp));
403 ok(tmp === 0x0ff0, "0xf0f0^0xff00 !== 0x0ff0");
404 ok(getVT(tmp) === "VT_I4
", "getVT(0xf0f0^0xff00) = " + getVT(tmp));
407 ok((tmp ^= 3) === 6, "tmp(5) ^= 3 !== 6");
408 ok(getVT(tmp) === "VT_I4
", "getVT(tmp
^= 3) = " + getVT(tmp));
411 ok(tmp === -2, "~1 !== -2");
412 ok(getVT(tmp) === "VT_I4
", "getVT(~1) = " + getVT(tmp));
414 ok((3,4) === 4, "(3,4) !== 4");
416 ok(+3 === 3, "+3 !== 3");
417 ok(+true === 1, "+true !== 1");
418 ok(+false === 0, "+false !== 0");
419 ok(+null === 0, "+null !== 0");
420 ok(+"0" === 0, "+'0' !== 0");
421 ok(+"3" === 3, "+'3' !== 3");
422 ok(+"-3" === -3, "+'-3' !== -3");
423 ok(+"0xff" === 255, "+'0xff' !== 255");
424 ok(+"3e3
" === 3000, "+'3e3' !== 3000");
427 ok(+tmp === 1, "+(new Number(1)) = " + (+tmp));
428 ok(tmp.constructor === Number, "unexpected tmp
.constructor");
429 tmp = new String("1");
430 ok(+tmp === 1, "+(new String('1')) = " + (+tmp));
431 ok(tmp.constructor === String, "unexpected tmp
.constructor");
433 ok("" + 0 === "0", "\"\" + 0 !== \"0\"");
434 ok("" + 123 === "123", "\"\" + 123 !== \"123\"");
435 ok("" + (-5) === "-5", "\"\" + (-5) !== \"-5\"");
436 ok("" + null === "null", "\"\" + null !== \"null\"");
437 ok("" + undefined === "undefined", "\"\" + undefined !== \"undefined\"");
438 ok("" + true === "true", "\"\" + true !== \"true\"");
439 ok("" + false === "false", "\"\" + false !== \"false\"");
440 ok("" + 0.5 === "0.5", "'' + 0.5 = " + 0.5);
441 ok("" + (-0.5432) === "-0.5432", "'' + (-0.5432) = " + (-0.5432));
443 ok(1 < 3.4, "1 < 3.4 failed
");
444 ok(!(3.4 < 1), "3.4 < 1");
445 ok("abc
" < "abcd
", "abc
< abcd failed
");
446 ok("abcd
" < "abce
", "abce
< abce failed
");
447 ok("" < "x
", "\"\" < \"x
\" failed
");
448 ok(!(0 < 0), "0 < 0");
450 ok(1 <= 3.4, "1 <= 3.4 failed
");
451 ok(!(3.4 <= 1), "3.4 <= 1");
452 ok("abc
" <= "abcd
", "abc
<= abcd failed
");
453 ok("abcd
" <= "abce
", "abce
<= abce failed
");
454 ok("" <= "x
", "\"\" <= \"x
\" failed
");
455 ok(0 <= 0, "0 <= 0 failed
");
457 ok(3.4 > 1, "3.4 > 1 failed
");
458 ok(!(1 > 3.4), "1 > 3.4");
459 ok("abcd
" > "abc
", "abc
> abcd failed
");
460 ok("abce
" > "abcd
", "abce
> abce failed
");
461 ok("x
" > "", "\"x
\" > \"\" failed
");
462 ok(!(0 > 0), "0 > 0");
464 ok(3.4 >= 1, "3.4 >= 1 failed
");
465 ok(!(1 >= 3.4), "1 >= 3.4");
466 ok("abcd
" >= "abc
", "abc
>= abcd failed
");
467 ok("abce
" >= "abcd
", "abce
>= abce failed
");
468 ok("x
" >= "", "\"x
\" >= \"\" failed
");
469 ok(0 >= 0, "0 >= 0");
472 ok(++tmp === 2, "++tmp (1) is not
2");
473 ok(tmp === 2, "incremented tmp is not
2");
474 ok(--tmp === 1, "--tmp (2) is not
1");
475 ok(tmp === 1, "decremented tmp is not
1");
476 ok(tmp++ === 1, "tmp
++ (1) is not
1");
477 ok(tmp === 2, "incremented
tmp(1) is not
2");
478 ok(tmp-- === 2, "tmp
-- (2) is not
2");
479 ok(tmp === 1, "decremented tmp is not
1");
481 String.prototype.test = true;
482 ok("".test === true, "\"\".test is not
true");
484 Boolean.prototype.test = true;
485 ok(true.test === true, "true.test is not
true");
487 Number.prototype.test = true;
488 ok((0).test === true, "(0).test is not
true");
489 ok((0.5).test === true, "(0.5).test is not
true");
493 ok(state === "", "try: state
= " + state);
496 ok(false, "unexpected
catch");
498 ok(state === "try", "state
= " + state + " expected
try");
502 ok(state === "", "try: state
= " + state);
505 ok(state === "try", "finally: state
= " + state);
508 ok(state === "finally", "state
= " + state + " expected
finally");
512 ok(state === "", "try: state
= " + state);
515 ok(false, "unexpected
catch");
517 ok(state === "try", "finally: state
= " + state);
520 ok(state === "finally", "state
= " + state + " expected
finally");
524 ok(state === "", "try: state
= " + state);
528 ok(state === "try", "catch: state
= " + state);
529 ok(ex === "except
", "ex is not
\"except
\"");
532 ok(state === "catch", "state
= " + state + " expected
catch");
536 ok(state === "", "try: state
= " + state);
540 ok(state === "try", "catch: state
= " + state);
541 ok(ex === true, "ex is not
true");
544 ok(state === "catch", "finally: state
= " + state);
547 ok(state === "finally", "state
= " + state + " expected
finally");
551 ok(state === "", "try: state
= " + state);
553 try { throw true; } finally {}
555 ok(state === "try", "catch: state
= " + state);
556 ok(ex === true, "ex is not
true");
559 ok(state === "catch", "finally: state
= " + state);
562 ok(state === "finally", "state
= " + state + " expected
finally");
566 ok(state === "", "try: state
= " + state);
568 try { throw "except
"; } catch(ex) { throw true; }
570 ok(state === "try", "catch: state
= " + state);
571 ok(ex === true, "ex is not
true");
574 ok(state === "catch", "finally: state
= " + state);
577 ok(state === "finally", "state
= " + state + " expected
finally");
579 function throwFunc(x) {
585 ok(state === "", "try: state
= " + state);
589 ok(state === "try", "catch: state
= " + state);
590 ok(ex === true, "ex is not
true");
593 ok(state === "catch", "finally: state
= " + state);
596 ok(state === "finally", "state
= " + state + " expected
finally");
601 ok(false, "unexpected
case \"1\"");
603 ok(state === "", "case 1: state
= " + state);
606 ok(state === "1", "default: state
= " + state);
609 ok(state === "default", "case false: state
= " + state);
612 ok(state === "false", "state
= " + state);
618 ok(false, "unexpected
case 1");
620 ok(state === "", "default: state
= " + state);
623 ok(state === "default", "case false: state
= " + state);
626 ok(state === "false", "state
= " + state);
631 ok(false, "unexpected
case \"1\"");
633 ok(state === "", "case 1: state
= " + state);
636 ok(state === "1", "default: state
= " + state);
640 ok(false, "unexpected
case false");
642 ok(state === "default", "state
= " + state);
645 ok(tmp === 1, "eval(\"1\") !== 1");
646 eval("{ ok(tmp
=== 1, 'eval: tmp !== 1'); } tmp
= 2;");
647 ok(tmp === 2, "tmp
!== 2");
649 ok(eval(false) === false, "eval(false) !== false");
650 ok(eval() === undefined, "eval() !== undefined");
652 tmp = eval("1", "2");
653 ok(tmp === 1, "eval(\"1\", \"2\") !== 1");
657 ok(state === "", "try: state
= " + state);
659 eval("throwFunc(true);");
661 ok(state === "try", "catch: state
= " + state);
662 ok(ex === true, "ex is not
true");
665 ok(state === "catch", "finally: state
= " + state);
668 ok(state === "finally", "state
= " + state + " expected
finally");
670 tmp = [,,1,2,,,true];
671 ok(tmp.length === 7, "tmp
.length
!== 7");
672 ok(tmp["0"] === undefined, "tmp
[0] is not
undefined");
673 ok(tmp["3"] === 2, "tmp
[3] !== 2");
674 ok(tmp["6"] === true, "tmp
[6] !== true");
675 ok(tmp[2] === 1, "tmp
[2] !== 1");
677 ok([1,].length === 2, "[1,].length
!== 2");
678 ok([,,].length === 3, "[,,].length
!== 3");
679 ok([,].length === 2, "[].length
!= 2");
680 ok([].length === 0, "[].length
!= 0");
684 ok(tmp < 4, "tmp
>= 4");
687 ok(tmp === 4, "tmp
!== 4");
691 ok(tmp < 4, "tmp
>= 4");
695 ok(false, "break did not
break");
698 ok(tmp === 4, "tmp
!== 4");
702 ok(tmp < 4, "tmp
>= 4");
705 ok(tmp === 4, "tmp
!== 4");
709 ok(tmp === 0, "tmp
!=== 0");
712 ok(tmp === 1, "tmp
!== 1");
716 ok(tmp < 4, "tmp
>= 4");
719 ok(tmp === 4, "tmp
!== 4")
726 ok(false, "break did not
break");
728 ok(tmp <= 4 && tmp != 2, "tmp
= " + tmp);
730 ok(tmp === 4, "tmp
!== 4");
732 for(tmp=0; tmp < 4; tmp++)
733 ok(tmp < 4, "tmp
= " + tmp);
734 ok(tmp === 4, "tmp
!== 4");
736 for(tmp=0; tmp < 4; tmp++) {
739 ok(tmp < 2, "tmp
= " + tmp);
741 ok(tmp === 2, "tmp
!== 2");
743 for(tmp=0; tmp < 4; tmp++) {
746 ok(tmp < 4 && tmp != 2, "tmp
= " + tmp);
748 ok(tmp === 4, "tmp
!== 4");
750 for(var fi=0; fi < 4; fi++)
751 ok(fi < 4, "fi
= " + fi);
752 ok(fi === 4, "fi
!== 4");
754 ok((void 1) === undefined, "(void 1) !== undefined");
756 var inobj = new Object();
758 for(var iter in inobj)
759 ok(false, "unexpected iter
= " + iter);
764 ok(iter == "test
", "unexpected iter
= " + iter);
767 ok(tmp === 1, "for..in tmp
= " + tmp);
769 function forinTestObj() {}
771 forinTestObj.prototype.test3 = true;
773 var arr = new Array();
774 inobj = new forinTestObj();
784 ok(tmp === 3, "for..in tmp
= " + tmp);
785 ok(arr["test1
"] === true, "arr
[test1
] !== true");
786 ok(arr["test2
"] === true, "arr
[test2
] !== true");
787 ok(arr["test3
"] === true, "arr
[test3
] !== true");
791 ok((delete tmp.test) === true, "delete returned
false");
792 ok(typeof(tmp.test) === "undefined", "tmp
.test type
= " + typeof(tmp.test));
794 ok(false, "tmp has prop
" + iter);
798 ok(testWith === true, "testWith
!== true");
804 ok(varTest1 === undefined, "varTest1
= " + varTest1);
805 ok(varTest2 === undefined, "varTest2
= " + varTest1);
809 function varTestFunc(varTest3) {
812 ok(varTest3 === 3, "varTest3
= " + varTest3);
813 ok(varTest4 === undefined, "varTest4
= " + varTest4);
824 ok(false, "deleteTest not throwed exception
?");
829 ok(false, "if evaluated
");
831 ok(false, "else should be associated
with nearest
if statement
");
835 ok(false, "if evaluated
");
837 ok(true, "else should be associated
with nearest
if statement
");
839 function instanceOfTest() {}
840 tmp = new instanceOfTest();
842 ok((tmp instanceof instanceOfTest) === true, "tmp is not instance
of instanceOfTest
");
843 ok((tmp instanceof Object) === true, "tmp is not instance
of Object
");
844 ok((tmp instanceof String) === false, "tmp is instance
of String
");
846 instanceOfTest.prototype = new Object();
847 ok((tmp instanceof instanceOfTest) === false, "tmp is instance
of instanceOfTest
");
848 ok((tmp instanceof Object) === true, "tmp is not instance
of Object
");
850 ok((1 instanceof Object) === false, "1 is instance
of Object
");
851 ok((false instanceof Boolean) === false, "false is instance
of Boolean
");
852 ok(("" instanceof Object) === false, "'' is instance
of Object
");
855 ok((arguments instanceof Object) === true, "argument is not instance
of Object
");
856 ok((arguments instanceof Array) === false, "argument is not instance
of Array
");
857 ok(arguments.toString() === "[object Object
]", "arguments
.toString() = " + arguments.toString());
861 ok(("length
" in obj) === true, "length is not
in obj
");
862 ok(("isPrototypeOf
" in obj) === true, "isPrototypeOf is not
in obj
");
863 ok(("abc
" in obj) === false, "test is
in obj
");
865 ok(("abc
" in obj) === true, "test is not
in obj
");
866 ok(("1" in obj) === false, "1 is
in obj
");
869 ok((1 in obj) === true, "1 is not
in obj
");
874 ok(false, "expected exception
");
876 ok(!("prop
" in obj), "prop
in obj
");
878 ok(isNaN(NaN) === true, "isNaN(NaN
) !== true");
879 ok(isNaN(0.5) === false, "isNaN(0.5) !== false");
880 ok(isNaN(Infinity) === false, "isNaN(Infinity
) !== false");
881 ok(isNaN() === true, "isNaN() !== true");
882 ok(isNaN(NaN, 0) === true, "isNaN(NaN
, 0) !== true");
883 ok(isNaN(0.5, NaN) === false, "isNaN(0.5, NaN
) !== false");
884 ok(isNaN(+undefined) === true, "isNaN(+undefined) !== true");
886 ok(isFinite(0.5) === true, "isFinite(0.5) !== true");
887 ok(isFinite(Infinity) === false, "isFinite(Infinity
) !== false");
888 ok(isFinite(-Infinity) === false, "isFinite(Infinity
) !== false");
889 ok(isFinite(NaN) === false, "isFinite(NaN
) !== false");
890 ok(isFinite(0.5, NaN) === true, "isFinite(0.5, NaN
) !== true");
891 ok(isFinite(NaN, 0.5) === false, "isFinite(NaN
, 0.5) !== false");
892 ok(isFinite() === false, "isFinite() !== false");
894 ok((1 < NaN) === false, "(1 < NaN
) !== false");
895 ok((1 > NaN) === false, "(1 > NaN
) !== false");
896 ok((1 <= NaN) === false, "(1 <= NaN
) !== false");
897 ok((1 >= NaN) === false, "(1 >= NaN
) !== false");
898 ok((NaN < 1) === false, "(NaN
< 1) !== false");
899 ok((NaN > 1) === false, "(NaN
> 1) !== false");
900 ok((NaN <= 1) === false, "(NaN
<= 1) !== false");
901 ok((NaN >= 1) === false, "(NaN
>= 1) !== false");
902 ok((Infinity < 2) === false, "(Infinity
< 2) !== false");
903 ok((Infinity > 2) === true, "(Infinity
> 2) !== true");
904 ok((-Infinity < 2) === true, "(-Infinity
< 2) !== true");
906 ok(isNaN(+"test
") === true, "isNaN(+'test') !== true");
907 ok(isNaN(+"123t
") === true, "isNaN(+'123t') !== true");
908 ok(isNaN(+"Infinity x
") === true, "isNaN(+'Infinity x') !== true");
909 ok(+"Infinity
" === Infinity, "+'Infinity' !== Infinity
");
910 ok(+" Infinity
" === Infinity, "+' Infinity ' !== Infinity
");
911 ok(+"-Infinity
" === -Infinity, "+'-Infinity' !== -Infinity
");
913 ok((NaN !== NaN) === true, "(NaN
!== NaN
) !== true");
914 ok((NaN === NaN) === false, "(NaN
=== NaN
) !== false");
915 ok((Infinity !== NaN) === true, "(Infinity
!== NaN
) !== true");
916 ok((Infinity !== NaN) === true, "(Infinity
!== NaN
) !== true");
917 ok((0 === NaN) === false, "(0 === NaN
) !== false");
919 ok((NaN != NaN) === true, "(NaN
!== NaN
) != true");
920 ok((NaN == NaN) === false, "(NaN
=== NaN
) != false");
921 ok((Infinity != NaN) === true, "(Infinity
!= NaN
) !== true");
922 ok((Infinity != NaN) === true, "(Infinity
!= NaN
) !== true");
923 ok((0 == NaN) === false, "(0 === NaN
) != false");
926 ok(typeof(testFunc2) === "function", "typeof(testFunc2
) = " + typeof(testFunc2));
928 ok(tmp === 2, "testFunc2(1) = " + tmp);
929 function testFunc2(x) { return x+1; }
931 ok(typeof(testFunc3) === "function", "typeof(testFunc3
) = " + typeof(testFunc3));
933 ok(tmp === 3, "testFunc3(1) = " + tmp);
934 tmp = function testFunc3(x) { return x+2; };
937 ok(tmp === 5, "testFunc4(1) = " + tmp);
938 tmp = function testFunc4(x) { return x+3; };
941 ok(testFunc4 === 1, "testFunc4
= " + testFunc4);
942 ok(tmp === 5, "testFunc4(1) = " + tmp);
943 tmp = function testFunc4(x) { return x+4; };
944 ok(testFunc4 === 1, "testFunc4
= " + testFunc4);
946 function testEmbededFunctions() {
947 ok(typeof(testFunc5) === "function", "typeof(testFunc5
) = " + typeof(testFunc5));
949 ok(tmp === 3, "testFunc5(1) = " + tmp);
950 tmp = function testFunc5(x) { return x+2; };
953 ok(tmp === 5, "testFunc6(1) = " + tmp);
954 tmp = function testFunc6(x) { return x+3; };
956 ok(tmp === 5, "testFunc6(1) = " + tmp);
957 tmp = function testFunc6(x) { return x+4; };
959 ok(testFunc6 === 1, "testFunc4
= " + testFunc6);
962 testEmbededFunctions();
965 date.toString = function() { return "toString
"; }
966 ok(""+date === "toString
", "''+date
= " + date);
967 date.toString = function() { return this; }
968 ok(""+date === ""+date.valueOf(), "''+date
= " + date);
970 str = new String("test
");
971 str.valueOf = function() { return "valueOf
"; }
972 ok(""+str === "valueOf
", "''+str
= " + str);
973 str.valueOf = function() { return new Date(); }
974 ok(""+str === "test
", "''+str
= " + str);
976 ok((function (){return 1;})() === 1, "(function (){return 1;})() = " + (function (){return 1;})());
978 var re = /=(\?|%3F)/g;
979 ok(re.source === "=(\\?|%3F
)", "re
.source
= " + re.source);
982 for(var i=0; i<2; i++)
984 ok(tmp[0] != tmp[1], "tmp
[0] == tmp
[1]");
986 ok(createNullBSTR() === '', "createNullBSTR() !== ''");
988 ok(getVT(nullDisp) === "VT_DISPATCH
", "getVT(nullDisp
) = " + getVT(nullDisp));
989 ok(typeof(nullDisp) === "object
", "typeof(nullDisp
) = " + typeof(nullDisp));
990 ok(nullDisp === nullDisp, "nullDisp
!== nullDisp
");
991 ok(nullDisp !== re, "nullDisp
=== re
");
992 ok(nullDisp === null, "nullDisp
=== null");
993 ok(nullDisp == null, "nullDisp
== null");
994 ok(getVT(true && nullDisp) === "VT_DISPATCH
",
995 "getVT(0 && nullDisp
) = " + getVT(true && nullDisp));
996 ok(!nullDisp === true, "!nullDisp
= " + !nullDisp);
997 ok(String(nullDisp) === "null", "String(nullDisp
) = " + String(nullDisp));
998 ok(nullDisp != new Object(), "nullDisp
== new Object()");
999 ok(new Object() != nullDisp, "new Object() == nullDisp
");
1000 ok((typeof Object(nullDisp)) === "object
", "typeof Object(nullDisp
) !== 'object'");
1001 tmp = getVT(Object(nullDisp));
1002 ok(tmp === "VT_DISPATCH
", "getVT(Object(nullDisp
) = " + tmp);
1003 tmp = Object(nullDisp).toString();
1004 ok(tmp === "[object Object
]", "Object(nullDisp
).toString() = " + tmp);
1006 function do_test() {}
1007 function nosemicolon() {} nosemicolon();
1008 function () {} nosemicolon();
1011 function in_if_false() { return true; } ok(false, "!?");
1014 ok(in_if_false(), "in_if_false failed
");
1016 ok(typeof(doesnotexist) === "undefined", "typeof(doesnotexist
) = " + typeof(doesnotexist));
1018 (function() { newValue = 1; })();
1019 ok(newValue === 1, "newValue
= " + newValue);
1021 obj = {undefined: 3};
1023 /* Keep this test in the end of file */
1025 ok(undefined === 6, "undefined = " + undefined);