jscript: Added support for no new line between return and expression rule.
[wine/wine-gecko.git] / dlls / jscript / tests / lang.js
blobdbb9d50d2df8e7f7d57bfc757a8545c8cdc63f37
1 /*
2  * Copyright 2008 Jacek Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
19 var tmp;
21 ok(true, "true is not true?");
22 ok(!false, "!false is not true");
23 ok(!undefined, "!undefined is not true");
24 ok(!null, "!null is not true");
25 ok(!0, "!0 is not true");
26 ok(!0.0, "!0.0 is not true");
28 ok(1 === 1, "1 === 1 is false");
29 ok(!(1 === 2), "!(1 === 2) is false");
30 ok(1.0 === 1, "1.0 === 1 is false");
31 ok("abc" === "abc", "\"abc\" === \"abc\" is false");
32 ok(true === true, "true === true is false");
33 ok(null === null, "null === null is false");
34 ok(undefined === undefined, "undefined === undefined is false");
35 ok(!(undefined === null), "!(undefined === null) is false");
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");
59 var trueVar = true;
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");
72     ok(testFunc1.arguments === arguments, "testFunc1.arguments = " + testFunc1.arguments);
74     return true;
77 ok(testFunc1.length === 2, "testFunc1.length is not 2");
78 ok(testFunc1.arguments === null, "testFunc1.arguments = " + testFunc1.arguments);
80 ok(Object.prototype !== undefined, "Object.prototype is undefined");
81 ok(Object.prototype.prototype === undefined, "Object.prototype is not undefined");
82 ok(String.prototype !== undefined, "String.prototype is undefined");
83 ok(Array.prototype !== undefined, "Array.prototype is undefined");
84 ok(Boolean.prototype !== undefined, "Boolean.prototype is undefined");
85 ok(Number.prototype !== undefined, "Number.prototype is undefined");
86 ok(RegExp.prototype !== undefined, "RegExp.prototype is undefined");
87 ok(Math !== undefined, "Math is undefined");
88 ok(Math.prototype === undefined, "Math.prototype is not undefined");
89 ok(Function.prototype !== undefined, "Function.prototype is undefined");
90 ok(Function.prototype.prototype === undefined, "Function.prototype.prototype is not undefined");
91 ok(Date.prototype !== undefined, "Date.prototype is undefined");
92 ok(Date.prototype.prototype === undefined, "Date.prototype is not undefined");
94 function testConstructor(constr, name, inst) {
95     ok(constr.prototype.constructor === constr, name + ".prototype.constructor !== " + name);
96     ok(constr.prototype.hasOwnProperty("constructor"), name + ".prototype.hasOwnProperty('constructor')");
98     if(!inst)
99         inst = new constr();
101     ok(inst.constructor === constr, "(new " + name + "()).constructor !== " + name);
102     ok(!inst.hasOwnProperty("constructor"), "(new " + name + "()).hasOwnProperty('constructor')");
105 testConstructor(Object, "Object");
106 testConstructor(String, "String");
107 testConstructor(Array, "Array");
108 testConstructor(Boolean, "Boolean");
109 testConstructor(Number, "Number");
110 testConstructor(RegExp, "RegExp", /x/);
111 testConstructor(Function, "Function");
112 testConstructor(Date, "Date");
113 testConstructor(VBArray, "VBArray", new VBArray(createArray()));
114 testConstructor(Error, "Error");
115 testConstructor(EvalError, "EvalError");
116 testConstructor(RangeError, "RangeError");
117 testConstructor(ReferenceError, "ReferenceError");
118 testConstructor(RegExpError, "RegExpError");
119 testConstructor(SyntaxError, "SyntaxError");
120 testConstructor(TypeError, "TypeError");
121 testConstructor(URIError, "URIError");
123 Function.prototype.test = true;
124 ok(testFunc1.test === true, "testFunc1.test !== true");
125 ok(Function.test === true, "Function.test !== true");
127 ok(typeof(0) === "number", "typeof(0) is not number");
128 ok(typeof(1.5) === "number", "typeof(1.5) is not number");
129 ok(typeof("abc") === "string", "typeof(\"abc\") is not string");
130 ok(typeof("") === "string", "typeof(\"\") is not string");
131 ok(typeof(true) === "boolean", "typeof(true) is not boolean");
132 ok(typeof(null) === "object", "typeof(null) is not object");
133 ok(typeof(undefined) === "undefined", "typeof(undefined) is not undefined");
134 ok(typeof(Math) === "object", "typeof(Math) is not object");
135 ok(typeof(String.prototype) === "object", "typeof(String.prototype) is not object");
136 ok(typeof(testFunc1) === "function", "typeof(testFunc1) is not function");
137 ok(typeof(String) === "function", "typeof(String) is not function");
138 ok(typeof(ScriptEngine) === "function", "typeof(ScriptEngine) is not function");
139 ok(typeof(this) === "object", "typeof(this) is not object");
140 ok(typeof(doesnotexist) === "undefined", "typeof(doesnotexist) = " + typeof(doesnotexist));
141 tmp = typeof((new Object()).doesnotexist);
142 ok(tmp === "undefined", "typeof((new Object).doesnotexist = " + tmp);
143 tmp = typeof(testObj.onlyDispID);
144 ok(tmp === "unknown", "typeof(testObj.onlyDispID) = " + tmp);
146 ok(testFunc1(true, "test") === true, "testFunc1 not returned true");
148 ok(testFunc1.arguments === null, "testFunc1.arguments = " + testFunc1.arguments);
150 (tmp) = 3;
151 ok(tmp === 3, "tmp = " + tmp);
153 function testRecFunc(x) {
154     ok(testRecFunc.arguments === arguments, "testRecFunc.arguments = " + testRecFunc.arguments);
155     if(x) {
156         testRecFunc(false);
157         ok(testRecFunc.arguments === arguments, "testRecFunc.arguments = " + testRecFunc.arguments);
158         ok(testRecFunc.arguments[0] === true, "testRecFunc.arguments.x = " + testRecFunc.arguments[0]);
159     }
162 testRecFunc.arguments = 5;
163 ok(testRecFunc.arguments === null, "testRecFunc.arguments = " + testRecFunc.arguments);
164 testRecFunc(true);
165 ok(testRecFunc.arguments === null, "testRecFunc.arguments = " + testRecFunc.arguments);
167 tmp = (function() {1;})();
168 ok(tmp === undefined, "tmp = " + tmp);
169 tmp = eval("1;");
170 ok(tmp === 1, "tmp = " + tmp);
171 tmp = eval("1,2;");
172 ok(tmp === 2, "tmp = " + tmp);
173 tmp = eval("if(true) {3}");
174 ok(tmp === 3, "tmp = " + tmp);
176 var obj1 = new Object();
177 ok(typeof(obj1) === "object", "typeof(obj1) is not object");
178 ok(obj1.constructor === Object, "unexpected obj1.constructor");
179 obj1.test = true;
180 obj1.func = function () {
181     ok(this === obj1, "this is not obj1");
182     ok(this.test === true, "this.test is not true");
183     ok(arguments.length === 1, "arguments.length is not 1");
184     ok(arguments["0"] === true, "arguments[0] is not true");
185     ok(typeof(arguments.callee) === "function", "typeof(arguments.calee) = " + typeof(arguments.calee));
187     return "test";
190 ok(obj1.func(true) === "test", "obj1.func(true) is not \"test\"");
192 function testConstr1() {
193     this.var1 = 1;
195     ok(this !== undefined, "this is undefined");
196     ok(arguments.length === 1, "arguments.length is not 1");
197     ok(arguments["0"] === true, "arguments[0] is not 1");
198     ok(arguments.callee === testConstr1, "arguments.calee !== testConstr1");
200     return false;
203 testConstr1.prototype.pvar = 1;
204 ok(testConstr1.prototype.constructor === testConstr1, "testConstr1.prototype.constructor !== testConstr1");
206 var obj2 = new testConstr1(true);
207 ok(typeof(obj2) === "object", "typeof(obj2) is not object");
208 ok(obj2.constructor === testConstr1, "unexpected obj2.constructor");
209 ok(obj2.pvar === 1, "obj2.pvar is not 1");
210 ok(!obj2.hasOwnProperty('constructor'), "obj2.hasOwnProperty('constructor')");
212 testConstr1.prototype.pvar = 2;
213 ok(obj2.pvar === 2, "obj2.pvar is not 2");
215 obj2.pvar = 3;
216 testConstr1.prototype.pvar = 1;
217 ok(obj2.pvar === 3, "obj2.pvar is not 3");
219 obj1 = new Object();
220 function testConstr3() {
221     return obj1;
224 obj2 = new testConstr3();
225 ok(obj1 === obj2, "obj1 != obj2");
227 function testConstr4() {
228     return 2;
231 obj2 = new testConstr3();
232 ok(typeof(obj2) === "object", "typeof(obj2) = " + typeof(obj2));
234 var obj3 = new Object;
235 ok(typeof(obj3) === "object", "typeof(obj3) is not object");
237 for(var iter in "test")
238     ok(false, "unexpected forin call, test = " + iter);
240 for(var iter in null)
241     ok(false, "unexpected forin call, test = " + iter);
243 for(var iter in false)
244     ok(false, "unexpected forin call, test = " + iter);
246 for(var iter in pureDisp)
247     ok(false, "unexpected forin call in pureDisp object");
249 tmp = new Object();
250 ok(!tmp.nonexistent, "!tmp.nonexistent = " + !tmp.nonexistent);
251 ok(!("nonexistent" in tmp), "nonexistent is in tmp after '!' expression")
253 tmp = new Object();
254 ok((~tmp.nonexistent) === -1, "!tmp.nonexistent = " + ~tmp.nonexistent);
255 ok(!("nonexistent" in tmp), "nonexistent is in tmp after '~' expression")
257 tmp = new Object();
258 ok(isNaN(+tmp.nonexistent), "!tmp.nonexistent = " + (+tmp.nonexistent));
259 ok(!("nonexistent" in tmp), "nonexistent is in tmp after '+' expression")
261 tmp = new Object();
262 tmp[tmp.nonexistent];
263 ok(!("nonexistent" in tmp), "nonexistent is in tmp after array expression")
265 tmp = 0;
266 if(true)
267     tmp = 1;
268 else
269     ok(false, "else evaluated");
270 ok(tmp === 1, "tmp !== 1, if not evaluated?");
272 tmp = 0;
273 if(1 === 0)
274     ok(false, "if evaluated");
275 else
276     tmp = 1;
277 ok(tmp === 1, "tmp !== 1, if not evaluated?");
279 if(false)
280     ok(false, "if(false) evaluated");
282 tmp = 0;
283 if(true)
284     tmp = 1;
285 ok(tmp === 1, "tmp !== 1, if(true) not evaluated?");
287 if(false) {
288 }else {
291 var obj3 = { prop1: 1,  prop2: typeof(false) };
292 ok(obj3.prop1 === 1, "obj3.prop1 is not 1");
293 ok(obj3.prop2 === "boolean", "obj3.prop2 is not \"boolean\"");
294 ok(obj3.constructor === Object, "unexpected obj3.constructor");
297     var blockVar = 1;
298     blockVar = 2;
300 ok(blockVar === 2, "blockVar !== 2");
302 ok((true ? 1 : 2) === 1, "conditional expression true is not 1");
303 ok((0 === 2 ? 1 : 2) === 2, "conditional expression true is not 2");
305 ok(getVT(undefined) === "VT_EMPTY", "getVT(undefined) is not VT_EMPTY");
306 ok(getVT(null) === "VT_NULL", "getVT(null) is not VT_NULL");
307 ok(getVT(0) === "VT_I4", "getVT(0) is not VT_I4");
308 ok(getVT(0.5) === "VT_R8", "getVT(0.5) is not VT_R8");
309 ok(getVT("test") === "VT_BSTR", "getVT(\"test\") is not VT_BSTR");
310 ok(getVT(Math) === "VT_DISPATCH", "getVT(Math) is not VT_DISPATCH");
311 ok(getVT(false) === "VT_BOOL", "getVT(false) is not VT_BOOL");
313 tmp = 2+2;
314 ok(tmp === 4, "2+2 !== 4");
315 ok(getVT(tmp) === "VT_I4", "getVT(2+2) !== VT_I4");
317 tmp = 2+2.5;
318 ok(tmp === 4.5, "2+2.5 !== 4.5");
319 ok(getVT(tmp) === "VT_R8", "getVT(2+2.5) !== VT_R8");
321 tmp = 1.5+2.5;
322 ok(tmp === 4, "1.4+2.5 !== 4");
323 ok(getVT(tmp) === "VT_I4", "getVT(1.5+2.5) !== VT_I4");
325 tmp = 4-2;
326 ok(tmp === 2, "4-2 !== 2");
327 ok(getVT(tmp) === "VT_I4", "getVT(4-2) !== VT_I4");
329 tmp = 4.5-2;
330 ok(tmp === 2.5, "4.5-2 !== 2.5");
331 ok(getVT(tmp) === "VT_R8", "getVT(4.5-2) !== VT_R8");
333 tmp = -2;
334 ok(tmp === 0-2, "-2 !== 0-2");
335 ok(getVT(tmp) === "VT_I4", "getVT(-2) !== VT_I4");
337 tmp = 2*3;
338 ok(tmp === 6, "2*3 !== 6");
339 ok(getVT(tmp) === "VT_I4", "getVT(2*3) !== VT_I4");
341 tmp = 2*3.5;
342 ok(tmp === 7, "2*3.5 !== 7");
343 ok(getVT(tmp) === "VT_I4", "getVT(2*3.5) !== VT_I4");
345 tmp = 2.5*3.5;
346 /* FIXME: the parser loses precision */
347 /* ok(tmp === 8.75, "2.5*3.5 !== 8.75"); */
348 ok(tmp > 8.749999 && tmp < 8.750001, "2.5*3.5 !== 8.75");
349 ok(getVT(tmp) === "VT_R8", "getVT(2.5*3.5) !== VT_R8");
351 tmp = 4/2;
352 ok(tmp === 2, "4/2 !== 2");
353 ok(getVT(tmp) === "VT_I4", "getVT(4/2) !== VT_I4");
355 tmp = 4.5/1.5;
356 ok(tmp === 3, "4.5/1.5 !== 3");
357 ok(getVT(tmp) === "VT_I4", "getVT(4.5/1.5) !== VT_I4");
359 tmp = 3/2;
360 ok(tmp === 1.5, "3/2 !== 1.5");
361 ok(getVT(tmp) === "VT_R8", "getVT(3/2) !== VT_R8");
363 tmp = 3%2;
364 ok(tmp === 1, "3%2 = " + tmp);
366 tmp = 4%2;
367 ok(tmp ===0, "4%2 = " + tmp);
369 tmp = 3.5%1.5;
370 ok(tmp === 0.5, "3.5%1.5 = " + tmp);
372 tmp = 3%true;
373 ok(tmp === 0, "3%true = " + tmp);
375 tmp = "ab" + "cd";
376 ok(tmp === "abcd", "\"ab\" + \"cd\" !== \"abcd\"");
378 tmp = 1;
379 ok((tmp += 1) === 2, "tmp += 1 !== 2");
380 ok(tmp === 2, "tmp !== 2");
382 tmp = 2;
383 ok((tmp -= 1) === 1, "tmp -= 1 !== 1");
384 ok(tmp === 1, "tmp !=== 1");
386 tmp = 2;
387 ok((tmp *= 1.5) === 3, "tmp *= 1.5 !== 3");
388 ok(tmp === 3, "tmp !=== 3");
390 tmp = 5;
391 ok((tmp /= 2) === 2.5, "tmp /= 2 !== 2.5");
392 ok(tmp === 2.5, "tmp !=== 2.5");
394 tmp = 3;
395 ok((tmp %= 2) === 1, "tmp %= 2 !== 1");
396 ok(tmp === 1, "tmp !== 1");
398 tmp = 8;
399 ok((tmp <<= 1) === 16, "tmp <<= 1 !== 16");
401 tmp = 8;
402 ok((tmp >>= 1) === 4, "tmp >>= 1 !== 4");
404 tmp = 8;
405 ok((tmp >>>= 1) === 4, "tmp >>>= 1 !== 4");
407 tmp = 3 || ok(false, "second or expression called");
408 ok(tmp === 3, "3 || (...) is not 3");
410 tmp = false || 2;
411 ok(tmp === 2, "false || 2 is not 2");
413 tmp = 0 && ok(false, "second and expression called");
414 ok(tmp === 0, "0 && (...) is not 0");
416 tmp = true && "test";
417 ok(tmp === "test", "true && \"test\" is not \"test\"");
419 tmp = true && 0;
420 ok(tmp === 0, "true && 0 is not 0");
422 tmp = 3 | 4;
423 ok(tmp === 7, "3 | 4 !== 7");
424 ok(getVT(tmp) === "VT_I4", "getVT(3|4) = " + getVT(tmp));
426 tmp = 3.5 | 0;
427 ok(tmp === 3, "3.5 | 0 !== 3");
428 ok(getVT(tmp) === "VT_I4", "getVT(3.5|0) = " + getVT(tmp));
430 tmp = -3.5 | 0;
431 ok(tmp === -3, "-3.5 | 0 !== -3");
432 ok(getVT(tmp) === "VT_I4", "getVT(3.5|0) = " + getVT(tmp));
434 tmp = 0 | NaN;
435 ok(tmp === 0, "0 | NaN = " + tmp);
437 tmp = 0 | Infinity;
438 ok(tmp === 0, "0 | NaN = " + tmp);
440 tmp = 0 | (-Infinity);
441 ok(tmp === 0, "0 | NaN = " + tmp);
443 tmp = 10;
444 ok((tmp |= 0x10) === 26, "tmp(10) |= 0x10 !== 26");
445 ok(getVT(tmp) === "VT_I4", "getVT(tmp |= 10) = " + getVT(tmp));
447 tmp = 3 & 5;
448 ok(tmp === 1, "3 & 5 !== 1");
449 ok(getVT(tmp) === "VT_I4", "getVT(3|5) = " + getVT(tmp));
451 tmp = 3.5 & 0xffff;
452 ok(tmp === 3, "3.5 & 0xffff !== 3 ");
453 ok(getVT(tmp) === "VT_I4", "getVT(3.5&0xffff) = " + getVT(tmp));
455 tmp = (-3.5) & 0xffffffff;
456 ok(tmp === -3, "-3.5 & 0xffff !== -3");
457 ok(getVT(tmp) === "VT_I4", "getVT(3.5&0xffff) = " + getVT(tmp));
459 tmp = 2 << 3;
460 ok(tmp === 16, "2 << 3 = " + tmp);
462 tmp = 2 << 35;
463 ok(tmp === 16, "2 << 35 = " + tmp);
465 tmp = 8 >> 2;
466 ok(tmp === 2, "8 >> 2 = " + tmp);
468 tmp = -64 >> 4;
469 ok(tmp === -4, "-64 >> 4 = " + tmp);
471 tmp = 8 >>> 2;
472 ok(tmp === 2, "8 >> 2 = " + tmp);
474 tmp = -64 >>> 4;
475 ok(tmp === 0x0ffffffc, "-64 >>> 4 = " + tmp);
477 tmp = 4 >>> NaN;
478 ok(tmp === 4, "4 >>> NaN = " + tmp);
480 tmp = 10;
481 ok((tmp &= 8) === 8, "tmp(10) &= 8 !== 8");
482 ok(getVT(tmp) === "VT_I4", "getVT(tmp &= 8) = " + getVT(tmp));
484 tmp = 0xf0f0^0xff00;
485 ok(tmp === 0x0ff0, "0xf0f0^0xff00 !== 0x0ff0");
486 ok(getVT(tmp) === "VT_I4", "getVT(0xf0f0^0xff00) = " + getVT(tmp));
488 tmp = 5;
489 ok((tmp ^= 3) === 6, "tmp(5) ^= 3 !== 6");
490 ok(getVT(tmp) === "VT_I4", "getVT(tmp ^= 3) = " + getVT(tmp));
492 tmp = ~1;
493 ok(tmp === -2, "~1 !== -2");
494 ok(getVT(tmp) === "VT_I4", "getVT(~1) = " + getVT(tmp));
496 ok((3,4) === 4, "(3,4) !== 4");
498 ok(+3 === 3, "+3 !== 3");
499 ok(+true === 1, "+true !== 1");
500 ok(+false === 0, "+false !== 0");
501 ok(+null === 0, "+null !== 0");
502 ok(+"0" === 0, "+'0' !== 0");
503 ok(+"3" === 3, "+'3' !== 3");
504 ok(+"-3" === -3, "+'-3' !== -3");
505 ok(+"0xff" === 255, "+'0xff' !== 255");
506 ok(+"3e3" === 3000, "+'3e3' !== 3000");
508 tmp = new Number(1);
509 ok(+tmp === 1, "+(new Number(1)) = " + (+tmp));
510 ok(tmp.constructor === Number, "unexpected tmp.constructor");
511 tmp = new String("1");
512 ok(+tmp === 1, "+(new String('1')) = " + (+tmp));
513 ok(tmp.constructor === String, "unexpected tmp.constructor");
515 ok("" + 0 === "0", "\"\" + 0 !== \"0\"");
516 ok("" + 123 === "123", "\"\" + 123 !== \"123\"");
517 ok("" + (-5) === "-5", "\"\" + (-5) !== \"-5\"");
518 ok("" + null === "null", "\"\" + null !== \"null\"");
519 ok("" + undefined === "undefined", "\"\" + undefined !== \"undefined\"");
520 ok("" + true === "true", "\"\" + true !== \"true\"");
521 ok("" + false === "false", "\"\" + false !== \"false\"");
522 ok("" + 0.5 === "0.5", "'' + 0.5 = " + 0.5);
523 ok("" + (-0.5432) === "-0.5432", "'' + (-0.5432) = " + (-0.5432));
525 ok(1 < 3.4, "1 < 3.4 failed");
526 ok(!(3.4 < 1), "3.4 < 1");
527 ok("abc" < "abcd", "abc < abcd failed");
528 ok("abcd" < "abce", "abce < abce failed");
529 ok("" < "x", "\"\" < \"x\" failed");
530 ok(!(0 < 0), "0 < 0");
532 ok(1 <= 3.4, "1 <= 3.4 failed");
533 ok(!(3.4 <= 1), "3.4 <= 1");
534 ok("abc" <= "abcd", "abc <= abcd failed");
535 ok("abcd" <= "abce", "abce <= abce failed");
536 ok("" <= "x", "\"\" <= \"x\" failed");
537 ok(0 <= 0, "0 <= 0 failed");
539 ok(3.4 > 1, "3.4 > 1 failed");
540 ok(!(1 > 3.4), "1 > 3.4");
541 ok("abcd" > "abc", "abc > abcd failed");
542 ok("abce" > "abcd", "abce > abce failed");
543 ok("x" > "", "\"x\" > \"\" failed");
544 ok(!(0 > 0), "0 > 0");
546 ok(3.4 >= 1, "3.4 >= 1 failed");
547 ok(!(1 >= 3.4), "1 >= 3.4");
548 ok("abcd" >= "abc", "abc >= abcd failed");
549 ok("abce" >= "abcd", "abce >= abce failed");
550 ok("x" >= "", "\"x\" >= \"\" failed");
551 ok(0 >= 0, "0 >= 0");
553 tmp = 1;
554 ok(++tmp === 2, "++tmp (1) is not 2");
555 ok(tmp === 2, "incremented tmp is not 2");
556 ok(--tmp === 1, "--tmp (2) is not 1");
557 ok(tmp === 1, "decremented tmp is not 1");
558 ok(tmp++ === 1, "tmp++ (1) is not 1");
559 ok(tmp === 2, "incremented tmp(1) is not 2");
560 ok(tmp-- === 2, "tmp-- (2) is not 2");
561 ok(tmp === 1, "decremented tmp is not 1");
563 tmp = new Object();
564 tmp.iii++;
565 ok(isNaN(tmp.iii), "tmp.iii = " + tmp.iii);
567 String.prototype.test = true;
568 ok("".test === true, "\"\".test is not true");
570 Boolean.prototype.test = true;
571 ok(true.test === true, "true.test is not true");
573 Number.prototype.test = true;
574 ok((0).test === true, "(0).test is not true");
575 ok((0.5).test === true, "(0.5).test is not true");
577 var state = "";
578 try {
579     ok(state === "", "try: state = " + state);
580     state = "try";
581 }catch(ex) {
582     ok(false, "unexpected catch");
584 ok(state === "try", "state = " + state + " expected try");
586 state = "";
587 try {
588     ok(state === "", "try: state = " + state);
589     state = "try";
590 }finally {
591     ok(state === "try", "finally: state = " + state);
592     state = "finally";
594 ok(state === "finally", "state = " + state + " expected finally");
596 state = "";
597 try {
598     try {
599         throw 0;
600     }finally {
601         state = "finally";
602     }
603 }catch(e) {
604     ok(state === "finally", "state = " + state + " expected finally");
605     state = "catch";
607 ok(state === "catch", "state = " + state + " expected catch");
609 try {
610     try {
611         throw 0;
612     }finally {
613         throw 1;
614     }
615 }catch(e) {
616     ok(e === 1, "e = " + e);
619 state = "";
620 try {
621     ok(state === "", "try: state = " + state);
622     state = "try";
623 }catch(ex) {
624     ok(false, "unexpected catch");
625 }finally {
626     ok(state === "try", "finally: state = " + state);
627     state = "finally";
629 ok(state === "finally", "state = " + state + " expected finally");
631 var state = "";
632 try {
633     ok(state === "", "try: state = " + state);
634     state = "try";
635     throw "except";
636 }catch(ex) {
637     ok(state === "try", "catch: state = " + state);
638     ok(ex === "except", "ex is not \"except\"");
639     state = "catch";
641 ok(state === "catch", "state = " + state + " expected catch");
643 var state = "";
644 try {
645     ok(state === "", "try: state = " + state);
646     state = "try";
647     throw true;
648 }catch(ex) {
649     ok(state === "try", "catch: state = " + state);
650     ok(ex === true, "ex is not true");
651     state = "catch";
652 }finally {
653     ok(state === "catch", "finally: state = " + state);
654     state = "finally";
656 ok(state === "finally", "state = " + state + " expected finally");
658 var state = "";
659 try {
660     ok(state === "", "try: state = " + state);
661     state = "try";
662     try { throw true; } finally {}
663 }catch(ex) {
664     ok(state === "try", "catch: state = " + state);
665     ok(ex === true, "ex is not true");
666     state = "catch";
667 }finally {
668     ok(state === "catch", "finally: state = " + state);
669     state = "finally";
671 ok(state === "finally", "state = " + state + " expected finally");
673 var state = "";
674 try {
675     ok(state === "", "try: state = " + state);
676     state = "try";
677     try { throw "except"; } catch(ex) { throw true; }
678 }catch(ex) {
679     ok(state === "try", "catch: state = " + state);
680     ok(ex === true, "ex is not true");
681     state = "catch";
682 }finally {
683     ok(state === "catch", "finally: state = " + state);
684     state = "finally";
686 ok(state === "finally", "state = " + state + " expected finally");
688 function throwFunc(x) {
689     throw x;
692 var state = "";
693 try {
694     ok(state === "", "try: state = " + state);
695     state = "try";
696     throwFunc(true);
697 }catch(ex) {
698     ok(state === "try", "catch: state = " + state);
699     ok(ex === true, "ex is not true");
700     state = "catch";
701 }finally {
702     ok(state === "catch", "finally: state = " + state);
703     state = "finally";
705 ok(state === "finally", "state = " + state + " expected finally");
707 state = "";
708 switch(1) {
709 case "1":
710     ok(false, "unexpected case \"1\"");
711 case 1:
712     ok(state === "", "case 1: state = " + state);
713     state = "1";
714 default:
715     ok(state === "1", "default: state = " + state);
716     state = "default";
717 case false:
718     ok(state === "default", "case false: state = " + state);
719     state = "false";
721 ok(state === "false", "state = " + state);
723 state = "";
724 switch("") {
725 case "1":
726 case 1:
727     ok(false, "unexpected case 1");
728 default:
729     ok(state === "", "default: state = " + state);
730     state = "default";
731 case false:
732     ok(state === "default", "case false: state = " + state);
733     state = "false";
735 ok(state === "false", "state = " + state);
737 state = "";
738 switch(1) {
739 case "1":
740     ok(false, "unexpected case \"1\"");
741 case 1:
742     ok(state === "", "case 1: state = " + state);
743     state = "1";
744 default:
745     ok(state === "1", "default: state = " + state);
746     state = "default";
747     break;
748 case false:
749     ok(false, "unexpected case false");
751 ok(state === "default", "state = " + state);
753 switch(1) {
754 case 2:
755     ok(false, "unexpected case 2");
756 case 3:
757     ok(false, "unexpected case 3");
760 switch(1) {
761 case 2:
762     ok(false, "unexpected case 2");
763     break;
764 default:
765     /* empty default */
768 switch(2) {
769 default:
770     ok(false, "unexpected default");
771     break;
772 case 2:
773     /* empty case */
776 switch(2) {
777 default:
778     ok(false, "unexpected default");
779     break;
780 case 1:
781 case 2:
782 case 3:
783     /* empty case */
786 (function() {
787     var i=0;
789     switch(1) {
790     case 1:
791         i++;
792     }
793     return i;
794 })();
796 tmp = eval("1");
797 ok(tmp === 1, "eval(\"1\") !== 1");
798 eval("{ ok(tmp === 1, 'eval: tmp !== 1'); } tmp = 2;");
799 ok(tmp === 2, "tmp !== 2");
801 ok(eval(false) === false, "eval(false) !== false");
802 ok(eval() === undefined, "eval() !== undefined");
804 tmp = eval("1", "2");
805 ok(tmp === 1, "eval(\"1\", \"2\") !== 1");
807 var state = "";
808 try {
809     ok(state === "", "try: state = " + state);
810     state = "try";
811     eval("throwFunc(true);");
812 }catch(ex) {
813     ok(state === "try", "catch: state = " + state);
814     ok(ex === true, "ex is not true");
815     state = "catch";
816 }finally {
817     ok(state === "catch", "finally: state = " + state);
818     state = "finally";
820 ok(state === "finally", "state = " + state + " expected finally");
822 tmp = [,,1,2,,,true];
823 ok(tmp.length === 7, "tmp.length !== 7");
824 ok(tmp["0"] === undefined, "tmp[0] is not undefined");
825 ok(tmp["3"] === 2, "tmp[3] !== 2");
826 ok(tmp["6"] === true, "tmp[6] !== true");
827 ok(tmp[2] === 1, "tmp[2] !== 1");
829 ok([1,].length === 2, "[1,].length !== 2");
830 ok([,,].length === 3, "[,,].length !== 3");
831 ok([,].length === 2, "[].length != 2");
832 ok([].length === 0, "[].length != 0");
834 tmp = 0;
835 while(tmp < 4) {
836     ok(tmp < 4, "tmp >= 4");
837     tmp++;
839 ok(tmp === 4, "tmp !== 4");
841 tmp = 0;
842 while(true) {
843     ok(tmp < 4, "tmp >= 4");
844     tmp++;
845     if(tmp === 4) {
846         break;
847         ok(false, "break did not break");
848     }
850 ok(tmp === 4, "tmp !== 4");
852 tmp = 0;
853 do {
854     ok(tmp < 4, "tmp >= 4");
855     tmp++;
856 } while(tmp < 4);
857 ok(tmp === 4, "tmp !== 4");
859 tmp = 0;
860 do {
861     ok(tmp === 0, "tmp !=== 0");
862     tmp++;
863 } while(false);
864 ok(tmp === 1, "tmp !== 1");
866 tmp = 0;
867 do {
868     ok(tmp < 4, "tmp >= 4");
869     tmp++;
870 } while(tmp < 4)
871 ok(tmp === 4, "tmp !== 4")
873 tmp = 0;
874 while(tmp < 4) {
875     tmp++;
876     if(tmp === 2) {
877         continue;
878         ok(false, "break did not break");
879     }
880     ok(tmp <= 4 && tmp != 2, "tmp = " + tmp);
882 ok(tmp === 4, "tmp !== 4");
884 for(tmp=0; tmp < 4; tmp++)
885     ok(tmp < 4, "tmp = " + tmp);
886 ok(tmp === 4, "tmp !== 4");
888 for(tmp=0; tmp < 4; tmp++) {
889     if(tmp === 2)
890         break;
891     ok(tmp < 2, "tmp = " + tmp);
893 ok(tmp === 2, "tmp !== 2");
895 for(tmp=0; tmp < 4; tmp++) {
896     if(tmp === 2)
897         continue;
898     ok(tmp < 4 && tmp != 2, "tmp = " + tmp);
900 ok(tmp === 4, "tmp !== 4");
902 for(var fi=0; fi < 4; fi++)
903     ok(fi < 4, "fi = " + fi);
904 ok(fi === 4, "fi !== 4");
906 tmp = true;
907 obj1 = new Object();
908 for(obj1.nonexistent; tmp; tmp = false)
909     ok(!("nonexistent" in obj1), "nonexistent added to obj1");
911 obj1 = new Object();
912 for(tmp in obj1.nonexistent)
913     ok(false, "for(tmp in obj1.nonexistent) called with tmp = " + tmp);
914 ok(!("nonexistent" in obj1), "nonexistent added to obj1 by for..in loop");
917 var i, j;
919 /* Previous versions have broken finally block implementation */
920 if(ScriptEngineMinorVersion() >= 8) {
921     tmp = "";
922     i = 0;
923     while(true) {
924         tmp += "1";
925         for(i = 1; i < 3; i++) {
926             switch(i) {
927             case 1:
928                 tmp += "2";
929                 continue;
930             case 2:
931                 tmp += "3";
932                 try {
933                     throw null;
934                 }finally {
935                     tmp += "4";
936                     break;
937                 }
938             default:
939                 ok(false, "unexpected state");
940             }
941             tmp += "5";
942         }
943         with({prop: "6"}) {
944             tmp += prop;
945             break;
946         }
947     }
948     ok(tmp === "123456", "tmp = " + tmp);
951 tmp = "";
952 i = 0;
953 for(j in [1,2,3]) {
954     tmp += "1";
955     for(;;) {
956         with({prop: "2"}) {
957             tmp += prop;
958             try {
959                 throw "3";
960             }catch(e) {
961                 tmp += e;
962                 with([0])
963                     break;
964             }
965         }
966         ok(false, "unexpected state");
967     }
968     while(true) {
969         tmp += "4";
970         break;
971     }
972     break;
974 ok(tmp === "1234", "tmp = " + tmp);
976 tmp = 0;
977 for(var iter in [1,2,3]) {
978     tmp += +iter;
979     continue;
981 ok(tmp === 3, "tmp = " + tmp);
983 tmp = false;
984 for(var iter in [1,2,3]) {
985     switch(+iter) {
986     case 1:
987         tmp = true;
988         try {
989             continue;
990         }finally {}
991     default:
992         continue;
993     }
995 ok(tmp, "tmp = " + tmp);
997 loop_label:
998 while(true) {
999     while(true)
1000         break loop_label;
1003 loop_label: {
1004     tmp = 0;
1005     while(true) {
1006         while(true)
1007             break loop_label;
1008     }
1009     ok(false, "unexpected evaluation 1");
1012 while(true) {
1013     some_label: break;
1014     ok(false, "unexpected evaluation 2");
1017 just_label: tmp = 1;
1018 ok(tmp === 1, "tmp != 1");
1020 some_label: break some_label;
1022 other_label: {
1023     break other_label;
1024     ok(false, "unexpected evaluation 3");
1027 loop_label:
1028 do {
1029     while(true)
1030         continue loop_label;
1031 }while(false);
1033 loop_label:
1034 for(i = 0; i < 3; i++) {
1035     while(true)
1036         continue loop_label;
1039 loop_label:
1040 other_label:
1041 for(i = 0; i < 3; i++) {
1042     while(true)
1043         continue loop_label;
1046 loop_label:
1047 for(tmp in {prop: false}) {
1048     while(true)
1049         continue loop_label;
1052 ok((void 1) === undefined, "(void 1) !== undefined");
1054 var inobj = new Object();
1056 for(var iter in inobj)
1057     ok(false, "unexpected iter = " + iter);
1059 inobj.test = true;
1060 tmp = 0;
1061 for(iter in inobj) {
1062     ok(iter == "test", "unexpected iter = " + iter);
1063     tmp++;
1065 ok(tmp === 1, "for..in tmp = " + tmp);
1067 function forinTestObj() {}
1069 forinTestObj.prototype.test3 = true;
1071 var arr = new Array();
1072 inobj = new forinTestObj();
1073 inobj.test1 = true;
1074 inobj.test2 = true;
1076 tmp = 0;
1077 for(iter in inobj) {
1078     arr[iter] = true;
1079     tmp++;
1082 ok(tmp === 3, "for..in tmp = " + tmp);
1083 ok(arr["test1"] === true, "arr[test1] !== true");
1084 ok(arr["test2"] === true, "arr[test2] !== true");
1085 ok(arr["test3"] === true, "arr[test3] !== true");
1087 tmp = new Object();
1088 tmp.test = false;
1089 ok((delete tmp.test) === true, "delete returned false");
1090 ok(typeof(tmp.test) === "undefined", "tmp.test type = " + typeof(tmp.test));
1091 ok(!("test" in tmp), "test is still in tmp after delete?");
1092 for(iter in tmp)
1093     ok(false, "tmp has prop " + iter);
1095 tmp = new Object();
1096 tmp.test = false;
1097 ok((delete tmp["test"]) === true, "delete returned false");
1098 ok(typeof(tmp.test) === "undefined", "tmp.test type = " + typeof(tmp.test));
1099 ok(!("test" in tmp), "test is still in tmp after delete?");
1101 tmp.testWith = true;
1102 with(tmp)
1103     ok(testWith === true, "testWith !== true");
1105 if(false) {
1106     var varTest1 = true;
1109 ok(varTest1 === undefined, "varTest1 = " + varTest1);
1110 ok(varTest2 === undefined, "varTest2 = " + varTest1);
1112 var varTest2;
1114 function varTestFunc(varTest3) {
1115     var varTest3;
1117     ok(varTest3 === 3, "varTest3 = " + varTest3);
1118     ok(varTest4 === undefined, "varTest4 = " + varTest4);
1120     var varTest4;
1123 varTestFunc(3);
1125 deleteTest = 1;
1126 delete deleteTest;
1127 try {
1128     tmp = deleteTest;
1129     ok(false, "deleteTest not throwed exception?");
1130 }catch(ex) {}
1132 if (false)
1133     if (true)
1134         ok(false, "if evaluated");
1135     else
1136         ok(false, "else should be associated with nearest if statement");
1138 if (true)
1139     if (false)
1140         ok(false, "if evaluated");
1141     else
1142         ok(true, "else should be associated with nearest if statement");
1144 function instanceOfTest() {}
1145 tmp = new instanceOfTest();
1147 ok((tmp instanceof instanceOfTest) === true, "tmp is not instance of instanceOfTest");
1148 ok((tmp instanceof Object) === true, "tmp is not instance of Object");
1149 ok((tmp instanceof String) === false, "tmp is instance of String");
1151 instanceOfTest.prototype = new Object();
1152 ok((tmp instanceof instanceOfTest) === false, "tmp is instance of instanceOfTest");
1153 ok((tmp instanceof Object) === true, "tmp is not instance of Object");
1155 ok((1 instanceof Object) === false, "1 is instance of Object");
1156 ok((false instanceof Boolean) === false, "false is instance of Boolean");
1157 ok(("" instanceof Object) === false, "'' is instance of Object");
1159 (function () {
1160     ok((arguments instanceof Object) === true, "argument is not instance of Object");
1161     ok((arguments instanceof Array) === false, "argument is not instance of Array");
1162     ok(arguments.toString() === "[object Object]", "arguments.toString() = " + arguments.toString());
1163 })(1,2);
1165 obj = new String();
1166 ok(("length" in obj) === true, "length is not in obj");
1167 ok(("isPrototypeOf" in obj) === true, "isPrototypeOf is not in obj");
1168 ok(("abc" in obj) === false, "test is in obj");
1169 obj.abc = 1;
1170 ok(("abc" in obj) === true, "test is not in obj");
1171 ok(("1" in obj) === false, "1 is in obj");
1173 obj = [1,2,3];
1174 ok((1 in obj) === true, "1 is not in obj");
1176 obj = new Object();
1177 try {
1178     obj.prop["test"];
1179     ok(false, "expected exception");
1180 }catch(e) {}
1181 ok(!("prop" in obj), "prop in obj");
1183 ok(isNaN(NaN) === true, "isNaN(NaN) !== true");
1184 ok(isNaN(0.5) === false, "isNaN(0.5) !== false");
1185 ok(isNaN(Infinity) === false, "isNaN(Infinity) !== false");
1186 ok(isNaN() === true, "isNaN() !== true");
1187 ok(isNaN(NaN, 0) === true, "isNaN(NaN, 0) !== true");
1188 ok(isNaN(0.5, NaN) === false, "isNaN(0.5, NaN) !== false");
1189 ok(isNaN(+undefined) === true, "isNaN(+undefined) !== true");
1191 ok(isFinite(0.5) === true, "isFinite(0.5) !== true");
1192 ok(isFinite(Infinity) === false, "isFinite(Infinity) !== false");
1193 ok(isFinite(-Infinity) === false, "isFinite(Infinity) !== false");
1194 ok(isFinite(NaN) === false, "isFinite(NaN) !== false");
1195 ok(isFinite(0.5, NaN) === true, "isFinite(0.5, NaN) !== true");
1196 ok(isFinite(NaN, 0.5) === false, "isFinite(NaN, 0.5) !== false");
1197 ok(isFinite() === false, "isFinite() !== false");
1199 ok((1 < NaN) === false, "(1 < NaN) !== false");
1200 ok((1 > NaN) === false, "(1 > NaN) !== false");
1201 ok((1 <= NaN) === false, "(1 <= NaN) !== false");
1202 ok((1 >= NaN) === false, "(1 >= NaN) !== false");
1203 ok((NaN < 1) === false, "(NaN < 1) !== false");
1204 ok((NaN > 1) === false, "(NaN > 1) !== false");
1205 ok((NaN <= 1) === false, "(NaN <= 1) !== false");
1206 ok((NaN >= 1) === false, "(NaN >= 1) !== false");
1207 ok((Infinity < 2) === false, "(Infinity < 2) !== false");
1208 ok((Infinity > 2) === true, "(Infinity > 2) !== true");
1209 ok((-Infinity < 2) === true, "(-Infinity < 2) !== true");
1211 ok(isNaN(+"test") === true, "isNaN(+'test') !== true");
1212 ok(isNaN(+"123t") === true, "isNaN(+'123t') !== true");
1213 ok(isNaN(+"Infinity x") === true, "isNaN(+'Infinity x') !== true");
1214 ok(+"Infinity" === Infinity, "+'Infinity' !== Infinity");
1215 ok(+" Infinity " === Infinity, "+' Infinity ' !== Infinity");
1216 ok(+"-Infinity" === -Infinity, "+'-Infinity' !== -Infinity");
1218 ok((NaN !== NaN) === true, "(NaN !== NaN) !== true");
1219 ok((NaN === NaN) === false, "(NaN === NaN) !== false");
1220 ok((Infinity !== NaN) === true, "(Infinity !== NaN) !== true");
1221 ok((Infinity !== NaN) === true, "(Infinity !== NaN) !== true");
1222 ok((0 === NaN) === false, "(0 === NaN) !== false");
1224 ok((NaN != NaN) === true, "(NaN !== NaN) != true");
1225 ok((NaN == NaN) === false, "(NaN === NaN) != false");
1226 ok((Infinity != NaN) === true, "(Infinity != NaN) !== true");
1227 ok((Infinity != NaN) === true, "(Infinity != NaN) !== true");
1228 ok((0 == NaN) === false, "(0 === NaN) != false");
1230 // escape tests
1231 var escapeTests = [
1232     ["\'", "\\'", 39],
1233     ["\"", "\\\"", 34],
1234     ["\\", "\\\\", 92],
1235     ["\b", "\\b", 8],
1236     ["\t", "\\t", 9],
1237     ["\n", "\\n", 10],
1238     ["\v", "\\v", 118],
1239     ["\f", "\\f", 12],
1240     ["\r", "\\r", 13],
1241     ["\xf3", "\\xf3", 0xf3],
1242     ["\u1234", "\\u1234", 0x1234],
1243     ["\a", "\\a", 97],
1244     ["\?", "\\?", 63]
1247 for(i=0; i<escapeTests.length; i++) {
1248     tmp = escapeTests[i][0].charCodeAt(0);
1249     ok(tmp === escapeTests[i][2], "escaped '" + escapeTests[i][1] + "' = " + tmp + " expected " + escapeTests[i][2]);
1252 tmp = !+"\v1";
1253 ok(tmp === true, '!+"\v1" = ' + tmp);
1255 ok(typeof(testFunc2) === "function", "typeof(testFunc2) = " + typeof(testFunc2));
1256 tmp = testFunc2(1);
1257 ok(tmp === 2, "testFunc2(1) = " + tmp);
1258 function testFunc2(x) { return x+1; }
1260 ok(typeof(testFunc3) === "function", "typeof(testFunc3) = " + typeof(testFunc3));
1261 tmp = testFunc3(1);
1262 ok(tmp === 3, "testFunc3(1) = " + tmp);
1263 tmp = function testFunc3(x) { return x+2; };
1265 tmp = testFunc4(1);
1266 ok(tmp === 5, "testFunc4(1) = " + tmp);
1267 tmp = function testFunc4(x) { return x+3; };
1268 tmp = testFunc4(1);
1269 testFunc4 = 1;
1270 ok(testFunc4 === 1, "testFunc4 = " + testFunc4);
1271 ok(tmp === 5, "testFunc4(1) = " + tmp);
1272 tmp = function testFunc4(x) { return x+4; };
1273 ok(testFunc4 === 1, "testFunc4 = " + testFunc4);
1275 function testEmbeddedFunctions() {
1276     ok(typeof(testFunc5) === "function", "typeof(testFunc5) = " + typeof(testFunc5));
1277     tmp = testFunc5(1);
1278     ok(tmp === 3, "testFunc5(1) = " + tmp);
1279     tmp = function testFunc5(x) { return x+2; };
1281     tmp = testFunc6(1);
1282     ok(tmp === 5, "testFunc6(1) = " + tmp);
1283     tmp = function testFunc6(x) { return x+3; };
1284     tmp = testFunc6(1);
1285     ok(tmp === 5, "testFunc6(1) = " + tmp);
1286     tmp = function testFunc6(x) { return x+4; };
1287     testFunc6 = 1;
1288     ok(testFunc6 === 1, "testFunc4 = " + testFunc6);
1291 testEmbeddedFunctions();
1293 date = new Date();
1294 date.toString = function() { return "toString"; }
1295 ok(""+date === "toString", "''+date = " + date);
1296 date.toString = function() { return this; }
1297 ok(""+date === ""+date.valueOf(), "''+date = " + date);
1299 str = new String("test");
1300 str.valueOf = function() { return "valueOf"; }
1301 ok(""+str === "valueOf", "''+str = " + str);
1302 str.valueOf = function() { return new Date(); }
1303 ok(""+str === "test", "''+str = " + str);
1305 ok((function (){return 1;})() === 1, "(function (){return 1;})() = " + (function (){return 1;})());
1307 var re = /=(\?|%3F)/g;
1308 ok(re.source === "=(\\?|%3F)", "re.source = " + re.source);
1310 tmp = new Array();
1311 for(var i=0; i<2; i++)
1312     tmp[i] = /b/;
1313 ok(tmp[0] != tmp[1], "tmp[0] == tmp [1]");
1315 ok(isNullBSTR(getNullBSTR()), "isNullBSTR(getNullBSTR()) failed\n");
1316 ok(getNullBSTR() === '', "getNullBSTR() !== ''");
1317 ok(+getNullBSTR() === 0 , "+getNullBTR() !=== 0");
1319 ok(getVT(nullDisp) === "VT_DISPATCH", "getVT(nullDisp) = " + getVT(nullDisp));
1320 ok(typeof(nullDisp) === "object", "typeof(nullDisp) = " + typeof(nullDisp));
1321 ok(nullDisp === nullDisp, "nullDisp !== nullDisp");
1322 ok(nullDisp !== re, "nullDisp === re");
1323 ok(nullDisp === null, "nullDisp === null");
1324 ok(nullDisp == null, "nullDisp == null");
1325 ok(getVT(true && nullDisp) === "VT_DISPATCH",
1326    "getVT(0 && nullDisp) = " + getVT(true && nullDisp));
1327 ok(!nullDisp === true, "!nullDisp = " + !nullDisp);
1328 ok(String(nullDisp) === "null", "String(nullDisp) = " + String(nullDisp));
1329 ok(nullDisp != new Object(), "nullDisp == new Object()");
1330 ok(new Object() != nullDisp, "new Object() == nullDisp");
1331 ok((typeof Object(nullDisp)) === "object", "typeof Object(nullDisp) !== 'object'");
1332 tmp = getVT(Object(nullDisp));
1333 ok(tmp === "VT_DISPATCH", "getVT(Object(nullDisp) = " + tmp);
1334 tmp = Object(nullDisp).toString();
1335 ok(tmp === "[object Object]", "Object(nullDisp).toString() = " + tmp);
1337 function do_test() {}
1338 function nosemicolon() {} nosemicolon();
1339 function () {} nosemicolon();
1341 if(false) {
1342     function in_if_false() { return true; } ok(false, "!?");
1345 ok(in_if_false(), "in_if_false failed");
1347 (function() { newValue = 1; })();
1348 ok(newValue === 1, "newValue = " + newValue);
1350 obj = {undefined: 3};
1352 ok(typeof(name_override_func) === "function", "typeof(name_override_func) = " + typeof(name_override_func));
1353 name_override_func = 3;
1354 ok(name_override_func === 3, "name_override_func = " + name_override_func);
1355 function name_override_func() {};
1356 ok(name_override_func === 3, "name_override_func = " + name_override_func);
1358 /* NoNewline rule parser tests */
1359 while(true) {
1360     if(true) break
1361     tmp = false
1364 while(true) {
1365     if(true) break /*
1366                     * no semicolon, but comment present */
1367     tmp = false
1370 while(true) {
1371     if(true) break // no semicolon, but comment present
1372     tmp = false
1375 while(true) {
1376     break
1377     continue
1378     tmp = false
1381 function returnTest() {
1382     return
1383     true;
1386 ok(returnTest() === undefined, "returnTest = " + returnTest());
1388 /* Keep this test in the end of file */
1389 undefined = 6;
1390 ok(undefined === 6, "undefined = " + undefined);
1392 NaN = 6;
1393 ok(NaN === 6, "NaN !== 6");
1395 Infinity = 6;
1396 ok(Infinity === 6, "Infinity !== 6");
1398 Math = 6;
1399 ok(Math === 6, "NaN !== 6");
1401 reportSuccess();