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