push cc8bc80451cc24f4d7cf75168b569f0ebfe19547
[wine/hacks.git] / dlls / jscript / tests / lang.js
blob86eba86f7382bfbce3065dbd5920fddf5ac2b45f
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"+8.64e15);
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 1");
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\"");
72     return true;
75 ok(testFunc1.length === 2, "testFunc1.length is not 2");
77 ok(Object.prototype !== undefined, "Object.prototype is undefined");
78 ok(Object.prototype.prototype === undefined, "Object.prototype is not undefined");
79 ok(String.prototype !== undefined, "String.prototype is undefined");
80 ok(Array.prototype !== undefined, "Array.prototype is undefined");
81 ok(Boolean.prototype !== undefined, "Boolean.prototype is undefined");
82 ok(Number.prototype !== undefined, "Number.prototype is undefined");
83 ok(RegExp.prototype !== undefined, "RegExp.prototype is undefined");
84 ok(Math !== undefined, "Math is undefined");
85 ok(Math.prototype === undefined, "Math.prototype is not undefined");
86 ok(Function.prototype !== undefined, "Function.prototype is undefined");
87 ok(Function.prototype.prototype === undefined, "Function.prototype is not undefined");
88 ok(Date.prototype !== undefined, "Date.prototype is undefined");
89 ok(Date.prototype.prototype === undefined, "Date.prototype is not undefined");
91 Function.prototype.test = true;
92 ok(testFunc1.test === true, "testFunc1.test !== true");
93 ok(Function.test === true, "Function.test !== true");
95 ok(typeof(0) === "number", "typeof(0) is not number");
96 ok(typeof(1.5) === "number", "typeof(1.5) is not number");
97 ok(typeof("abc") === "string", "typeof(\"abc\") is not string");
98 ok(typeof("") === "string", "typeof(\"\") is not string");
99 ok(typeof(true) === "boolean", "typeof(true) is not boolean");
100 ok(typeof(null) === "object", "typeof(null) is not object");
101 ok(typeof(undefined) === "undefined", "typeof(undefined) is not undefined");
102 ok(typeof(Math) === "object", "typeof(Math) is not object");
103 ok(typeof(String.prototype) === "object", "typeof(String.prototype) is not object");
104 ok(typeof(testFunc1) === "function", "typeof(testFunc1) is not function");
105 ok(typeof(String) === "function", "typeof(String) is not function");
106 ok(typeof(ScriptEngine) === "function", "typeof(ScriptEngine) is not function");
107 ok(typeof(this) === "object", "typeof(this) is not object");
109 ok(testFunc1(true, "test") === true, "testFunc1 not returned true");
111 var obj1 = new Object();
112 ok(typeof(obj1) === "object", "typeof(obj1) is not object");
113 obj1.test = true;
114 obj1.func = function () {
115     ok(this === obj1, "this is not obj1");
116     ok(this.test === true, "this.test is not true");
117     ok(arguments.length === 1, "arguments.length is not 1");
118     ok(arguments["0"] === true, "arguments[0] is not true");
120     return "test";
123 ok(obj1.func(true) === "test", "obj1.func(true) is not \"test\"");
125 function testConstr1() {
126     this.var1 = 1;
128     ok(this !== undefined, "this is undefined");
129     ok(arguments.length === 1, "arguments.length is not 1");
130     ok(arguments["0"] === true, "arguments[0] is not 1");
132     return false;
135 testConstr1.prototype.pvar = 1;
137 var obj2 = new testConstr1(true);
138 ok(typeof(obj2) === "object", "typeof(obj2) is not object");
139 ok(obj2.pvar === 1, "obj2.pvar is not 1");
141 testConstr1.prototype.pvar = 2;
142 ok(obj2.pvar === 2, "obj2.pvar is not 2");
144 obj2.pvar = 3;
145 testConstr1.prototype.pvar = 1;
146 ok(obj2.pvar === 3, "obj2.pvar is not 3");
148 var obj3 = new Object;
149 ok(typeof(obj3) === "object", "typeof(obj3) is not object");
151 for(var iter in "test")
152     ok(false, "unexpected forin call, test = " + iter);
154 for(var iter in null)
155     ok(false, "unexpected forin call, test = " + iter);
157 for(var iter in false)
158     ok(false, "unexpected forin call, test = " + iter);
160 tmp = 0;
161 if(true)
162     tmp = 1;
163 else
164     ok(false, "else evaluated");
165 ok(tmp === 1, "tmp !== 1, if not evaluated?");
167 tmp = 0;
168 if(1 === 0)
169     ok(false, "if evaluated");
170 else
171     tmp = 1;
172 ok(tmp === 1, "tmp !== 1, if not evaluated?");
174 if(false)
175     ok(false, "if(false) evaluated");
177 tmp = 0;
178 if(true)
179     tmp = 1;
180 ok(tmp === 1, "tmp !== 1, if(true) not evaluated?");
182 if(false) {
183 }else {
186 var obj3 = { prop1: 1,  prop2: typeof(false) };
187 ok(obj3.prop1 === 1, "obj3.prop1 is not 1");
188 ok(obj3.prop2 === "boolean", "obj3.prop2 is not \"boolean\"");
191     var blockVar = 1;
192     blockVar = 2;
194 ok(blockVar === 2, "blockVar !== 2");
196 ok((true ? 1 : 2) === 1, "conditional expression true is not 1");
197 ok((0 === 2 ? 1 : 2) === 2, "conditional expression true is not 2");
199 ok(getVT(undefined) === "VT_EMPTY", "getVT(undefined) is not VT_EMPTY");
200 ok(getVT(null) === "VT_NULL", "getVT(null) is not VT_NULL");
201 ok(getVT(0) === "VT_I4", "getVT(0) is not VT_I4");
202 ok(getVT(0.5) === "VT_R8", "getVT(1.5) is not VT_R8");
203 ok(getVT("test") === "VT_BSTR", "getVT(\"test\") is not VT_BSTR");
204 ok(getVT(Math) === "VT_DISPATCH", "getVT(Math) is not VT_DISPATCH");
205 ok(getVT(false) === "VT_BOOL", "getVT(false) is not VT_BOOL");
207 tmp = 2+2;
208 ok(tmp === 4, "2+2 !== 4");
209 ok(getVT(tmp) === "VT_I4", "getVT(2+2) !== VT_I4");
211 tmp = 2+2.5;
212 ok(tmp === 4.5, "2+2.5 !== 4.5");
213 ok(getVT(tmp) === "VT_R8", "getVT(2+2.5) !== VT_R8");
215 tmp = 1.5+2.5;
216 ok(tmp === 4, "1.4+2.5 !== 4");
217 ok(getVT(tmp) === "VT_I4", "getVT(1.5+2.5) !== VT_I4");
219 tmp = 4-2;
220 ok(tmp === 2, "4-2 !== 2");
221 ok(getVT(tmp) === "VT_I4", "getVT(4-2) !== VT_I4");
223 tmp = 4.5-2;
224 ok(tmp === 2.5, "4.5-2 !== 2.5");
225 ok(getVT(tmp) === "VT_R8", "getVT(4-2) !== VT_R8");
227 tmp = -2;
228 ok(tmp === 0-2, "-2 !== 0-2");
229 ok(getVT(tmp) === "VT_I4", "getVT(-2) !== VT_I4");
231 tmp = 2*3;
232 ok(tmp === 6, "2*3 !== 6");
233 ok(getVT(tmp) === "VT_I4", "getVT(2*3) !== VT_I4");
235 tmp = 2*3.5;
236 ok(tmp === 7, "2*3.5 !== 7");
237 ok(getVT(tmp) === "VT_I4", "getVT(2*3.5) !== VT_I4");
239 tmp = 2.5*3.5;
240 ok(tmp === 8.75, "2.5*3.5 !== 8.75");
241 ok(getVT(tmp) === "VT_R8", "getVT(2.5*3.5) !== VT_R8");
243 tmp = 4/2;
244 ok(tmp === 2, "4/2 !== 2");
245 ok(getVT(tmp) === "VT_I4", "getVT(4/2) !== VT_I4");
247 tmp = 4.5/1.5;
248 ok(tmp === 3, "4.5/1.5 !== 3");
249 ok(getVT(tmp) === "VT_I4", "getVT(4.5/1.5) !== VT_I4");
251 tmp = 3/2;
252 ok(tmp === 1.5, "3/2 !== 1.5");
253 ok(getVT(tmp) === "VT_R8", "getVT(3/2) !== VT_R8");
255 tmp = 3%2;
256 ok(tmp === 1, "3%2 = " + tmp);
258 tmp = 4%2;
259 ok(tmp ===0, "4%2 = " + tmp);
261 tmp = 3.5%1.5;
262 ok(tmp === 0.5, "3.5%1.5 = " + tmp);
264 tmp = 3%true;
265 ok(tmp === 0, "3%true = " + tmp);
267 tmp = "ab" + "cd";
268 ok(tmp === "abcd", "\"ab\" + \"cd\" !== \"abcd\"");
270 tmp = 1;
271 ok((tmp += 1) === 2, "tmp += 1 !== 2");
272 ok(tmp === 2, "tmp !== 2");
274 tmp = 2;
275 ok((tmp -= 1) === 1, "tmp -= 1 !== 1");
276 ok(tmp === 1, "tmp !=== 1");
278 tmp = 2;
279 ok((tmp *= 1.5) === 3, "tmp *= 1.5 !== 3");
280 ok(tmp === 3, "tmp !=== 3");
282 tmp = 5;
283 ok((tmp /= 2) === 2.5, "tmp /= 2 !== 2.5");
284 ok(tmp === 2.5, "tmp !=== 2.5");
286 tmp = 3;
287 ok((tmp %= 2) === 1, "tmp %= 2 !== 1");
288 ok(tmp === 1, "tmp !== 1");
290 tmp = 8;
291 ok((tmp <<= 1) === 16, "tmp <<= 1 !== 16");
293 tmp = 8;
294 ok((tmp >>= 1) === 4, "tmp >>= 1 !== 4");
296 tmp = 8;
297 ok((tmp >>>= 1) === 4, "tmp >>>= 1 !== 4");
299 tmp = 3 || ok(false, "second or expression called");
300 ok(tmp === 3, "3 || (...) is not 3");
302 tmp = false || 2;
303 ok(tmp === 2, "false || 2 is not 2");
305 tmp = 0 && ok(false, "second and expression called");
306 ok(tmp === 0, "0 && (...) is not 0");
308 tmp = true && "test";
309 ok(tmp === "test", "true && \"test\" is not \"test\"");
311 tmp = true && 0;
312 ok(tmp === 0, "true && 0 is not 0");
314 tmp = 3 | 4;
315 ok(tmp === 7, "3 | 4 !== 7");
316 ok(getVT(tmp) === "VT_I4", "getVT(3|4) = " + getVT(tmp));
318 tmp = 3.5 | 0;
319 ok(tmp === 3, "3.5 | 0 !== 3");
320 ok(getVT(tmp) === "VT_I4", "getVT(3.5|0) = " + getVT(tmp));
322 tmp = -3.5 | 0;
323 ok(tmp === -3, "-3.5 | 0 !== -3");
324 ok(getVT(tmp) === "VT_I4", "getVT(3.5|0) = " + getVT(tmp));
326 tmp = 10;
327 ok((tmp |= 0x10) === 26, "tmp(10) |= 0x10 !== 26");
328 ok(getVT(tmp) === "VT_I4", "getVT(tmp |= 10) = " + getVT(tmp));
330 tmp = 3 & 5;
331 ok(tmp === 1, "3 & 5 !== 1");
332 ok(getVT(tmp) === "VT_I4", "getVT(3|5) = " + getVT(tmp));
334 tmp = 3.5 & 0xffff;
335 ok(tmp === 3, "3.5 & 0xffff !== 3 ");
336 ok(getVT(tmp) === "VT_I4", "getVT(3.5&0xffff) = " + getVT(tmp));
338 tmp = (-3.5) & 0xffffffff;
339 ok(tmp === -3, "-3.5 & 0xffff !== -3");
340 ok(getVT(tmp) === "VT_I4", "getVT(3.5&0xffff) = " + getVT(tmp));
342 tmp = 2 << 3;
343 ok(tmp === 16, "2 << 3 = " + tmp);
345 tmp = 2 << 35;
346 ok(tmp === 16, "2 << 35 = " + tmp);
348 tmp = 8 >> 2;
349 ok(tmp === 2, "8 >> 2 = " + tmp);
351 tmp = -64 >> 4;
352 ok(tmp === -4, "-64 >> 4 = " + tmp);
354 tmp = 8 >>> 2;
355 ok(tmp === 2, "8 >> 2 = " + tmp);
357 tmp = -64 >>> 4;
358 ok(tmp === 0x0ffffffc, "-64 >>> 4 = " + tmp);
360 tmp = 10;
361 ok((tmp &= 8) === 8, "tmp(10) &= 8 !== 8");
362 ok(getVT(tmp) === "VT_I4", "getVT(tmp &= 8) = " + getVT(tmp));
364 tmp = 0xf0f0^0xff00;
365 ok(tmp === 0x0ff0, "0xf0f0^0xff00 !== 0x0ff0");
366 ok(getVT(tmp) === "VT_I4", "getVT(0xf0f0^0xff00) = " + getVT(tmp));
368 tmp = 5;
369 ok((tmp ^= 3) === 6, "tmp(5) ^= 3 !== 6");
370 ok(getVT(tmp) === "VT_I4", "getVT(tmp ^= 3) = " + getVT(tmp));
372 tmp = ~1;
373 ok(tmp === -2, "~1 !== -2");
374 ok(getVT(tmp) === "VT_I4", "getVT(~1) = " + getVT(tmp));
376 ok((3,4) === 4, "(3,4) !== 4");
378 ok(+3 === 3, "+3 !== 3");
379 ok(+true === 1, "+true !== 1");
380 ok(+false === 0, "+false !== 0");
381 ok(+null === 0, "+null !== 0");
382 ok(+"0" === 0, "+'0' !== 0");
383 ok(+"3" === 3, "+'3' !== 3");
384 ok(+"-3" === -3, "+'-3' !== -3");
385 ok(+"0xff" === 255, "+'0xff' !== 255");
386 ok(+"3e3" === 3000, "+'3e3' !== 3000");
388 tmp = new Number(1);
389 ok(+tmp === 1, "ToNumber(new Number(1)) = " + (+tmp));
390 tmp = new String("1");
391 ok(+tmp === 1, "ToNumber(new String('1')) = " + (+tmp));
393 ok("" + 0 === "0", "\"\" + 0 !== \"0\"");
394 ok("" + 123 === "123", "\"\" + 123 !== \"123\"");
395 ok("" + (-5) === "-5", "\"\" + (-5) !== \"-5\"");
396 ok("" + null === "null", "\"\" + null !== \"null\"");
397 ok("" + undefined === "undefined", "\"\" + undefined !== \"undefined\"");
398 ok("" + true === "true", "\"\" + true !== \"true\"");
399 ok("" + false === "false", "\"\" + false !== \"false\"");
400 ok("" + 0.5 === "0.5", "'' + 0.5 = " + 0.5);
401 ok("" + (-0.5432) === "-0.5432", "'' + (-0.5432) = " + (-0.5432));
403 ok(1 < 3.4, "1 < 3.4 failed");
404 ok(!(3.4 < 1), "3.4 < 1");
405 ok("abc" < "abcd", "abc < abcd failed");
406 ok("abcd" < "abce", "abce < abce failed");
407 ok("" < "x", "\"\" < \"x\" failed");
408 ok(!(0 < 0), "0 < 0");
410 ok(1 <= 3.4, "1 <= 3.4 failed");
411 ok(!(3.4 <= 1), "3.4 <= 1");
412 ok("abc" <= "abcd", "abc <= abcd failed");
413 ok("abcd" <= "abce", "abce <= abce failed");
414 ok("" <= "x", "\"\" <= \"x\" failed");
415 ok(0 <= 0, "0 <= 0 failed");
417 ok(3.4 > 1, "3.4 > 1 failed");
418 ok(!(1 > 3.4), "1 > 3.4");
419 ok("abcd" > "abc", "abc > abcd failed");
420 ok("abce" > "abcd", "abce > abce failed");
421 ok("x" > "", "\"x\" > \"\" failed");
422 ok(!(0 > 0), "0 > 0");
424 ok(3.4 >= 1, "3.4 >= 1 failed");
425 ok(!(1 >= 3.4), "1 >= 3.4");
426 ok("abcd" >= "abc", "abc >= abcd failed");
427 ok("abce" >= "abcd", "abce >= abce failed");
428 ok("x" >= "", "\"x\" >= \"\" failed");
429 ok(0 >= 0, "0 >= 0");
431 tmp = 1;
432 ok(++tmp === 2, "++tmp (1) is not 2");
433 ok(tmp === 2, "incremented tmp is not 2");
434 ok(--tmp === 1, "--tmp (2) is not 1");
435 ok(tmp === 1, "decremented tmp is not 1");
436 ok(tmp++ === 1, "tmp++ (1) is not 1");
437 ok(tmp === 2, "incremented tmp(1) is not 2");
438 ok(tmp-- === 2, "tmp-- (2) is not 2");
439 ok(tmp === 1, "decremented tmp is not 1");
441 String.prototype.test = true;
442 ok("".test === true, "\"\".test is not true");
444 Boolean.prototype.test = true;
445 ok(true.test === true, "true.test is not true");
447 Number.prototype.test = true;
448 ok((0).test === true, "(0).test is not true");
449 ok((0.5).test === true, "(0.5).test is not true");
451 var state = "";
452 try {
453     ok(state === "", "try: state = " + state);
454     state = "try";
455 }catch(ex) {
456     ok(false, "unexpected catch");
458 ok(state === "try", "state = " + state + " expected try");
460 state = "";
461 try {
462     ok(state === "", "try: state = " + state);
463     state = "try";
464 }finally {
465     ok(state === "try", "funally: state = " + state);
466     state = "finally";
468 ok(state === "finally", "state = " + state + " expected finally");
470 state = "";
471 try {
472     ok(state === "", "try: state = " + state);
473     state = "try";
474 }catch(ex) {
475     ok(false, "unexpected catch");
476 }finally {
477     ok(state === "try", "funally: state = " + state);
478     state = "finally";
480 ok(state === "finally", "state = " + state + " expected finally");
482 var state = "";
483 try {
484     ok(state === "", "try: state = " + state);
485     state = "try";
486     throw "except";
487 }catch(ex) {
488     ok(state === "try", "catch: state = " + state);
489     ok(ex === "except", "ex is not \"except\"");
490     state = "catch";
492 ok(state === "catch", "state = " + state + " expected catch");
494 var state = "";
495 try {
496     ok(state === "", "try: state = " + state);
497     state = "try";
498     throw true;
499 }catch(ex) {
500     ok(state === "try", "catch: state = " + state);
501     ok(ex === true, "ex is not true");
502     state = "catch";
503 }finally {
504     ok(state === "catch", "funally: state = " + state);
505     state = "finally";
507 ok(state === "finally", "state = " + state + " expected finally");
509 var state = "";
510 try {
511     ok(state === "", "try: state = " + state);
512     state = "try";
513     try { throw true; } finally {}
514 }catch(ex) {
515     ok(state === "try", "catch: state = " + state);
516     ok(ex === true, "ex is not true");
517     state = "catch";
518 }finally {
519     ok(state === "catch", "funally: state = " + state);
520     state = "finally";
522 ok(state === "finally", "state = " + state + " expected finally");
524 var state = "";
525 try {
526     ok(state === "", "try: state = " + state);
527     state = "try";
528     try { throw "except"; } catch(ex) { throw true; }
529 }catch(ex) {
530     ok(state === "try", "catch: state = " + state);
531     ok(ex === true, "ex is not true");
532     state = "catch";
533 }finally {
534     ok(state === "catch", "funally: state = " + state);
535     state = "finally";
537 ok(state === "finally", "state = " + state + " expected finally");
539 function throwFunc(x) {
540     throw x;
543 var state = "";
544 try {
545     ok(state === "", "try: state = " + state);
546     state = "try";
547     throwFunc(true);
548 }catch(ex) {
549     ok(state === "try", "catch: state = " + state);
550     ok(ex === true, "ex is not true");
551     state = "catch";
552 }finally {
553     ok(state === "catch", "funally: state = " + state);
554     state = "finally";
556 ok(state === "finally", "state = " + state + " expected finally");
558 state = "";
559 switch(1) {
560 case "1":
561     ok(false, "unexpected case \"1\"");
562 case 1:
563     ok(state === "", "case 1: state = " + state);
564     state = "1";
565 default:
566     ok(state === "1", "default: state = " + state);
567     state = "default";
568 case false:
569     ok(state === "default", "case false: state = " + state);
570     state = "false";
572 ok(state === "false", "state = " + state);
574 state = "";
575 switch("") {
576 case "1":
577 case 1:
578     ok(false, "unexpected case 1");
579 default:
580     ok(state === "", "default: state = " + state);
581     state = "default";
582 case false:
583     ok(state === "default", "case false: state = " + state);
584     state = "false";
586 ok(state === "false", "state = " + state);
588 state = "";
589 switch(1) {
590 case "1":
591     ok(false, "unexpected case \"1\"");
592 case 1:
593     ok(state === "", "case 1: state = " + state);
594     state = "1";
595 default:
596     ok(state === "1", "default: state = " + state);
597     state = "default";
598     break;
599 case false:
600     ok(false, "unexpected case false");
602 ok(state === "default", "state = " + state);
604 tmp = eval("1");
605 ok(tmp === 1, "eval(\"1\") !== 1");
606 eval("{ ok(tmp === 1, 'eval: tmp !== 1'); } tmp = 2;");
607 ok(tmp === 2, "tmp !== 2");
609 ok(eval(false) === false, "eval(false) !== false");
610 ok(eval() === undefined, "eval() !== undefined");
612 tmp = eval("1", "2");
613 ok(tmp === 1, "eval(\"1\", \"2\") !== 1");
615 var state = "";
616 try {
617     ok(state === "", "try: state = " + state);
618     state = "try";
619     eval("throwFunc(true);");
620 }catch(ex) {
621     ok(state === "try", "catch: state = " + state);
622     ok(ex === true, "ex is not true");
623     state = "catch";
624 }finally {
625     ok(state === "catch", "funally: state = " + state);
626     state = "finally";
628 ok(state === "finally", "state = " + state + " expected finally");
630 tmp = [,,1,2,,,true];
631 ok(tmp.length === 7, "tmp.length !== 7");
632 ok(tmp["0"] === undefined, "tmp[0] is not undefined");
633 ok(tmp["3"] === 2, "tmp[3] !== 2");
634 ok(tmp["6"] === true, "tmp[6] !== true");
635 ok(tmp[2] === 1, "tmp[2] !== 1");
637 ok([1,].length === 2, "[1,].length !== 2");
638 ok([,,].length === 3, "[,,].length !== 3");
639 ok([,].length === 2, "[].length != 2");
640 ok([].length === 0, "[].length != 0");
642 tmp = 0;
643 while(tmp < 4) {
644     ok(tmp < 4, "tmp >= 4");
645     tmp++;
647 ok(tmp === 4, "tmp !== 4");
649 tmp = 0;
650 while(true) {
651     ok(tmp < 4, "tmp >= 4");
652     tmp++;
653     if(tmp === 4) {
654         break;
655         ok(false, "break did not break");
656     }
658 ok(tmp === 4, "tmp !== 4");
660 tmp = 0;
661 do {
662     ok(tmp < 4, "tmp >= 4");
663     tmp++;
664 } while(tmp < 4);
665 ok(tmp === 4, "tmp !== 4");
667 tmp = 0;
668 do {
669     ok(tmp === 0, "tmp !=== 0");
670     tmp++;
671 } while(false);
672 ok(tmp === 1, "tmp !== 1");
674 tmp = 0;
675 while(tmp < 4) {
676     tmp++;
677     if(tmp === 2) {
678         continue;
679         ok(false, "break did not break");
680     }
681     ok(tmp <= 4 && tmp != 2, "tmp = " + tmp);
683 ok(tmp === 4, "tmp !== 4");
685 for(tmp=0; tmp < 4; tmp++)
686     ok(tmp < 4, "tmp = " + tmp);
687 ok(tmp === 4, "tmp !== 4");
689 for(tmp=0; tmp < 4; tmp++) {
690     if(tmp === 2)
691         break;
692     ok(tmp < 2, "tmp = " + tmp);
694 ok(tmp === 2, "tmp !== 2");
696 for(tmp=0; tmp < 4; tmp++) {
697     if(tmp === 2)
698         continue;
699     ok(tmp < 4 && tmp != 2, "tmp = " + tmp);
701 ok(tmp === 4, "tmp !== 4");
703 for(var fi=0; fi < 4; fi++)
704     ok(fi < 4, "fi = " + fi);
705 ok(fi === 4, "fi !== 4");
707 ok((void 1) === undefined, "(void 1) !== undefined");
709 var inobj = new Object();
711 for(var iter in inobj)
712     ok(false, "unexpected iter = " + iter);
714 inobj.test = true;
715 tmp = 0;
716 for(iter in inobj) {
717     ok(iter == "test", "unexpected iter = " + iter);
718     tmp++;
720 ok(tmp === 1, "for..in tmp = " + tmp);
722 function forinTestObj() {}
724 forinTestObj.prototype.test3 = true;
726 var arr = new Array();
727 inobj = new forinTestObj();
728 inobj.test1 = true;
729 inobj.test2 = true;
731 tmp = 0;
732 for(iter in inobj) {
733     arr[iter] = true;
734     tmp++;
737 ok(tmp === 3, "for..in tmp = " + tmp);
738 ok(arr["test1"] === true, "arr[test1] !== true");
739 ok(arr["test2"] === true, "arr[test2] !== true");
740 ok(arr["test3"] === true, "arr[test3] !== true");
742 tmp = new Object();
743 tmp.test = false;
744 ok((delete tmp.test) === true, "delete returned false");
745 ok(typeof(tmp.test) === "undefined", "tmp.test type = " + typeof(tmp.test));
746 for(iter in tmp)
747     ok(false, "tmp has prop " + iter);
749 tmp.testWith = true;
750 with(tmp)
751     ok(testWith === true, "testWith !== true");
753 if(false) {
754     var varTest1 = true;
757 ok(varTest1 === undefined, "varTest1 = " + varTest1);
758 ok(varTest2 === undefined, "varTest2 = " + varTest1);
760 var varTest2;
762 function varTestFunc(varTest3) {
763     var varTest3;
765     ok(varTest3 === 3, "varTest3 = " + varTest3);
766     ok(varTest4 === undefined, "varTest4 = " + varTest4);
768     var varTest4;
771 varTestFunc(3);
773 deleteTest = 1;
774 delete deleteTest;
775 try {
776     tmp = deleteTest;
777     ok(false, "deleteTest not throwed exception?");
778 }catch(ex) {}
780 if (false)
781     if (true)
782         ok(false, "if evaluated");
783     else
784         ok(false, "else should be associated with nearest if statement");
786 if (true)
787     if (false)
788         ok(false, "if evaluated");
789     else
790         ok(true, "else should be associated with nearest if statement");
792 ok(isNaN(NaN) === true, "isNaN(NaN) !== true");
793 ok(isNaN(0.5) === false, "isNaN(0.5) !== false");
794 ok(isNaN(Infinity) === false, "isNaN(Infinity) !== false");
795 ok(isNaN() === true, "isNaN() !== true");
796 ok(isNaN(NaN, 0) === true, "isNaN(NaN, 0) !== true");
797 ok(isNaN(0.5, NaN) === false, "isNaN(0.5, NaN) !== false");
798 ok(isNaN(+undefined) === true, "isNaN(+undefined) !== true");
800 ok(isFinite(0.5) === true, "isFinite(0.5) !== true");
801 ok(isFinite(Infinity) === false, "isFinite(Infinity) !== fals");
802 ok(isFinite(-Infinity) === false, "isFinite(Infinity) !== fals");
803 ok(isFinite(NaN) === false, "isFinite(NaN) !== false");
804 ok(isFinite(0.5, NaN) === true, "isFinite(0.5, NaN) !== true");
805 ok(isFinite(NaN, 0.5) === false, "isFinite(NaN, 0.5) !== false");
806 ok(isFinite() === false, "isFinite() !== false");
808 ok((1 < NaN) === false, "(1 < NaN) !== false");
809 ok((1 > NaN) === false, "(1 > NaN) !== false");
810 ok((1 <= NaN) === false, "(1 <= NaN) !== false");
811 ok((1 >= NaN) === false, "(1 >= NaN) !== false");
812 ok((NaN < 1) === false, "(NaN < 1) !== false");
813 ok((NaN > 1) === false, "(NaN > 1) !== false");
814 ok((NaN <= 1) === false, "(NaN <= 1) !== false");
815 ok((NaN >= 1) === false, "(NaN >= 1) !== false");
816 ok((Infinity < 2) === false, "(Infinity < 2) !== false");
817 ok((Infinity > 2) === true, "(Infinity > 2) !== true");
818 ok((-Infinity < 2) === true, "(-Infinity < 2) !== true");
820 ok(isNaN(+"test") === true, "isNaN(+'test') !== true");
821 ok(isNaN(+"123t") === true, "isNaN(+'123t') !== true");
822 ok(isNaN(+"Infinity x") === true, "isNaN(+'Infinity x') !== true");
823 ok(+"Infinity" === Infinity, "+'Infinity' !== Infinity");
824 ok(+" Infinity " === Infinity, "+' Infinity ' !== Infinity");
825 ok(+"-Infinity" === -Infinity, "+'-Infinity' !== -Infinity");
827 ok((NaN !== NaN) === true, "(NaN !== NaN) !== true");
828 ok((NaN === NaN) === false, "(NaN === NaN) !== false");
829 ok((Infinity !== NaN) === true, "(Infinity !== NaN) !== true");
830 ok((Infinity !== NaN) === true, "(Infinity !== NaN) !== true");
831 ok((0 === NaN) === false, "(0 === NaN) !== false");
833 ok((NaN != NaN) === true, "(NaN !== NaN) != true");
834 ok((NaN == NaN) === false, "(NaN === NaN) != false");
835 ok((Infinity != NaN) === true, "(Infinity != NaN) !== true");
836 ok((Infinity != NaN) === true, "(Infinity != NaN) !== true");
837 ok((0 == NaN) === false, "(0 === NaN) != false");
840 ok(typeof(testFunc2) === "function", "typeof(testFunc2) = " + typeof(testFunc2));
841 tmp = testFunc2(1);
842 ok(tmp === 2, "testFunc2(1) = " + tmp);
843 function testFunc2(x) { return x+1; }
845 ok(typeof(testFunc3) === "function", "typeof(testFunc3) = " + typeof(testFunc3));
846 tmp = testFunc3(1);
847 ok(tmp === 3, "testFunc3(1) = " + tmp);
848 tmp = function testFunc3(x) { return x+2; };
850 tmp = testFunc4(1);
851 ok(tmp === 5, "testFunc4(1) = " + tmp);
852 tmp = function testFunc4(x) { return x+3; };
853 tmp = testFunc4(1);
854 testFunc4 = 1;
855 ok(testFunc4 === 1, "testFunc4 = " + testFunc4);
856 ok(tmp === 5, "testFunc4(1) = " + tmp);
857 tmp = function testFunc4(x) { return x+4; };
858 ok(testFunc4 === 1, "testFunc4 = " + testFunc4);
860 function testEmbededFunctions() {
861     ok(typeof(testFunc5) === "function", "typeof(testFunc5) = " + typeof(testFunc5));
862     tmp = testFunc5(1);
863     ok(tmp === 3, "testFunc5(1) = " + tmp);
864     tmp = function testFunc5(x) { return x+2; };
866     tmp = testFunc6(1);
867     ok(tmp === 5, "testFunc6(1) = " + tmp);
868     tmp = function testFunc6(x) { return x+3; };
869     tmp = testFunc6(1);
870     ok(tmp === 5, "testFunc6(1) = " + tmp);
871     tmp = function testFunc6(x) { return x+4; };
872     testFunc6 = 1;
873     ok(testFunc6 === 1, "testFunc4 = " + testFunc6);
876 testEmbededFunctions();
878 reportSuccess();