jscript: Separate flags parsing from regexp creating.
[wine] / dlls / jscript / tests / api.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, i;
20
21 i = parseInt("0");
22 ok(i === 0, "parseInt('0') = " + i);
23 i = parseInt("123");
24 ok(i === 123, "parseInt('123') = " + i);
25 i = parseInt("-123");
26 ok(i === -123, "parseInt('-123') = " + i);
27 i = parseInt("0xff");
28 ok(i === 0xff, "parseInt('0xff') = " + i);
29 i = parseInt("11", 8);
30 ok(i === 9, "parseInt('11', 8) = " + i);
31 i = parseInt("1j", 22);
32 ok(i === 41, "parseInt('1j', 32) = " + i);
33 i = parseInt("123", 0);
34 ok(i === 123, "parseInt('123', 0) = " + i);
35 i = parseInt("123", 10, "test");
36 ok(i === 123, "parseInt('123', 10, 'test') = " + i);
37 i = parseInt("11", "8");
38 ok(i === 9, "parseInt('11', '8') = " + i);
39
40 tmp = encodeURI("abc");
41 ok(tmp === "abc", "encodeURI('abc') = " + tmp);
42 tmp = encodeURI("{abc}");
43 ok(tmp === "%7Babc%7D", "encodeURI('{abc}') = " + tmp);
44 tmp = encodeURI("");
45 ok(tmp === "", "encodeURI('') = " + tmp);
46 tmp = encodeURI("\01\02\03\04");
47 ok(tmp === "%01%02%03%04", "encodeURI('\\01\\02\\03\\04') = " + tmp);
48 tmp = encodeURI("{#@}");
49 ok(tmp === "%7B#@%7D", "encodeURI('{#@}') = " + tmp);
50 tmp = encodeURI("\xa1 ");
51 ok(tmp === "%C2%A1%20", "encodeURI(\\xa1 ) = " + tmp);
52 tmp = encodeURI("\xffff");
53 ok(tmp.length === 8, "encodeURI('\\xffff').length = " + tmp.length);
54 tmp = encodeURI("abcABC123;/?:@&=+$,-_.!~*'()");
55 ok(tmp === "abcABC123;/?:@&=+$,-_.!~*'()", "encodeURI('abcABC123;/?:@&=+$,-_.!~*'()') = " + tmp);
56 tmp = encodeURI();
57 ok(tmp === "undefined", "encodeURI() = " + tmp);
58 tmp = encodeURI("abc", "test");
59 ok(tmp === "abc", "encodeURI('abc') = " + tmp);
60
61 tmp = encodeURIComponent("abc");
62 ok(tmp === "abc", "encodeURIComponent('abc') = " + tmp);
63 tmp = encodeURIComponent("{abc}");
64 ok(tmp === "%7Babc%7D", "encodeURIComponent('{abc}') = " + tmp);
65 tmp = encodeURIComponent("");
66 ok(tmp === "", "encodeURIComponent('') = " + tmp);
67 tmp = encodeURIComponent("\01\02\03\04");
68 ok(tmp === "%01%02%03%04", "encodeURIComponent('\\01\\02\\03\\04') = " + tmp);
69 tmp = encodeURIComponent("{#@}");
70 ok(tmp === "%7B%23%40%7D", "encodeURIComponent('{#@}') = " + tmp);
71 tmp = encodeURIComponent("\xa1 ");
72 ok(tmp === "%C2%A1%20", "encodeURIComponent(\\xa1 ) = " + tmp);
73 tmp = encodeURIComponent("\xffff");
74 ok(tmp.length === 8, "encodeURIComponent('\\xffff').length = " + tmp.length);
75 tmp = encodeURIComponent("abcABC123;/?:@&=+$,-_.!~*'()");
76 ok(tmp === "abcABC123%3B%2F%3F%3A%40%26%3D%2B%24%2C-_.!~*'()", "encodeURIComponent('abcABC123;/?:@&=+$,-_.!~*'()') = " + tmp);
77 tmp = encodeURIComponent();
78 ok(tmp === "undefined", "encodeURIComponent() = " + tmp);
79 tmp = encodeURIComponent("abc", "test");
80 ok(tmp === "abc", "encodeURIComponent('abc') = " + tmp);
81
82 tmp = escape("abc");
83 ok(tmp === "abc", "escape('abc') = " + tmp);
84 tmp = escape("");
85 ok(tmp === "", "escape('') = " + tmp);
86 tmp = escape("a1b c!d+e@*-_+./,");
87 ok(tmp === "a1b%20c%21d+e@*-_+./%2C", "escape('a1b c!d+e@*-_+./,') = " + tmp);
88 tmp = escape();
89 ok(tmp === "undefined", "escape() = " + tmp);
90 tmp = escape('\u1234\123\xf3');
91 ok(tmp == "%u1234S%F3", "escape('\u1234\123\xf3') = " + tmp);
92
93 tmp = unescape("abc");
94 ok(tmp === "abc", "unescape('abc') = " + tmp);
95 tmp = unescape("");
96 ok(tmp === "", "unescape('') = " + tmp);
97 tmp = unescape("%%%");
98 ok(tmp === "%%%", "unescape('%%%') = " + tmp);
99 tmp = unescape();
100 ok(tmp === "undefined", "unescape() = " + tmp);
101 tmp = unescape("%54%65s%u0074");
102 ok(tmp === "Test", "unescape('%54%65s%u0074') = " + tmp);
103
104 tmp = "aA1~`!@#$%^&*()_+=-][{}';:/.,<>?\|";
105 ok(escape(tmp) === "aA1%7E%60%21@%23%24%25%5E%26*%28%29_+%3D-%5D%5B%7B%7D%27%3B%3A/.%2C%3C%3E%3F%7C", "escape('" + tmp + "') = " + escape(tmp));
106 ok(unescape(escape(tmp)) === tmp, "unescape(escape('" + tmp + "')) = " + unescape(escape(tmp)));
107
108 tmp = "" + new Object();
109 ok(tmp === "[object Object]", "'' + new Object() = " + tmp);
110 (tmp = new Array).f = Object.prototype.toString;
111 ok(tmp.f() === "[object Array]", "tmp.f() = " + tmp.f());
112 (tmp = new Boolean).f = Object.prototype.toString;
113 ok(tmp.f() === "[object Boolean]", "tmp.f() = " + tmp.f());
114 (tmp = new Date).f = Object.prototype.toString;
115 ok(tmp.f() === "[object Date]", "tmp.f() = " + tmp.f());
116 (tmp = function() {}).f = Object.prototype.toString;
117 ok(tmp.f() === "[object Function]", "tmp.f() = " + tmp.f());
118 Math.f = Object.prototype.toString;
119 ok(Math.f() === "[object Math]", "tmp.f() = " + tmp.f());
120 (tmp = new Number).f = Object.prototype.toString;
121 ok(tmp.f() === "[object Number]", "tmp.f() = " + tmp.f());
122 (tmp = new RegExp("")).f = Object.prototype.toString;
123 ok(tmp.f() === "[object RegExp]", "tmp.f() = " + tmp.f());
124 (tmp = new String).f = Object.prototype.toString;
125 ok(tmp.f() === "[object String]", "tmp.f() = " + tmp.f());
126 tmp = Object.prototype.toString.call(testObj);
127 ok(tmp === "[object Object]", "toString.call(testObj) = " + tmp);
128 tmp = Object.prototype.toString.call(this);
129 ok(tmp === "[object Object]", "toString.call(this) = " + tmp);
130 (function () { tmp = Object.prototype.toString.call(arguments); })();
131 ok(tmp === "[object Object]", "toString.call(arguments) = " + tmp);
132
133 ok(Object(1) instanceof Number, "Object(1) is not instance of Number");
134 ok(Object("") instanceof String, "Object('') is not instance of String");
135 ok(Object(false) instanceof Boolean, "Object(false) is not instance of Boolean");
136
137 obj = new Object();
138 ok(Object(obj) === obj, "Object(obj) !== obj");
139
140 ok(typeof(Object()) === "object", "typeof(Object()) !== 'object'");
141 ok(typeof(Object(undefined)) === "object", "typeof(Object(undefined)) !== 'object'");
142 ok(typeof(Object(null)) === "object", "typeof(Object(null)) !== 'object'");
143
144 var obj = new Object();
145 obj.toString = function (x) {
146     ok(arguments.length === 0, "arguments.length = " + arguments.length);
147     return "test";
148 };
149 ok((tmp = obj.toLocaleString()) === "test", "obj.toLocaleString() = " + tmp);
150 ok((tmp = obj.toLocaleString(1)) === "test", "obj.toLocaleString(1) = " + tmp);
151 ok(obj === obj.valueOf(), "obj !== obj.valueOf");
152
153 ok("".length === 0, "\"\".length = " + "".length);
154 ok(getVT("".length) == "VT_I4", "\"\".length = " + "".length);
155 ok("abc".length === 3, "\"abc\".length = " + "abc".length);
156 ok(String.prototype.length === 0, "String.prototype.length = " + String.prototype.length);
157
158 tmp = "".toString();
159 ok(tmp === "", "''.toString() = " + tmp);
160 tmp = "test".toString();
161 ok(tmp === "test", "''.toString() = " + tmp);
162 tmp = "test".toString(3);
163 ok(tmp === "test", "''.toString(3) = " + tmp);
164
165 tmp = "".valueOf();
166 ok(tmp === "", "''.valueOf() = " + tmp);
167 tmp = "test".valueOf();
168 ok(tmp === "test", "''.valueOf() = " + tmp);
169 tmp = "test".valueOf(3);
170 ok(tmp === "test", "''.valueOf(3) = " + tmp);
171
172 var str = new String("test");
173 ok(str.toString() === "test", "str.toString() = " + str.toString());
174 var str = new String();
175 ok(str.toString() === "", "str.toString() = " + str.toString());
176 var str = new String("test", "abc");
177 ok(str.toString() === "test", "str.toString() = " + str.toString());
178
179 var strObj = new Object();
180 strObj.toString = function() { return "abcd" };
181 strObj.substr = String.prototype.substr;
182 strObj.lastIndexOf = String.prototype.lastIndexOf;
183
184 tmp = "value " + str;
185 ok(tmp === "value test", "'value ' + str = " + tmp);
186
187 tmp = String();
188 ok(tmp === "", "String() = " + tmp);
189 tmp = String(false);
190 ok(tmp === "false", "String(false) = " + tmp);
191 tmp = String(null);
192 ok(tmp === "null", "String(null) = " + tmp);
193 tmp = String("test");
194 ok(tmp === "test", "String('test') = " + tmp);
195 tmp = String("test", "abc");
196 ok(tmp === "test", "String('test','abc') = " + tmp);
197
198 tmp = "abc".charAt(0);
199 ok(tmp === "a", "'abc',charAt(0) = " + tmp);
200 tmp = "abc".charAt(1);
201 ok(tmp === "b", "'abc',charAt(1) = " + tmp);
202 tmp = "abc".charAt(2);
203 ok(tmp === "c", "'abc',charAt(2) = " + tmp);
204 tmp = "abc".charAt(3);
205 ok(tmp === "", "'abc',charAt(3) = " + tmp);
206 tmp = "abc".charAt(4);
207 ok(tmp === "", "'abc',charAt(4) = " + tmp);
208 tmp = "abc".charAt();
209 ok(tmp === "a", "'abc',charAt() = " + tmp);
210 tmp = "abc".charAt(-1);
211 ok(tmp === "", "'abc',charAt(-1) = " + tmp);
212 tmp = "abc".charAt(0,2);
213 ok(tmp === "a", "'abc',charAt(0.2) = " + tmp);
214
215 tmp = "abc".charCodeAt(0);
216 ok(tmp === 0x61, "'abc'.charCodeAt(0) = " + tmp);
217 tmp = "abc".charCodeAt(1);
218 ok(tmp === 0x62, "'abc'.charCodeAt(1) = " + tmp);
219 tmp = "abc".charCodeAt(2);
220 ok(tmp === 0x63, "'abc'.charCodeAt(2) = " + tmp);
221 tmp = "abc".charCodeAt();
222 ok(tmp === 0x61, "'abc'.charCodeAt() = " + tmp);
223 tmp = "abc".charCodeAt(true);
224 ok(tmp === 0x62, "'abc'.charCodeAt(true) = " + tmp);
225 tmp = "abc".charCodeAt(0,2);
226 ok(tmp === 0x61, "'abc'.charCodeAt(0,2) = " + tmp);
227 tmp = "\u49F4".charCodeAt(0);
228 ok(tmp === 0x49F4, "'\u49F4'.charCodeAt(0) = " + tmp);
229 tmp = "\052".charCodeAt(0);
230 ok(tmp === 0x2A, "'\052'.charCodeAt(0) = " + tmp);
231 tmp = "\xa2".charCodeAt(0);
232 ok(tmp === 0xA2, "'\xa2'.charCodeAt(0) = " + tmp);
233
234 tmp = "abcd".substring(1,3);
235 ok(tmp === "bc", "'abcd'.substring(1,3) = " + tmp);
236 tmp = "abcd".substring(-1,3);
237 ok(tmp === "abc", "'abcd'.substring(-1,3) = " + tmp);
238 tmp = "abcd".substring(1,6);
239 ok(tmp === "bcd", "'abcd'.substring(1,6) = " + tmp);
240 tmp = "abcd".substring(3,1);
241 ok(tmp === "bc", "'abcd'.substring(3,1) = " + tmp);
242 tmp = "abcd".substring(2,2);
243 ok(tmp === "", "'abcd'.substring(2,2) = " + tmp);
244 tmp = "abcd".substring(true,"3");
245 ok(tmp === "bc", "'abcd'.substring(true,'3') = " + tmp);
246 tmp = "abcd".substring(1,3,2);
247 ok(tmp === "bc", "'abcd'.substring(1,3,2) = " + tmp);
248 tmp = "abcd".substring();
249 ok(tmp === "abcd", "'abcd'.substring() = " + tmp);
250
251 tmp = "abcd".substr(1,3);
252 ok(tmp === "bcd", "'abcd'.substr(1,3) = " + tmp);
253 tmp = "abcd".substr(-1,3);
254 ok(tmp === "abc", "'abcd'.substr(-1,3) = " + tmp);
255 tmp = "abcd".substr(1,6);
256 ok(tmp === "bcd", "'abcd'.substr(1,6) = " + tmp);
257 tmp = "abcd".substr(2,-1);
258 ok(tmp === "", "'abcd'.substr(3,1) = " + tmp);
259 tmp = "abcd".substr(2,0);
260 ok(tmp === "", "'abcd'.substr(2,2) = " + tmp);
261 tmp = "abcd".substr(true,"3");
262 ok(tmp === "bcd", "'abcd'.substr(true,'3') = " + tmp);
263 tmp = "abcd".substr(1,3,2);
264 ok(tmp === "bcd", "'abcd'.substr(1,3,2) = " + tmp);
265 tmp = "abcd".substr();
266 ok(tmp === "abcd", "'abcd'.substr() = " + tmp);
267 tmp = strObj.substr(1,1);
268 ok(tmp === "b", "'abcd'.substr(1,3) = " + tmp);
269
270 tmp = "abcd".slice(1,3);
271 ok(tmp === "bc", "'abcd'.slice(1,3) = " + tmp);
272 tmp = "abcd".slice(1,-1);
273 ok(tmp === "bc", "'abcd'.slice(1,-1) = " + tmp);
274 tmp = "abcd".slice(-3,3);
275 ok(tmp === "bc", "'abcd'.slice(-3,3) = " + tmp);
276 tmp = "abcd".slice(-6,3);
277 ok(tmp === "abc", "'abcd'.slice(-6,3) = " + tmp);
278 tmp = "abcd".slice(3,1);
279 ok(tmp === "", "'abcd'.slice(3,1) = " + tmp);
280 tmp = "abcd".slice(true,3);
281 ok(tmp === "bc", "'abcd'.slice(true,3) = " + tmp);
282 tmp = "abcd".slice();
283 ok(tmp === "abcd", "'abcd'.slice() = " + tmp);
284 tmp = "abcd".slice(1);
285 ok(tmp === "bcd", "'abcd'.slice(1) = " + tmp);
286
287 tmp = "abc".concat(["d",1],2,false);
288 ok(tmp === "abcd,12false", "concat returned " + tmp);
289 var arr = new Array(2,"a");
290 arr.concat = String.prototype.concat;
291 tmp = arr.concat("d");
292 ok(tmp === "2,ad", "arr.concat = " + tmp);
293
294 m = "a+bcabc".match("a+");
295 ok(typeof(m) === "object", "typeof m is not object");
296 ok(m.length === 1, "m.length is not 1");
297 ok(m["0"] === "a", "m[0] is not \"ab\"");
298
299 r = "- [test] -".replace("[test]", "success");
300 ok(r === "- success -", "r = " + r + " expected '- success -'");
301
302 r = "- [test] -".replace("[test]", "success", "test");
303 ok(r === "- success -", "r = " + r + " expected '- success -'");
304
305 r = "test".replace();
306 ok(r === "test", "r = " + r + " expected 'test'");
307
308 function replaceFunc3(m, off, str) {
309     ok(arguments.length === 3, "arguments.length = " + arguments.length);
310     ok(m === "[test]", "m = " + m + " expected [test1]");
311     ok(off === 1, "off = " + off + " expected 0");
312     ok(str === "-[test]-", "str = " + arguments[3]);
313     return "ret";
314 }
315
316 r = "-[test]-".replace("[test]", replaceFunc3);
317 ok(r === "-ret-", "r = " + r + " expected '-ret-'");
318
319 r = "-[test]-".replace("[test]", replaceFunc3, "test");
320 ok(r === "-ret-", "r = " + r + " expected '-ret-'");
321
322 r = "1,2,3".split(",");
323 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
324 ok(r.length === 3, "r.length = " + r.length);
325 ok(r[0] === "1", "r[0] = " + r[0]);
326 ok(r[1] === "2", "r[1] = " + r[1]);
327 ok(r[2] === "3", "r[2] = " + r[2]);
328
329
330 r = "1,2,3".split(",*");
331 ok(r.length === 1, "r.length = " + r.length);
332 ok(r[0] === "1,2,3", "r[0] = " + r[0]);
333
334 r = "123".split("");
335 ok(r.length === 3, "r.length = " + r.length);
336 ok(r[0] === "1", "r[0] = " + r[0]);
337 ok(r[1] === "2", "r[1] = " + r[1]);
338 ok(r[2] === "3", "r[2] = " + r[2]);
339
340 r = "123".split(2);
341 ok(r.length === 2, "r.length = " + r.length);
342 ok(r[0] === "1", "r[0] = " + r[0]);
343 ok(r[1] === "3", "r[1] = " + r[1]);
344
345 r = "1,2,".split(",");
346 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
347 ok(r.length === 3, "r.length = " + r.length);
348 ok(r[0] === "1", "r[0] = " + r[0]);
349 ok(r[1] === "2", "r[1] = " + r[1]);
350 ok(r[2] === "", "r[2] = " + r[2]);
351
352 tmp = "abcd".indexOf("bc",0);
353 ok(tmp === 1, "indexOf = " + tmp);
354 tmp = "abcd".indexOf("bc",1);
355 ok(tmp === 1, "indexOf = " + tmp);
356 tmp = "abcd".indexOf("bc");
357 ok(tmp === 1, "indexOf = " + tmp);
358 tmp = "abcd".indexOf("ac");
359 ok(tmp === -1, "indexOf = " + tmp);
360 tmp = "abcd".indexOf("bc",2);
361 ok(tmp === -1, "indexOf = " + tmp);
362 tmp = "abcd".indexOf("a",0);
363 ok(tmp === 0, "indexOf = " + tmp);
364 tmp = "abcd".indexOf("bc",0,"test");
365 ok(tmp === 1, "indexOf = " + tmp);
366 tmp = "abcd".indexOf();
367 ok(tmp == -1, "indexOf = " + tmp);
368
369 tmp = "abcd".lastIndexOf("bc",1);
370 ok(tmp === 1, "lastIndexOf = " + tmp);
371 tmp = "abcd".lastIndexOf("bc",2);
372 ok(tmp === 1, "lastIndexOf = " + tmp);
373 tmp = "abcd".lastIndexOf("bc");
374 ok(tmp === 1, "lastIndexOf = " + tmp);
375 tmp = "abcd".lastIndexOf("ac");
376 ok(tmp === -1, "lastIndexOf = " + tmp);
377 tmp = "abcd".lastIndexOf("d",10);
378 ok(tmp === 3, "lastIndexOf = " + tmp);
379 tmp = "abcd".lastIndexOf("bc",0,"test");
380 ok(tmp === -1, "lastIndexOf = " + tmp);
381 tmp = "abcd".lastIndexOf();
382 ok(tmp === -1, "lastIndexOf = " + tmp);
383 tmp = "aaaa".lastIndexOf("a",2);
384 ok(tmp == 2, "lastIndexOf = " + tmp);
385 tmp = strObj.lastIndexOf("b");
386 ok(tmp === 1, "lastIndexOf = " + tmp);
387
388 tmp = "".toLowerCase();
389 ok(tmp === "", "''.toLowerCase() = " + tmp);
390 tmp = "test".toLowerCase();
391 ok(tmp === "test", "''.toLowerCase() = " + tmp);
392 tmp = "test".toLowerCase(3);
393 ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
394 tmp = "tEsT".toLowerCase();
395 ok(tmp === "test", "''.toLowerCase() = " + tmp);
396 tmp = "tEsT".toLowerCase(3);
397 ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
398
399 tmp = "".toUpperCase();
400 ok(tmp === "", "''.toUpperCase() = " + tmp);
401 tmp = "TEST".toUpperCase();
402 ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
403 tmp = "TEST".toUpperCase(3);
404 ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
405 tmp = "tEsT".toUpperCase();
406 ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
407 tmp = "tEsT".toUpperCase(3);
408 ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
409
410 tmp = "".anchor();
411 ok(tmp === "<A NAME=\"undefined\"></A>", "''.anchor() = " + tmp);
412 tmp = "".anchor(3);
413 ok(tmp === "<A NAME=\"3\"></A>", "''.anchor(3) = " + tmp);
414 tmp = "".anchor("red");
415 ok(tmp === "<A NAME=\"red\"></A>", "''.anchor('red') = " + tmp);
416 tmp = "test".anchor();
417 ok(tmp === "<A NAME=\"undefined\">test</A>", "'test'.anchor() = " + tmp);
418 tmp = "test".anchor(3);
419 ok(tmp === "<A NAME=\"3\">test</A>", "'test'.anchor(3) = " + tmp);
420 tmp = "test".anchor("green");
421 ok(tmp === "<A NAME=\"green\">test</A>", "'test'.anchor('green') = " + tmp);
422
423 tmp = "".big();
424 ok(tmp === "<BIG></BIG>", "''.big() = " + tmp);
425 tmp = "".big(3);
426 ok(tmp === "<BIG></BIG>", "''.big(3) = " + tmp);
427 tmp = "test".big();
428 ok(tmp === "<BIG>test</BIG>", "'test'.big() = " + tmp);
429 tmp = "test".big(3);
430 ok(tmp === "<BIG>test</BIG>", "'test'.big(3) = " + tmp);
431
432 tmp = "".blink();
433 ok(tmp === "<BLINK></BLINK>", "''.blink() = " + tmp);
434 tmp = "".blink(3);
435 ok(tmp === "<BLINK></BLINK>", "''.blink(3) = " + tmp);
436 tmp = "test".blink();
437 ok(tmp === "<BLINK>test</BLINK>", "'test'.blink() = " + tmp);
438 tmp = "test".blink(3);
439 ok(tmp === "<BLINK>test</BLINK>", "'test'.blink(3) = " + tmp);
440
441 tmp = "".bold();
442 ok(tmp === "<B></B>", "''.bold() = " + tmp);
443 tmp = "".bold(3);
444 ok(tmp === "<B></B>", "''.bold(3) = " + tmp);
445 tmp = "test".bold();
446 ok(tmp === "<B>test</B>", "'test'.bold() = " + tmp);
447 tmp = "test".bold(3);
448 ok(tmp === "<B>test</B>", "'test'.bold(3) = " + tmp);
449
450 tmp = "".fixed();
451 ok(tmp === "<TT></TT>", "''.fixed() = " + tmp);
452 tmp = "".fixed(3);
453 ok(tmp === "<TT></TT>", "''.fixed(3) = " + tmp);
454 tmp = "test".fixed();
455 ok(tmp === "<TT>test</TT>", "'test'.fixed() = " + tmp);
456 tmp = "test".fixed(3);
457 ok(tmp === "<TT>test</TT>", "'test'.fixed(3) = " + tmp);
458
459 tmp = "".fontcolor();
460 ok(tmp === "<FONT COLOR=\"undefined\"></FONT>", "''.fontcolor() = " + tmp);
461 tmp = "".fontcolor(3);
462 ok(tmp === "<FONT COLOR=\"3\"></FONT>", "''.fontcolor(3) = " + tmp);
463 tmp = "".fontcolor("red");
464 ok(tmp === "<FONT COLOR=\"red\"></FONT>", "''.fontcolor('red') = " + tmp);
465 tmp = "test".fontcolor();
466 ok(tmp === "<FONT COLOR=\"undefined\">test</FONT>", "'test'.fontcolor() = " + tmp);
467 tmp = "test".fontcolor(3);
468 ok(tmp === "<FONT COLOR=\"3\">test</FONT>", "'test'.fontcolor(3) = " + tmp);
469 tmp = "test".fontcolor("green");
470 ok(tmp === "<FONT COLOR=\"green\">test</FONT>", "'test'.fontcolor('green') = " + tmp);
471
472 tmp = "".fontsize();
473 ok(tmp === "<FONT SIZE=\"undefined\"></FONT>", "''.fontsize() = " + tmp);
474 tmp = "".fontsize(3);
475 ok(tmp === "<FONT SIZE=\"3\"></FONT>", "''.fontsize(3) = " + tmp);
476 tmp = "".fontsize("red");
477 ok(tmp === "<FONT SIZE=\"red\"></FONT>", "''.fontsize('red') = " + tmp);
478 tmp = "test".fontsize();
479 ok(tmp === "<FONT SIZE=\"undefined\">test</FONT>", "'test'.fontsize() = " + tmp);
480 tmp = "test".fontsize(3);
481 ok(tmp === "<FONT SIZE=\"3\">test</FONT>", "'test'.fontsize(3) = " + tmp);
482 tmp = "test".fontsize("green");
483 ok(tmp === "<FONT SIZE=\"green\">test</FONT>", "'test'.fontsize('green') = " + tmp);
484
485 tmp = ("".fontcolor()).fontsize();
486 ok(tmp === "<FONT SIZE=\"undefined\"><FONT COLOR=\"undefined\"></FONT></FONT>", "(''.fontcolor()).fontsize() = " + tmp);
487
488 tmp = "".italics();
489 ok(tmp === "<I></I>", "''.italics() = " + tmp);
490 tmp = "".italics(3);
491 ok(tmp === "<I></I>", "''.italics(3) = " + tmp);
492 tmp = "test".italics();
493 ok(tmp === "<I>test</I>", "'test'.italics() = " + tmp);
494 tmp = "test".italics(3);
495 ok(tmp === "<I>test</I>", "'test'.italics(3) = " + tmp);
496
497 tmp = "".link();
498 ok(tmp === "<A HREF=\"undefined\"></A>", "''.link() = " + tmp);
499 tmp = "".link(3);
500 ok(tmp === "<A HREF=\"3\"></A>", "''.link(3) = " + tmp);
501 tmp = "".link("red");
502 ok(tmp === "<A HREF=\"red\"></A>", "''.link('red') = " + tmp);
503 tmp = "test".link();
504 ok(tmp === "<A HREF=\"undefined\">test</A>", "'test'.link() = " + tmp);
505 tmp = "test".link(3);
506 ok(tmp === "<A HREF=\"3\">test</A>", "'test'.link(3) = " + tmp);
507 tmp = "test".link("green");
508 ok(tmp === "<A HREF=\"green\">test</A>", "'test'.link('green') = " + tmp);
509
510 tmp = "".small();
511 ok(tmp === "<SMALL></SMALL>", "''.small() = " + tmp);
512 tmp = "".small(3);
513 ok(tmp === "<SMALL></SMALL>", "''.small(3) = " + tmp);
514 tmp = "test".small();
515 ok(tmp === "<SMALL>test</SMALL>", "'test'.small() = " + tmp);
516 tmp = "test".small(3);
517 ok(tmp === "<SMALL>test</SMALL>", "'test'.small(3) = " + tmp);
518
519 tmp = "".strike();
520 ok(tmp === "<STRIKE></STRIKE>", "''.strike() = " + tmp);
521 tmp = "".strike(3);
522 ok(tmp === "<STRIKE></STRIKE>", "''.strike(3) = " + tmp);
523 tmp = "test".strike();
524 ok(tmp === "<STRIKE>test</STRIKE>", "'test'.strike() = " + tmp);
525 tmp = "test".strike(3);
526 ok(tmp === "<STRIKE>test</STRIKE>", "'test'.strike(3) = " + tmp);
527
528 tmp = "".sub();
529 ok(tmp === "<SUB></SUB>", "''.sub() = " + tmp);
530 tmp = "".sub(3);
531 ok(tmp === "<SUB></SUB>", "''.sub(3) = " + tmp);
532 tmp = "test".sub();
533 ok(tmp === "<SUB>test</SUB>", "'test'.sub() = " + tmp);
534 tmp = "test".sub(3);
535 ok(tmp === "<SUB>test</SUB>", "'test'.sub(3) = " + tmp);
536
537 tmp = "".sup();
538 ok(tmp === "<SUP></SUP>", "''.sup() = " + tmp);
539 tmp = "".sup(3);
540 ok(tmp === "<SUP></SUP>", "''.sup(3) = " + tmp);
541 tmp = "test".sup();
542 ok(tmp === "<SUP>test</SUP>", "'test'.sup() = " + tmp);
543 tmp = "test".sup(3);
544 ok(tmp === "<SUP>test</SUP>", "'test'.sup(3) = " + tmp);
545
546 ok(String.fromCharCode() === "", "String.fromCharCode() = " + String.fromCharCode());
547 ok(String.fromCharCode(65,"66",67) === "ABC", "String.fromCharCode(65,'66',67) = " + String.fromCharCode(65,"66",67));
548 ok(String.fromCharCode(1024*64+65, -1024*64+65) === "AA",
549         "String.fromCharCode(1024*64+65, -1024*64+65) = " + String.fromCharCode(1024*64+65, -1024*64+65));
550 ok(String.fromCharCode(65, NaN, undefined).length === 3,
551         "String.fromCharCode(65, NaN, undefined).length = " + String.fromCharCode(65, NaN, undefined).length);
552
553 var arr = new Array();
554 ok(typeof(arr) === "object", "arr () is not object");
555 ok((arr.length === 0), "arr.length is not 0");
556 ok(arr["0"] === undefined, "arr[0] is not undefined");
557
558 var arr = new Array(1, 2, "test");
559 ok(typeof(arr) === "object", "arr (1,2,test) is not object");
560 ok((arr.length === 3), "arr.length is not 3");
561 ok(arr["0"] === 1, "arr[0] is not 1");
562 ok(arr["1"] === 2, "arr[1] is not 2");
563 ok(arr["2"] === "test", "arr[2] is not \"test\"");
564
565 arr["7"] = true;
566 ok((arr.length === 8), "arr.length is not 8");
567
568 tmp = "" + [];
569 ok(tmp === "", "'' + [] = " + tmp);
570 tmp = "" + [1,true];
571 ok(tmp === "1,true", "'' + [1,true] = " + tmp);
572
573 var arr = new Array(6);
574 ok(typeof(arr) === "object", "arr (6) is not object");
575 ok((arr.length === 6), "arr.length is not 6");
576 ok(arr["0"] === undefined, "arr[0] is not undefined");
577
578 ok(arr.push() === 6, "arr.push() !== 6");
579 ok(arr.push(1) === 7, "arr.push(1) !== 7");
580 ok(arr[6] === 1, "arr[6] != 1");
581 ok(arr.length === 7, "arr.length != 10");
582 ok(arr.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10");
583 ok(arr[8] === "b", "arr[8] != 'b'");
584 ok(arr.length === 10, "arr.length != 10");
585
586 var arr = new Object();
587 arr.push = Array.prototype.push;
588
589 arr.length = 6;
590
591 ok(arr.push() === 6, "arr.push() !== 6");
592 ok(arr.push(1) === 7, "arr.push(1) !== 7");
593 ok(arr[6] === 1, "arr[6] != 1");
594 ok(arr.length === 7, "arr.length != 10");
595 ok(arr.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10");
596 ok(arr[8] === "b", "arr[8] != 'b'");
597 ok(arr.length === 10, "arr.length != 10");
598
599 arr = [3,4,5];
600 tmp = arr.pop();
601 ok(arr.length === 2, "arr.length = " + arr.length);
602 ok(tmp === 5, "pop() = " + tmp);
603 tmp = arr.pop(2);
604 ok(arr.length === 1, "arr.length = " + arr.length);
605 ok(tmp === 4, "pop() = " + tmp);
606 tmp = arr.pop();
607 ok(arr.length === 0, "arr.length = " + arr.length);
608 ok(tmp === 3, "pop() = " + tmp);
609 for(tmp in arr)
610     ok(false, "not deleted " + tmp);
611 tmp = arr.pop();
612 ok(arr.length === 0, "arr.length = " + arr.length);
613 ok(tmp === undefined, "tmp = " + tmp);
614 arr = [,,,,,];
615 tmp = arr.pop();
616 ok(arr.length === 5, "arr.length = " + arr.length);
617 ok(tmp === undefined, "tmp = " + tmp);
618
619 arr = [1,2,null,false,undefined,,"a"];
620
621 tmp = arr.join();
622 ok(tmp === "1,2,,false,,,a", "arr.join() = " + tmp);
623 tmp = arr.join(";");
624 ok(tmp === "1;2;;false;;;a", "arr.join(';') = " + tmp);
625 tmp = arr.join(";","test");
626 ok(tmp === "1;2;;false;;;a", "arr.join(';') = " + tmp);
627 tmp = arr.join("");
628 ok(tmp === "12falsea", "arr.join('') = " + tmp);
629
630 tmp = arr.toString();
631 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
632 tmp = arr.toString("test");
633 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
634
635 arr = [5,true,2,-1,3,false,"2.5"];
636 tmp = arr.sort(function(x,y) { return y-x; });
637 ok(tmp === arr, "tmp !== arr");
638 tmp = [5,3,"2.5",2,true,false,-1];
639 for(var i=0; i < arr.length; i++)
640     ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
641
642 arr = [5,false,2,0,"abc",3,"a",-1];
643 tmp = arr.sort();
644 ok(tmp === arr, "tmp !== arr");
645 tmp = [-1,0,2,3,5,"a","abc",false];
646 for(var i=0; i < arr.length; i++)
647     ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
648
649 arr = ["a", "b", "ab"];
650 tmp = ["a", "ab", "b"];
651 ok(arr.sort() === arr, "arr.sort() !== arr");
652 for(var i=0; i < arr.length; i++)
653     ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
654
655 arr = ["1", "2", "3"];
656 arr.length = 1;
657 ok(arr.length === 1, "arr.length = " + arr.length);
658 arr.length = 3;
659 ok(arr.length === 3, "arr.length = " + arr.length);
660 ok(arr.toString() === "1,,", "arr.toString() = " + arr.toString());
661
662 arr = Array("a","b","c");
663 ok(arr.toString() === "a,b,c", "arr.toString() = " + arr.toString());
664
665 ok(arr.valueOf === Object.prototype.valueOf, "arr.valueOf !== Object.prototype.valueOf");
666 ok(arr === arr.valueOf(), "arr !== arr.valueOf");
667
668 arr = [1,2,3];
669 tmp = arr.unshift(0);
670 ok(tmp === undefined, "[1,2,3].unshift(0) returned " +tmp);
671 ok(arr.length === 4, "arr.length = " + arr.length);
672 ok(arr.toString() === "0,1,2,3", "arr.toString() = " + arr.toString());
673
674 arr = new Array(3);
675 arr[0] = 1;
676 arr[2] = 3;
677 tmp = arr.unshift(-1,0);
678 ok(tmp === undefined, "unshift returned " +tmp);
679 ok(arr.length === 5, "arr.length = " + arr.length);
680 ok(arr.toString() === "-1,0,1,,3", "arr.toString() = " + arr.toString());
681
682 arr = [1,2,3];
683 tmp = arr.unshift();
684 ok(tmp === undefined, "unshift returned " +tmp);
685 ok(arr.length === 3, "arr.length = " + arr.length);
686 ok(arr.toString() === "1,2,3", "arr.toString() = " + arr.toString());
687
688 arr = new Object();
689 arr.length = 2;
690 arr[0] = 1;
691 arr[1] = 2;
692 tmp = Array.prototype.unshift.call(arr, 0);
693 ok(tmp === undefined, "unshift returned " +tmp);
694 ok(arr.length === 3, "arr.length = " + arr.length);
695 ok(arr[0] === 0 && arr[1] === 1 && arr[2] === 2, "unexpected array");
696
697 arr = [1,2,,4];
698 tmp = arr.shift();
699 ok(tmp === 1, "[1,2,,4].shift() = " + tmp);
700 ok(arr.toString() === "2,,4", "arr = " + arr.toString());
701
702 arr = [];
703 tmp = arr.shift();
704 ok(tmp === undefined, "[].shift() = " + tmp);
705 ok(arr.toString() === "", "arr = " + arr.toString());
706
707 arr = [1,2,,4];
708 tmp = arr.shift(2);
709 ok(tmp === 1, "[1,2,,4].shift(2) = " + tmp);
710 ok(arr.toString() === "2,,4", "arr = " + arr.toString());
711
712 arr = [1,];
713 tmp = arr.shift();
714 ok(tmp === 1, "[1,].shift() = " + tmp);
715 ok(arr.toString() === "", "arr = " + arr.toString());
716
717 obj = new Object();
718 obj[0] = "test";
719 obj[2] = 3;
720 obj.length = 3;
721 tmp = Array.prototype.shift.call(obj);
722 ok(tmp === "test", "obj.shift() = " + tmp);
723 ok(obj.length == 2, "obj.length = " + obj.length);
724 ok(obj[1] === 3, "obj[1] = " + obj[1]);
725
726 var num = new Number(6);
727 arr = [0,1,2];
728 tmp = arr.concat(3, [4,5], num);
729 ok(tmp !== arr, "tmp === arr");
730 for(var i=0; i<6; i++)
731     ok(tmp[i] === i, "tmp[" + i + "] = " + tmp[i]);
732 ok(tmp[6] === num, "tmp[6] !== num");
733 ok(tmp.length === 7, "tmp.length = " + tmp.length);
734
735 arr = [].concat();
736 ok(arr.length === 0, "arr.length = " + arr.length);
737
738 arr = [1,];
739 tmp = arr.concat([2]);
740 ok(tmp.length === 3, "tmp.length = " + tmp.length);
741 ok(tmp[1] === undefined, "tmp[1] = " + tmp[1]);
742
743 arr = [1,false,'a',null,undefined,'a'];
744 ok(arr.slice(0,6).toString() === "1,false,a,,,a", "arr.slice(0,6).toString() = " + arr.slice(0,6));
745 ok(arr.slice(0,6).length === 6, "arr.slice(0,6).length = " + arr.slice(0,6).length);
746 ok(arr.slice().toString() === "1,false,a,,,a", "arr.slice().toString() = " + arr.slice());
747 ok(arr.slice("abc").toString() === "1,false,a,,,a", "arr.slice(\"abc\").toString() = " + arr.slice("abc"));
748 ok(arr.slice(3,8).toString() === ",,a", "arr.slice(3,8).toString() = " + arr.slice(3,8));
749 ok(arr.slice(3,8).length === 3, "arr.slice(3,8).length = " + arr.slice(3,8).length);
750 ok(arr.slice(1).toString() === "false,a,,,a", "arr.slice(1).toString() = " + arr.slice(1));
751 ok(arr.slice(-2).toString() === ",a", "arr.slice(-2).toString() = " + arr.slice(-2));
752 ok(arr.slice(3,1).toString() === "", "arr.slice(3,1).toString() = " + arr.slice(3,1));
753 tmp = arr.slice(0,6);
754 for(var i=0; i < arr.length; i++)
755     ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
756 arr[12] = 2;
757 ok(arr.slice(5).toString() === "a,,,,,,,2", "arr.slice(5).toString() = " + arr.slice(5).toString());
758 ok(arr.slice(5).length === 8, "arr.slice(5).length = " + arr.slice(5).length);
759
760 arr = [1,2,3,4,5];
761 tmp = arr.splice(2,2);
762 ok(tmp.toString() == "3,4", "arr.splice(2,2) returned " + tmp.toString());
763 ok(arr.toString() == "1,2,5", "arr.splice(2,2) is " + arr.toString());
764
765 arr = [1,2,3,4,5];
766 tmp = arr.splice(2,2,"a");
767 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a') returned " + tmp.toString());
768 ok(arr.toString() == "1,2,a,5", "arr.splice(2,2,'a') is " + arr.toString());
769
770 arr = [1,2,3,4,5];
771 tmp = arr.splice(2,2,'a','b','c');
772 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a','b','c') returned " + tmp.toString());
773 ok(arr.toString() == "1,2,a,b,c,5", "arr.splice(2,2,'a','b','c') is " + arr.toString());
774
775 arr = [1,2,3,4,];
776 tmp = arr.splice(2,2,'a','b','c');
777 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a','b','c') returned " + tmp.toString());
778 ok(arr.toString() == "1,2,a,b,c,", "arr.splice(2,2,'a','b','c') is " + arr.toString());
779
780 arr = [1,2,3,4,];
781 arr.splice(2,2,'a','b','c');
782 ok(arr.toString() == "1,2,a,b,c,", "arr.splice(2,2,'a','b','c') is " + arr.toString());
783
784 arr = [1,2,3,4,5];
785 tmp = arr.splice(2,2,'a','b');
786 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a','b') returned " + tmp.toString());
787 ok(arr.toString() == "1,2,a,b,5", "arr.splice(2,2,'a','b') is " + arr.toString());
788
789 arr = [1,2,3,4,5];
790 tmp = arr.splice(-1,2);
791 ok(tmp.toString() == "5", "arr.splice(-1,2) returned " + tmp.toString());
792 ok(arr.toString() == "1,2,3,4", "arr.splice(-1,2) is " + arr.toString());
793
794 arr = [1,2,3,4,5];
795 tmp = arr.splice(-10,3);
796 ok(tmp.toString() == "1,2,3", "arr.splice(-10,3) returned " + tmp.toString());
797 ok(arr.toString() == "4,5", "arr.splice(-10,3) is " + arr.toString());
798
799 arr = [1,2,3,4,5];
800 tmp = arr.splice(-10,100);
801 ok(tmp.toString() == "1,2,3,4,5", "arr.splice(-10,100) returned " + tmp.toString());
802 ok(arr.toString() == "", "arr.splice(-10,100) is " + arr.toString());
803
804 arr = [1,2,3,4,5];
805 tmp = arr.splice(2,-1);
806 ok(tmp.toString() == "", "arr.splice(2,-1) returned " + tmp.toString());
807 ok(arr.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr.toString());
808
809 arr = [1,2,3,4,5];
810 tmp = arr.splice(2);
811 ok(tmp.toString() == "", "arr.splice(2,-1) returned " + tmp.toString());
812 ok(arr.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr.toString());
813
814 arr = [1,2,3,4,5];
815 tmp = arr.splice();
816 ok(tmp.toString() == "", "arr.splice(2,-1) returned " + tmp.toString());
817 ok(arr.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr.toString());
818
819 obj = new Object();
820 obj.length = 3;
821 obj[0] = 1;
822 obj[1] = 2;
823 obj[2] = 3;
824 tmp = Array.prototype.splice.call(obj, 1, 1, 'a', 'b');
825 ok(tmp.toString() === "2", "obj.splice returned " + tmp);
826 ok(obj.length === 4, "obj.length = " + obj.length);
827 ok(obj[0] === 1, "obj[0] = " + obj[0]);
828 ok(obj[1] === 'a', "obj[1] = " + obj[1]);
829 ok(obj[2] === 'b', "obj[2] = " + obj[2]);
830 ok(obj[3] === 3, "obj[3] = " + obj[3]);
831
832 obj = new Object();
833 obj.length = 3;
834 obj[0] = 1;
835 obj[1] = 2;
836 obj[2] = 3;
837 tmp = Array.prototype.slice.call(obj, 1, 2);
838 ok(tmp.length === 1, "tmp.length = " + tmp.length);
839 ok(tmp[0] === 2, "tmp[0] = " + tmp[0]);
840
841 var num = new Number(2);
842 ok(num.toString() === "2", "num(2).toString !== 2");
843 var num = new Number();
844 ok(num.toString() === "0", "num().toString !== 0");
845
846 ok(Number() === 0, "Number() = " + Number());
847 ok(Number(false) === 0, "Number(false) = " + Number(false));
848 ok(Number("43") === 43, "Number('43') = " + Number("43"));
849
850 tmp = (new Number(1)).valueOf();
851 ok(tmp === 1, "(new Number(1)).valueOf = " + tmp);
852 tmp = (new Number(1,2)).valueOf();
853 ok(tmp === 1, "(new Number(1,2)).valueOf = " + tmp);
854 tmp = (new Number()).valueOf();
855 ok(tmp === 0, "(new Number()).valueOf = " + tmp);
856 tmp = Number.prototype.valueOf();
857 ok(tmp === 0, "Number.prototype.valueOf = " + tmp);
858
859 function equals(val, base) {
860     var i;
861     var num = 0;
862     var str = val.toString(base);
863
864     for(i=0; i<str.length; i++) {
865         if(str.substring(i, i+1) == '(') break;
866         if(str.substring(i, i+1) == '.') break;
867         num = num*base + parseInt(str.substring(i, i+1));
868     }
869
870     if(str.substring(i, i+1) == '.') {
871         var mult = base;
872         for(i++; i<str.length; i++) {
873             if(str.substring(i, i+1) == '(') break;
874             num += parseInt(str.substring(i, i+1))/mult;
875             mult *= base;
876         }
877     }
878
879     if(str.substring(i, i+1) == '(') {
880         exp = parseInt(str.substring(i+2));
881         num *= Math.pow(base, exp);
882     }
883
884     ok(num>val-val/1000 && num<val+val/1000, "equals: num = " + num);
885 }
886
887 ok((10).toString(11) === "a", "(10).toString(11) = " + (10).toString(11));
888 ok((213213433).toString(17) === "8e2ddcb", "(213213433).toString(17) = " + (213213433).toString(17));
889 ok((-3254343).toString(33) === "-2oicf", "(-3254343).toString(33) = " + (-3254343).toString(33));
890 ok((NaN).toString(12) === "NaN", "(NaN).toString(11) = " + (NaN).toString(11));
891 ok((Infinity).toString(13) === "Infinity", "(Infinity).toString(11) = " + (Infinity).toString(11));
892 for(i=2; i<10; i++) {
893     equals(1.123, i);
894     equals(2305843009200000000, i);
895     equals(5.123, i);
896     equals(21711, i);
897     equals(1024*1024*1024*1024*1024*1024*1.9999, i);
898     equals(748382, i);
899     equals(0.6, i);
900     equals(4.65661287308e-10, i);
901     ok((0).toString(i) === "0", "(0).toString("+i+") = " + (0).toString(i));
902 }
903
904 ok(parseFloat('123') === 123, "parseFloat('123') = " + parseFloat('123'));
905 ok(parseFloat('-13.7') === -13.7, "parseFloat('-13.7') = " + parseFloat('-13.7'));
906 ok(parseFloat('-0.01e-2') === -0.01e-2, "parseFloat('-0.01e-2') = " + parseFloat('-0.01e-2'));
907 ok(parseFloat('-12e+5') === -12e+5, "parseFloat('-12e+5') = " + parseFloat('-12e+5'));
908 ok(parseFloat('1E5 not parsed') === 1E5, "parseFloat('1E5 not parsed') = " + parseFloat('1E5 not parsed'));
909 ok(isNaN(parseFloat('not a number')), "parseFloat('not a number') is not NaN");
910 ok(parseFloat('+13.2e-3') === 13.2e-3, "parseFloat('+13.2e-3') = " + parseFloat('+13.2e-3'));
911 ok(parseFloat('.12') === 0.12, "parseFloat('.12') = " + parseFloat('.12'));
912 ok(parseFloat('1e') === 1, "parseFloat('1e') = " + parseFloat('1e'));
913
914 tmp = Math.min(1);
915 ok(tmp === 1, "Math.min(1) = " + tmp);
916
917 tmp = Math.min(1, false);
918 ok(tmp === 0, "Math.min(1, false) = " + tmp);
919
920 tmp = Math.min();
921 ok(tmp === Infinity, "Math.min() = " + tmp);
922
923 tmp = Math.min(1, NaN, -Infinity, false);
924 ok(isNaN(tmp), "Math.min(1, NaN, -Infinity, false) is not NaN");
925
926 tmp = Math.min(1, false, true, null, -3);
927 ok(tmp === -3, "Math.min(1, false, true, null, -3) = " + tmp);
928
929 tmp = Math.max(1);
930 ok(tmp === 1, "Math.max(1) = " + tmp);
931
932 tmp = Math.max(true, 0);
933 ok(tmp === 1, "Math.max(true, 0) = " + tmp);
934
935 tmp = Math.max(-2, false, true, null, 1);
936 ok(tmp === 1, "Math.max(-2, false, true, null, 1) = " + tmp);
937
938 tmp = Math.max();
939 ok(tmp === -Infinity, "Math.max() = " + tmp);
940
941 tmp = Math.max(true, NaN, 0);
942 ok(isNaN(tmp), "Math.max(true, NaN, 0) is not NaN");
943
944 tmp = Math.round(0.5);
945 ok(tmp === 1, "Math.round(0.5) = " + tmp);
946
947 tmp = Math.round(-0.5);
948 ok(tmp === 0, "Math.round(-0.5) = " + tmp);
949
950 tmp = Math.round(1.1);
951 ok(tmp === 1, "Math.round(1.1) = " + tmp);
952
953 tmp = Math.round(true);
954 ok(tmp === 1, "Math.round(true) = " + tmp);
955
956 tmp = Math.round(1.1, 3, 4);
957 ok(tmp === 1, "Math.round(1.1, 3, 4) = " + tmp);
958
959 tmp = Math.round();
960 ok(isNaN(tmp), "Math.round() is not NaN");
961
962 tmp = Math.ceil(0.5);
963 ok(tmp === 1, "Math.ceil(0.5) = " + tmp);
964
965 tmp = Math.ceil(-0.5);
966 ok(tmp === 0, "Math.ceil(-0.5) = " + tmp);
967
968 tmp = Math.ceil(1.1);
969 ok(tmp === 2, "Math.round(1.1) = " + tmp);
970
971 tmp = Math.ceil(true);
972 ok(tmp === 1, "Math.ceil(true) = " + tmp);
973
974 tmp = Math.ceil(1.1, 3, 4);
975 ok(tmp === 2, "Math.ceil(1.1, 3, 4) = " + tmp);
976
977 tmp = Math.ceil();
978 ok(isNaN(tmp), "ceil() is not NaN");
979
980 tmp = Math.floor(0.5);
981 ok(tmp === 0, "Math.floor(0.5) = " + tmp);
982
983 tmp = Math.floor(-0.5);
984 ok(tmp === -1, "Math.floor(-0.5) = " + tmp);
985
986 tmp = Math.floor(1.1);
987 ok(tmp === 1, "Math.floor(1.1) = " + tmp);
988
989 tmp = Math.floor(true);
990 ok(tmp === 1, "Math.floor(true) = " + tmp);
991
992 tmp = Math.floor(1.1, 3, 4);
993 ok(tmp === 1, "Math.floor(1.1, 3, 4) = " + tmp);
994
995 tmp = Math.floor();
996 ok(isNaN(tmp), "floor is not NaN");
997
998 tmp = Math.abs(3);
999 ok(tmp === 3, "Math.abs(3) = " + tmp);
1000
1001 tmp = Math.abs(-3);
1002 ok(tmp === 3, "Math.abs(-3) = " + tmp);
1003
1004 tmp = Math.abs(true);
1005 ok(tmp === 1, "Math.abs(true) = " + tmp);
1006
1007 tmp = Math.abs();
1008 ok(isNaN(tmp), "Math.abs() is not NaN");
1009
1010 tmp = Math.abs(NaN);
1011 ok(isNaN(tmp), "Math.abs() is not NaN");
1012
1013 tmp = Math.abs(-Infinity);
1014 ok(tmp === Infinity, "Math.abs(-Infinite) = " + tmp);
1015
1016 tmp = Math.abs(-3, 2);
1017 ok(tmp === 3, "Math.abs(-3, 2) = " + tmp);
1018
1019 tmp = Math.cos(0);
1020 ok(tmp === 1, "Math.cos(0) = " + tmp);
1021
1022 tmp = Math.cos(Math.PI/2);
1023 ok(Math.floor(tmp*100) === 0, "Math.cos(Math.PI/2) = " + tmp);
1024
1025 tmp = Math.cos(-Math.PI/2);
1026 ok(Math.floor(tmp*100) === 0, "Math.cos(-Math.PI/2) = " + tmp);
1027
1028 tmp = Math.cos(Math.PI/3, 2);
1029 ok(Math.floor(tmp*100) === 50, "Math.cos(Math.PI/3, 2) = " + tmp);
1030
1031 tmp = Math.cos(true);
1032 ok(Math.floor(tmp*100) === 54, "Math.cos(true) = " + tmp);
1033
1034 tmp = Math.cos(false);
1035 ok(tmp === 1, "Math.cos(false) = " + tmp);
1036
1037 tmp = Math.cos();
1038 ok(isNaN(tmp), "Math.cos() is not NaN");
1039
1040 tmp = Math.cos(NaN);
1041 ok(isNaN(tmp), "Math.cos(NaN) is not NaN");
1042
1043 tmp = Math.cos(Infinity);
1044 ok(isNaN(tmp), "Math.cos(Infinity) is not NaN");
1045
1046 tmp = Math.cos(-Infinity);
1047 ok(isNaN(tmp), "Math.cos(-Infinity) is not NaN");
1048
1049 tmp = Math.pow(2, 2);
1050 ok(tmp === 4, "Math.pow(2, 2) = " + tmp);
1051
1052 tmp = Math.pow(4, 0.5);
1053 ok(tmp === 2, "Math.pow(2, 2) = " + tmp);
1054
1055 tmp = Math.pow(2, 2, 3);
1056 ok(tmp === 4, "Math.pow(2, 2, 3) = " + tmp);
1057
1058 tmp = Math.pow(2);
1059 ok(isNaN(tmp), "Math.pow(2) is not NaN");
1060
1061 tmp = Math.pow();
1062 ok(isNaN(tmp), "Math.pow() is not NaN");
1063
1064 tmp = Math.random();
1065 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
1066 ok(0 <= tmp && tmp <= 1, "Math.random() = " + tmp);
1067
1068 tmp = Math.random(100);
1069 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
1070 ok(0 <= tmp && tmp <= 1, "Math.random(100) = " + tmp);
1071
1072 tmp = Math.acos(0);
1073 ok(Math.floor(tmp*100) === 157, "Math.acos(0) = " + tmp);
1074
1075 tmp = Math.acos(1);
1076 ok(Math.floor(tmp*100) === 0, "Math.acos(1) = " + tmp);
1077
1078 tmp = Math.acos(-1);
1079 ok(Math.floor(tmp*100) === 314, "Math.acos(-1) = " + tmp);
1080
1081 tmp = Math.acos(Math.PI/4, 2);
1082 ok(Math.floor(tmp*100) === 66, "Math.acos(Math.PI/4, 2) = " + tmp);
1083
1084 tmp = Math.acos(true);
1085 ok(Math.floor(tmp*100) === 0, "Math.acos(true) = " + tmp);
1086
1087 tmp = Math.acos(false);
1088 ok(Math.floor(tmp*100) === 157, "Math.acos(false) = " + tmp);
1089
1090 tmp = Math.acos(1.1);
1091 ok(isNaN(tmp), "Math.acos(1.1) is not NaN");
1092
1093 tmp = Math.acos();
1094 ok(isNaN(tmp), "Math.acos() is not NaN");
1095
1096 tmp = Math.acos(NaN);
1097 ok(isNaN(tmp), "Math.acos(NaN) is not NaN");
1098
1099 tmp = Math.acos(Infinity);
1100 ok(isNaN(tmp), "Math.acos(Infinity) is not NaN");
1101
1102 tmp = Math.acos(-Infinity);
1103 ok(isNaN(tmp), "Math.acos(-Infinity) is not NaN");
1104
1105 tmp = Math.asin(0);
1106 ok(Math.floor(tmp*100) === 0, "Math.asin(0) = " + tmp);
1107
1108 tmp = Math.asin(1);
1109 ok(Math.floor(tmp*100) === 157, "Math.asin(1) = " + tmp);
1110
1111 tmp = Math.asin(-1);
1112 ok(Math.floor(tmp*100) === -158, "Math.asin(-1) = " + tmp);
1113
1114 tmp = Math.asin(Math.PI/4, 2);
1115 ok(Math.floor(tmp*100) === 90, "Math.asin(Math.PI/4, 2) = " + tmp);
1116
1117 tmp = Math.asin(true);
1118 ok(Math.floor(tmp*100) === 157, "Math.asin(true) = " + tmp);
1119
1120 tmp = Math.asin(false);
1121 ok(Math.floor(tmp*100) === 0, "Math.asin(false) = " + tmp);
1122
1123 tmp = Math.asin(1.1);
1124 ok(isNaN(tmp), "Math.asin(1.1) is not NaN");
1125
1126 tmp = Math.asin();
1127 ok(isNaN(tmp), "Math.asin() is not NaN");
1128
1129 tmp = Math.asin(NaN);
1130 ok(isNaN(tmp), "Math.asin(NaN) is not NaN");
1131
1132 tmp = Math.asin(Infinity);
1133 ok(isNaN(tmp), "Math.asin(Infinity) is not NaN");
1134
1135 tmp = Math.asin(-Infinity);
1136 ok(isNaN(tmp), "Math.asin(-Infinity) is not NaN");
1137
1138 tmp = Math.atan(0);
1139 ok(Math.floor(tmp*100) === 0, "Math.atan(0) = " + tmp);
1140
1141 tmp = Math.atan(1);
1142 ok(Math.floor(tmp*100) === 78, "Math.atan(1) = " + tmp);
1143
1144 tmp = Math.atan(-1);
1145 ok(Math.floor(tmp*100) === -79, "Math.atan(-1) = " + tmp);
1146
1147 tmp = Math.atan(true);
1148 ok(Math.floor(tmp*100) === 78, "Math.atan(true) = " + tmp);
1149
1150 tmp = Math.atan(false);
1151 ok(Math.floor(tmp*100) === 0, "Math.atan(false) = " + tmp);
1152
1153 tmp = Math.atan();
1154 ok(isNaN(tmp), "Math.atan() is not NaN");
1155
1156 tmp = Math.atan(NaN);
1157 ok(isNaN(tmp), "Math.atan(NaN) is not NaN");
1158
1159 tmp = Math.atan(Infinity);
1160 ok(Math.floor(tmp*100) === 157, "Math.atan(Infinity) = " + tmp);
1161
1162 tmp = Math.atan(-Infinity);
1163 ok(Math.floor(tmp*100) === -158, "Math.atan(Infinity) = " + tmp);
1164
1165 tmp = Math.atan2(0, 0);
1166 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 0) = " + tmp);
1167
1168 tmp = Math.atan2(0, 1);
1169 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 1) = " + tmp);
1170
1171 tmp = Math.atan2(0, Infinity);
1172 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, Infinity) = " + tmp);
1173
1174 tmp = Math.atan2(0, -1);
1175 ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -1) = " + tmp);
1176
1177 tmp = Math.atan2(0, -Infinity);
1178 ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -Infinity) = " + tmp);
1179
1180 tmp = Math.atan2(1, 0);
1181 ok(Math.floor(tmp*100) === 157, "Math.atan2(1, 0) = " + tmp);
1182
1183 tmp = Math.atan2(Infinity, 0);
1184 ok(Math.floor(tmp*100) === 157, "Math.atan2(Infinity, 0) = " + tmp);
1185
1186 tmp = Math.atan2(-1, 0);
1187 ok(Math.floor(tmp*100) === -158, "Math.atan2(-1, 0) = " + tmp);
1188
1189 tmp = Math.atan2(-Infinity, 0);
1190 ok(Math.floor(tmp*100) === -158, "Math.atan2(-Infinity, 0) = " + tmp);
1191
1192 tmp = Math.atan2(1, 1);
1193 ok(Math.floor(tmp*100) === 78, "Math.atan2(1, 1) = " + tmp);
1194
1195 tmp = Math.atan2(-1, -1);
1196 ok(Math.floor(tmp*100) === -236, "Math.atan2(-1, -1) = " + tmp);
1197
1198 tmp = Math.atan2(-1, 1);
1199 ok(Math.floor(tmp*100) === -79, "Math.atan2(-1, 1) = " + tmp);
1200
1201 tmp = Math.atan2(Infinity, Infinity);
1202 ok(Math.floor(tmp*100) === 78, "Math.atan2(Infinity, Infinity) = " + tmp);
1203
1204 tmp = Math.atan2(Infinity, -Infinity, 1);
1205 ok(Math.floor(tmp*100) === 235, "Math.atan2(Infinity, -Infinity, 1) = " + tmp);
1206
1207 tmp = Math.atan2();
1208 ok(isNaN(tmp), "Math.atan2() is not NaN");
1209
1210 tmp = Math.atan2(1);
1211 ok(isNaN(tmp), "Math.atan2(1) is not NaN");
1212
1213 tmp = Math.exp(0);
1214 ok(tmp === 1, "Math.exp(0) = " + tmp);
1215
1216 tmp = Math.exp(1);
1217 ok(Math.floor(tmp*100) === 271, "Math.exp(1) = " + tmp);
1218
1219 tmp = Math.exp(-1);
1220 ok(Math.floor(tmp*100) === 36, "Math.exp(-1) = " + tmp);
1221
1222 tmp = Math.exp(true);
1223 ok(Math.floor(tmp*100) === 271, "Math.exp(true) = " + tmp);
1224
1225 tmp = Math.exp(1, 1);
1226 ok(Math.floor(tmp*100) === 271, "Math.exp(1, 1) = " + tmp);
1227
1228 tmp = Math.exp();
1229 ok(isNaN(tmp), "Math.exp() is not NaN");
1230
1231 tmp = Math.exp(NaN);
1232 ok(isNaN(tmp), "Math.exp(NaN) is not NaN");
1233
1234 tmp = Math.exp(Infinity);
1235 ok(tmp === Infinity, "Math.exp(Infinity) = " + tmp);
1236
1237 tmp = Math.exp(-Infinity);
1238 ok(tmp === 0, "Math.exp(-Infinity) = " + tmp);
1239
1240 tmp = Math.log(1);
1241 ok(Math.floor(tmp*100) === 0, "Math.log(1) = " + tmp);
1242
1243 tmp = Math.log(-1);
1244 ok(isNaN(tmp), "Math.log(-1) is not NaN");
1245
1246 tmp = Math.log(true);
1247 ok(Math.floor(tmp*100) === 0, "Math.log(true) = " + tmp);
1248
1249 tmp = Math.log(1, 1);
1250 ok(Math.floor(tmp*100) === 0, "Math.log(1, 1) = " + tmp);
1251
1252 tmp = Math.log();
1253 ok(isNaN(tmp), "Math.log() is not NaN");
1254
1255 tmp = Math.log(NaN);
1256 ok(isNaN(tmp), "Math.log(NaN) is not NaN");
1257
1258 tmp = Math.log(Infinity);
1259 ok(tmp === Infinity, "Math.log(Infinity) = " + tmp);
1260
1261 tmp = Math.log(-Infinity);
1262 ok(isNaN(tmp), "Math.log(-Infinity) is not NaN");
1263
1264 tmp = Math.sin(0);
1265 ok(tmp === 0, "Math.sin(0) = " + tmp);
1266
1267 tmp = Math.sin(Math.PI/2);
1268 ok(tmp === 1, "Math.sin(Math.PI/2) = " + tmp);
1269
1270 tmp = Math.sin(-Math.PI/2);
1271 ok(tmp === -1, "Math.sin(-Math.PI/2) = " + tmp);
1272
1273 tmp = Math.sin(Math.PI/3, 2);
1274 ok(Math.floor(tmp*100) === 86, "Math.sin(Math.PI/3, 2) = " + tmp);
1275
1276 tmp = Math.sin(true);
1277 ok(Math.floor(tmp*100) === 84, "Math.sin(true) = " + tmp);
1278
1279 tmp = Math.sin(false);
1280 ok(tmp === 0, "Math.sin(false) = " + tmp);
1281
1282 tmp = Math.sin();
1283 ok(isNaN(tmp), "Math.sin() is not NaN");
1284
1285 tmp = Math.sin(NaN);
1286 ok(isNaN(tmp), "Math.sin(NaN) is not NaN");
1287
1288 tmp = Math.sin(Infinity);
1289 ok(isNaN(tmp), "Math.sin(Infinity) is not NaN");
1290
1291 tmp = Math.sin(-Infinity);
1292 ok(isNaN(tmp), "Math.sin(-Infinity) is not NaN");
1293
1294 tmp = Math.sqrt(0);
1295 ok(tmp === 0, "Math.sqrt(0) = " + tmp);
1296
1297 tmp = Math.sqrt(4);
1298 ok(tmp === 2, "Math.sqrt(4) = " + tmp);
1299
1300 tmp = Math.sqrt(-1);
1301 ok(isNaN(tmp), "Math.sqrt(-1) is not NaN");
1302
1303 tmp = Math.sqrt(2, 2);
1304 ok(Math.floor(tmp*100) === 141, "Math.sqrt(2, 2) = " + tmp);
1305
1306 tmp = Math.sqrt(true);
1307 ok(tmp === 1, "Math.sqrt(true) = " + tmp);
1308
1309 tmp = Math.sqrt(false);
1310 ok(tmp === 0, "Math.sqrt(false) = " + tmp);
1311
1312 tmp = Math.sqrt();
1313 ok(isNaN(tmp), "Math.sqrt() is not NaN");
1314
1315 tmp = Math.sqrt(NaN);
1316 ok(isNaN(tmp), "Math.sqrt(NaN) is not NaN");
1317
1318 tmp = Math.sqrt(Infinity);
1319 ok(tmp === Infinity, "Math.sqrt(Infinity) = " + tmp);
1320
1321 tmp = Math.sqrt(-Infinity);
1322 ok(isNaN(tmp), "Math.sqrt(-Infinity) is not NaN");
1323
1324 tmp = Math.tan(0);
1325 ok(tmp === 0, "Math.tan(0) = " + tmp);
1326
1327 tmp = Math.tan(Math.PI);
1328 ok(Math.floor(tmp*100) === -1, "Math.tan(Math.PI) = " + tmp);
1329
1330 tmp = Math.tan(2, 2);
1331 ok(Math.floor(tmp*100) === -219, "Math.tan(2, 2) = " + tmp);
1332
1333 tmp = Math.tan(true);
1334 ok(Math.floor(tmp*100) === 155, "Math.tan(true) = " + tmp);
1335
1336 tmp = Math.tan(false);
1337 ok(tmp === 0, "Math.tan(false) = " + tmp);
1338
1339 tmp = Math.tan();
1340 ok(isNaN(tmp), "Math.tan() is not NaN");
1341
1342 tmp = Math.tan(NaN);
1343 ok(isNaN(tmp), "Math.tan(NaN) is not NaN");
1344
1345 tmp = Math.tan(Infinity);
1346 ok(isNaN(tmp), "Math.tan(Infinity) is not NaN");
1347
1348 tmp = Math.tan(-Infinity);
1349 ok(isNaN(tmp), "Math.tan(-Infinity) is not NaN");
1350
1351 var func = function  (a) {
1352         var a = 1;
1353         if(a) return;
1354     };
1355 ok(func.toString() === "function  (a) {\n        var a = 1;\n        if(a) return;\n    }",
1356    "func.toString() = " + func.toString());
1357 ok("" + func === "function  (a) {\n        var a = 1;\n        if(a) return;\n    }",
1358    "'' + func.toString() = " + func);
1359
1360 ok(func.valueOf === Object.prototype.valueOf, "func.valueOf !== Object.prototype.valueOf");
1361 ok(func === func.valueOf(), "func !== func.valueOf()");
1362
1363 function testFuncToString(x,y) {
1364     return x+y;
1365 }
1366 ok(testFuncToString.toString() === "function testFuncToString(x,y) {\n    return x+y;\n}",
1367    "testFuncToString.toString() = " + testFuncToString.toString());
1368 ok("" + testFuncToString === "function testFuncToString(x,y) {\n    return x+y;\n}",
1369    "'' + testFuncToString = " + testFuncToString);
1370
1371 tmp = new Object();
1372
1373 function callTest(argc) {
1374     ok(this === tmp, "this !== tmp\n");
1375     ok(arguments.length === argc+1, "arguments.length = " + arguments.length + " expected " + (argc+1));
1376     for(var i=1; i <= argc; i++)
1377         ok(arguments[i] === i, "arguments[i] = " + arguments[i]);
1378 }
1379
1380 callTest.call(tmp, 1, 1);
1381 callTest.call(tmp, 2, 1, 2);
1382
1383 callTest.apply(tmp, [1, 1]);
1384 callTest.apply(tmp, [2, 1, 2]);
1385 (function () { callTest.apply(tmp, arguments); })(2,1,2);
1386
1387 function callTest2() {
1388     ok(this === tmp, "this !== tmp\n");
1389     ok(arguments.length === 0, "callTest2: arguments.length = " + arguments.length + " expected 0");
1390 }
1391
1392 callTest2.call(tmp);
1393 callTest2.apply(tmp, []);
1394 callTest2.apply(tmp);
1395 (function () { callTest2.apply(tmp, arguments); })();
1396
1397 function callTest3() {
1398     ok(arguments.length === 0, "arguments.length = " + arguments.length + " expected 0");
1399 }
1400
1401 callTest3.call();
1402
1403 tmp = Number.prototype.toString.call(3);
1404 ok(tmp === "3", "Number.prototype.toString.call(3) = " + tmp);
1405
1406 var date = new Date();
1407
1408 date = new Date(100);
1409 ok(date.getTime() === 100, "date.getTime() = " + date.getTime());
1410 ok(Date.prototype.getTime() === 0, "date.prototype.getTime() = " + Date.prototype.getTime());
1411 date = new Date(8.64e15);
1412 ok(date.getTime() === 8.64e15, "date.getTime() = " + date.getTime());
1413 date = new Date(8.64e15+1);
1414 ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
1415 date = new Date(Infinity);
1416 ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
1417 date = new Date("3 July 2009 22:28:00 UTC+0100");
1418 ok(date.getTime() === 1246656480000, "date.getTime() = " + date.getTime());
1419 date = new Date(1984, 11, 29, 13, 51, 24, 120);
1420 ok(date.getFullYear() === 1984, "date.getFullYear() = " + date.getFullYear());
1421 ok(date.getMonth() === 11, "date.getMonth() = " + date.getMonth());
1422 ok(date.getDate() === 29, "date.getDate() = " + date.getDate());
1423 ok(date.getHours() === 13, "date.getHours() = " + date.getHours());
1424 ok(date.getMinutes() === 51, "date.getMinutes() = " + date.getMinutes());
1425 ok(date.getSeconds() === 24, "date.getSeconds() = " + date.getSeconds());
1426 ok(date.getMilliseconds() === 120, "date.getMilliseconds() = " + date.getMilliseconds());
1427 date = new Date(731, -32, 40, -1, 70, 65, -13);
1428 ok(date.getFullYear() === 728, "date.getFullYear() = " + date.getFullYear());
1429 ok(date.getMonth() === 5, "date.getMonth() = " + date.getMonth());
1430 ok(date.getDate() === 9, "date.getDate() = " + date.getDate());
1431 ok(date.getHours() === 0, "date.getHours() = " + date.getHours());
1432 ok(date.getMinutes() === 11, "date.getMinutes() = " + date.getMinutes());
1433 ok(date.getSeconds() === 4, "date.getSeconds() = " + date.getSeconds());
1434 ok(date.getMilliseconds() === 987, "date.getMilliseconds() = " + date.getMilliseconds());
1435
1436 ok(date.setTime(123) === 123, "date.setTime(123) !== 123");
1437 ok(date.setTime("123", NaN) === 123, "date.setTime(\"123\") !== 123");
1438 ok(isNaN(date.setTime(NaN)), "date.setTime(NaN) is not NaN");
1439
1440 ok(date.setTime(0) === date.getTime(), "date.setTime(0) !== date.getTime()");
1441 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
1442 ok(date.getUTCMonth() === 0, "date.getUTCMonth() = " + date.getUTCMonth());
1443 ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
1444 ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
1445 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
1446 ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
1447 ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
1448 ok(date.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1449 date.setTime(60*24*60*60*1000);
1450 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
1451 ok(date.getUTCMonth() === 2, "date.getUTCMonth() = " + date.getUTCMonth());
1452 ok(date.getUTCDate() === 2, "date.getUTCDate() = " + date.getUTCDate());
1453 ok(date.getUTCDay() === 1, "date.getUTCDay() = " + date.getUTCDay());
1454 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
1455 ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
1456 ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
1457 ok(date.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1458 date.setTime(59*24*60*60*1000 + 4*365*24*60*60*1000 + 60*60*1000 + 2*60*1000 + 2*1000 + 640);
1459 ok(date.getUTCFullYear() === 1974, "date.getUTCFullYear() = " + date.getUTCFullYear());
1460 ok(date.getUTCMonth() === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1461 ok(date.getUTCMonth(123) === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1462 ok(date.getUTCDate() === 28, "date.getUTCDate() = " + date.getUTCDate());
1463 ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
1464 ok(date.getUTCHours() === 1, "date.getUTCHours() = " + date.getUTCHours());
1465 ok(date.getUTCMinutes() === 2, "date.getUTCMinutes() = " + date.getUTCMinutes());
1466 ok(date.getUTCSeconds() === 2, "date.getUTCSeconds() = " + date.getUTCSeconds());
1467 ok(date.getUTCMilliseconds() === 640, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1468 date.setTime(Infinity);
1469 ok(isNaN(date.getUTCFullYear()), "date.getUTCFullYear() is not NaN");
1470 ok(isNaN(date.getUTCMonth()), "date.getUTCMonth() is not NaN");
1471 ok(isNaN(date.getUTCDate()), "date.getUTCDate() is not NaN");
1472 ok(isNaN(date.getUTCDay()), "date.getUTCDay() is not NaN");
1473 ok(isNaN(date.getUTCHours()), "date.getUTCHours() is not NaN");
1474 ok(isNaN(date.getUTCMinutes()), "date.getUTCMinutes() is not NaN");
1475 ok(isNaN(date.getUTCSeconds()), "date.getUTCSeconds() is not NaN");
1476 ok(isNaN(date.getUTCMilliseconds()), "date.getUTCMilliseconds() is not NaN");
1477 ok(isNaN(date.setMilliseconds(0)), "date.setMilliseconds() is not NaN");
1478
1479 date.setTime(0);
1480 date.setUTCMilliseconds(-10, 2);
1481 ok(date.getUTCMilliseconds() === 990, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1482 date.setUTCMilliseconds(10);
1483 ok(date.getUTCMilliseconds() === 10, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1484 date.setUTCSeconds(-10);
1485 ok(date.getUTCSeconds() === 50, "date.getUTCSeconds() = " + date.getUTCSeconds());
1486 date.setUTCMinutes(-10);
1487 ok(date.getUTCMinutes() === 50, "date.getUTCMinutes() = " + date.getUTCMinutes());
1488 date.setUTCHours(-10);
1489 ok(date.getUTCHours() === 14, "date.getUTCHours() = " + date.getUTCHours());
1490 date.setUTCHours(-123);
1491 ok(date.getTime() === -612549990, "date.getTime() = " + date.getTime());
1492 date.setUTCHours(20);
1493 ok(date.getUTCHours() === 20, "date.getUTCHours() = " + date.getUTCHours());
1494 date.setUTCDate(32);
1495 ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
1496 date.setUTCMonth(22, 37);
1497 ok(date.getTime() === 60987050010, "date.getTime() = " + date.getTime());
1498 date.setUTCFullYear(83, 21, 321);
1499 ok(date.getTime() === -59464984149990, "date.getTime() = " + date.getTime());
1500 ok(Math.abs(date) === 59464984149990, "Math.abs(date) = " + Math.abs(date));
1501 ok(getVT(date+1) === "VT_BSTR", "getVT(date+1) = " + getVT(date+1));
1502
1503 ok(isNaN(Date.parse()), "Date.parse() is not NaN");
1504 ok(isNaN(Date.parse("")), "Date.parse(\"\") is not NaN");
1505 ok(isNaN(Date.parse("Jan Jan 20 2009")), "Date.parse(\"Jan Jan 20 2009\") is not NaN");
1506 ok(Date.parse("Jan 20 2009 UTC") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC\") = " + Date.parse("Jan 20 2009 UTC"));
1507 ok(Date.parse("Jan 20 2009 GMT") === 1232409600000, "Date.parse(\"Jan 20 2009 GMT\") = " + Date.parse("Jan 20 2009 GMT"));
1508 ok(Date.parse("Jan 20 2009 UTC-0") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC-0\") = " + Date.parse("Jan 20 2009 UTC-0"));
1509 ok(Date.parse("Jan 20 2009 UTC+0000") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC+0000\") = " + Date.parse("Jan 20 2009 UTC+0000"));
1510 ok(Date.parse("Ju 13 79 UTC") === 300672000000, "Date.parse(\"Ju 13 79 UTC\") = " + Date.parse("Ju 13 79 UTC"));
1511 ok(Date.parse("12Au91 UTC") === 681955200000, "Date.parse(\"12Au91 UTC\") = " + Date.parse("12Au91 UTC"));
1512 ok(Date.parse("7/02/17 UTC") === -1656806400000, "Date.parse(\"7/02/17 UTC\") = " + Date.parse("7/02/17 UTC"));
1513 ok(Date.parse("Se001   70 12:31:17 UTC") === 21040277000, "Date.parse(\"Se001   70 12:31:17 UTC\") = " + Date.parse("Se001   70 12:31:17 UTC"));
1514 ok(Date.parse("February 31   UTC, 2000 12:31:17 PM") === 952000277000,
1515         "Date.parse(\"February 31   UTC, 2000 12:31:17 PM\") = " + Date.parse("February 31   UTC, 2000 12:31:17 PM"));
1516 ok(Date.parse("71 11:32AM Dec 12 UTC BC ") === -64346358480000, "Date.parse(\"71 11:32AM Dec 12 UTC BC \") = " + Date.parse("71 11:32AM Dec 12 UTC BC "));
1517 ok(Date.parse("23/71/2000 11::32::UTC") === 1010662320000, "Date.parse(\"23/71/2000 11::32::UTC\") = " + Date.parse("23/71/2000 11::32::UTC"));
1518
1519 ok(typeof(Math.PI) === "number", "typeof(Math.PI) = " + typeof(Math.PI));
1520 ok(Math.floor(Math.PI*100) === 314, "Math.PI = " + Math.PI);
1521 Math.PI = "test";
1522 ok(Math.floor(Math.PI*100) === 314, "modified Math.PI = " + Math.PI);
1523
1524 ok(typeof(Math.E) === "number", "typeof(Math.E) = " + typeof(Math.E));
1525 ok(Math.floor(Math.E*100) === 271, "Math.E = " + Math.E);
1526 Math.E = "test";
1527 ok(Math.floor(Math.E*100) === 271, "modified Math.E = " + Math.E);
1528
1529 ok(typeof(Math.LOG2E) === "number", "typeof(Math.LOG2E) = " + typeof(Math.LOG2E));
1530 ok(Math.floor(Math.LOG2E*100) === 144, "Math.LOG2E = " + Math.LOG2E);
1531 Math.LOG2E = "test";
1532 ok(Math.floor(Math.LOG2E*100) === 144, "modified Math.LOG2E = " + Math.LOG2E);
1533
1534 ok(typeof(Math.LOG10E) === "number", "typeof(Math.LOG10E) = " + typeof(Math.LOG10E));
1535 ok(Math.floor(Math.LOG10E*100) === 43, "Math.LOG10E = " + Math.LOG10E);
1536 Math.LOG10E = "test";
1537 ok(Math.floor(Math.LOG10E*100) === 43, "modified Math.LOG10E = " + Math.LOG10E);
1538
1539 ok(typeof(Math.LN2) === "number", "typeof(Math.LN2) = " + typeof(Math.LN2));
1540 ok(Math.floor(Math.LN2*100) === 69, "Math.LN2 = " + Math.LN2);
1541 Math.LN2 = "test";
1542 ok(Math.floor(Math.LN2*100) === 69, "modified Math.LN2 = " + Math.LN2);
1543
1544 ok(typeof(Math.LN10) === "number", "typeof(Math.LN10) = " + typeof(Math.LN10));
1545 ok(Math.floor(Math.LN10*100) === 230, "Math.LN10 = " + Math.LN10);
1546 Math.LN10 = "test";
1547 ok(Math.floor(Math.LN10*100) === 230, "modified Math.LN10 = " + Math.LN10);
1548
1549 ok(typeof(Math.SQRT2) === "number", "typeof(Math.SQRT2) = " + typeof(Math.SQRT2));
1550 ok(Math.floor(Math.SQRT2*100) === 141, "Math.SQRT2 = " + Math.SQRT2);
1551 Math.SQRT2 = "test";
1552 ok(Math.floor(Math.SQRT2*100) === 141, "modified Math.SQRT2 = " + Math.SQRT2);
1553
1554 ok(typeof(Math.SQRT1_2) === "number", "typeof(Math.SQRT1_2) = " + typeof(Math.SQRT1_2));
1555 ok(Math.floor(Math.SQRT1_2*100) === 70, "Math.SQRT1_2 = " + Math.SQRT1_2);
1556 Math.SQRT1_2 = "test";
1557 ok(Math.floor(Math.SQRT1_2*100) === 70, "modified Math.SQRT1_2 = " + Math.SQRT1_2);
1558
1559 ok(isNaN.toString() === "\nfunction isNaN() {\n    [native code]\n}\n",
1560    "isNaN.toString = '" + isNaN.toString() + "'");
1561 ok(Array.toString() === "\nfunction Array() {\n    [native code]\n}\n",
1562    "isNaN.toString = '" + Array.toString() + "'");
1563 ok(Function.toString() === "\nfunction Function() {\n    [native code]\n}\n",
1564    "isNaN.toString = '" + Function.toString() + "'");
1565 ok(Function.prototype.toString() === "\nfunction prototype() {\n    [native code]\n}\n",
1566    "isNaN.toString = '" + Function.prototype.toString() + "'");
1567 ok("".substr.toString() === "\nfunction substr() {\n    [native code]\n}\n",
1568    "''.substr.toString = '" + "".substr.toString() + "'");
1569
1570 var bool = new Boolean();
1571 ok(bool.toString() === "false", "bool.toString() = " + bool.toString());
1572 var bool = new Boolean("false");
1573 ok(bool.toString() === "true", "bool.toString() = " + bool.toString());
1574 ok(bool.valueOf() === Boolean(1), "bool.valueOf() = " + bool.valueOf());
1575 ok(bool.toLocaleString() === bool.toString(), "bool.toLocaleString() = " + bool.toLocaleString());
1576
1577 ok(ActiveXObject instanceof Function, "ActiveXObject is not instance of Function");
1578 ok(ActiveXObject.prototype instanceof Object, "ActiveXObject.prototype is not instance of Object");
1579
1580 ok(Error.prototype !== TypeError.prototype, "Error.prototype === TypeError.prototype");
1581 ok(RangeError.prototype !== TypeError.prototype, "RangeError.prototype === TypeError.prototype");
1582 ok(Error.prototype.toLocaleString === Object.prototype.toLocaleString,
1583         "Error.prototype.toLocaleString !== Object.prototype.toLocaleString");
1584 err = new Error();
1585 ok(err.valueOf === Object.prototype.valueOf, "err.valueOf !== Object.prototype.valueOf");
1586 ok(Error.prototype.name === "Error", "Error.prototype.name = " + Error.prototype.name);
1587 ok(err.name === "Error", "err.name = " + err.name);
1588 EvalError.prototype.message = "test";
1589 ok(err.toString !== Object.prototype.toString, "err.toString === Object.prototype.toString");
1590 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1591 err = new EvalError();
1592 ok(EvalError.prototype.name === "EvalError", "EvalError.prototype.name = " + EvalError.prototype.name);
1593 ok(err.name === "EvalError", "err.name = " + err.name);
1594 ok(err.toString === Error.prototype.toString, "err.toString !== Error.prototype.toString");
1595 ok(err.message === "", "err.message != ''");
1596 err.message = date;
1597 ok(err.message === date, "err.message != date");
1598 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1599 ok(err.toString !== Object.prototype.toString, "err.toString === Object.prototype.toString");
1600 err = new RangeError();
1601 ok(RangeError.prototype.name === "RangeError", "RangeError.prototype.name = " + RangeError.prototype.name);
1602 ok(err.name === "RangeError", "err.name = " + err.name);
1603 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1604 err = new ReferenceError();
1605 ok(ReferenceError.prototype.name === "ReferenceError", "ReferenceError.prototype.name = " + ReferenceError.prototype.name);
1606 ok(err.name === "ReferenceError", "err.name = " + err.name);
1607 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1608 err = new SyntaxError();
1609 ok(SyntaxError.prototype.name === "SyntaxError", "SyntaxError.prototype.name = " + SyntaxError.prototype.name);
1610 ok(err.name === "SyntaxError", "err.name = " + err.name);
1611 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1612 err = new TypeError();
1613 ok(TypeError.prototype.name === "TypeError", "TypeError.prototype.name = " + TypeError.prototype.name);
1614 ok(err.name === "TypeError", "err.name = " + err.name);
1615 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1616 err = new URIError();
1617 ok(URIError.prototype.name === "URIError", "URIError.prototype.name = " + URIError.prototype.name);
1618 ok(err.name === "URIError", "err.name = " + err.name);
1619 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1620 err = new Error("message");
1621 ok(err.message === "message", "err.message !== 'message'");
1622 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1623 err = new Error(123);
1624 ok(err.number === 123, "err.number = " + err.number);
1625 err = new Error(0, "message");
1626 ok(err.number === 0, "err.number = " + err.number);
1627 ok(err.message === "message", "err.message = " + err.message);
1628 ok(err.description === "message", "err.description = " + err.description);
1629
1630 function exception_test(func, type, number) {
1631     ret = "";
1632     num = "";
1633     try {
1634         func();
1635     } catch(e) {
1636         ret = e.name;
1637         num = e.number;
1638     }
1639     ok(ret === type, "Exception test, ret = " + ret + ", expected " + type +". Executed function: " + func.toString());
1640     ok(num === number, "Exception test, num = " + num + ", expected " + number + ". Executed function: " + func.toString());
1641 }
1642 exception_test(function() {arr.toString = Date.prototype.toString; arr.toString();}, "TypeError", -2146823282);
1643 exception_test(function() {Array(-3);}, "RangeError", -2146823259);
1644 exception_test(function() {arr.toString = Boolean.prototype.toString; arr.toString();}, "TypeError", -2146823278);
1645 exception_test(function() {date.setTime();}, "TypeError", -2146827839);
1646 exception_test(function() {arr.test();}, "TypeError", -2146827850);
1647 exception_test(function() {arr.toString = Number.prototype.toString; arr.toString();}, "TypeError", -2146823287);
1648 exception_test(function() {(new Number(3)).toString(1);}, "TypeError", -2146828283);
1649 exception_test(function() {not_existing_variable.something();}, "TypeError", -2146823279);
1650 exception_test(function() {arr.toString = Function.prototype.toString; arr.toString();}, "TypeError", -2146823286);
1651 exception_test(function() {date();}, "TypeError", -2146823286);
1652 exception_test(function() {arr();}, "TypeError", -2146823286);
1653 exception_test(function() {eval("for(i=0;) {}");}, "SyntaxError", -2146827286);
1654 exception_test(function() {eval("function {};");}, "SyntaxError", -2146827283);
1655 exception_test(function() {eval("if");}, "SyntaxError", -2146827283);
1656 exception_test(function() {eval("do i=0; while");}, "SyntaxError", -2146827283);
1657 exception_test(function() {eval("while");}, "SyntaxError", -2146827283);
1658 exception_test(function() {eval("for");}, "SyntaxError", -2146827283);
1659 exception_test(function() {eval("with");}, "SyntaxError", -2146827283);
1660 exception_test(function() {eval("switch");}, "SyntaxError", -2146827283);
1661 exception_test(function() {eval("if(false");}, "SyntaxError", -2146827282);
1662 exception_test(function() {eval("for(i=0; i<10; i++");}, "SyntaxError", -2146827282);
1663 exception_test(function() {eval("while(true");}, "SyntaxError", -2146827282);
1664 exception_test(function() {test = function() {}}, "ReferenceError", -2146823280);
1665 exception_test(function() {eval("for(i=0")}, "SyntaxError", -2146827284);
1666 exception_test(function() {eval("for(i=0;i<10")}, "SyntaxError", -2146827284);
1667 exception_test(function() {eval("while(")}, "SyntaxError", -2146827286);
1668 exception_test(function() {eval("if(")}, "SyntaxError", -2146827286);
1669 exception_test(function() {eval("'unterminated")}, "SyntaxError", -2146827273);
1670 exception_test(function() {eval("nonexistingfunc()")}, "TypeError", -2146823281);
1671 exception_test(function() {RegExp(/a/, "g");}, "RegExpError", -2146823271);
1672
1673 function testThisExcept(func, number) {
1674     exception_test(function() {func.call(new Object())}, "TypeError", number);
1675 }
1676
1677 function testBoolThis(func) {
1678     testThisExcept(Boolean.prototype[func], -2146823278);
1679 }
1680
1681 testBoolThis("toString");
1682 testBoolThis("valueOf");
1683
1684 function testDateThis(func) {
1685     testThisExcept(Date.prototype[func], -2146823282);
1686 }
1687
1688 testDateThis("getDate");
1689 testDateThis("getDay");
1690 testDateThis("getFullYear");
1691 testDateThis("getHours");
1692 testDateThis("getMilliseconds");
1693 testDateThis("getMinutes");
1694 testDateThis("getMonth");
1695 testDateThis("getSeconds");
1696 testDateThis("getTime");
1697 testDateThis("getTimezoneOffset");
1698 testDateThis("getUTCDate");
1699 testDateThis("getUTCDay");
1700 testDateThis("getUTCFullYear");
1701 testDateThis("getUTCHours");
1702 testDateThis("getUTCMilliseconds");
1703 testDateThis("getUTCMinutes");
1704 testDateThis("getUTCMonth");
1705 testDateThis("getUTCSeconds");
1706 testDateThis("setDate");
1707 testDateThis("setFullYear");
1708 testDateThis("setHours");
1709 testDateThis("setMilliseconds");
1710 testDateThis("setMinutes");
1711 testDateThis("setMonth");
1712 testDateThis("setSeconds");
1713 testDateThis("setTime");
1714 testDateThis("setUTCDate");
1715 testDateThis("setUTCFullYear");
1716 testDateThis("setUTCHours");
1717 testDateThis("setUTCMilliseconds");
1718 testDateThis("setUTCMinutes");
1719 testDateThis("setUTCMonth");
1720 testDateThis("setUTCSeconds");
1721 testDateThis("toDateString");
1722 testDateThis("toLocaleDateString");
1723 testDateThis("toLocaleString");
1724 testDateThis("toLocaleTimeString");
1725 testDateThis("toString");
1726 testDateThis("toTimeString");
1727 testDateThis("toUTCString");
1728 testDateThis("valueOf");
1729
1730 function testArrayThis(func) {
1731     testThisExcept(Array.prototype[func], -2146823257);
1732 }
1733
1734 testArrayThis("toString");
1735
1736 function testFunctionThis(func) {
1737     testThisExcept(Function.prototype[func], -2146823286);
1738 }
1739
1740 testFunctionThis("toString");
1741 testFunctionThis("call");
1742 testFunctionThis("apply");
1743
1744 function testArrayHostThis(func) {
1745     exception_test(function() { Array.prototype[func].call(testObj); }, "TypeError", -2146823274);
1746 }
1747
1748 testArrayHostThis("push");
1749 testArrayHostThis("shift");
1750 testArrayHostThis("slice");
1751 testArrayHostThis("splice");
1752 testArrayHostThis("unshift");
1753
1754 function testObjectInherit(obj, constr, ts, tls, vo) {
1755     ok(obj instanceof Object, "obj is not instance of Object");
1756     ok(obj instanceof constr, "obj is not instance of its constructor");
1757
1758     ok(obj.hasOwnProperty === Object.prototype.hasOwnProperty,
1759        "obj.hasOwnProperty !== Object.prototype.hasOwnProprty");
1760     ok(obj.isPrototypeOf === Object.prototype.isPrototypeOf,
1761        "obj.isPrototypeOf !== Object.prototype.isPrototypeOf");
1762     ok(obj.propertyIsEnumerable === Object.prototype.propertyIsEnumerable,
1763        "obj.propertyIsEnumerable !== Object.prototype.propertyIsEnumerable");
1764
1765     if(ts)
1766         ok(obj.toString === Object.prototype.toString,
1767            "obj.toString !== Object.prototype.toString");
1768     else
1769         ok(obj.toString != Object.prototype.toString,
1770            "obj.toString == Object.prototype.toString");
1771
1772     if(tls)
1773         ok(obj.toLocaleString === Object.prototype.toLocaleString,
1774            "obj.toLocaleString !== Object.prototype.toLocaleString");
1775     else
1776         ok(obj.toLocaleString != Object.prototype.toLocaleString,
1777            "obj.toLocaleString == Object.prototype.toLocaleString");
1778
1779     if(vo)
1780         ok(obj.valueOf === Object.prototype.valueOf,
1781            "obj.valueOf !== Object.prototype.valueOf");
1782     else
1783         ok(obj.valueOf != Object.prototype.valueOf,
1784            "obj.valueOf == Object.prototype.valueOf");
1785
1786     ok(obj._test === "test", "obj.test = " + obj._test);
1787 }
1788
1789 Object.prototype._test = "test";
1790 testObjectInherit(new String("test"), String, false, true, false);
1791 testObjectInherit(/test/g, RegExp, false, true, true);
1792 testObjectInherit(new Number(1), Number, false, false, false);
1793 testObjectInherit(new Date(), Date, false, false, false);
1794 testObjectInherit(new Boolean(true), Boolean, false, true, false);
1795 testObjectInherit(new Array(), Array, false, false, true);
1796 testObjectInherit(new Error(), Error, false, true, true);
1797 testObjectInherit(testObjectInherit, Function, false, true, true);
1798 testObjectInherit(Math, Object, true, true, true);
1799
1800 (function() { testObjectInherit(arguments, Object, true, true, true); })();
1801
1802 function testFunctions(obj, arr) {
1803     var l;
1804
1805     for(var i=0; i<arr.length; i++) {
1806         l = obj[arr[i][0]].length;
1807         ok(l === arr[i][1], arr[i][0] + ".length = " + l);
1808     }
1809 }
1810
1811 testFunctions(Boolean.prototype, [
1812         ["valueOf", 0],
1813         ["toString", 0]
1814     ]);
1815
1816 testFunctions(Number.prototype, [
1817         ["valueOf", 0],
1818         ["toString", 1],
1819         ["toExponential", 1],
1820         ["toLocaleString", 0],
1821         ["toPrecision", 1]
1822     ]);
1823
1824 testFunctions(String.prototype, [
1825         ["valueOf", 0],
1826         ["toString", 0],
1827         ["anchor", 1],
1828         ["big", 0],
1829         ["blink", 0],
1830         ["bold", 0],
1831         ["charAt", 1],
1832         ["charCodeAt", 1],
1833         ["concat", 1],
1834         ["fixed", 0],
1835         ["fontcolor", 1],
1836         ["fontsize", 1],
1837         ["indexOf", 2],
1838         ["italics", 0],
1839         ["lastIndexOf", 2],
1840         ["link", 1],
1841         ["localeCompare", 1],
1842         ["match", 1],
1843         ["replace", 1],
1844         ["search", 0],
1845         ["slice", 0],
1846         ["small", 0],
1847         ["split", 2],
1848         ["strike", 0],
1849         ["sub", 0],
1850         ["substr", 2],
1851         ["substring", 2],
1852         ["sup", 0],
1853         ["toLocaleLowerCase", 0],
1854         ["toLocaleUpperCase", 0],
1855         ["toLowerCase", 0],
1856         ["toUpperCase", 0]
1857     ]);
1858
1859 testFunctions(RegExp.prototype, [
1860         ["toString", 0],
1861         ["exec", 1],
1862         ["test", 1]
1863     ]);
1864
1865 testFunctions(Date.prototype, [
1866         ["getDate", 0],
1867         ["getDay", 0],
1868         ["getFullYear", 0],
1869         ["getHours", 0],
1870         ["getMilliseconds", 0],
1871         ["getMinutes", 0],
1872         ["getMonth", 0],
1873         ["getSeconds", 0],
1874         ["getTime", 0],
1875         ["getTimezoneOffset", 0],
1876         ["getUTCDate", 0],
1877         ["getUTCDay", 0],
1878         ["getUTCFullYear", 0],
1879         ["getUTCHours", 0],
1880         ["getUTCMilliseconds", 0],
1881         ["getUTCMinutes", 0],
1882         ["getUTCMonth", 0],
1883         ["getUTCSeconds", 0],
1884         ["setDate", 1],
1885         ["setFullYear", 3],
1886         ["setHours", 4],
1887         ["setMilliseconds", 1],
1888         ["setMinutes", 3],
1889         ["setMonth", 2],
1890         ["setSeconds", 2],
1891         ["setTime", 1],
1892         ["setUTCDate", 1],
1893         ["setUTCFullYear", 3],
1894         ["setUTCHours", 4],
1895         ["setUTCMilliseconds", 1],
1896         ["setUTCMinutes", 3],
1897         ["setUTCMonth", 2],
1898         ["setUTCSeconds", 2],
1899         ["toDateString", 0],
1900         ["toLocaleDateString", 0],
1901         ["toLocaleString", 0],
1902         ["toLocaleTimeString", 0],
1903         ["toString", 0],
1904         ["toTimeString", 0],
1905         ["toUTCString", 0],
1906         ["toGMTString", 0],
1907         ["valueOf", 0]
1908     ]);
1909
1910 testFunctions(Array.prototype, [
1911         ["concat", 1],
1912         ["join", 1],
1913         ["push", 1],
1914         ["pop", 0],
1915         ["reverse", 0],
1916         ["shift", 0],
1917         ["slice", 2],
1918         ["sort", 1],
1919         ["splice", 2],
1920         ["toLocaleString", 0],
1921         ["toString", 0],
1922         ["unshift", 1]
1923     ]);
1924
1925 testFunctions(Error.prototype, [
1926         ["toString", 0]
1927     ]);
1928
1929 testFunctions(Math, [
1930         ["abs", 1],
1931         ["acos", 1],
1932         ["asin", 1],
1933         ["atan", 1],
1934         ["atan2", 2],
1935         ["ceil", 1],
1936         ["cos", 1],
1937         ["exp", 1],
1938         ["floor", 1],
1939         ["log", 1],
1940         ["max", 2],
1941         ["min", 2],
1942         ["pow", 2],
1943         ["random", 0],
1944         ["round", 1],
1945         ["sin", 1],
1946         ["sqrt", 1],
1947         ["tan", 1]
1948     ]);
1949
1950 testFunctions(Object.prototype, [
1951         ["hasOwnProperty", 1],
1952         ["isPrototypeOf", 1],
1953         ["propertyIsEnumerable", 1],
1954         ["toLocaleString", 0],
1955         ["toString", 0],
1956         ["valueOf", 0]
1957     ]);
1958
1959 testFunctions(Function.prototype, [
1960         ["apply", 2],
1961         ["call", 1],
1962         ["toString", 0]
1963     ]);
1964
1965 ok(ActiveXObject.length == 1, "ActiveXObject.length = " + ActiveXObject.length);
1966 ok(Array.length == 1, "Array.length = " + Array.length);
1967 ok(Boolean.length == 1, "Boolean.length = " + Boolean.length);
1968 ok(CollectGarbage.length == 0, "CollectGarbage.length = " + CollectGarbage.length);
1969 //ok(Date.length == 7, "Date.length = " + Date.length);
1970 ok(Enumerator.length == 7, "Enumerator.length = " + Enumerator.length);
1971 ok(Error.length == 1, "Error.length = " + Error.length);
1972 ok(EvalError.length == 1, "EvalError.length = " + EvalError.length);
1973 ok(Function.length == 1, "Function.length = " + Function.length);
1974 ok(GetObject.length == 2, "GetObject.length = " + GetObject.length);
1975 ok(Number.length == 1, "Number.length = " + Number.length);
1976 ok(Object.length == 0, "Object.length = " + Object.length);
1977 ok(RangeError.length == 1, "RangeError.length = " + RangeError.length);
1978 ok(ReferenceError.length == 1, "ReferenceError.length = " + ReferenceError.length);
1979 ok(RegExp.length == 2, "RegExp.length = " + RegExp.length);
1980 ok(ScriptEngine.length == 0, "ScriptEngine.length = " + ScriptEngine.length);
1981 ok(ScriptEngineBuildVersion.length == 0,
1982     "ScriptEngineBuildVersion.length = " + ScriptEngineBuildVersion.length);
1983 ok(ScriptEngineMajorVersion.length == 0,
1984     "ScriptEngineMajorVersion.length = " + ScriptEngineMajorVersion.length);
1985 ok(ScriptEngineMinorVersion.length == 0,
1986     "ScriptEngineMinorVersion.length = " + ScriptEngineMinorVersion.length);
1987 //ok(String.length == 1, "String.length = " + String.length);
1988 ok(SyntaxError.length == 1, "SyntaxError.length = " + SyntaxError.length);
1989 ok(TypeError.length == 1, "TypeError.length = " + TypeError.length);
1990 ok(URIError.length == 1, "URIError.length = " + URIError.length);
1991 ok(VBArray.length == 1, "VBArray.length = " + VBArray.length);
1992 ok(decodeURI.length == 1, "decodeURI.length = " + decodeURI.length);
1993 ok(decodeURIComponent.length == 1, "decodeURIComponent.length = " + decodeURIComponent.length);
1994 ok(encodeURI.length == 1, "encodeURI.length = " + encodeURI.length);
1995 ok(encodeURIComponent.length == 1, "encodeURIComponent.length = " + encodeURIComponent.length);
1996 ok(escape.length == 1, "escape.length = " + escape.length);
1997 ok(eval.length == 1, "eval.length = " + eval.length);
1998 ok(isFinite.length == 1, "isFinite.length = " + isFinite.length);
1999 ok(isNaN.length == 1, "isNaN.length = " + isNaN.length);
2000 ok(parseFloat.length == 1, "parseFloat.length = " + parseFloat.length);
2001 ok(parseInt.length == 2, "parseInt.length = " + parseInt.length);
2002 ok(unescape.length == 1, "unescape.length = " + unescape.length);
2003
2004 reportSuccess();