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