jscript: Added '<<=' expression implementation.
[wine] / dlls / jscript / tests / lang.js
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  */
18
19 var tmp;
20
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");
27
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
37 ok(1 !== 2, "1 !== 2 is false");
38 ok(null !== undefined, "null !== undefined is false");
39
40 ok(1 == 1, "1 == 1 is false");
41 ok(!(1 == 2), "!(1 == 2) is false");
42 ok(1.0 == 1, "1.0 == 1 is false");
43 ok("abc" == "abc", "\"abc\" == \"abc\" is false");
44 ok(true == true, "true == true is false");
45 ok(null == null, "null == null is false");
46 ok(undefined == undefined, "undefined == undefined is false");
47 ok(undefined == null, "undefined == null is false");
48 ok(true == 1, "true == 1 is false");
49 ok(!(true == 2), "true == 2");
50 ok(0 == false, "0 == false is false");
51
52 ok(1 != 2, "1 != 2 is false");
53 ok(false != 1, "false != 1 is false");
54
55 var trueVar = true;
56 ok(trueVar, "trueVar is not true");
57
58 ok(ScriptEngine.length === 0, "ScriptEngine.length is not 0");
59
60 function testFunc1(x, y) {
61     ok(this !== undefined, "this is undefined");
62     ok(x === true, "x is not 1");
63     ok(y === "test", "y is not \"test\"");
64     ok(arguments.length === 2, "arguments.length is not 2");
65     ok(arguments["0"] === true, "arguments[0] is not true");
66     ok(arguments["1"] === "test", "arguments[1] is not \"test\"");
67
68     return true;
69 }
70
71 ok(testFunc1.length === 2, "testFunc1.length is not 2");
72
73 ok(Object.prototype !== undefined, "Object.prototype is undefined");
74 ok(Object.prototype.prototype === undefined, "Object.prototype is not undefined");
75 ok(String.prototype !== undefined, "String.prototype is undefined");
76 ok(Array.prototype !== undefined, "Array.prototype is undefined");
77 ok(Boolean.prototype !== undefined, "Boolean.prototype is undefined");
78 ok(Number.prototype !== undefined, "Number.prototype is undefined");
79 ok(RegExp.prototype !== undefined, "RegExp.prototype is undefined");
80 ok(Math !== undefined, "Math is undefined");
81 ok(Math.prototype === undefined, "Math.prototype is not undefined");
82
83 ok(typeof(0) === "number", "typeof(0) is not number");
84 ok(typeof(1.5) === "number", "typeof(1.5) is not number");
85 ok(typeof("abc") === "string", "typeof(\"abc\") is not string");
86 ok(typeof("") === "string", "typeof(\"\") is not string");
87 ok(typeof(true) === "boolean", "typeof(true) is not boolean");
88 ok(typeof(null) === "object", "typeof(null) is not object");
89 ok(typeof(undefined) === "undefined", "typeof(undefined) is not undefined");
90 ok(typeof(Math) === "object", "typeof(Math) is not object");
91 ok(typeof(String.prototype) === "object", "typeof(String.prototype) is not object");
92 ok(typeof(testFunc1) === "function", "typeof(testFunc1) is not function");
93 ok(typeof(String) === "function", "typeof(String) is not function");
94 ok(typeof(ScriptEngine) === "function", "typeof(ScriptEngine) is not function");
95 ok(typeof(this) === "object", "typeof(this) is not object");
96
97 ok(testFunc1(true, "test") === true, "testFunc1 not returned true");
98
99 var obj1 = new Object();
100 ok(typeof(obj1) === "object", "typeof(obj1) is not object");
101 obj1.test = true;
102 obj1.func = function () {
103     ok(this === obj1, "this is not obj1");
104     ok(this.test === true, "this.test is not true");
105     ok(arguments.length === 1, "arguments.length is not 1");
106     ok(arguments["0"] === true, "arguments[0] is not true");
107
108     return "test";
109 };
110
111 ok(obj1.func(true) === "test", "obj1.func(true) is not \"test\"");
112
113 function testConstr1() {
114     this.var1 = 1;
115
116     ok(this !== undefined, "this is undefined");
117     ok(arguments.length === 1, "arguments.length is not 1");
118     ok(arguments["0"] === true, "arguments[0] is not 1");
119
120     return false;
121 }
122
123 testConstr1.prototype.pvar = 1;
124
125 var obj2 = new testConstr1(true);
126 ok(typeof(obj2) === "object", "typeof(obj2) is not object");
127 ok(obj2.pvar === 1, "obj2.pvar is not 1");
128
129 testConstr1.prototype.pvar = 2;
130 ok(obj2.pvar === 2, "obj2.pvar is not 2");
131
132 obj2.pvar = 3;
133 testConstr1.prototype.pvar = 1;
134 ok(obj2.pvar === 3, "obj2.pvar is not 3");
135
136 var obj3 = new Object;
137 ok(typeof(obj3) === "object", "typeof(obj3) is not object");
138
139 tmp = 0;
140 if(true)
141     tmp = 1;
142 else
143     ok(false, "else evaluated");
144 ok(tmp === 1, "tmp !== 1, if not evaluated?");
145
146 tmp = 0;
147 if(1 === 0)
148     ok(false, "if evaluated");
149 else
150     tmp = 1;
151 ok(tmp === 1, "tmp !== 1, if not evaluated?");
152
153 if(false)
154     ok(false, "if(false) evaluated");
155
156 tmp = 0;
157 if(true)
158     tmp = 1;
159 ok(tmp === 1, "tmp !== 1, if(true) not evaluated?");
160
161 var obj3 = { prop1: 1,  prop2: typeof(false) };
162 ok(obj3.prop1 === 1, "obj3.prop1 is not 1");
163 ok(obj3.prop2 === "boolean", "obj3.prop2 is not \"boolean\"");
164
165 {
166     var blockVar = 1;
167     blockVar = 2;
168 }
169 ok(blockVar === 2, "blockVar !== 2");
170
171 ok((true ? 1 : 2) === 1, "conditional expression true is not 1");
172 ok((0 === 2 ? 1 : 2) === 2, "conditional expression true is not 2");
173
174 ok(getVT(undefined) === "VT_EMPTY", "getVT(undefined) is not VT_EMPTY");
175 ok(getVT(null) === "VT_NULL", "getVT(null) is not VT_NULL");
176 ok(getVT(0) === "VT_I4", "getVT(0) is not VT_I4");
177 ok(getVT(0.5) === "VT_R8", "getVT(1.5) is not VT_R8");
178 ok(getVT("test") === "VT_BSTR", "getVT(\"test\") is not VT_BSTR");
179 ok(getVT(Math) === "VT_DISPATCH", "getVT(Math) is not VT_DISPATCH");
180 ok(getVT(false) === "VT_BOOL", "getVT(false) is not VT_BOOL");
181
182 tmp = 2+2;
183 ok(tmp === 4, "2+2 !== 4");
184 ok(getVT(tmp) === "VT_I4", "getVT(2+2) !== VT_I4");
185
186 tmp = 2+2.5;
187 ok(tmp === 4.5, "2+2.5 !== 4.5");
188 ok(getVT(tmp) === "VT_R8", "getVT(2+2.5) !== VT_R8");
189
190 tmp = 1.5+2.5;
191 ok(tmp === 4, "1.4+2.5 !== 4");
192 ok(getVT(tmp) === "VT_I4", "getVT(1.5+2.5) !== VT_I4");
193
194 tmp = 4-2;
195 ok(tmp === 2, "4-2 !== 2");
196 ok(getVT(tmp) === "VT_I4", "getVT(4-2) !== VT_I4");
197
198 tmp = 4.5-2;
199 ok(tmp === 2.5, "4.5-2 !== 2.5");
200 ok(getVT(tmp) === "VT_R8", "getVT(4-2) !== VT_R8");
201
202 tmp = -2;
203 ok(tmp === 0-2, "-2 !== 0-2");
204 ok(getVT(tmp) === "VT_I4", "getVT(-2) !== VT_I4");
205
206 tmp = 2*3;
207 ok(tmp === 6, "2*3 !== 6");
208 ok(getVT(tmp) === "VT_I4", "getVT(2*3) !== VT_I4");
209
210 tmp = 2*3.5;
211 ok(tmp === 7, "2*3.5 !== 7");
212 ok(getVT(tmp) === "VT_I4", "getVT(2*3.5) !== VT_I4");
213
214 tmp = 2.5*3.5;
215 ok(tmp === 8.75, "2.5*3.5 !== 8.75");
216 ok(getVT(tmp) === "VT_R8", "getVT(2.5*3.5) !== VT_R8");
217
218 tmp = 4/2;
219 ok(tmp === 2, "4/2 !== 2");
220 ok(getVT(tmp) === "VT_I4", "getVT(4/2) !== VT_I4");
221
222 tmp = 4.5/1.5;
223 ok(tmp === 3, "4.5/1.5 !== 3");
224 ok(getVT(tmp) === "VT_I4", "getVT(4.5/1.5) !== VT_I4");
225
226 tmp = 3/2;
227 ok(tmp === 1.5, "3/2 !== 1.5");
228 ok(getVT(tmp) === "VT_R8", "getVT(3/2) !== VT_R8");
229
230 tmp = "ab" + "cd";
231 ok(tmp === "abcd", "\"ab\" + \"cd\" !== \"abcd\"");
232
233 tmp = 1;
234 ok((tmp += 1) === 2, "tmp += 1 !== 2");
235 ok(tmp === 2, "tmp !== 2");
236
237 tmp = 2;
238 ok((tmp -= 1) === 1, "tmp -= 1 !== 1");
239 ok(tmp === 1, "tmp !=== 1");
240
241 tmp = 2;
242 ok((tmp *= 1.5) === 3, "tmp *= 1.5 !== 3");
243 ok(tmp === 3, "tmp !=== 3");
244
245 tmp = 5;
246 ok((tmp /= 2) === 2.5, "tmp /= 2 !== 2.5");
247 ok(tmp === 2.5, "tmp !=== 2.5");
248
249 tmp = 8;
250 ok((tmp <<= 1) === 16, "tmp <<= 1 !== 16");
251
252 tmp = 3 || ok(false, "second or expression called");
253 ok(tmp === 3, "3 || (...) is not 3");
254
255 tmp = false || 2;
256 ok(tmp === 2, "false || 2 is not 2");
257
258 tmp = 0 && ok(false, "second and expression called");
259 ok(tmp === 0, "0 && (...) is not 0");
260
261 tmp = true && "test";
262 ok(tmp === "test", "true && \"test\" is not \"test\"");
263
264 tmp = true && 0;
265 ok(tmp === 0, "true && 0 is not 0");
266
267 tmp = 3 | 4;
268 ok(tmp === 7, "3 | 4 !== 7");
269 ok(getVT(tmp) === "VT_I4", "getVT(3|4) = " + getVT(tmp));
270
271 tmp = 3.5 | 0;
272 ok(tmp === 3, "3.5 | 0 !== 3");
273 ok(getVT(tmp) === "VT_I4", "getVT(3.5|0) = " + getVT(tmp));
274
275 tmp = -3.5 | 0;
276 ok(tmp === -3, "-3.5 | 0 !== -3");
277 ok(getVT(tmp) === "VT_I4", "getVT(3.5|0) = " + getVT(tmp));
278
279 tmp = 10;
280 ok((tmp |= 0x10) === 26, "tmp(10) |= 0x10 !== 26");
281 ok(getVT(tmp) === "VT_I4", "getVT(tmp |= 10) = " + getVT(tmp));
282
283 tmp = 3 & 5;
284 ok(tmp === 1, "3 & 5 !== 1");
285 ok(getVT(tmp) === "VT_I4", "getVT(3|5) = " + getVT(tmp));
286
287 tmp = 3.5 & 0xffff;
288 ok(tmp === 3, "3.5 & 0xffff !== 3 ");
289 ok(getVT(tmp) === "VT_I4", "getVT(3.5&0xffff) = " + getVT(tmp));
290
291 tmp = (-3.5) & 0xffffffff;
292 ok(tmp === -3, "-3.5 & 0xffff !== -3");
293 ok(getVT(tmp) === "VT_I4", "getVT(3.5&0xffff) = " + getVT(tmp));
294
295 tmp = 2 << 3;
296 ok(tmp === 16, "2 << 3 = " + tmp);
297
298 tmp = 2 << 35;
299 ok(tmp === 16, "2 << 35 = " + tmp);
300
301 tmp = 8 >> 2;
302 ok(tmp === 2, "8 >> 2 = " + tmp);
303
304 tmp = -64 >> 4;
305 ok(tmp === -4, "-64 >> 4 = " + tmp);
306
307 tmp = 8 >>> 2;
308 ok(tmp === 2, "8 >> 2 = " + tmp);
309
310 tmp = -64 >>> 4;
311 ok(tmp === 0x0ffffffc, "-64 >>> 4 = " + tmp);
312
313 tmp = 10;
314 ok((tmp &= 8) === 8, "tmp(10) &= 8 !== 8");
315 ok(getVT(tmp) === "VT_I4", "getVT(tmp &= 8) = " + getVT(tmp));
316
317 tmp = 0xf0f0^0xff00;
318 ok(tmp === 0x0ff0, "0xf0f0^0xff00 !== 0x0ff0");
319 ok(getVT(tmp) === "VT_I4", "getVT(0xf0f0^0xff00) = " + getVT(tmp));
320
321 tmp = 5;
322 ok((tmp ^= 3) === 6, "tmp(5) ^= 3 !== 6");
323 ok(getVT(tmp) === "VT_I4", "getVT(tmp ^= 3) = " + getVT(tmp));
324
325 tmp = ~1;
326 ok(tmp === -2, "~1 !== -2");
327 ok(getVT(tmp) === "VT_I4", "getVT(~1) = " + getVT(tmp));
328
329 ok((3,4) === 4, "(3,4) !== 4");
330
331 ok(+3 === 3, "+3 !== 3");
332 ok(+true === 1, "+true !== 1");
333 ok(+false === 0, "+false !== 0");
334 ok(+null === 0, "+null !== 0");
335
336 ok("" + 0 === "0", "\"\" + 0 !== \"0\"");
337 ok("" + 123 === "123", "\"\" + 123 !== \"123\"");
338 ok("" + (-5) === "-5", "\"\" + (-5) !== \"-5\"");
339
340 ok(1 < 3.4, "1 < 3.4 failed");
341 ok(!(3.4 < 1), "3.4 < 1");
342 ok("abc" < "abcd", "abc < abcd failed");
343 ok("abcd" < "abce", "abce < abce failed");
344 ok("" < "x", "\"\" < \"x\" failed");
345 ok(!(0 < 0), "0 < 0");
346
347 ok(1 <= 3.4, "1 <= 3.4 failed");
348 ok(!(3.4 <= 1), "3.4 <= 1");
349 ok("abc" <= "abcd", "abc <= abcd failed");
350 ok("abcd" <= "abce", "abce <= abce failed");
351 ok("" <= "x", "\"\" <= \"x\" failed");
352 ok(0 <= 0, "0 <= 0 failed");
353
354 ok(3.4 > 1, "3.4 > 1 failed");
355 ok(!(1 > 3.4), "1 > 3.4");
356 ok("abcd" > "abc", "abc > abcd failed");
357 ok("abce" > "abcd", "abce > abce failed");
358 ok("x" > "", "\"x\" > \"\" failed");
359 ok(!(0 > 0), "0 > 0");
360
361 ok(3.4 >= 1, "3.4 >= 1 failed");
362 ok(!(1 >= 3.4), "1 >= 3.4");
363 ok("abcd" >= "abc", "abc >= abcd failed");
364 ok("abce" >= "abcd", "abce >= abce failed");
365 ok("x" >= "", "\"x\" >= \"\" failed");
366 ok(0 >= 0, "0 >= 0");
367
368 tmp = 1;
369 ok(++tmp === 2, "++tmp (1) is not 2");
370 ok(tmp === 2, "incremented tmp is not 2");
371 ok(--tmp === 1, "--tmp (2) is not 1");
372 ok(tmp === 1, "decremented tmp is not 1");
373 ok(tmp++ === 1, "tmp++ (1) is not 1");
374 ok(tmp === 2, "incremented tmp(1) is not 2");
375 ok(tmp-- === 2, "tmp-- (2) is not 2");
376 ok(tmp === 1, "decremented tmp is not 1");
377
378 String.prototype.test = true;
379 ok("".test === true, "\"\".test is not true");
380
381 Boolean.prototype.test = true;
382 ok(true.test === true, "true.test is not true");
383
384 Number.prototype.test = true;
385 ok((0).test === true, "(0).test is not true");
386 ok((0.5).test === true, "(0.5).test is not true");
387
388 var state = "";
389 try {
390     ok(state === "", "try: state = " + state);
391     state = "try";
392 }catch(ex) {
393     ok(false, "unexpected catch");
394 }
395 ok(state === "try", "state = " + state + " expected try");
396
397 state = "";
398 try {
399     ok(state === "", "try: state = " + state);
400     state = "try";
401 }finally {
402     ok(state === "try", "funally: state = " + state);
403     state = "finally";
404 }
405 ok(state === "finally", "state = " + state + " expected finally");
406
407 state = "";
408 try {
409     ok(state === "", "try: state = " + state);
410     state = "try";
411 }catch(ex) {
412     ok(false, "unexpected catch");
413 }finally {
414     ok(state === "try", "funally: state = " + state);
415     state = "finally";
416 }
417 ok(state === "finally", "state = " + state + " expected finally");
418
419 var state = "";
420 try {
421     ok(state === "", "try: state = " + state);
422     state = "try";
423     throw "except";
424 }catch(ex) {
425     ok(state === "try", "catch: state = " + state);
426     ok(ex === "except", "ex is not \"except\"");
427     state = "catch";
428 }
429 ok(state === "catch", "state = " + state + " expected catch");
430
431 var state = "";
432 try {
433     ok(state === "", "try: state = " + state);
434     state = "try";
435     throw true;
436 }catch(ex) {
437     ok(state === "try", "catch: state = " + state);
438     ok(ex === true, "ex is not true");
439     state = "catch";
440 }finally {
441     ok(state === "catch", "funally: state = " + state);
442     state = "finally";
443 }
444 ok(state === "finally", "state = " + state + " expected finally");
445
446 var state = "";
447 try {
448     ok(state === "", "try: state = " + state);
449     state = "try";
450     try { throw true; } finally {}
451 }catch(ex) {
452     ok(state === "try", "catch: state = " + state);
453     ok(ex === true, "ex is not true");
454     state = "catch";
455 }finally {
456     ok(state === "catch", "funally: state = " + state);
457     state = "finally";
458 }
459 ok(state === "finally", "state = " + state + " expected finally");
460
461 var state = "";
462 try {
463     ok(state === "", "try: state = " + state);
464     state = "try";
465     try { throw "except"; } catch(ex) { throw true; }
466 }catch(ex) {
467     ok(state === "try", "catch: state = " + state);
468     ok(ex === true, "ex is not true");
469     state = "catch";
470 }finally {
471     ok(state === "catch", "funally: state = " + state);
472     state = "finally";
473 }
474 ok(state === "finally", "state = " + state + " expected finally");
475
476 function throwFunc(x) {
477     throw x;
478 }
479
480 var state = "";
481 try {
482     ok(state === "", "try: state = " + state);
483     state = "try";
484     throwFunc(true);
485 }catch(ex) {
486     ok(state === "try", "catch: state = " + state);
487     ok(ex === true, "ex is not true");
488     state = "catch";
489 }finally {
490     ok(state === "catch", "funally: state = " + state);
491     state = "finally";
492 }
493 ok(state === "finally", "state = " + state + " expected finally");
494
495 state = "";
496 switch(1) {
497 case "1":
498     ok(false, "unexpected case \"1\"");
499 case 1:
500     ok(state === "", "case 1: state = " + state);
501     state = "1";
502 default:
503     ok(state === "1", "default: state = " + state);
504     state = "default";
505 case false:
506     ok(state === "default", "case false: state = " + state);
507     state = "false";
508 }
509 ok(state === "false", "state = " + state);
510
511 state = "";
512 switch("") {
513 case "1":
514 case 1:
515     ok(false, "unexpected case 1");
516 default:
517     ok(state === "", "default: state = " + state);
518     state = "default";
519 case false:
520     ok(state === "default", "case false: state = " + state);
521     state = "false";
522 }
523 ok(state === "false", "state = " + state);
524
525 state = "";
526 switch(1) {
527 case "1":
528     ok(false, "unexpected case \"1\"");
529 case 1:
530     ok(state === "", "case 1: state = " + state);
531     state = "1";
532 default:
533     ok(state === "1", "default: state = " + state);
534     state = "default";
535     break;
536 case false:
537     ok(false, "unexpected case false");
538 }
539 ok(state === "default", "state = " + state);
540
541 tmp = eval("1");
542 ok(tmp === 1, "eval(\"1\") !== 1");
543 eval("{ ok(tmp === 1, 'eval: tmp !== 1'); } tmp = 2;");
544 ok(tmp === 2, "tmp !== 2");
545
546 ok(eval(false) === false, "eval(false) !== false");
547 ok(eval() === undefined, "eval() !== undefined");
548
549 tmp = eval("1", "2");
550 ok(tmp === 1, "eval(\"1\", \"2\") !== 1");
551
552 var state = "";
553 try {
554     ok(state === "", "try: state = " + state);
555     state = "try";
556     eval("throwFunc(true);");
557 }catch(ex) {
558     ok(state === "try", "catch: state = " + state);
559     ok(ex === true, "ex is not true");
560     state = "catch";
561 }finally {
562     ok(state === "catch", "funally: state = " + state);
563     state = "finally";
564 }
565 ok(state === "finally", "state = " + state + " expected finally");
566
567 tmp = [,,1,2,,,true];
568 ok(tmp.length === 7, "tmp.length !== 7");
569 ok(tmp["0"] === undefined, "tmp[0] is not undefined");
570 ok(tmp["3"] === 2, "tmp[3] !== 2");
571 ok(tmp["6"] === true, "tmp[6] !== true");
572 ok(tmp[2] === 1, "tmp[2] !== 1");
573
574 tmp = 0;
575 while(tmp < 4) {
576     ok(tmp < 4, "tmp >= 4");
577     tmp++;
578 }
579 ok(tmp === 4, "tmp !== 4");
580
581 tmp = 0;
582 while(true) {
583     ok(tmp < 4, "tmp >= 4");
584     tmp++;
585     if(tmp === 4) {
586         break;
587         ok(false, "break did not break");
588     }
589 }
590 ok(tmp === 4, "tmp !== 4");
591
592 tmp = 0;
593 do {
594     ok(tmp < 4, "tmp >= 4");
595     tmp++;
596 } while(tmp < 4);
597 ok(tmp === 4, "tmp !== 4");
598
599 tmp = 0;
600 do {
601     ok(tmp === 0, "tmp !=== 0");
602     tmp++;
603 } while(false);
604 ok(tmp === 1, "tmp !== 4");
605
606 tmp = 0;
607 while(tmp < 4) {
608     tmp++;
609     if(tmp === 2) {
610         continue;
611         ok(false, "break did not break");
612     }
613     ok(tmp <= 4 && tmp != 2, "tmp = " + tmp);
614 }
615 ok(tmp === 4, "tmp !== 4");
616
617 for(tmp=0; tmp < 4; tmp++)
618     ok(tmp < 4, "tmp = " + tmp);
619 ok(tmp === 4, "tmp !== 4");
620
621 for(tmp=0; tmp < 4; tmp++) {
622     if(tmp === 2)
623         break;
624     ok(tmp < 2, "tmp = " + tmp);
625 }
626 ok(tmp === 2, "tmp !== 2");
627
628 for(tmp=0; tmp < 4; tmp++) {
629     if(tmp === 2)
630         continue;
631     ok(tmp < 4 && tmp != 2, "tmp = " + tmp);
632 }
633 ok(tmp === 4, "tmp !== 4");
634
635 for(var fi=0; fi < 4; fi++)
636     ok(fi < 4, "fi = " + fi);
637 ok(fi === 4, "fi !== 4");
638
639 ok((void 1) === undefined, "(void 1) !== undefined");
640
641 var inobj = new Object();
642
643 for(var iter in inobj)
644     ok(false, "unexpected iter = " + iter);
645
646 inobj.test = true;
647 tmp = 0;
648 for(iter in inobj) {
649     ok(iter == "test", "unexpected iter = " + iter);
650     tmp++;
651 }
652 ok(tmp === 1, "for..in tmp = " + tmp);
653
654 function forinTestObj() {}
655
656 forinTestObj.prototype.test3 = true;
657
658 var arr = new Array();
659 inobj = new forinTestObj();
660 inobj.test1 = true;
661 inobj.test2 = true;
662
663 tmp = 0;
664 for(iter in inobj) {
665     arr[iter] = true;
666     tmp++;
667 }
668
669 ok(tmp === 3, "for..in tmp = " + tmp);
670 ok(arr["test1"] === true, "arr[test1] !== true");
671 ok(arr["test2"] === true, "arr[test2] !== true");
672 ok(arr["test3"] === true, "arr[test3] !== true");
673
674 tmp = new Object();
675 tmp.test = false;
676 ok((delete tmp.test) === true, "delete returned false");
677 ok(typeof(tmp.test) === "undefined", "tmp.test type = " + typeof(tmp.test));
678 for(iter in tmp)
679     ok(false, "tmp has prop " + iter);
680
681 tmp.testWith = true;
682 with(tmp)
683     ok(testWith === true, "testWith !== true");
684
685 reportSuccess();