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(00 === 0, "00 != 0");
42 ok(010 === 8, "010 != 8");
43 ok(077 === 63, "077 != 63");
44 ok(080 === 80, "080 != 80");
45 ok(090 === 90, "090 != 90");
46 ok(018 === 18, "018 != 18");
47 tmp = 07777777777777777777777;
48 ok(typeof(tmp) === "number" && tmp > 0xffffffff, "tmp = " + tmp);
49 tmp = 07777777779777777777777;
50 ok(typeof(tmp) === "number" && tmp > 0xffffffff, "tmp = " + tmp);
51 ok(0xffffffff === 4294967295, "0xffffffff = " + 0xffffffff);
52 tmp = 0x10000000000000000000000000000000000000000000000000000000000000000;
53 ok(tmp === Math.pow(2, 256), "0x1000...00 != 2^256");
55 ok(1 !== 2, "1 !== 2 is false");
56 ok(null !== undefined, "null !== undefined is false");
58 ok(1 == 1, "1 == 1 is false");
59 ok(!(1 == 2), "!(1 == 2) is false");
60 ok(1.0 == 1, "1.0 == 1 is false");
61 ok("abc" == "abc", "\"abc\" == \"abc\" is false");
62 ok(true == true, "true == true is false");
63 ok(null == null, "null == null is false");
64 ok(undefined == undefined, "undefined == undefined is false");
65 ok(undefined == null, "undefined == null is false");
66 ok(true == 1, "true == 1 is false");
67 ok(!(true == 2), "true == 2");
68 ok(0 == false, "0 == false is false");
70 ok(1 != 2, "1 != 2 is false");
71 ok(false != 1, "false != 1 is false");
73 ok(this === test, "this !== test");
74 eval('ok(this === test, "this !== test");');
77 ok(trueVar, "trueVar is not true");
79 ok(ScriptEngine.length === 0, "ScriptEngine.length is not 0");
81 function testFunc1(x, y) {
82 ok(this !== undefined, "this is undefined");
83 ok(x === true, "x is not true");
84 ok(y === "test", "y is not \"test\"");
85 ok(arguments.length === 2, "arguments.length is not 2");
86 ok(arguments["0"] === true, "arguments[0] is not true");
87 ok(arguments["1"] === "test", "arguments[1] is not \"test\"");
88 ok(arguments.callee === testFunc1, "arguments.calee !== testFunc1");
89 ok(testFunc1.arguments === arguments, "testFunc1.arguments = " + testFunc1.arguments);
92 ok(arguments[0] === false, "arguments[0] is not false");
94 ok(y === "x", "y = " + y);
95 ok(arguments[1] === "x", "arguments[1] = " + arguments[1]);
97 ok(arguments["0x0"] === undefined, "arguments['0x0'] = " + arguments["0x0"]);
98 ok(arguments["x"] === undefined, "arguments['x'] = " + arguments["x"]);
100 ok(this === test, "this !== test");
101 eval('ok(this === test, "this !== test");');
103 tmp = delete arguments;
104 ok(tmp === false, "arguments deleted");
105 ok(typeof(arguments) === "object", "typeof(arguments) = " + typeof(arguments));
108 ok(x === 2, "x = " + x);
109 ok(arguments[0] === 2, "arguments[0] = " + arguments[0]);
114 ok(testFunc1.length === 2, "testFunc1.length is not 2");
115 ok(testFunc1.arguments === null, "testFunc1.arguments = " + testFunc1.arguments);
117 ok(Object.prototype !== undefined, "Object.prototype is undefined");
118 ok(Object.prototype.prototype === undefined, "Object.prototype is not undefined");
119 ok(String.prototype !== undefined, "String.prototype is undefined");
120 ok(Array.prototype !== undefined, "Array.prototype is undefined");
121 ok(Boolean.prototype !== undefined, "Boolean.prototype is undefined");
122 ok(Number.prototype !== undefined, "Number.prototype is undefined");
123 ok(RegExp.prototype !== undefined, "RegExp.prototype is undefined");
124 ok(Math !== undefined, "Math is undefined");
125 ok(Math.prototype === undefined, "Math.prototype is not undefined");
126 ok(Function.prototype !== undefined, "Function.prototype is undefined");
127 ok(Function.prototype.prototype === undefined, "Function.prototype.prototype is not undefined");
128 ok(Date.prototype !== undefined, "Date.prototype is undefined");
129 ok(Date.prototype.prototype === undefined, "Date.prototype is not undefined");
131 function testConstructor(constr, name, inst) {
132 ok(constr.prototype.constructor === constr, name + ".prototype.constructor !== " + name);
133 ok(constr.prototype.hasOwnProperty("constructor"), name + ".prototype.hasOwnProperty('constructor')");
138 ok(inst.constructor === constr, "(new " + name + "()).constructor !== " + name);
139 ok(!inst.hasOwnProperty("constructor"), "(new " + name + "()).hasOwnProperty('constructor')");
142 testConstructor(Object, "Object");
143 testConstructor(String, "String");
144 testConstructor(Array, "Array");
145 testConstructor(Boolean, "Boolean");
146 testConstructor(Number, "Number");
147 testConstructor(RegExp, "RegExp", /x/);
148 testConstructor(Function, "Function");
149 testConstructor(Date, "Date");
150 testConstructor(VBArray, "VBArray", new VBArray(createArray()));
151 testConstructor(Error, "Error");
152 testConstructor(EvalError, "EvalError");
153 testConstructor(RangeError, "RangeError");
154 testConstructor(ReferenceError, "ReferenceError");
155 testConstructor(RegExpError, "RegExpError");
156 testConstructor(SyntaxError, "SyntaxError");
157 testConstructor(TypeError, "TypeError");
158 testConstructor(URIError, "URIError");
160 Function.prototype.test = true;
161 ok(testFunc1.test === true, "testFunc1.test !== true");
162 ok(Function.test === true, "Function.test !== true");
164 ok(typeof(0) === "number", "typeof(0) is not number");
165 ok(typeof(1.5) === "number", "typeof(1.5) is not number");
166 ok(typeof("abc") === "string", "typeof(\"abc\") is not string");
167 ok(typeof("") === "string", "typeof(\"\") is not string");
168 ok(typeof(true) === "boolean", "typeof(true) is not boolean");
169 ok(typeof(null) === "object", "typeof(null) is not object");
170 ok(typeof(undefined) === "undefined", "typeof(undefined) is not undefined");
171 ok(typeof(Math) === "object", "typeof(Math) is not object");
172 ok(typeof(String.prototype) === "object", "typeof(String.prototype) is not object");
173 ok(typeof(testFunc1) === "function", "typeof(testFunc1) is not function");
174 ok(typeof(String) === "function", "typeof(String) is not function");
175 ok(typeof(ScriptEngine) === "function", "typeof(ScriptEngine) is not function");
176 ok(typeof(this) === "object", "typeof(this) is not object");
177 ok(typeof(doesnotexist) === "undefined", "typeof(doesnotexist) = " + typeof(doesnotexist));
178 tmp = typeof((new Object()).doesnotexist);
179 ok(tmp === "undefined", "typeof((new Object).doesnotexist = " + tmp);
180 tmp = typeof(testObj.onlyDispID);
181 ok(tmp === "unknown", "typeof(testObj.onlyDispID) = " + tmp);
183 ok("\0\0x\0\0".length === 5, "\"\\0\\0x\\0\\0\".length = " + "\0\0x\0\0".length);
184 ok("\0\0x\0\0" === String.fromCharCode(0) + "\0x\0" + String.fromCharCode(0), "\"\\0\\0x\\0\\0\" unexpected");
186 ok(testFunc1(true, "test") === true, "testFunc1 not returned true");
188 ok(testFunc1.arguments === null, "testFunc1.arguments = " + testFunc1.arguments);
191 ok(tmp === 3, "tmp = " + tmp);
194 /* VT_DATE handling */
196 ok(getVT(v_date(0)) === "VT_DATE", "vt v_date(0) = " + getVT(v_date(0)));
198 e = Date.parse("Sat Dec 30 00:00:00 1899");
199 ok(getVT(d) === "VT_DATE", "vt v_date(0) = " + getVT(d));
200 ok(getVT(+d) === "VT_R8", "vt +v_date(0) = " + getVT(d));
201 ok(getVT(d / d) === "VT_I4", "vt v_date(0) / v_date(0) = " + getVT(d / d));
202 ok((+d) === e, "+v_date(0) = " + (+d) + " expected " + e);
203 ok(("" + d).match(/^Sat Dec 30 00:00:00 .* 1899$/) != null, "+v_date(0) = " + d);
204 ok(d != d, "date d == d");
207 e = Date.parse("Mon Jan 1 12:00:00 1900");
208 ok((+d) === e, "+v_date(2.5) = " + (+d));
209 ok(("" + d).match(/^Mon Jan 1 12:00:00 .* 1900$/) != null, "+v_date(2.5) = " + d);
212 e = Date.parse("Sat Mar 28 00:00:00 2015");
213 ok((+d) === e, "+v_date(2015y) = " + (+d) + " expected " + e);
214 ok(("" + d).match(/^Sat Mar 28 00:00:00 .* 2015$/) != null, "+v_date(2015y) = " + d);
215 ok(d != d, "date d == d");
221 todo_wine_ok(getVT(v_cy(0)) === "VT_R8", "vt v_cy(0) = " + getVT(v_cy(0)));
222 todo_wine_ok(getVT(v_cy(10000)) === "VT_R8", "vt v_cy(10000) = " + getVT(v_cy(0)));
224 todo_wine_ok(getVT(d) === "VT_R8", "vt v_cy(0) = " + getVT(d));
225 todo_wine_ok(getVT(+d) === "VT_R8", "vt +v_cy(0) = " + getVT(d));
226 ok(d == 0, "v_cy(0) != 0\n");
227 ok(d === 0, "v_cy(0) !== 0\n");
228 ok("" + d === "0", "str(v_cy(0)) = " + d);
229 ok(d === d, "date d !== d");
232 ok(getVT(d) === "VT_R8", "vt v_cy(1000) = " + getVT(d));
233 ok(getVT(+d) === "VT_R8", "vt +v_cy(1000) = " + getVT(d));
234 ok(d == 0.1, "v_cy(1000) != 0, d = " + d);
235 ok(d === 0.1, "v_cy(1000) !== 0.1\n");
236 ok("" + d === "0.1", "str(v_cy(1000)) = " + d);
237 ok(d === d, "date d !== d");
240 ok(getVT(d) === "VT_R8", "vt v_cy(25000) = " + getVT(d));
241 ok(getVT(+d) === "VT_R8", "vt +v_cy(25000) = " + getVT(d));
242 ok(d === 2.5, "v_cy(25000) !== 2.5\n");
243 ok("" + d === "2.5", "str(v_cy(25000)) = " + d);
246 function testRecFunc(x) {
247 ok(testRecFunc.arguments === arguments, "testRecFunc.arguments = " + testRecFunc.arguments);
250 ok(testRecFunc.arguments === arguments, "testRecFunc.arguments = " + testRecFunc.arguments);
251 ok(testRecFunc.arguments[0] === true, "testRecFunc.arguments.x = " + testRecFunc.arguments[0]);
255 testRecFunc.arguments = 5;
256 ok(testRecFunc.arguments === null, "testRecFunc.arguments = " + testRecFunc.arguments);
258 ok(testRecFunc.arguments === null, "testRecFunc.arguments = " + testRecFunc.arguments);
260 function argumentsTest() {
261 var save = arguments;
262 with({arguments: 1}) {
263 ok(arguments === 1, "arguments = " + arguments);
265 ok(argumentsTest.arguments === save, "unexpected argumentsTest.arguments");
268 eval('ok(arguments === save, "unexpected arguments");');
269 [1,2].sort(function() {
270 ok(argumentsTest.arguments === save, "unexpected argumentsTest.arguments");
277 // arguments object detached from its execution context
279 var args, get_x, set_x;
281 function test_args(detached) {
282 ok(args[0] === 1, "args[0] = " + args[0]);
284 ok(args[0] === (detached ? 1 : 2), "args[0] = " + args[0] + " expected " + (detached ? 1 : 2));
286 ok(get_x() === (detached ? 2 : 3), "get_x() = " + get_x());
287 ok(args[0] === 3, "args[0] = " + args[0]);
292 get_x = function() { return x; };
293 set_x = function(v) { x = v; };
302 // arguments is a regular variable, it may be overwritten
304 ok(typeof(arguments) === "object", "typeof(arguments) = " + typeof(arguments));
306 ok(arguments === 1, "arguments = " + arguments);
309 (function callAsExprTest() {
310 ok(callAsExprTest.arguments === null, "callAsExprTest.arguments = " + callAsExprTest.arguments);
313 tmp = (function() {1;})();
314 ok(tmp === undefined, "tmp = " + tmp);
316 ok(tmp === 1, "tmp = " + tmp);
318 ok(tmp === 2, "tmp = " + tmp);
319 tmp = eval("testNoRes(),2;");
320 ok(tmp === 2, "tmp = " + tmp);
321 tmp = eval("if(true) {3}");
322 ok(tmp === 3, "tmp = " + tmp);
323 eval("testRes(); testRes()");
324 tmp = eval("3; if(false) {4;} else {};;;")
325 ok(tmp === 3, "tmp = " + tmp);
326 tmp = eval("try { 1; } finally { 2; }")
327 ok(tmp === 2, "tmp = " + tmp);
330 testRes() && testRes();
331 testNoRes(), testNoRes();
335 ok(x === 1, "x = " + x);
341 ok(r === 1, "r = " + r);
342 (function(x, a) { x(a); })(eval, "2");
347 ok(r === 1, "r = " + r);
348 (function(x, a) { x(a); })(eval, "2");
351 tmp = (function(){ return testNoRes(), testRes();})();
355 ok(funcexpr() == 2, "funcexpr() = " + funcexpr());
357 f1 = function funcexpr() { return 1; }
358 ok(f1 != funcexpr, "f1 == funcexpr");
359 ok(f1() === 1, "f1() = " + f1());
361 f2 = function funcexpr() { return 2; }
362 ok(f2 != funcexpr, "f2 != funcexpr");
363 ok(f2() === 2, "f2() = " + f2());
366 for(i = 0; i < 3; i++) {
367 f2 = function funcexpr2() {};
368 ok(f1 != f2, "f1 == f2");
373 for(i = 0; i < 3; i++) {
375 ok(f1 != f2, "f1 == f2");
380 ok(infuncexpr() == 2, "infuncexpr() = " + infuncexpr());
382 f1 = function infuncexpr() { return 1; }
383 ok(f1 != funcexpr, "f1 == funcexpr");
384 ok(f1() === 1, "f1() = " + f1());
386 f2 = function infuncexpr() { return 2; }
387 ok(f2 != funcexpr, "f2 != funcexpr");
388 ok(f2() === 2, "f2() = " + f2());
391 for(i = 0; i < 3; i++) {
392 f2 = function infuncexpr2() {};
393 ok(f1 != f2, "f1 == f2");
398 for(i = 0; i < 3; i++) {
400 ok(f1 != f2, "f1 == f2");
405 var obj1 = new Object();
406 ok(typeof(obj1) === "object", "typeof(obj1) is not object");
407 ok(obj1.constructor === Object, "unexpected obj1.constructor");
409 obj1.func = function () {
410 ok(this === obj1, "this is not obj1");
411 ok(this.test === true, "this.test is not true");
412 ok(arguments.length === 1, "arguments.length is not 1");
413 ok(arguments["0"] === true, "arguments[0] is not true");
414 ok(typeof(arguments.callee) === "function", "typeof(arguments.calee) = " + typeof(arguments.calee));
419 ok(obj1.func(true) === "test", "obj1.func(true) is not \"test\"");
421 function testConstr1() {
424 ok(this !== undefined, "this is undefined");
425 ok(arguments.length === 1, "arguments.length is not 1");
426 ok(arguments["0"] === true, "arguments[0] is not 1");
427 ok(arguments.callee === testConstr1, "arguments.calee !== testConstr1");
432 testConstr1.prototype.pvar = 1;
433 ok(testConstr1.prototype.constructor === testConstr1, "testConstr1.prototype.constructor !== testConstr1");
435 var obj2 = new testConstr1(true);
436 ok(typeof(obj2) === "object", "typeof(obj2) is not object");
437 ok(obj2.constructor === testConstr1, "unexpected obj2.constructor");
438 ok(obj2.pvar === 1, "obj2.pvar is not 1");
439 ok(!obj2.hasOwnProperty('constructor'), "obj2.hasOwnProperty('constructor')");
441 testConstr1.prototype.pvar = 2;
442 ok(obj2.pvar === 2, "obj2.pvar is not 2");
445 testConstr1.prototype.pvar = 1;
446 ok(obj2.pvar === 3, "obj2.pvar is not 3");
449 function testConstr3() {
453 obj2 = new testConstr3();
454 ok(obj1 === obj2, "obj1 != obj2");
456 function testConstr4() {
460 obj2 = new testConstr3();
461 ok(typeof(obj2) === "object", "typeof(obj2) = " + typeof(obj2));
463 var obj3 = new Object;
464 ok(typeof(obj3) === "object", "typeof(obj3) is not object");
467 ok(typeof(func) === "function", "typeof(func) = " + typeof(func));
469 ok(typeof(func) === "function", "typeof(func) = " + typeof(func));
471 ok(typeof(func) === "number", "typeof(func) = " + typeof(func));
475 ok(typeof(f) === "function", "typeof(f) = " + typeof(f));
477 ok(typeof(f) === "function", "typeof(f) = " + typeof(f));
480 for(var iter in "test")
481 ok(false, "unexpected forin call, test = " + iter);
483 for(var iter in null)
484 ok(false, "unexpected forin call, test = " + iter);
486 for(var iter in false)
487 ok(false, "unexpected forin call, test = " + iter);
489 for(var iter in pureDisp)
490 ok(false, "unexpected forin call in pureDisp object");
493 ok(!tmp.nonexistent, "!tmp.nonexistent = " + !tmp.nonexistent);
494 ok(!("nonexistent" in tmp), "nonexistent is in tmp after '!' expression")
497 ok((~tmp.nonexistent) === -1, "!tmp.nonexistent = " + ~tmp.nonexistent);
498 ok(!("nonexistent" in tmp), "nonexistent is in tmp after '~' expression")
501 ok(isNaN(+tmp.nonexistent), "!tmp.nonexistent = " + (+tmp.nonexistent));
502 ok(!("nonexistent" in tmp), "nonexistent is in tmp after '+' expression")
505 tmp[tmp.nonexistent];
506 ok(!("nonexistent" in tmp), "nonexistent is in tmp after array expression")
512 ok(false, "else evaluated");
513 ok(tmp === 1, "tmp !== 1, if not evaluated?");
517 ok(false, "if evaluated");
520 ok(tmp === 1, "tmp !== 1, if not evaluated?");
523 ok(false, "if(false) evaluated");
528 ok(tmp === 1, "tmp !== 1, if(true) not evaluated?");
534 var obj3 = { prop1: 1, prop2: typeof(false) };
535 ok(obj3.prop1 === 1, "obj3.prop1 is not 1");
536 ok(obj3.prop2 === "boolean", "obj3.prop2 is not \"boolean\"");
537 ok(obj3.constructor === Object, "unexpected obj3.constructor");
539 if(invokeVersion >= 2) {
540 eval("tmp = {prop: 'value',}");
541 ok(tmp.prop === "value", "tmp.prop = " + tmp.prop);
542 eval("tmp = {prop: 'value',second:2,}");
543 ok(tmp.prop === "value", "tmp.prop = " + tmp.prop);
546 eval("tmp = {prop: 'value',}");
550 ok(tmp === true, "exception not fired");
557 ok(blockVar === 2, "blockVar !== 2");
559 ok((true ? 1 : 2) === 1, "conditional expression true is not 1");
560 ok((0 === 2 ? 1 : 2) === 2, "conditional expression true is not 2");
562 ok(getVT(undefined) === "VT_EMPTY", "getVT(undefined) is not VT_EMPTY");
563 ok(getVT(null) === "VT_NULL", "getVT(null) is not VT_NULL");
564 ok(getVT(0) === "VT_I4", "getVT(0) is not VT_I4");
565 ok(getVT(0.5) === "VT_R8", "getVT(0.5) is not VT_R8");
566 ok(getVT("test") === "VT_BSTR", "getVT(\"test\") is not VT_BSTR");
567 ok(getVT(Math) === "VT_DISPATCH", "getVT(Math) is not VT_DISPATCH");
568 ok(getVT(false) === "VT_BOOL", "getVT(false) is not VT_BOOL");
571 ok(tmp === 4, "2+2 !== 4");
572 ok(getVT(tmp) === "VT_I4", "getVT(2+2) !== VT_I4");
575 ok(tmp === 4.5, "2+2.5 !== 4.5");
576 ok(getVT(tmp) === "VT_R8", "getVT(2+2.5) !== VT_R8");
579 ok(tmp === 4, "1.4+2.5 !== 4");
580 ok(getVT(tmp) === "VT_I4", "getVT(1.5+2.5) !== VT_I4");
583 ok(tmp === 2, "4-2 !== 2");
584 ok(getVT(tmp) === "VT_I4", "getVT(4-2) !== VT_I4");
587 ok(tmp === 2.5, "4.5-2 !== 2.5");
588 ok(getVT(tmp) === "VT_R8", "getVT(4.5-2) !== VT_R8");
591 ok(tmp === 0-2, "-2 !== 0-2");
592 ok(getVT(tmp) === "VT_I4", "getVT(-2) !== VT_I4");
595 ok(tmp === 6, "2*3 !== 6");
596 ok(getVT(tmp) === "VT_I4", "getVT(2*3) !== VT_I4");
599 ok(tmp === 7, "2*3.5 !== 7");
600 ok(getVT(tmp) === "VT_I4", "getVT(2*3.5) !== VT_I4");
603 /* FIXME: the parser loses precision */
604 /* ok(tmp === 8.75, "2.5*3.5 !== 8.75"); */
605 ok(tmp > 8.749999 && tmp < 8.750001, "2.5*3.5 !== 8.75");
606 ok(getVT(tmp) === "VT_R8", "getVT(2.5*3.5) !== VT_R8");
609 ok(tmp === 1, "2*.5 !== 1");
610 ok(getVT(tmp) == "VT_I4", "getVT(2*.5) !== VT_I4");
613 ok(tmp === 2, "4/2 !== 2");
614 ok(getVT(tmp) === "VT_I4", "getVT(4/2) !== VT_I4");
617 ok(tmp === 3, "4.5/1.5 !== 3");
618 ok(getVT(tmp) === "VT_I4", "getVT(4.5/1.5) !== VT_I4");
621 ok(tmp === 1.5, "3/2 !== 1.5");
622 ok(getVT(tmp) === "VT_R8", "getVT(3/2) !== VT_R8");
625 ok(tmp === 1, "3%2 = " + tmp);
628 ok(tmp ===0, "4%2 = " + tmp);
631 ok(tmp === 0.5, "3.5%1.5 = " + tmp);
634 ok(tmp === 0, "3%true = " + tmp);
637 ok(tmp === "abcd", "\"ab\" + \"cd\" !== \"abcd\"");
640 ok((tmp += 1) === 2, "tmp += 1 !== 2");
641 ok(tmp === 2, "tmp !== 2");
644 ok((tmp -= 1) === 1, "tmp -= 1 !== 1");
645 ok(tmp === 1, "tmp !=== 1");
648 ok((tmp *= 1.5) === 3, "tmp *= 1.5 !== 3");
649 ok(tmp === 3, "tmp !=== 3");
652 ok((tmp /= 2) === 2.5, "tmp /= 2 !== 2.5");
653 ok(tmp === 2.5, "tmp !=== 2.5");
656 ok((tmp %= 2) === 1, "tmp %= 2 !== 1");
657 ok(tmp === 1, "tmp !== 1");
660 ok((tmp <<= 1) === 16, "tmp <<= 1 !== 16");
663 ok((tmp >>= 1) === 4, "tmp >>= 1 !== 4");
666 ok((tmp >>>= 1) === 4, "tmp >>>= 1 !== 4");
668 tmp = 3 || ok(false, "second or expression called");
669 ok(tmp === 3, "3 || (...) is not 3");
672 ok(tmp === 2, "false || 2 is not 2");
674 tmp = 0 && ok(false, "second and expression called");
675 ok(tmp === 0, "0 && (...) is not 0");
677 tmp = true && "test";
678 ok(tmp === "test", "true && \"test\" is not \"test\"");
681 ok(tmp === 0, "true && 0 is not 0");
684 ok(tmp === 7, "3 | 4 !== 7");
685 ok(getVT(tmp) === "VT_I4", "getVT(3|4) = " + getVT(tmp));
688 ok(tmp === 3, "3.5 | 0 !== 3");
689 ok(getVT(tmp) === "VT_I4", "getVT(3.5|0) = " + getVT(tmp));
692 ok(tmp === -3, "-3.5 | 0 !== -3");
693 ok(getVT(tmp) === "VT_I4", "getVT(3.5|0) = " + getVT(tmp));
696 ok(tmp === 0, "0 | NaN = " + tmp);
699 ok(tmp === 0, "0 | NaN = " + tmp);
701 tmp = 0 | (-Infinity);
702 ok(tmp === 0, "0 | NaN = " + tmp);
705 ok((tmp |= 0x10) === 26, "tmp(10) |= 0x10 !== 26");
706 ok(getVT(tmp) === "VT_I4", "getVT(tmp |= 10) = " + getVT(tmp));
708 tmp = (123 * Math.pow(2,32) + 2) | 0;
709 ok(tmp === 2, "123*2^32+2 | 0 = " + tmp);
711 tmp = (-123 * Math.pow(2,32) + 2) | 0;
712 ok(tmp === 2, "123*2^32+2 | 0 = " + tmp);
715 ok(tmp === 1, "3 & 5 !== 1");
716 ok(getVT(tmp) === "VT_I4", "getVT(3|5) = " + getVT(tmp));
719 ok(tmp === 3, "3.5 & 0xffff !== 3 ");
720 ok(getVT(tmp) === "VT_I4", "getVT(3.5&0xffff) = " + getVT(tmp));
722 tmp = (-3.5) & 0xffffffff;
723 ok(tmp === -3, "-3.5 & 0xffff !== -3");
724 ok(getVT(tmp) === "VT_I4", "getVT(3.5&0xffff) = " + getVT(tmp));
727 ok(tmp === 16, "2 << 3 = " + tmp);
730 ok(tmp === 16, "2 << 35 = " + tmp);
733 ok(tmp === 2, "8 >> 2 = " + tmp);
736 ok(tmp === -4, "-64 >> 4 = " + tmp);
739 ok(tmp === 2, "8 >> 2 = " + tmp);
742 ok(tmp === 0x0ffffffc, "-64 >>> 4 = " + tmp);
745 ok(tmp === 4, "4 >>> NaN = " + tmp);
748 ok((tmp &= 8) === 8, "tmp(10) &= 8 !== 8");
749 ok(getVT(tmp) === "VT_I4", "getVT(tmp &= 8) = " + getVT(tmp));
752 ok(tmp === 0x0ff0, "0xf0f0^0xff00 !== 0x0ff0");
753 ok(getVT(tmp) === "VT_I4", "getVT(0xf0f0^0xff00) = " + getVT(tmp));
756 ok((tmp ^= 3) === 6, "tmp(5) ^= 3 !== 6");
757 ok(getVT(tmp) === "VT_I4", "getVT(tmp ^= 3) = " + getVT(tmp));
760 ok(tmp === -2, "~1 !== -2");
761 ok(getVT(tmp) === "VT_I4", "getVT(~1) = " + getVT(tmp));
763 ok((3,4) === 4, "(3,4) !== 4");
765 ok(+3 === 3, "+3 !== 3");
766 ok(+true === 1, "+true !== 1");
767 ok(+false === 0, "+false !== 0");
768 ok(+null === 0, "+null !== 0");
769 ok(+"0" === 0, "+'0' !== 0");
770 ok(+"3" === 3, "+'3' !== 3");
771 ok(+"-3" === -3, "+'-3' !== -3");
772 ok(+"0xff" === 255, "+'0xff' !== 255");
773 ok(+"3e3" === 3000, "+'3e3' !== 3000");
776 ok(+tmp === 1, "+(new Number(1)) = " + (+tmp));
777 ok(tmp.constructor === Number, "unexpected tmp.constructor");
778 tmp = new String("1");
779 ok(+tmp === 1, "+(new String('1')) = " + (+tmp));
780 ok(tmp.constructor === String, "unexpected tmp.constructor");
782 ok("" + 0 === "0", "\"\" + 0 !== \"0\"");
783 ok("" + 123 === "123", "\"\" + 123 !== \"123\"");
784 ok("" + (-5) === "-5", "\"\" + (-5) !== \"-5\"");
785 ok("" + null === "null", "\"\" + null !== \"null\"");
786 ok("" + undefined === "undefined", "\"\" + undefined !== \"undefined\"");
787 ok("" + true === "true", "\"\" + true !== \"true\"");
788 ok("" + false === "false", "\"\" + false !== \"false\"");
789 ok("" + 0.5 === "0.5", "'' + 0.5 = " + 0.5);
790 ok("" + (-0.5432) === "-0.5432", "'' + (-0.5432) = " + (-0.5432));
792 ok(1 < 3.4, "1 < 3.4 failed");
793 ok(!(3.4 < 1), "3.4 < 1");
794 ok("abc" < "abcd", "abc < abcd failed");
795 ok("abcd" < "abce", "abce < abce failed");
796 ok("" < "x", "\"\" < \"x\" failed");
797 ok(!(0 < 0), "0 < 0");
799 ok(1 <= 3.4, "1 <= 3.4 failed");
800 ok(!(3.4 <= 1), "3.4 <= 1");
801 ok("abc" <= "abcd", "abc <= abcd failed");
802 ok("abcd" <= "abce", "abce <= abce failed");
803 ok("" <= "x", "\"\" <= \"x\" failed");
804 ok(0 <= 0, "0 <= 0 failed");
806 ok(3.4 > 1, "3.4 > 1 failed");
807 ok(!(1 > 3.4), "1 > 3.4");
808 ok("abcd" > "abc", "abc > abcd failed");
809 ok("abce" > "abcd", "abce > abce failed");
810 ok("x" > "", "\"x\" > \"\" failed");
811 ok(!(0 > 0), "0 > 0");
813 ok(3.4 >= 1, "3.4 >= 1 failed");
814 ok(!(1 >= 3.4), "1 >= 3.4");
815 ok("abcd" >= "abc", "abc >= abcd failed");
816 ok("abce" >= "abcd", "abce >= abce failed");
817 ok("x" >= "", "\"x\" >= \"\" failed");
818 ok(0 >= 0, "0 >= 0");
821 ok(++tmp === 2, "++tmp (1) is not 2");
822 ok(tmp === 2, "incremented tmp is not 2");
823 ok(--tmp === 1, "--tmp (2) is not 1");
824 ok(tmp === 1, "decremented tmp is not 1");
825 ok(tmp++ === 1, "tmp++ (1) is not 1");
826 ok(tmp === 2, "incremented tmp(1) is not 2");
827 ok(tmp-- === 2, "tmp-- (2) is not 2");
828 ok(tmp === 1, "decremented tmp is not 1");
832 ok(isNaN(tmp.iii), "tmp.iii = " + tmp.iii);
834 String.prototype.test = true;
835 ok("".test === true, "\"\".test is not true");
837 Boolean.prototype.test = true;
838 ok(true.test === true, "true.test is not true");
840 Number.prototype.test = true;
841 ok((0).test === true, "(0).test is not true");
842 ok((0.5).test === true, "(0.5).test is not true");
846 ok(state === "", "try: state = " + state);
849 ok(false, "unexpected catch");
851 ok(state === "try", "state = " + state + " expected try");
855 ok(state === "", "try: state = " + state);
858 ok(state === "try", "finally: state = " + state);
861 ok(state === "finally", "state = " + state + " expected finally");
871 ok(state === "finally", "state = " + state + " expected finally");
874 ok(state === "catch", "state = " + state + " expected catch");
883 ok(e === 1, "e = " + e);
888 ok(state === "", "try: state = " + state);
891 ok(false, "unexpected catch");
893 ok(state === "try", "finally: state = " + state);
896 ok(state === "finally", "state = " + state + " expected finally");
900 ok(state === "", "try: state = " + state);
904 ok(state === "try", "catch: state = " + state);
905 ok(ex === "except", "ex is not \"except\"");
908 ok(state === "catch", "state = " + state + " expected catch");
912 ok(state === "", "try: state = " + state);
916 ok(state === "try", "catch: state = " + state);
917 ok(ex === true, "ex is not true");
920 ok(state === "catch", "finally: state = " + state);
923 ok(state === "finally", "state = " + state + " expected finally");
927 ok(state === "", "try: state = " + state);
929 try { throw true; } finally {}
931 ok(state === "try", "catch: state = " + state);
932 ok(ex === true, "ex is not true");
935 ok(state === "catch", "finally: state = " + state);
938 ok(state === "finally", "state = " + state + " expected finally");
942 ok(state === "", "try: state = " + state);
944 try { throw "except"; } catch(ex) { throw true; }
946 ok(state === "try", "catch: state = " + state);
947 ok(ex === true, "ex is not true");
950 ok(state === "catch", "finally: state = " + state);
953 ok(state === "finally", "state = " + state + " expected finally");
955 function throwFunc(x) {
961 ok(state === "", "try: state = " + state);
965 ok(state === "try", "catch: state = " + state);
966 ok(ex === true, "ex is not true");
969 ok(state === "catch", "finally: state = " + state);
972 ok(state === "finally", "state = " + state + " expected finally");
977 ok(false, "unexpected case \"1\"");
979 ok(state === "", "case 1: state = " + state);
982 ok(state === "1", "default: state = " + state);
985 ok(state === "default", "case false: state = " + state);
988 ok(state === "false", "state = " + state);
994 ok(false, "unexpected case 1");
996 ok(state === "", "default: state = " + state);
999 ok(state === "default", "case false: state = " + state);
1002 ok(state === "false", "state = " + state);
1007 ok(false, "unexpected case \"1\"");
1009 ok(state === "", "case 1: state = " + state);
1012 ok(state === "1", "default: state = " + state);
1016 ok(false, "unexpected case false");
1018 ok(state === "default", "state = " + state);
1022 ok(false, "unexpected case 2");
1024 ok(false, "unexpected case 3");
1029 ok(false, "unexpected case 2");
1037 ok(false, "unexpected default");
1045 ok(false, "unexpected default");
1066 function unreachable() {
1067 ok(false, "unreachable");
1070 function expect(value, expect_value) {
1071 ok(value === expect_value, "got " + value + " expected " + expect_value);
1086 expect(ret, "finally");
1101 expect(ret, "try,");
1102 expect(x, "try,finally,");
1121 expect(ret, "finally");
1122 expect(x, "try,catch,finally,");
1139 expect(ret, "catch");
1140 expect(x, "try,catch,finally,");
1162 expect(ret, "try2");
1163 expect(x, "try,try2,finally2,finally,");
1190 expect(x, "try,try2,finally2,finally,ret");
1218 expect(x, "try,try2,finally2,finally,ret");
1228 var tmp = (function() {
1229 var s = new String();
1244 var E_FAIL = -2147467259;
1245 var JS_E_SUBSCRIPT_OUT_OF_RANGE = -2146828279;
1252 ok(e.name === "Error", "e.name = " + e.name);
1253 ok(e.message === "", "e.message = " + e.message);
1254 ok(e.number === E_FAIL, "e.number = " + e.number);
1257 throwInt(JS_E_SUBSCRIPT_OUT_OF_RANGE);
1261 ok(e.name === "RangeError", "e.name = " + e.name);
1262 ok(e.number === JS_E_SUBSCRIPT_OUT_OF_RANGE, "e.number = " + e.number);
1265 throwEI(JS_E_SUBSCRIPT_OUT_OF_RANGE);
1269 ok(e.name === "RangeError", "e.name = " + e.name);
1270 ok(e.number === JS_E_SUBSCRIPT_OUT_OF_RANGE, "e.number = " + e.number);
1274 ok(tmp === 1, "eval(\"1\") !== 1");
1275 eval("{ ok(tmp === 1, 'eval: tmp !== 1'); } tmp = 2;");
1276 ok(tmp === 2, "tmp !== 2");
1278 ok(eval(false) === false, "eval(false) !== false");
1279 ok(eval() === undefined, "eval() !== undefined");
1281 tmp = eval("1", "2");
1282 ok(tmp === 1, "eval(\"1\", \"2\") !== 1");
1286 ok(state === "", "try: state = " + state);
1288 eval("throwFunc(true);");
1290 ok(state === "try", "catch: state = " + state);
1291 ok(ex === true, "ex is not true");
1294 ok(state === "catch", "finally: state = " + state);
1297 ok(state === "finally", "state = " + state + " expected finally");
1299 tmp = [,,1,2,,,true];
1300 ok(tmp.length === 7, "tmp.length !== 7");
1301 ok(tmp["0"] === undefined, "tmp[0] is not undefined");
1302 ok(tmp["3"] === 2, "tmp[3] !== 2");
1303 ok(tmp["6"] === true, "tmp[6] !== true");
1304 ok(tmp[2] === 1, "tmp[2] !== 1");
1305 ok(!("0" in tmp), "0 found in array");
1306 ok(!("1" in tmp), "1 found in array");
1307 ok("2" in tmp, "2 not found in array");
1308 ok(!("2" in [1,,,,]), "2 found in [1,,,,]");
1310 ok([1,].length === 2, "[1,].length !== 2");
1311 ok([,,].length === 3, "[,,].length !== 3");
1312 ok([,].length === 2, "[].length != 2");
1313 ok([].length === 0, "[].length != 0");
1317 ok(tmp < 4, "tmp >= 4");
1320 ok(tmp === 4, "tmp !== 4");
1324 ok(tmp < 4, "tmp >= 4");
1328 ok(false, "break did not break");
1331 ok(tmp === 4, "tmp !== 4");
1335 ok(tmp < 4, "tmp >= 4");
1338 ok(tmp === 4, "tmp !== 4");
1342 ok(tmp === 0, "tmp !=== 0");
1345 ok(tmp === 1, "tmp !== 1");
1349 ok(tmp < 4, "tmp >= 4");
1352 ok(tmp === 4, "tmp !== 4")
1359 ok(false, "break did not break");
1361 ok(tmp <= 4 && tmp != 2, "tmp = " + tmp);
1363 ok(tmp === 4, "tmp !== 4");
1365 for(tmp=0; tmp < 4; tmp++)
1366 ok(tmp < 4, "tmp = " + tmp);
1367 ok(tmp === 4, "tmp !== 4");
1369 for(tmp=0; tmp < 4; tmp++) {
1372 ok(tmp < 2, "tmp = " + tmp);
1374 ok(tmp === 2, "tmp !== 2");
1376 for(tmp=0; tmp < 4; tmp++) {
1379 ok(tmp < 4 && tmp != 2, "tmp = " + tmp);
1381 ok(tmp === 4, "tmp !== 4");
1383 for(var fi=0; fi < 4; fi++)
1384 ok(fi < 4, "fi = " + fi);
1385 ok(fi === 4, "fi !== 4");
1388 obj1 = new Object();
1389 for(obj1.nonexistent; tmp; tmp = false)
1390 ok(!("nonexistent" in obj1), "nonexistent added to obj1");
1392 obj1 = new Object();
1393 for(tmp in obj1.nonexistent)
1394 ok(false, "for(tmp in obj1.nonexistent) called with tmp = " + tmp);
1395 ok(!("nonexistent" in obj1), "nonexistent added to obj1 by for..in loop");
1400 /* Previous versions have broken finally block implementation */
1401 if(ScriptEngineMinorVersion() >= 8) {
1406 for(i = 1; i < 3; i++) {
1420 ok(false, "unexpected state");
1429 ok(tmp === "123456", "tmp = " + tmp);
1447 ok(false, "unexpected state");
1455 ok(tmp === "1234", "tmp = " + tmp);
1458 for(var iter in [1,2,3]) {
1462 ok(tmp === 3, "tmp = " + tmp);
1465 for(var iter in [1,2,3]) {
1476 ok(tmp, "tmp = " + tmp);
1490 ok(false, "unexpected evaluation 1");
1495 ok(false, "unexpected evaluation 2");
1498 just_label: tmp = 1;
1499 ok(tmp === 1, "tmp != 1");
1501 some_label: break some_label;
1505 ok(false, "unexpected evaluation 3");
1511 continue loop_label;
1515 for(i = 0; i < 3; i++) {
1517 continue loop_label;
1522 for(i = 0; i < 3; i++) {
1524 continue loop_label;
1528 for(tmp in {prop: false}) {
1530 continue loop_label;
1533 ok((void 1) === undefined, "(void 1) !== undefined");
1535 var inobj = new Object();
1537 for(var iter in inobj)
1538 ok(false, "unexpected iter = " + iter);
1542 for(iter in inobj) {
1543 ok(iter == "test", "unexpected iter = " + iter);
1546 ok(tmp === 1, "for..in tmp = " + tmp);
1548 function forinTestObj() {}
1550 forinTestObj.prototype.test3 = true;
1552 var arr = new Array();
1553 inobj = new forinTestObj();
1558 for(iter in inobj) {
1563 ok(tmp === 3, "for..in tmp = " + tmp);
1564 ok(arr["test1"] === true, "arr[test1] !== true");
1565 ok(arr["test2"] === true, "arr[test2] !== true");
1566 ok(arr["test3"] === true, "arr[test3] !== true");
1570 ok((delete tmp.test) === true, "delete returned false");
1571 ok(typeof(tmp.test) === "undefined", "tmp.test type = " + typeof(tmp.test));
1572 ok(!("test" in tmp), "test is still in tmp after delete?");
1574 ok(false, "tmp has prop " + iter);
1575 ok((delete tmp.test) === true, "deleting test didn't return true");
1576 ok((delete tmp.nonexistent) === true, "deleting nonexistent didn't return true");
1577 ok((delete nonexistent) === true, "deleting nonexistent didn't return true");
1581 ok((delete tmp["test"]) === true, "delete returned false");
1582 ok(typeof(tmp.test) === "undefined", "tmp.test type = " + typeof(tmp.test));
1583 ok(!("test" in tmp), "test is still in tmp after delete?");
1585 tmp.testWith = true;
1587 ok(testWith === true, "testWith !== true");
1590 var varTest1 = true;
1593 ok(varTest1 === undefined, "varTest1 = " + varTest1);
1594 ok(varTest2 === undefined, "varTest2 = " + varTest1);
1598 function varTestFunc(varTest3) {
1601 ok(varTest3 === 3, "varTest3 = " + varTest3);
1602 ok(varTest4 === undefined, "varTest4 = " + varTest4);
1613 ok(false, "deleteTest did not throw an exception?");
1618 var r = delete to_delete;
1619 ok(r === false, "delete 1 returned " + r);
1622 ok(to_delete === 2, "to_delete = " + to_delete);
1624 to_delete = new Object();
1625 r = delete to_delete;
1626 ok(r === false, "delete 2 returned " + r);
1627 ok(typeof(to_delete) === "object", "typeof(to_delete) = " + typeof(to_delete));
1630 (function(to_delete) {
1631 var r = delete to_delete;
1632 ok(r === false, "delete 3 returned " + r);
1633 ok(to_delete === 2, "to_delete = " + to_delete);
1635 to_delete = new Object();
1636 r = delete to_delete;
1637 ok(r === false, "delete 4 returned " + r);
1638 ok(typeof(to_delete) === "object", "typeof(to_delete) = " + typeof(to_delete));
1642 with({to_delete: new Object()}) {
1643 var r = delete to_delete;
1644 ok(r === true, "delete returned " + r);
1650 ok(false, "if evaluated");
1652 ok(false, "else should be associated with nearest if statement");
1656 ok(false, "if evaluated");
1658 ok(true, "else should be associated with nearest if statement");
1660 function instanceOfTest() {}
1661 tmp = new instanceOfTest();
1663 ok((tmp instanceof instanceOfTest) === true, "tmp is not instance of instanceOfTest");
1664 ok((tmp instanceof Object) === true, "tmp is not instance of Object");
1665 ok((tmp instanceof String) === false, "tmp is instance of String");
1667 instanceOfTest.prototype = new Object();
1668 ok((tmp instanceof instanceOfTest) === false, "tmp is instance of instanceOfTest");
1669 ok((tmp instanceof Object) === true, "tmp is not instance of Object");
1671 ok((1 instanceof Object) === false, "1 is instance of Object");
1672 ok((false instanceof Boolean) === false, "false is instance of Boolean");
1673 ok(("" instanceof Object) === false, "'' is instance of Object");
1676 ok((arguments instanceof Object) === true, "argument is not instance of Object");
1677 ok((arguments instanceof Array) === false, "argument is not instance of Array");
1678 ok(arguments.toString() === "[object Object]", "arguments.toString() = " + arguments.toString());
1682 ok(("length" in obj) === true, "length is not in obj");
1683 ok(("isPrototypeOf" in obj) === true, "isPrototypeOf is not in obj");
1684 ok(("abc" in obj) === false, "test is in obj");
1686 ok(("abc" in obj) === true, "test is not in obj");
1687 ok(("1" in obj) === false, "1 is in obj");
1690 ok((1 in obj) === true, "1 is not in obj");
1695 ok(false, "expected exception");
1697 ok(!("prop" in obj), "prop in obj");
1699 if(invokeVersion >= 2) {
1700 ok("test"[0] === "t", '"test"[0] = ' + test[0]);
1701 ok("test"[5] === undefined, '"test"[0] = ' + test[0]);
1704 ok(tmp[1] === "e", "tmp[1] = " + tmp[1]);
1706 ok(tmp[1] === "e", "tmp[1] = " + tmp[1]);
1707 ok(tmp["1"] === "e", "tmp['1'] = " + tmp["1"]);
1708 ok(tmp["0x1"] === undefined, "tmp['0x1'] = " + tmp["0x1"]);
1710 ok("test"[0] === undefined, '"test"[0] = ' + test[0]);
1713 ok(isNaN(NaN) === true, "isNaN(NaN) !== true");
1714 ok(isNaN(0.5) === false, "isNaN(0.5) !== false");
1715 ok(isNaN(Infinity) === false, "isNaN(Infinity) !== false");
1716 ok(isNaN() === true, "isNaN() !== true");
1717 ok(isNaN(NaN, 0) === true, "isNaN(NaN, 0) !== true");
1718 ok(isNaN(0.5, NaN) === false, "isNaN(0.5, NaN) !== false");
1719 ok(isNaN(+undefined) === true, "isNaN(+undefined) !== true");
1721 ok(isFinite(0.5) === true, "isFinite(0.5) !== true");
1722 ok(isFinite(Infinity) === false, "isFinite(Infinity) !== false");
1723 ok(isFinite(-Infinity) === false, "isFinite(Infinity) !== false");
1724 ok(isFinite(NaN) === false, "isFinite(NaN) !== false");
1725 ok(isFinite(0.5, NaN) === true, "isFinite(0.5, NaN) !== true");
1726 ok(isFinite(NaN, 0.5) === false, "isFinite(NaN, 0.5) !== false");
1727 ok(isFinite() === false, "isFinite() !== false");
1729 ok((1 < NaN) === false, "(1 < NaN) !== false");
1730 ok((1 > NaN) === false, "(1 > NaN) !== false");
1731 ok((1 <= NaN) === false, "(1 <= NaN) !== false");
1732 ok((1 >= NaN) === false, "(1 >= NaN) !== false");
1733 ok((NaN < 1) === false, "(NaN < 1) !== false");
1734 ok((NaN > 1) === false, "(NaN > 1) !== false");
1735 ok((NaN <= 1) === false, "(NaN <= 1) !== false");
1736 ok((NaN >= 1) === false, "(NaN >= 1) !== false");
1737 ok((Infinity < 2) === false, "(Infinity < 2) !== false");
1738 ok((Infinity > 2) === true, "(Infinity > 2) !== true");
1739 ok((-Infinity < 2) === true, "(-Infinity < 2) !== true");
1741 ok(isNaN(+"test") === true, "isNaN(+'test') !== true");
1742 ok(isNaN(+"123t") === true, "isNaN(+'123t') !== true");
1743 ok(isNaN(+"Infinity x") === true, "isNaN(+'Infinity x') !== true");
1744 ok(+"Infinity" === Infinity, "+'Infinity' !== Infinity");
1745 ok(+" Infinity " === Infinity, "+' Infinity ' !== Infinity");
1746 ok(+"-Infinity" === -Infinity, "+'-Infinity' !== -Infinity");
1748 ok((NaN !== NaN) === true, "(NaN !== NaN) !== true");
1749 ok((NaN === NaN) === false, "(NaN === NaN) !== false");
1750 ok((Infinity !== NaN) === true, "(Infinity !== NaN) !== true");
1751 ok((Infinity !== NaN) === true, "(Infinity !== NaN) !== true");
1752 ok((0 === NaN) === false, "(0 === NaN) !== false");
1754 ok((NaN != NaN) === true, "(NaN !== NaN) != true");
1755 ok((NaN == NaN) === false, "(NaN === NaN) != false");
1756 ok((Infinity != NaN) === true, "(Infinity != NaN) !== true");
1757 ok((Infinity != NaN) === true, "(Infinity != NaN) !== true");
1758 ok((0 == NaN) === false, "(0 === NaN) != false");
1771 ["\xf3", "\\xf3", 0xf3],
1772 ["\u1234", "\\u1234", 0x1234],
1777 for(i=0; i<escapeTests.length; i++) {
1778 tmp = escapeTests[i][0].charCodeAt(0);
1779 ok(tmp === escapeTests[i][2], "escaped '" + escapeTests[i][1] + "' = " + tmp + " expected " + escapeTests[i][2]);
1783 ok(tmp === true, '!+"\v1" = ' + tmp);
1785 ok(typeof(testFunc2) === "function", "typeof(testFunc2) = " + typeof(testFunc2));
1787 ok(tmp === 2, "testFunc2(1) = " + tmp);
1788 function testFunc2(x) { return x+1; }
1790 ok(typeof(testFunc3) === "function", "typeof(testFunc3) = " + typeof(testFunc3));
1792 ok(tmp === 3, "testFunc3(1) = " + tmp);
1793 tmp = function testFunc3(x) { return x+2; };
1796 ok(tmp === 5, "testFunc4(1) = " + tmp);
1797 tmp = function testFunc4(x) { return x+3; };
1800 ok(testFunc4 === 1, "testFunc4 = " + testFunc4);
1801 ok(tmp === 5, "testFunc4(1) = " + tmp);
1802 tmp = function testFunc4(x) { return x+4; };
1803 ok(testFunc4 === 1, "testFunc4 = " + testFunc4);
1805 function testEmbeddedFunctions() {
1806 ok(typeof(testFunc5) === "function", "typeof(testFunc5) = " + typeof(testFunc5));
1808 ok(tmp === 3, "testFunc5(1) = " + tmp);
1809 tmp = function testFunc5(x) { return x+2; };
1812 ok(tmp === 5, "testFunc6(1) = " + tmp);
1813 tmp = function testFunc6(x) { return x+3; };
1815 ok(tmp === 5, "testFunc6(1) = " + tmp);
1816 tmp = function testFunc6(x) { return x+4; };
1818 ok(testFunc6 === 1, "testFunc4 = " + testFunc6);
1821 testEmbeddedFunctions();
1824 date.toString = function() { return "toString"; }
1825 ok(""+date === "toString", "''+date = " + date);
1826 date.toString = function() { return this; }
1827 ok(""+date === ""+date.valueOf(), "''+date = " + date);
1829 str = new String("test");
1830 str.valueOf = function() { return "valueOf"; }
1831 ok(""+str === "valueOf", "''+str = " + str);
1832 str.valueOf = function() { return new Date(); }
1833 ok(""+str === "test", "''+str = " + str);
1835 ok((function (){return 1;})() === 1, "(function (){return 1;})() = " + (function (){return 1;})());
1838 var order = "", o = {};
1839 o[order += "1,", { toString: function() { order += "2,"; } }] = (order += "3");
1840 ok(order === "1,2,3", "array expression order = " + order);
1843 var re = /=(\?|%3F)/g;
1844 ok(re.source === "=(\\?|%3F)", "re.source = " + re.source);
1847 for(var i=0; i<2; i++)
1849 ok(tmp[0] != tmp[1], "tmp[0] == tmp [1]");
1851 ok(isNullBSTR(getNullBSTR()), "isNullBSTR(getNullBSTR()) failed\n");
1852 ok(getNullBSTR() === '', "getNullBSTR() !== ''");
1853 ok(+getNullBSTR() === 0 , "+getNullBTR() !=== 0");
1855 ok(getVT(nullDisp) === "VT_DISPATCH", "getVT(nullDisp) = " + getVT(nullDisp));
1856 ok(typeof(nullDisp) === "object", "typeof(nullDisp) = " + typeof(nullDisp));
1857 ok(nullDisp === nullDisp, "nullDisp !== nullDisp");
1858 ok(nullDisp !== re, "nullDisp === re");
1859 ok(nullDisp === null, "nullDisp === null");
1860 ok(nullDisp == null, "nullDisp == null");
1861 ok(getVT(true && nullDisp) === "VT_DISPATCH",
1862 "getVT(0 && nullDisp) = " + getVT(true && nullDisp));
1863 ok(!nullDisp === true, "!nullDisp = " + !nullDisp);
1864 ok(String(nullDisp) === "null", "String(nullDisp) = " + String(nullDisp));
1865 ok(nullDisp != new Object(), "nullDisp == new Object()");
1866 ok(new Object() != nullDisp, "new Object() == nullDisp");
1867 ok((typeof Object(nullDisp)) === "object", "typeof Object(nullDisp) !== 'object'");
1868 tmp = getVT(Object(nullDisp));
1869 ok(tmp === "VT_DISPATCH", "getVT(Object(nullDisp) = " + tmp);
1870 tmp = Object(nullDisp).toString();
1871 ok(tmp === "[object Object]", "Object(nullDisp).toString() = " + tmp);
1873 function testNullPrototype() {
1876 tmp = new testNullPrototype();
1877 ok(tmp.x === 13, "tmp.x !== 13");
1878 ok(!("y" in tmp), "tmp has 'y' property");
1879 testNullPrototype.prototype.y = 10;
1880 ok("y" in tmp, "tmp does not have 'y' property");
1881 tmp = new testNullPrototype();
1882 ok(tmp.y === 10, "tmp.y !== 10");
1883 testNullPrototype.prototype = nullDisp;
1884 tmp = new testNullPrototype();
1885 ok(tmp.x === 13, "tmp.x !== 13");
1886 ok(!("y" in tmp), "tmp has 'y' property");
1887 ok(!tmp.hasOwnProperty("y"), "tmp has 'y' property");
1888 ok(!tmp.propertyIsEnumerable("y"), "tmp has 'y' property enumerable");
1889 ok(tmp.toString() == "[object Object]", "tmp.toString returned " + tmp.toString());
1890 testNullPrototype.prototype = null;
1891 tmp = new testNullPrototype();
1892 ok(!tmp.hasOwnProperty("y"), "tmp has 'y' property");
1893 ok(!tmp.propertyIsEnumerable("y"), "tmp has 'y' property enumerable");
1894 ok(tmp.toString() == "[object Object]", "tmp.toString returned " + tmp.toString());
1896 testNullPrototype.prototype = 42;
1897 tmp = new testNullPrototype();
1898 ok(tmp.hasOwnProperty("x"), "tmp does not have 'x' property");
1899 ok(!tmp.hasOwnProperty("y"), "tmp has 'y' property");
1900 ok(tmp.toString() == "[object Object]", "tmp.toString returned " + tmp.toString());
1902 testNullPrototype.prototype = true;
1903 tmp = new testNullPrototype();
1904 ok(tmp.hasOwnProperty("x"), "tmp does not have 'x' property");
1905 ok(!tmp.hasOwnProperty("y"), "tmp has 'y' property");
1906 ok(tmp.toString() == "[object Object]", "tmp.toString returned " + tmp.toString());
1908 testNullPrototype.prototype = "foobar";
1909 tmp = new testNullPrototype();
1910 ok(tmp.hasOwnProperty("x"), "tmp does not have 'x' property");
1911 ok(!tmp.hasOwnProperty("y"), "tmp has 'y' property");
1912 ok(tmp.toString() == "[object Object]", "tmp.toString returned " + tmp.toString());
1914 function do_test() {}
1915 function nosemicolon() {} nosemicolon();
1916 function () {} nosemicolon();
1919 function in_if_false() { return true; } ok(false, "!?");
1922 ok(in_if_false(), "in_if_false failed");
1924 (function() { newValue = 1; })();
1925 ok(newValue === 1, "newValue = " + newValue);
1927 obj = {undefined: 3};
1929 ok(typeof(name_override_func) === "function", "typeof(name_override_func) = " + typeof(name_override_func));
1930 name_override_func = 3;
1931 ok(name_override_func === 3, "name_override_func = " + name_override_func);
1932 function name_override_func() {};
1933 ok(name_override_func === 3, "name_override_func = " + name_override_func);
1940 ok(tmp, "tmp = " + tmp);
1943 for(var iter in [1,2,3,4]) {
1949 ok(tmp, "tmp = " + tmp);
1952 ok(typeof(func) === "function", "typeof(func) = " + typeof(func));
1953 with(new Object()) {
1954 var x = false && function func() {};
1956 ok(typeof(func) === "function", "typeof(func) = " + typeof(func));
1960 ok(x === undefined, "x = " + x); // x is declared, but never initialized
1962 ok(x === 1, "x = " + x);
1964 ok(x === 2, "x = " + x);
1966 ok(x === undefined, "x = " + x);
1971 /* NoNewline rule parser tests */
1979 * no semicolon, but comment present */
1984 if(true) break // no semicolon, but comment present
1994 function returnTest() {
1999 ok(returnTest() === undefined, "returnTest = " + returnTest());
2002 ok(ActiveXObject === 1, "ActiveXObject = " + ActiveXObject);
2005 ok(Boolean === 1, "Boolean = " + Boolean);
2008 ok(Object === 1, "Object = " + Object);
2011 ok(Array === 1, "Array = " + Array);
2014 ok(Date === 1, "Date = " + Date);
2017 ok(Error === 1, "Error = " + Error);
2019 /* Keep this test in the end of file */
2021 ok(undefined === 6, "undefined = " + undefined);
2024 ok(NaN === 6, "NaN !== 6");
2027 ok(Infinity === 6, "Infinity !== 6");
2030 ok(Math === 6, "NaN !== 6");