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);
52 ok(1 !== 2, "1 !== 2 is false");
53 ok(null !== undefined, "null !== undefined is false");
55 ok(1 == 1, "1 == 1 is false");
56 ok(!(1 == 2), "!(1 == 2) is false");
57 ok(1.0 == 1, "1.0 == 1 is false");
58 ok("abc" == "abc", "\"abc\" == \"abc\" is false");
59 ok(true == true, "true == true is false");
60 ok(null == null, "null == null is false");
61 ok(undefined == undefined, "undefined == undefined is false");
62 ok(undefined == null, "undefined == null is false");
63 ok(true == 1, "true == 1 is false");
64 ok(!(true == 2), "true == 2");
65 ok(0 == false, "0 == false is false");
67 ok(1 != 2, "1 != 2 is false");
68 ok(false != 1, "false != 1 is false");
70 ok(this === test, "this !== test");
71 eval('ok(this === test, "this !== test");');
74 ok(trueVar, "trueVar is not true");
76 ok(ScriptEngine.length === 0, "ScriptEngine.length is not 0");
78 function testFunc1(x, y) {
79 ok(this !== undefined, "this is undefined");
80 ok(x === true, "x is not true");
81 ok(y === "test", "y is not \"test\"");
82 ok(arguments.length === 2, "arguments.length is not 2");
83 ok(arguments["0"] === true, "arguments[0] is not true");
84 ok(arguments["1"] === "test", "arguments[1] is not \"test\"");
85 ok(arguments.callee === testFunc1, "arguments.calee !== testFunc1");
86 ok(testFunc1.arguments === arguments, "testFunc1.arguments = " + testFunc1.arguments);
89 ok(arguments[0] === false, "arguments[0] is not false");
91 ok(y === "x", "y = " + y);
92 ok(arguments[1] === "x", "arguments[1] = " + arguments[1]);
94 ok(arguments["0x0"] === undefined, "arguments['0x0'] = " + arguments["0x0"]);
95 ok(arguments["x"] === undefined, "arguments['x'] = " + arguments["x"]);
97 ok(this === test, "this !== test");
98 eval('ok(this === test, "this !== test");');
100 tmp = delete arguments;
101 ok(tmp === false, "arguments deleted");
102 ok(typeof(arguments) === "object", "typeof(arguments) = " + typeof(arguments));
105 ok(x === 2, "x = " + x);
106 ok(arguments[0] === 2, "arguments[0] = " + arguments[0]);
111 ok(testFunc1.length === 2, "testFunc1.length is not 2");
112 ok(testFunc1.arguments === null, "testFunc1.arguments = " + testFunc1.arguments);
114 ok(Object.prototype !== undefined, "Object.prototype is undefined");
115 ok(Object.prototype.prototype === undefined, "Object.prototype is not undefined");
116 ok(String.prototype !== undefined, "String.prototype is undefined");
117 ok(Array.prototype !== undefined, "Array.prototype is undefined");
118 ok(Boolean.prototype !== undefined, "Boolean.prototype is undefined");
119 ok(Number.prototype !== undefined, "Number.prototype is undefined");
120 ok(RegExp.prototype !== undefined, "RegExp.prototype is undefined");
121 ok(Math !== undefined, "Math is undefined");
122 ok(Math.prototype === undefined, "Math.prototype is not undefined");
123 ok(Function.prototype !== undefined, "Function.prototype is undefined");
124 ok(Function.prototype.prototype === undefined, "Function.prototype.prototype is not undefined");
125 ok(Date.prototype !== undefined, "Date.prototype is undefined");
126 ok(Date.prototype.prototype === undefined, "Date.prototype is not undefined");
128 function testConstructor(constr, name, inst) {
129 ok(constr.prototype.constructor === constr, name + ".prototype.constructor !== " + name);
130 ok(constr.prototype.hasOwnProperty("constructor"), name + ".prototype.hasOwnProperty('constructor')");
135 ok(inst.constructor === constr, "(new " + name + "()).constructor !== " + name);
136 ok(!inst.hasOwnProperty("constructor"), "(new " + name + "()).hasOwnProperty('constructor')");
139 testConstructor(Object, "Object");
140 testConstructor(String, "String");
141 testConstructor(Array, "Array");
142 testConstructor(Boolean, "Boolean");
143 testConstructor(Number, "Number");
144 testConstructor(RegExp, "RegExp", /x/);
145 testConstructor(Function, "Function");
146 testConstructor(Date, "Date");
147 testConstructor(VBArray, "VBArray", new VBArray(createArray()));
148 testConstructor(Error, "Error");
149 testConstructor(EvalError, "EvalError");
150 testConstructor(RangeError, "RangeError");
151 testConstructor(ReferenceError, "ReferenceError");
152 testConstructor(RegExpError, "RegExpError");
153 testConstructor(SyntaxError, "SyntaxError");
154 testConstructor(TypeError, "TypeError");
155 testConstructor(URIError, "URIError");
157 Function.prototype.test = true;
158 ok(testFunc1.test === true, "testFunc1.test !== true");
159 ok(Function.test === true, "Function.test !== true");
161 ok(typeof(0) === "number", "typeof(0) is not number");
162 ok(typeof(1.5) === "number", "typeof(1.5) is not number");
163 ok(typeof("abc") === "string", "typeof(\"abc\") is not string");
164 ok(typeof("") === "string", "typeof(\"\") is not string");
165 ok(typeof(true) === "boolean", "typeof(true) is not boolean");
166 ok(typeof(null) === "object", "typeof(null) is not object");
167 ok(typeof(undefined) === "undefined", "typeof(undefined) is not undefined");
168 ok(typeof(Math) === "object", "typeof(Math) is not object");
169 ok(typeof(String.prototype) === "object", "typeof(String.prototype) is not object");
170 ok(typeof(testFunc1) === "function", "typeof(testFunc1) is not function");
171 ok(typeof(String) === "function", "typeof(String) is not function");
172 ok(typeof(ScriptEngine) === "function", "typeof(ScriptEngine) is not function");
173 ok(typeof(this) === "object", "typeof(this) is not object");
174 ok(typeof(doesnotexist) === "undefined", "typeof(doesnotexist) = " + typeof(doesnotexist));
175 tmp = typeof((new Object()).doesnotexist);
176 ok(tmp === "undefined", "typeof((new Object).doesnotexist = " + tmp);
177 tmp = typeof(testObj.onlyDispID);
178 ok(tmp === "unknown", "typeof(testObj.onlyDispID) = " + tmp);
180 ok(testFunc1(true, "test") === true, "testFunc1 not returned true");
182 ok(testFunc1.arguments === null, "testFunc1.arguments = " + testFunc1.arguments);
185 ok(tmp === 3, "tmp = " + tmp);
187 function testRecFunc(x) {
188 ok(testRecFunc.arguments === arguments, "testRecFunc.arguments = " + testRecFunc.arguments);
191 ok(testRecFunc.arguments === arguments, "testRecFunc.arguments = " + testRecFunc.arguments);
192 ok(testRecFunc.arguments[0] === true, "testRecFunc.arguments.x = " + testRecFunc.arguments[0]);
196 testRecFunc.arguments = 5;
197 ok(testRecFunc.arguments === null, "testRecFunc.arguments = " + testRecFunc.arguments);
199 ok(testRecFunc.arguments === null, "testRecFunc.arguments = " + testRecFunc.arguments);
201 function argumentsTest() {
202 var save = arguments;
203 with({arguments: 1}) {
204 ok(arguments === 1, "arguments = " + arguments);
206 ok(argumentsTest.arguments === save, "unexpected argumentsTest.arguments");
209 eval('ok(arguments === save, "unexpected arguments");');
210 [1,2].sort(function() {
211 ok(argumentsTest.arguments === save, "unexpected argumentsTest.arguments");
218 // arguments object detached from its execution context
220 var args, get_x, set_x;
222 function test_args(detached) {
223 ok(args[0] === 1, "args[0] = " + args[0]);
225 ok(args[0] === (detached ? 1 : 2), "args[0] = " + args[0] + " expected " + (detached ? 1 : 2));
227 ok(get_x() === (detached ? 2 : 3), "get_x() = " + get_x());
228 ok(args[0] === 3, "args[0] = " + args[0]);
233 get_x = function() { return x; };
234 set_x = function(v) { x = v; };
243 // arguments is a regular variable, it may be overwritten
245 ok(typeof(arguments) === "object", "typeof(arguments) = " + typeof(arguments));
247 ok(arguments === 1, "arguments = " + arguments);
250 (function callAsExprTest() {
251 ok(callAsExprTest.arguments === null, "callAsExprTest.arguments = " + callAsExprTest.arguments);
254 tmp = (function() {1;})();
255 ok(tmp === undefined, "tmp = " + tmp);
257 ok(tmp === 1, "tmp = " + tmp);
259 ok(tmp === 2, "tmp = " + tmp);
260 tmp = eval("testNoRes(),2;");
261 ok(tmp === 2, "tmp = " + tmp);
262 tmp = eval("if(true) {3}");
263 ok(tmp === 3, "tmp = " + tmp);
264 eval("testRes(); testRes()");
265 tmp = eval("3; if(false) {4;} else {};;;")
266 ok(tmp === 3, "tmp = " + tmp);
267 tmp = eval("try { 1; } finally { 2; }")
268 ok(tmp === 2, "tmp = " + tmp);
271 testRes() && testRes();
272 testNoRes(), testNoRes();
276 ok(x === 1, "x = " + x);
282 ok(r === 1, "r = " + r);
283 (function(x, a) { x(a); })(eval, "2");
288 ok(r === 1, "r = " + r);
289 (function(x, a) { x(a); })(eval, "2");
292 tmp = (function(){ return testNoRes(), testRes();})();
296 ok(funcexpr() == 2, "funcexpr() = " + funcexpr());
298 f1 = function funcexpr() { return 1; }
299 ok(f1 != funcexpr, "f1 == funcexpr");
300 ok(f1() === 1, "f1() = " + f1());
302 f2 = function funcexpr() { return 2; }
303 ok(f2 != funcexpr, "f2 != funcexpr");
304 ok(f2() === 2, "f2() = " + f2());
307 for(i = 0; i < 3; i++) {
308 f2 = function funcexpr2() {};
309 ok(f1 != f2, "f1 == f2");
314 for(i = 0; i < 3; i++) {
316 ok(f1 != f2, "f1 == f2");
321 ok(infuncexpr() == 2, "infuncexpr() = " + infuncexpr());
323 f1 = function infuncexpr() { return 1; }
324 ok(f1 != funcexpr, "f1 == funcexpr");
325 ok(f1() === 1, "f1() = " + f1());
327 f2 = function infuncexpr() { return 2; }
328 ok(f2 != funcexpr, "f2 != funcexpr");
329 ok(f2() === 2, "f2() = " + f2());
332 for(i = 0; i < 3; i++) {
333 f2 = function infuncexpr2() {};
334 ok(f1 != f2, "f1 == f2");
339 for(i = 0; i < 3; i++) {
341 ok(f1 != f2, "f1 == f2");
346 var obj1 = new Object();
347 ok(typeof(obj1) === "object", "typeof(obj1) is not object");
348 ok(obj1.constructor === Object, "unexpected obj1.constructor");
350 obj1.func = function () {
351 ok(this === obj1, "this is not obj1");
352 ok(this.test === true, "this.test is not true");
353 ok(arguments.length === 1, "arguments.length is not 1");
354 ok(arguments["0"] === true, "arguments[0] is not true");
355 ok(typeof(arguments.callee) === "function", "typeof(arguments.calee) = " + typeof(arguments.calee));
360 ok(obj1.func(true) === "test", "obj1.func(true) is not \"test\"");
362 function testConstr1() {
365 ok(this !== undefined, "this is undefined");
366 ok(arguments.length === 1, "arguments.length is not 1");
367 ok(arguments["0"] === true, "arguments[0] is not 1");
368 ok(arguments.callee === testConstr1, "arguments.calee !== testConstr1");
373 testConstr1.prototype.pvar = 1;
374 ok(testConstr1.prototype.constructor === testConstr1, "testConstr1.prototype.constructor !== testConstr1");
376 var obj2 = new testConstr1(true);
377 ok(typeof(obj2) === "object", "typeof(obj2) is not object");
378 ok(obj2.constructor === testConstr1, "unexpected obj2.constructor");
379 ok(obj2.pvar === 1, "obj2.pvar is not 1");
380 ok(!obj2.hasOwnProperty('constructor'), "obj2.hasOwnProperty('constructor')");
382 testConstr1.prototype.pvar = 2;
383 ok(obj2.pvar === 2, "obj2.pvar is not 2");
386 testConstr1.prototype.pvar = 1;
387 ok(obj2.pvar === 3, "obj2.pvar is not 3");
390 function testConstr3() {
394 obj2 = new testConstr3();
395 ok(obj1 === obj2, "obj1 != obj2");
397 function testConstr4() {
401 obj2 = new testConstr3();
402 ok(typeof(obj2) === "object", "typeof(obj2) = " + typeof(obj2));
404 var obj3 = new Object;
405 ok(typeof(obj3) === "object", "typeof(obj3) is not object");
408 ok(typeof(func) === "function", "typeof(func) = " + typeof(func));
410 ok(typeof(func) === "function", "typeof(func) = " + typeof(func));
412 ok(typeof(func) === "number", "typeof(func) = " + typeof(func));
416 ok(typeof(f) === "function", "typeof(f) = " + typeof(f));
418 ok(typeof(f) === "function", "typeof(f) = " + typeof(f));
421 for(var iter in "test")
422 ok(false, "unexpected forin call, test = " + iter);
424 for(var iter in null)
425 ok(false, "unexpected forin call, test = " + iter);
427 for(var iter in false)
428 ok(false, "unexpected forin call, test = " + iter);
430 for(var iter in pureDisp)
431 ok(false, "unexpected forin call in pureDisp object");
434 ok(!tmp.nonexistent, "!tmp.nonexistent = " + !tmp.nonexistent);
435 ok(!("nonexistent" in tmp), "nonexistent is in tmp after '!' expression")
438 ok((~tmp.nonexistent) === -1, "!tmp.nonexistent = " + ~tmp.nonexistent);
439 ok(!("nonexistent" in tmp), "nonexistent is in tmp after '~' expression")
442 ok(isNaN(+tmp.nonexistent), "!tmp.nonexistent = " + (+tmp.nonexistent));
443 ok(!("nonexistent" in tmp), "nonexistent is in tmp after '+' expression")
446 tmp[tmp.nonexistent];
447 ok(!("nonexistent" in tmp), "nonexistent is in tmp after array expression")
453 ok(false, "else evaluated");
454 ok(tmp === 1, "tmp !== 1, if not evaluated?");
458 ok(false, "if evaluated");
461 ok(tmp === 1, "tmp !== 1, if not evaluated?");
464 ok(false, "if(false) evaluated");
469 ok(tmp === 1, "tmp !== 1, if(true) not evaluated?");
475 var obj3 = { prop1: 1, prop2: typeof(false) };
476 ok(obj3.prop1 === 1, "obj3.prop1 is not 1");
477 ok(obj3.prop2 === "boolean", "obj3.prop2 is not \"boolean\"");
478 ok(obj3.constructor === Object, "unexpected obj3.constructor");
484 ok(blockVar === 2, "blockVar !== 2");
486 ok((true ? 1 : 2) === 1, "conditional expression true is not 1");
487 ok((0 === 2 ? 1 : 2) === 2, "conditional expression true is not 2");
489 ok(getVT(undefined) === "VT_EMPTY", "getVT(undefined) is not VT_EMPTY");
490 ok(getVT(null) === "VT_NULL", "getVT(null) is not VT_NULL");
491 ok(getVT(0) === "VT_I4", "getVT(0) is not VT_I4");
492 ok(getVT(0.5) === "VT_R8", "getVT(0.5) is not VT_R8");
493 ok(getVT("test") === "VT_BSTR", "getVT(\"test\") is not VT_BSTR");
494 ok(getVT(Math) === "VT_DISPATCH", "getVT(Math) is not VT_DISPATCH");
495 ok(getVT(false) === "VT_BOOL", "getVT(false) is not VT_BOOL");
498 ok(tmp === 4, "2+2 !== 4");
499 ok(getVT(tmp) === "VT_I4", "getVT(2+2) !== VT_I4");
502 ok(tmp === 4.5, "2+2.5 !== 4.5");
503 ok(getVT(tmp) === "VT_R8", "getVT(2+2.5) !== VT_R8");
506 ok(tmp === 4, "1.4+2.5 !== 4");
507 ok(getVT(tmp) === "VT_I4", "getVT(1.5+2.5) !== VT_I4");
510 ok(tmp === 2, "4-2 !== 2");
511 ok(getVT(tmp) === "VT_I4", "getVT(4-2) !== VT_I4");
514 ok(tmp === 2.5, "4.5-2 !== 2.5");
515 ok(getVT(tmp) === "VT_R8", "getVT(4.5-2) !== VT_R8");
518 ok(tmp === 0-2, "-2 !== 0-2");
519 ok(getVT(tmp) === "VT_I4", "getVT(-2) !== VT_I4");
522 ok(tmp === 6, "2*3 !== 6");
523 ok(getVT(tmp) === "VT_I4", "getVT(2*3) !== VT_I4");
526 ok(tmp === 7, "2*3.5 !== 7");
527 ok(getVT(tmp) === "VT_I4", "getVT(2*3.5) !== VT_I4");
530 /* FIXME: the parser loses precision */
531 /* ok(tmp === 8.75, "2.5*3.5 !== 8.75"); */
532 ok(tmp > 8.749999 && tmp < 8.750001, "2.5*3.5 !== 8.75");
533 ok(getVT(tmp) === "VT_R8", "getVT(2.5*3.5) !== VT_R8");
536 ok(tmp === 1, "2*.5 !== 1");
537 ok(getVT(tmp) == "VT_I4", "getVT(2*.5) !== VT_I4");
540 ok(tmp === 2, "4/2 !== 2");
541 ok(getVT(tmp) === "VT_I4", "getVT(4/2) !== VT_I4");
544 ok(tmp === 3, "4.5/1.5 !== 3");
545 ok(getVT(tmp) === "VT_I4", "getVT(4.5/1.5) !== VT_I4");
548 ok(tmp === 1.5, "3/2 !== 1.5");
549 ok(getVT(tmp) === "VT_R8", "getVT(3/2) !== VT_R8");
552 ok(tmp === 1, "3%2 = " + tmp);
555 ok(tmp ===0, "4%2 = " + tmp);
558 ok(tmp === 0.5, "3.5%1.5 = " + tmp);
561 ok(tmp === 0, "3%true = " + tmp);
564 ok(tmp === "abcd", "\"ab\" + \"cd\" !== \"abcd\"");
567 ok((tmp += 1) === 2, "tmp += 1 !== 2");
568 ok(tmp === 2, "tmp !== 2");
571 ok((tmp -= 1) === 1, "tmp -= 1 !== 1");
572 ok(tmp === 1, "tmp !=== 1");
575 ok((tmp *= 1.5) === 3, "tmp *= 1.5 !== 3");
576 ok(tmp === 3, "tmp !=== 3");
579 ok((tmp /= 2) === 2.5, "tmp /= 2 !== 2.5");
580 ok(tmp === 2.5, "tmp !=== 2.5");
583 ok((tmp %= 2) === 1, "tmp %= 2 !== 1");
584 ok(tmp === 1, "tmp !== 1");
587 ok((tmp <<= 1) === 16, "tmp <<= 1 !== 16");
590 ok((tmp >>= 1) === 4, "tmp >>= 1 !== 4");
593 ok((tmp >>>= 1) === 4, "tmp >>>= 1 !== 4");
595 tmp = 3 || ok(false, "second or expression called");
596 ok(tmp === 3, "3 || (...) is not 3");
599 ok(tmp === 2, "false || 2 is not 2");
601 tmp = 0 && ok(false, "second and expression called");
602 ok(tmp === 0, "0 && (...) is not 0");
604 tmp = true && "test";
605 ok(tmp === "test", "true && \"test\" is not \"test\"");
608 ok(tmp === 0, "true && 0 is not 0");
611 ok(tmp === 7, "3 | 4 !== 7");
612 ok(getVT(tmp) === "VT_I4", "getVT(3|4) = " + getVT(tmp));
615 ok(tmp === 3, "3.5 | 0 !== 3");
616 ok(getVT(tmp) === "VT_I4", "getVT(3.5|0) = " + getVT(tmp));
619 ok(tmp === -3, "-3.5 | 0 !== -3");
620 ok(getVT(tmp) === "VT_I4", "getVT(3.5|0) = " + getVT(tmp));
623 ok(tmp === 0, "0 | NaN = " + tmp);
626 ok(tmp === 0, "0 | NaN = " + tmp);
628 tmp = 0 | (-Infinity);
629 ok(tmp === 0, "0 | NaN = " + tmp);
632 ok((tmp |= 0x10) === 26, "tmp(10) |= 0x10 !== 26");
633 ok(getVT(tmp) === "VT_I4", "getVT(tmp |= 10) = " + getVT(tmp));
636 ok(tmp === 1, "3 & 5 !== 1");
637 ok(getVT(tmp) === "VT_I4", "getVT(3|5) = " + getVT(tmp));
640 ok(tmp === 3, "3.5 & 0xffff !== 3 ");
641 ok(getVT(tmp) === "VT_I4", "getVT(3.5&0xffff) = " + getVT(tmp));
643 tmp = (-3.5) & 0xffffffff;
644 ok(tmp === -3, "-3.5 & 0xffff !== -3");
645 ok(getVT(tmp) === "VT_I4", "getVT(3.5&0xffff) = " + getVT(tmp));
648 ok(tmp === 16, "2 << 3 = " + tmp);
651 ok(tmp === 16, "2 << 35 = " + tmp);
654 ok(tmp === 2, "8 >> 2 = " + tmp);
657 ok(tmp === -4, "-64 >> 4 = " + tmp);
660 ok(tmp === 2, "8 >> 2 = " + tmp);
663 ok(tmp === 0x0ffffffc, "-64 >>> 4 = " + tmp);
666 ok(tmp === 4, "4 >>> NaN = " + tmp);
669 ok((tmp &= 8) === 8, "tmp(10) &= 8 !== 8");
670 ok(getVT(tmp) === "VT_I4", "getVT(tmp &= 8) = " + getVT(tmp));
673 ok(tmp === 0x0ff0, "0xf0f0^0xff00 !== 0x0ff0");
674 ok(getVT(tmp) === "VT_I4", "getVT(0xf0f0^0xff00) = " + getVT(tmp));
677 ok((tmp ^= 3) === 6, "tmp(5) ^= 3 !== 6");
678 ok(getVT(tmp) === "VT_I4", "getVT(tmp ^= 3) = " + getVT(tmp));
681 ok(tmp === -2, "~1 !== -2");
682 ok(getVT(tmp) === "VT_I4", "getVT(~1) = " + getVT(tmp));
684 ok((3,4) === 4, "(3,4) !== 4");
686 ok(+3 === 3, "+3 !== 3");
687 ok(+true === 1, "+true !== 1");
688 ok(+false === 0, "+false !== 0");
689 ok(+null === 0, "+null !== 0");
690 ok(+"0" === 0, "+'0' !== 0");
691 ok(+"3" === 3, "+'3' !== 3");
692 ok(+"-3" === -3, "+'-3' !== -3");
693 ok(+"0xff" === 255, "+'0xff' !== 255");
694 ok(+"3e3" === 3000, "+'3e3' !== 3000");
697 ok(+tmp === 1, "+(new Number(1)) = " + (+tmp));
698 ok(tmp.constructor === Number, "unexpected tmp.constructor");
699 tmp = new String("1");
700 ok(+tmp === 1, "+(new String('1')) = " + (+tmp));
701 ok(tmp.constructor === String, "unexpected tmp.constructor");
703 ok("" + 0 === "0", "\"\" + 0 !== \"0\"");
704 ok("" + 123 === "123", "\"\" + 123 !== \"123\"");
705 ok("" + (-5) === "-5", "\"\" + (-5) !== \"-5\"");
706 ok("" + null === "null", "\"\" + null !== \"null\"");
707 ok("" + undefined === "undefined", "\"\" + undefined !== \"undefined\"");
708 ok("" + true === "true", "\"\" + true !== \"true\"");
709 ok("" + false === "false", "\"\" + false !== \"false\"");
710 ok("" + 0.5 === "0.5", "'' + 0.5 = " + 0.5);
711 ok("" + (-0.5432) === "-0.5432", "'' + (-0.5432) = " + (-0.5432));
713 ok(1 < 3.4, "1 < 3.4 failed");
714 ok(!(3.4 < 1), "3.4 < 1");
715 ok("abc" < "abcd", "abc < abcd failed");
716 ok("abcd" < "abce", "abce < abce failed");
717 ok("" < "x", "\"\" < \"x\" failed");
718 ok(!(0 < 0), "0 < 0");
720 ok(1 <= 3.4, "1 <= 3.4 failed");
721 ok(!(3.4 <= 1), "3.4 <= 1");
722 ok("abc" <= "abcd", "abc <= abcd failed");
723 ok("abcd" <= "abce", "abce <= abce failed");
724 ok("" <= "x", "\"\" <= \"x\" failed");
725 ok(0 <= 0, "0 <= 0 failed");
727 ok(3.4 > 1, "3.4 > 1 failed");
728 ok(!(1 > 3.4), "1 > 3.4");
729 ok("abcd" > "abc", "abc > abcd failed");
730 ok("abce" > "abcd", "abce > abce failed");
731 ok("x" > "", "\"x\" > \"\" failed");
732 ok(!(0 > 0), "0 > 0");
734 ok(3.4 >= 1, "3.4 >= 1 failed");
735 ok(!(1 >= 3.4), "1 >= 3.4");
736 ok("abcd" >= "abc", "abc >= abcd failed");
737 ok("abce" >= "abcd", "abce >= abce failed");
738 ok("x" >= "", "\"x\" >= \"\" failed");
739 ok(0 >= 0, "0 >= 0");
742 ok(++tmp === 2, "++tmp (1) is not 2");
743 ok(tmp === 2, "incremented tmp is not 2");
744 ok(--tmp === 1, "--tmp (2) is not 1");
745 ok(tmp === 1, "decremented tmp is not 1");
746 ok(tmp++ === 1, "tmp++ (1) is not 1");
747 ok(tmp === 2, "incremented tmp(1) is not 2");
748 ok(tmp-- === 2, "tmp-- (2) is not 2");
749 ok(tmp === 1, "decremented tmp is not 1");
753 ok(isNaN(tmp.iii), "tmp.iii = " + tmp.iii);
755 String.prototype.test = true;
756 ok("".test === true, "\"\".test is not true");
758 Boolean.prototype.test = true;
759 ok(true.test === true, "true.test is not true");
761 Number.prototype.test = true;
762 ok((0).test === true, "(0).test is not true");
763 ok((0.5).test === true, "(0.5).test is not true");
767 ok(state === "", "try: state = " + state);
770 ok(false, "unexpected catch");
772 ok(state === "try", "state = " + state + " expected try");
776 ok(state === "", "try: state = " + state);
779 ok(state === "try", "finally: state = " + state);
782 ok(state === "finally", "state = " + state + " expected finally");
792 ok(state === "finally", "state = " + state + " expected finally");
795 ok(state === "catch", "state = " + state + " expected catch");
804 ok(e === 1, "e = " + e);
809 ok(state === "", "try: state = " + state);
812 ok(false, "unexpected catch");
814 ok(state === "try", "finally: state = " + state);
817 ok(state === "finally", "state = " + state + " expected finally");
821 ok(state === "", "try: state = " + state);
825 ok(state === "try", "catch: state = " + state);
826 ok(ex === "except", "ex is not \"except\"");
829 ok(state === "catch", "state = " + state + " expected catch");
833 ok(state === "", "try: state = " + state);
837 ok(state === "try", "catch: state = " + state);
838 ok(ex === true, "ex is not true");
841 ok(state === "catch", "finally: state = " + state);
844 ok(state === "finally", "state = " + state + " expected finally");
848 ok(state === "", "try: state = " + state);
850 try { throw true; } finally {}
852 ok(state === "try", "catch: state = " + state);
853 ok(ex === true, "ex is not true");
856 ok(state === "catch", "finally: state = " + state);
859 ok(state === "finally", "state = " + state + " expected finally");
863 ok(state === "", "try: state = " + state);
865 try { throw "except"; } catch(ex) { throw true; }
867 ok(state === "try", "catch: state = " + state);
868 ok(ex === true, "ex is not true");
871 ok(state === "catch", "finally: state = " + state);
874 ok(state === "finally", "state = " + state + " expected finally");
876 function throwFunc(x) {
882 ok(state === "", "try: state = " + state);
886 ok(state === "try", "catch: state = " + state);
887 ok(ex === true, "ex is not true");
890 ok(state === "catch", "finally: state = " + state);
893 ok(state === "finally", "state = " + state + " expected finally");
898 ok(false, "unexpected case \"1\"");
900 ok(state === "", "case 1: state = " + state);
903 ok(state === "1", "default: state = " + state);
906 ok(state === "default", "case false: state = " + state);
909 ok(state === "false", "state = " + state);
915 ok(false, "unexpected case 1");
917 ok(state === "", "default: state = " + state);
920 ok(state === "default", "case false: state = " + state);
923 ok(state === "false", "state = " + state);
928 ok(false, "unexpected case \"1\"");
930 ok(state === "", "case 1: state = " + state);
933 ok(state === "1", "default: state = " + state);
937 ok(false, "unexpected case false");
939 ok(state === "default", "state = " + state);
943 ok(false, "unexpected case 2");
945 ok(false, "unexpected case 3");
950 ok(false, "unexpected case 2");
958 ok(false, "unexpected default");
966 ok(false, "unexpected default");
985 ok(tmp === 1, "eval(\"1\") !== 1");
986 eval("{ ok(tmp === 1, 'eval: tmp !== 1'); } tmp = 2;");
987 ok(tmp === 2, "tmp !== 2");
989 ok(eval(false) === false, "eval(false) !== false");
990 ok(eval() === undefined, "eval() !== undefined");
992 tmp = eval("1", "2");
993 ok(tmp === 1, "eval(\"1\", \"2\") !== 1");
997 ok(state === "", "try: state = " + state);
999 eval("throwFunc(true);");
1001 ok(state === "try", "catch: state = " + state);
1002 ok(ex === true, "ex is not true");
1005 ok(state === "catch", "finally: state = " + state);
1008 ok(state === "finally", "state = " + state + " expected finally");
1010 tmp = [,,1,2,,,true];
1011 ok(tmp.length === 7, "tmp.length !== 7");
1012 ok(tmp["0"] === undefined, "tmp[0] is not undefined");
1013 ok(tmp["3"] === 2, "tmp[3] !== 2");
1014 ok(tmp["6"] === true, "tmp[6] !== true");
1015 ok(tmp[2] === 1, "tmp[2] !== 1");
1017 ok([1,].length === 2, "[1,].length !== 2");
1018 ok([,,].length === 3, "[,,].length !== 3");
1019 ok([,].length === 2, "[].length != 2");
1020 ok([].length === 0, "[].length != 0");
1024 ok(tmp < 4, "tmp >= 4");
1027 ok(tmp === 4, "tmp !== 4");
1031 ok(tmp < 4, "tmp >= 4");
1035 ok(false, "break did not break");
1038 ok(tmp === 4, "tmp !== 4");
1042 ok(tmp < 4, "tmp >= 4");
1045 ok(tmp === 4, "tmp !== 4");
1049 ok(tmp === 0, "tmp !=== 0");
1052 ok(tmp === 1, "tmp !== 1");
1056 ok(tmp < 4, "tmp >= 4");
1059 ok(tmp === 4, "tmp !== 4")
1066 ok(false, "break did not break");
1068 ok(tmp <= 4 && tmp != 2, "tmp = " + tmp);
1070 ok(tmp === 4, "tmp !== 4");
1072 for(tmp=0; tmp < 4; tmp++)
1073 ok(tmp < 4, "tmp = " + tmp);
1074 ok(tmp === 4, "tmp !== 4");
1076 for(tmp=0; tmp < 4; tmp++) {
1079 ok(tmp < 2, "tmp = " + tmp);
1081 ok(tmp === 2, "tmp !== 2");
1083 for(tmp=0; tmp < 4; tmp++) {
1086 ok(tmp < 4 && tmp != 2, "tmp = " + tmp);
1088 ok(tmp === 4, "tmp !== 4");
1090 for(var fi=0; fi < 4; fi++)
1091 ok(fi < 4, "fi = " + fi);
1092 ok(fi === 4, "fi !== 4");
1095 obj1 = new Object();
1096 for(obj1.nonexistent; tmp; tmp = false)
1097 ok(!("nonexistent" in obj1), "nonexistent added to obj1");
1099 obj1 = new Object();
1100 for(tmp in obj1.nonexistent)
1101 ok(false, "for(tmp in obj1.nonexistent) called with tmp = " + tmp);
1102 ok(!("nonexistent" in obj1), "nonexistent added to obj1 by for..in loop");
1107 /* Previous versions have broken finally block implementation */
1108 if(ScriptEngineMinorVersion() >= 8) {
1113 for(i = 1; i < 3; i++) {
1127 ok(false, "unexpected state");
1136 ok(tmp === "123456", "tmp = " + tmp);
1154 ok(false, "unexpected state");
1162 ok(tmp === "1234", "tmp = " + tmp);
1165 for(var iter in [1,2,3]) {
1169 ok(tmp === 3, "tmp = " + tmp);
1172 for(var iter in [1,2,3]) {
1183 ok(tmp, "tmp = " + tmp);
1197 ok(false, "unexpected evaluation 1");
1202 ok(false, "unexpected evaluation 2");
1205 just_label: tmp = 1;
1206 ok(tmp === 1, "tmp != 1");
1208 some_label: break some_label;
1212 ok(false, "unexpected evaluation 3");
1218 continue loop_label;
1222 for(i = 0; i < 3; i++) {
1224 continue loop_label;
1229 for(i = 0; i < 3; i++) {
1231 continue loop_label;
1235 for(tmp in {prop: false}) {
1237 continue loop_label;
1240 ok((void 1) === undefined, "(void 1) !== undefined");
1242 var inobj = new Object();
1244 for(var iter in inobj)
1245 ok(false, "unexpected iter = " + iter);
1249 for(iter in inobj) {
1250 ok(iter == "test", "unexpected iter = " + iter);
1253 ok(tmp === 1, "for..in tmp = " + tmp);
1255 function forinTestObj() {}
1257 forinTestObj.prototype.test3 = true;
1259 var arr = new Array();
1260 inobj = new forinTestObj();
1265 for(iter in inobj) {
1270 ok(tmp === 3, "for..in tmp = " + tmp);
1271 ok(arr["test1"] === true, "arr[test1] !== true");
1272 ok(arr["test2"] === true, "arr[test2] !== true");
1273 ok(arr["test3"] === true, "arr[test3] !== true");
1277 ok((delete tmp.test) === true, "delete returned false");
1278 ok(typeof(tmp.test) === "undefined", "tmp.test type = " + typeof(tmp.test));
1279 ok(!("test" in tmp), "test is still in tmp after delete?");
1281 ok(false, "tmp has prop " + iter);
1282 ok((delete tmp.test) === true, "deleting test didn't return true");
1283 ok((delete tmp.nonexistent) === true, "deleting nonexistent didn't return true");
1284 ok((delete nonexistent) === true, "deleting nonexistent didn't return true");
1288 ok((delete tmp["test"]) === true, "delete returned false");
1289 ok(typeof(tmp.test) === "undefined", "tmp.test type = " + typeof(tmp.test));
1290 ok(!("test" in tmp), "test is still in tmp after delete?");
1292 tmp.testWith = true;
1294 ok(testWith === true, "testWith !== true");
1297 var varTest1 = true;
1300 ok(varTest1 === undefined, "varTest1 = " + varTest1);
1301 ok(varTest2 === undefined, "varTest2 = " + varTest1);
1305 function varTestFunc(varTest3) {
1308 ok(varTest3 === 3, "varTest3 = " + varTest3);
1309 ok(varTest4 === undefined, "varTest4 = " + varTest4);
1320 ok(false, "deleteTest not throwed exception?");
1325 var r = delete to_delete;
1326 ok(r === false, "delete 1 returned " + r);
1329 ok(to_delete === 2, "to_delete = " + to_delete);
1331 to_delete = new Object();
1332 r = delete to_delete;
1333 ok(r === false, "delete 2 returned " + r);
1334 ok(typeof(to_delete) === "object", "typeof(to_delete) = " + typeof(to_delete));
1337 (function(to_delete) {
1338 var r = delete to_delete;
1339 ok(r === false, "delete 3 returned " + r);
1340 ok(to_delete === 2, "to_delete = " + to_delete);
1342 to_delete = new Object();
1343 r = delete to_delete;
1344 ok(r === false, "delete 4 returned " + r);
1345 ok(typeof(to_delete) === "object", "typeof(to_delete) = " + typeof(to_delete));
1349 with({to_delete: new Object()}) {
1350 var r = delete to_delete;
1351 ok(r === true, "delete returned " + r);
1357 ok(false, "if evaluated");
1359 ok(false, "else should be associated with nearest if statement");
1363 ok(false, "if evaluated");
1365 ok(true, "else should be associated with nearest if statement");
1367 function instanceOfTest() {}
1368 tmp = new instanceOfTest();
1370 ok((tmp instanceof instanceOfTest) === true, "tmp is not instance of instanceOfTest");
1371 ok((tmp instanceof Object) === true, "tmp is not instance of Object");
1372 ok((tmp instanceof String) === false, "tmp is instance of String");
1374 instanceOfTest.prototype = new Object();
1375 ok((tmp instanceof instanceOfTest) === false, "tmp is instance of instanceOfTest");
1376 ok((tmp instanceof Object) === true, "tmp is not instance of Object");
1378 ok((1 instanceof Object) === false, "1 is instance of Object");
1379 ok((false instanceof Boolean) === false, "false is instance of Boolean");
1380 ok(("" instanceof Object) === false, "'' is instance of Object");
1383 ok((arguments instanceof Object) === true, "argument is not instance of Object");
1384 ok((arguments instanceof Array) === false, "argument is not instance of Array");
1385 ok(arguments.toString() === "[object Object]", "arguments.toString() = " + arguments.toString());
1389 ok(("length" in obj) === true, "length is not in obj");
1390 ok(("isPrototypeOf" in obj) === true, "isPrototypeOf is not in obj");
1391 ok(("abc" in obj) === false, "test is in obj");
1393 ok(("abc" in obj) === true, "test is not in obj");
1394 ok(("1" in obj) === false, "1 is in obj");
1397 ok((1 in obj) === true, "1 is not in obj");
1402 ok(false, "expected exception");
1404 ok(!("prop" in obj), "prop in obj");
1406 if(invokeVersion >= 2) {
1407 ok("test"[0] === "t", '"test"[0] = ' + test[0]);
1408 ok("test"[5] === undefined, '"test"[0] = ' + test[0]);
1411 ok(tmp[1] === "e", "tmp[1] = " + tmp[1]);
1413 ok(tmp[1] === "e", "tmp[1] = " + tmp[1]);
1414 ok(tmp["1"] === "e", "tmp['1'] = " + tmp["1"]);
1415 ok(tmp["0x1"] === undefined, "tmp['0x1'] = " + tmp["0x1"]);
1417 ok("test"[0] === undefined, '"test"[0] = ' + test[0]);
1420 ok(isNaN(NaN) === true, "isNaN(NaN) !== true");
1421 ok(isNaN(0.5) === false, "isNaN(0.5) !== false");
1422 ok(isNaN(Infinity) === false, "isNaN(Infinity) !== false");
1423 ok(isNaN() === true, "isNaN() !== true");
1424 ok(isNaN(NaN, 0) === true, "isNaN(NaN, 0) !== true");
1425 ok(isNaN(0.5, NaN) === false, "isNaN(0.5, NaN) !== false");
1426 ok(isNaN(+undefined) === true, "isNaN(+undefined) !== true");
1428 ok(isFinite(0.5) === true, "isFinite(0.5) !== true");
1429 ok(isFinite(Infinity) === false, "isFinite(Infinity) !== false");
1430 ok(isFinite(-Infinity) === false, "isFinite(Infinity) !== false");
1431 ok(isFinite(NaN) === false, "isFinite(NaN) !== false");
1432 ok(isFinite(0.5, NaN) === true, "isFinite(0.5, NaN) !== true");
1433 ok(isFinite(NaN, 0.5) === false, "isFinite(NaN, 0.5) !== false");
1434 ok(isFinite() === false, "isFinite() !== false");
1436 ok((1 < NaN) === false, "(1 < NaN) !== false");
1437 ok((1 > NaN) === false, "(1 > NaN) !== false");
1438 ok((1 <= NaN) === false, "(1 <= NaN) !== false");
1439 ok((1 >= NaN) === false, "(1 >= NaN) !== false");
1440 ok((NaN < 1) === false, "(NaN < 1) !== false");
1441 ok((NaN > 1) === false, "(NaN > 1) !== false");
1442 ok((NaN <= 1) === false, "(NaN <= 1) !== false");
1443 ok((NaN >= 1) === false, "(NaN >= 1) !== false");
1444 ok((Infinity < 2) === false, "(Infinity < 2) !== false");
1445 ok((Infinity > 2) === true, "(Infinity > 2) !== true");
1446 ok((-Infinity < 2) === true, "(-Infinity < 2) !== true");
1448 ok(isNaN(+"test") === true, "isNaN(+'test') !== true");
1449 ok(isNaN(+"123t") === true, "isNaN(+'123t') !== true");
1450 ok(isNaN(+"Infinity x") === true, "isNaN(+'Infinity x') !== true");
1451 ok(+"Infinity" === Infinity, "+'Infinity' !== Infinity");
1452 ok(+" Infinity " === Infinity, "+' Infinity ' !== Infinity");
1453 ok(+"-Infinity" === -Infinity, "+'-Infinity' !== -Infinity");
1455 ok((NaN !== NaN) === true, "(NaN !== NaN) !== true");
1456 ok((NaN === NaN) === false, "(NaN === NaN) !== false");
1457 ok((Infinity !== NaN) === true, "(Infinity !== NaN) !== true");
1458 ok((Infinity !== NaN) === true, "(Infinity !== NaN) !== true");
1459 ok((0 === NaN) === false, "(0 === NaN) !== false");
1461 ok((NaN != NaN) === true, "(NaN !== NaN) != true");
1462 ok((NaN == NaN) === false, "(NaN === NaN) != false");
1463 ok((Infinity != NaN) === true, "(Infinity != NaN) !== true");
1464 ok((Infinity != NaN) === true, "(Infinity != NaN) !== true");
1465 ok((0 == NaN) === false, "(0 === NaN) != false");
1478 ["\xf3", "\\xf3", 0xf3],
1479 ["\u1234", "\\u1234", 0x1234],
1484 for(i=0; i<escapeTests.length; i++) {
1485 tmp = escapeTests[i][0].charCodeAt(0);
1486 ok(tmp === escapeTests[i][2], "escaped '" + escapeTests[i][1] + "' = " + tmp + " expected " + escapeTests[i][2]);
1490 ok(tmp === true, '!+"\v1" = ' + tmp);
1492 ok(typeof(testFunc2) === "function", "typeof(testFunc2) = " + typeof(testFunc2));
1494 ok(tmp === 2, "testFunc2(1) = " + tmp);
1495 function testFunc2(x) { return x+1; }
1497 ok(typeof(testFunc3) === "function", "typeof(testFunc3) = " + typeof(testFunc3));
1499 ok(tmp === 3, "testFunc3(1) = " + tmp);
1500 tmp = function testFunc3(x) { return x+2; };
1503 ok(tmp === 5, "testFunc4(1) = " + tmp);
1504 tmp = function testFunc4(x) { return x+3; };
1507 ok(testFunc4 === 1, "testFunc4 = " + testFunc4);
1508 ok(tmp === 5, "testFunc4(1) = " + tmp);
1509 tmp = function testFunc4(x) { return x+4; };
1510 ok(testFunc4 === 1, "testFunc4 = " + testFunc4);
1512 function testEmbeddedFunctions() {
1513 ok(typeof(testFunc5) === "function", "typeof(testFunc5) = " + typeof(testFunc5));
1515 ok(tmp === 3, "testFunc5(1) = " + tmp);
1516 tmp = function testFunc5(x) { return x+2; };
1519 ok(tmp === 5, "testFunc6(1) = " + tmp);
1520 tmp = function testFunc6(x) { return x+3; };
1522 ok(tmp === 5, "testFunc6(1) = " + tmp);
1523 tmp = function testFunc6(x) { return x+4; };
1525 ok(testFunc6 === 1, "testFunc4 = " + testFunc6);
1528 testEmbeddedFunctions();
1531 date.toString = function() { return "toString"; }
1532 ok(""+date === "toString", "''+date = " + date);
1533 date.toString = function() { return this; }
1534 ok(""+date === ""+date.valueOf(), "''+date = " + date);
1536 str = new String("test");
1537 str.valueOf = function() { return "valueOf"; }
1538 ok(""+str === "valueOf", "''+str = " + str);
1539 str.valueOf = function() { return new Date(); }
1540 ok(""+str === "test", "''+str = " + str);
1542 ok((function (){return 1;})() === 1, "(function (){return 1;})() = " + (function (){return 1;})());
1544 var re = /=(\?|%3F)/g;
1545 ok(re.source === "=(\\?|%3F)", "re.source = " + re.source);
1548 for(var i=0; i<2; i++)
1550 ok(tmp[0] != tmp[1], "tmp[0] == tmp [1]");
1552 ok(isNullBSTR(getNullBSTR()), "isNullBSTR(getNullBSTR()) failed\n");
1553 ok(getNullBSTR() === '', "getNullBSTR() !== ''");
1554 ok(+getNullBSTR() === 0 , "+getNullBTR() !=== 0");
1556 ok(getVT(nullDisp) === "VT_DISPATCH", "getVT(nullDisp) = " + getVT(nullDisp));
1557 ok(typeof(nullDisp) === "object", "typeof(nullDisp) = " + typeof(nullDisp));
1558 ok(nullDisp === nullDisp, "nullDisp !== nullDisp");
1559 ok(nullDisp !== re, "nullDisp === re");
1560 ok(nullDisp === null, "nullDisp === null");
1561 ok(nullDisp == null, "nullDisp == null");
1562 ok(getVT(true && nullDisp) === "VT_DISPATCH",
1563 "getVT(0 && nullDisp) = " + getVT(true && nullDisp));
1564 ok(!nullDisp === true, "!nullDisp = " + !nullDisp);
1565 ok(String(nullDisp) === "null", "String(nullDisp) = " + String(nullDisp));
1566 ok(nullDisp != new Object(), "nullDisp == new Object()");
1567 ok(new Object() != nullDisp, "new Object() == nullDisp");
1568 ok((typeof Object(nullDisp)) === "object", "typeof Object(nullDisp) !== 'object'");
1569 tmp = getVT(Object(nullDisp));
1570 ok(tmp === "VT_DISPATCH", "getVT(Object(nullDisp) = " + tmp);
1571 tmp = Object(nullDisp).toString();
1572 ok(tmp === "[object Object]", "Object(nullDisp).toString() = " + tmp);
1574 function do_test() {}
1575 function nosemicolon() {} nosemicolon();
1576 function () {} nosemicolon();
1579 function in_if_false() { return true; } ok(false, "!?");
1582 ok(in_if_false(), "in_if_false failed");
1584 (function() { newValue = 1; })();
1585 ok(newValue === 1, "newValue = " + newValue);
1587 obj = {undefined: 3};
1589 ok(typeof(name_override_func) === "function", "typeof(name_override_func) = " + typeof(name_override_func));
1590 name_override_func = 3;
1591 ok(name_override_func === 3, "name_override_func = " + name_override_func);
1592 function name_override_func() {};
1593 ok(name_override_func === 3, "name_override_func = " + name_override_func);
1600 ok(tmp, "tmp = " + tmp);
1603 for(var iter in [1,2,3,4]) {
1609 ok(tmp, "tmp = " + tmp);
1612 ok(typeof(func) === "function", "typeof(func) = " + typeof(func));
1613 with(new Object()) {
1614 var x = false && function func() {};
1616 ok(typeof(func) === "function", "typeof(func) = " + typeof(func));
1620 ok(x === undefined, "x = " + x); // x is declared, but never initialized
1622 ok(x === 1, "x = " + x);
1624 ok(x === 2, "x = " + x);
1626 ok(x === undefined, "x = " + x);
1629 /* NoNewline rule parser tests */
1637 * no semicolon, but comment present */
1642 if(true) break // no semicolon, but comment present
1652 function returnTest() {
1657 ok(returnTest() === undefined, "returnTest = " + returnTest());
1660 ok(ActiveXObject === 1, "ActiveXObject = " + ActiveXObject);
1663 ok(Boolean === 1, "Boolean = " + Boolean);
1666 ok(Object === 1, "Object = " + Object);
1669 ok(Array === 1, "Array = " + Array);
1672 ok(Date === 1, "Date = " + Date);
1675 ok(Error === 1, "Error = " + Error);
1677 /* Keep this test in the end of file */
1679 ok(undefined === 6, "undefined = " + undefined);
1682 ok(NaN === 6, "NaN !== 6");
1685 ok(Infinity === 6, "Infinity !== 6");
1688 ok(Math === 6, "NaN !== 6");