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