jscript: Added 'instanceof' keyword implementation.
[wine.git] / dlls / jscript / tests / api.js
bloba77f31a9091051801b15deecf49ca69862333f6d
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 = "" + new Object();
62 ok(tmp === "[object Object]", "'' + new Object() = " + tmp);
63 (tmp = new Array).f = Object.prototype.toString;
64 ok(tmp.f() === "[object Array]", "tmp.f() = " + tmp.f());
65 (tmp = new Boolean).f = Object.prototype.toString;
66 ok(tmp.f() === "[object Boolean]", "tmp.f() = " + tmp.f());
67 (tmp = new Date).f = Object.prototype.toString;
68 ok(tmp.f() === "[object Date]", "tmp.f() = " + tmp.f());
69 (tmp = function() {}).f = Object.prototype.toString;
70 ok(tmp.f() === "[object Function]", "tmp.f() = " + tmp.f());
71 Math.f = Object.prototype.toString;
72 ok(Math.f() === "[object Math]", "tmp.f() = " + tmp.f());
73 (tmp = new Number).f = Object.prototype.toString;
74 ok(tmp.f() === "[object Number]", "tmp.f() = " + tmp.f());
75 (tmp = new RegExp("")).f = Object.prototype.toString;
76 ok(tmp.f() === "[object RegExp]", "tmp.f() = " + tmp.f());
77 (tmp = new String).f = Object.prototype.toString;
78 ok(tmp.f() === "[object String]", "tmp.f() = " + tmp.f());
80 var obj = new Object();
81 obj.toString = function (x) {
82     ok(arguments.length === 0, "arguments.length = " + arguments.length);
83     return "test";
85 ok((tmp = obj.toLocaleString()) === "test", "obj.toLocaleString() = " + tmp);
86 ok((tmp = obj.toLocaleString(1)) === "test", "obj.toLocaleString(1) = " + tmp);
88 ok("".length === 0, "\"\".length = " + "".length);
89 ok(getVT("".length) == "VT_I4", "\"\".length = " + "".length);
90 ok("abc".length === 3, "\"abc\".length = " + "abc".length);
91 ok(String.prototype.length === 0, "String.prototype.length = " + String.prototype.length);
93 tmp = "".toString();
94 ok(tmp === "", "''.toString() = " + tmp);
95 tmp = "test".toString();
96 ok(tmp === "test", "''.toString() = " + tmp);
97 tmp = "test".toString(3);
98 ok(tmp === "test", "''.toString(3) = " + tmp);
100 tmp = "".valueOf();
101 ok(tmp === "", "''.valueOf() = " + tmp);
102 tmp = "test".valueOf();
103 ok(tmp === "test", "''.valueOf() = " + tmp);
104 tmp = "test".valueOf(3);
105 ok(tmp === "test", "''.valueOf(3) = " + tmp);
107 var str = new String("test");
108 ok(str.toString() === "test", "str.toString() = " + str.toString());
109 var str = new String();
110 ok(str.toString() === "", "str.toString() = " + str.toString());
111 var str = new String("test", "abc");
112 ok(str.toString() === "test", "str.toString() = " + str.toString());
114 var strObj = new Object();
115 strObj.toString = function() { return "abcd" };
116 strObj.substr = String.prototype.substr;
118 tmp = "value " + str;
119 ok(tmp === "value test", "'value ' + str = " + tmp);
121 tmp = String();
122 ok(tmp === "", "String() = " + tmp);
123 tmp = String(false);
124 ok(tmp === "false", "String(false) = " + tmp);
125 tmp = String(null);
126 ok(tmp === "null", "String(null) = " + tmp);
127 tmp = String("test");
128 ok(tmp === "test", "String('test') = " + tmp);
129 tmp = String("test", "abc");
130 ok(tmp === "test", "String('test','abc') = " + tmp);
132 tmp = "abc".charAt(0);
133 ok(tmp === "a", "'abc',charAt(0) = " + tmp);
134 tmp = "abc".charAt(1);
135 ok(tmp === "b", "'abc',charAt(1) = " + tmp);
136 tmp = "abc".charAt(2);
137 ok(tmp === "c", "'abc',charAt(2) = " + tmp);
138 tmp = "abc".charAt(3);
139 ok(tmp === "", "'abc',charAt(3) = " + tmp);
140 tmp = "abc".charAt(4);
141 ok(tmp === "", "'abc',charAt(4) = " + tmp);
142 tmp = "abc".charAt();
143 ok(tmp === "a", "'abc',charAt() = " + tmp);
144 tmp = "abc".charAt(-1);
145 ok(tmp === "", "'abc',charAt(-1) = " + tmp);
146 tmp = "abc".charAt(0,2);
147 ok(tmp === "a", "'abc',charAt(0.2) = " + tmp);
149 tmp = "abc".charCodeAt(0);
150 ok(tmp === 0x61, "'abc'.charCodeAt(0) = " + tmp);
151 tmp = "abc".charCodeAt(1);
152 ok(tmp === 0x62, "'abc'.charCodeAt(1) = " + tmp);
153 tmp = "abc".charCodeAt(2);
154 ok(tmp === 0x63, "'abc'.charCodeAt(2) = " + tmp);
155 tmp = "abc".charCodeAt();
156 ok(tmp === 0x61, "'abc'.charCodeAt() = " + tmp);
157 tmp = "abc".charCodeAt(true);
158 ok(tmp === 0x62, "'abc'.charCodeAt(true) = " + tmp);
159 tmp = "abc".charCodeAt(0,2);
160 ok(tmp === 0x61, "'abc'.charCodeAt(0,2) = " + tmp);
162 tmp = "abcd".substring(1,3);
163 ok(tmp === "bc", "'abcd'.substring(1,3) = " + tmp);
164 tmp = "abcd".substring(-1,3);
165 ok(tmp === "abc", "'abcd'.substring(-1,3) = " + tmp);
166 tmp = "abcd".substring(1,6);
167 ok(tmp === "bcd", "'abcd'.substring(1,6) = " + tmp);
168 tmp = "abcd".substring(3,1);
169 ok(tmp === "bc", "'abcd'.substring(3,1) = " + tmp);
170 tmp = "abcd".substring(2,2);
171 ok(tmp === "", "'abcd'.substring(2,2) = " + tmp);
172 tmp = "abcd".substring(true,"3");
173 ok(tmp === "bc", "'abcd'.substring(true,'3') = " + tmp);
174 tmp = "abcd".substring(1,3,2);
175 ok(tmp === "bc", "'abcd'.substring(1,3,2) = " + tmp);
176 tmp = "abcd".substring();
177 ok(tmp === "abcd", "'abcd'.substring() = " + tmp);
179 tmp = "abcd".substr(1,3);
180 ok(tmp === "bcd", "'abcd'.substr(1,3) = " + tmp);
181 tmp = "abcd".substr(-1,3);
182 ok(tmp === "abc", "'abcd'.substr(-1,3) = " + tmp);
183 tmp = "abcd".substr(1,6);
184 ok(tmp === "bcd", "'abcd'.substr(1,6) = " + tmp);
185 tmp = "abcd".substr(2,-1);
186 ok(tmp === "", "'abcd'.substr(3,1) = " + tmp);
187 tmp = "abcd".substr(2,0);
188 ok(tmp === "", "'abcd'.substr(2,2) = " + tmp);
189 tmp = "abcd".substr(true,"3");
190 ok(tmp === "bcd", "'abcd'.substr(true,'3') = " + tmp);
191 tmp = "abcd".substr(1,3,2);
192 ok(tmp === "bcd", "'abcd'.substr(1,3,2) = " + tmp);
193 tmp = "abcd".substr();
194 ok(tmp === "abcd", "'abcd'.substr() = " + tmp);
195 tmp = strObj.substr(1,1);
196 ok(tmp === "b", "'abcd'.substr(1,3) = " + tmp);
198 tmp = "abcd".slice(1,3);
199 ok(tmp === "bc", "'abcd'.slice(1,3) = " + tmp);
200 tmp = "abcd".slice(1,-1);
201 ok(tmp === "bc", "'abcd'.slice(1,-1) = " + tmp);
202 tmp = "abcd".slice(-3,3);
203 ok(tmp === "bc", "'abcd'.slice(-3,3) = " + tmp);
204 tmp = "abcd".slice(-6,3);
205 ok(tmp === "abc", "'abcd'.slice(-6,3) = " + tmp);
206 tmp = "abcd".slice(3,1);
207 ok(tmp === "", "'abcd'.slice(3,1) = " + tmp);
208 tmp = "abcd".slice(true,3);
209 ok(tmp === "bc", "'abcd'.slice(true,3) = " + tmp);
210 tmp = "abcd".slice();
211 ok(tmp === "abcd", "'abcd'.slice() = " + tmp);
212 tmp = "abcd".slice(1);
213 ok(tmp === "bcd", "'abcd'.slice(1) = " + tmp);
215 tmp = "abc".concat(["d",1],2,false);
216 ok(tmp === "abcd,12false", "concat returned " + tmp);
217 var arr = new Array(2,"a");
218 arr.concat = String.prototype.concat;
219 tmp = arr.concat("d");
220 ok(tmp === "2,ad", "arr.concat = " + tmp);
222 m = "a+bcabc".match("a+");
223 ok(typeof(m) === "object", "typeof m is not object");
224 ok(m.length === 1, "m.length is not 1");
225 ok(m["0"] === "a", "m[0] is not \"ab\"");
227 r = "- [test] -".replace("[test]", "success");
228 ok(r === "- success -", "r = " + r + " expected '- success -'");
230 r = "- [test] -".replace("[test]", "success", "test");
231 ok(r === "- success -", "r = " + r + " expected '- success -'");
233 r = "test".replace();
234 ok(r === "test", "r = " + r + " expected 'test'");
236 function replaceFunc3(m, off, str) {
237     ok(arguments.length === 3, "arguments.length = " + arguments.length);
238     ok(m === "[test]", "m = " + m + " expected [test1]");
239     ok(off === 1, "off = " + off + " expected 0");
240     ok(str === "-[test]-", "str = " + arguments[3]);
241     return "ret";
244 r = "-[test]-".replace("[test]", replaceFunc3);
245 ok(r === "-ret-", "r = " + r + " expected '-ret-'");
247 r = "-[test]-".replace("[test]", replaceFunc3, "test");
248 ok(r === "-ret-", "r = " + r + " expected '-ret-'");
250 r = "1,2,3".split(",");
251 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
252 ok(r.length === 3, "r.length = " + r.length);
253 ok(r[0] === "1", "r[0] = " + r[0]);
254 ok(r[1] === "2", "r[1] = " + r[1]);
255 ok(r[2] === "3", "r[2] = " + r[2]);
258 r = "1,2,3".split(",*");
259 ok(r.length === 1, "r.length = " + r.length);
260 ok(r[0] === "1,2,3", "r[0] = " + r[0]);
262 r = "123".split("");
263 ok(r.length === 3, "r.length = " + r.length);
264 ok(r[0] === "1", "r[0] = " + r[0]);
265 ok(r[1] === "2", "r[1] = " + r[1]);
266 ok(r[2] === "3", "r[2] = " + r[2]);
268 r = "123".split(2);
269 ok(r.length === 2, "r.length = " + r.length);
270 ok(r[0] === "1", "r[0] = " + r[0]);
271 ok(r[1] === "3", "r[1] = " + r[1]);
273 r = "1,2,".split(",");
274 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
275 ok(r.length === 3, "r.length = " + r.length);
276 ok(r[0] === "1", "r[0] = " + r[0]);
277 ok(r[1] === "2", "r[1] = " + r[1]);
278 ok(r[2] === "", "r[2] = " + r[2]);
280 tmp = "abcd".indexOf("bc",0);
281 ok(tmp === 1, "indexOf = " + tmp);
282 tmp = "abcd".indexOf("bc",1);
283 ok(tmp === 1, "indexOf = " + tmp);
284 tmp = "abcd".indexOf("bc");
285 ok(tmp === 1, "indexOf = " + tmp);
286 tmp = "abcd".indexOf("ac");
287 ok(tmp === -1, "indexOf = " + tmp);
288 tmp = "abcd".indexOf("bc",2);
289 ok(tmp === -1, "indexOf = " + tmp);
290 tmp = "abcd".indexOf("a",0);
291 ok(tmp === 0, "indexOf = " + tmp);
292 tmp = "abcd".indexOf("bc",0,"test");
293 ok(tmp === 1, "indexOf = " + tmp);
294 tmp = "abcd".indexOf();
295 ok(tmp == -1, "indexOf = " + tmp);
297 tmp = "".toLowerCase();
298 ok(tmp === "", "''.toLowerCase() = " + tmp);
299 tmp = "test".toLowerCase();
300 ok(tmp === "test", "''.toLowerCase() = " + tmp);
301 tmp = "test".toLowerCase(3);
302 ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
303 tmp = "tEsT".toLowerCase();
304 ok(tmp === "test", "''.toLowerCase() = " + tmp);
305 tmp = "tEsT".toLowerCase(3);
306 ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
308 tmp = "".toUpperCase();
309 ok(tmp === "", "''.toUpperCase() = " + tmp);
310 tmp = "TEST".toUpperCase();
311 ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
312 tmp = "TEST".toUpperCase(3);
313 ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
314 tmp = "tEsT".toUpperCase();
315 ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
316 tmp = "tEsT".toUpperCase(3);
317 ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
319 tmp = "".anchor();
320 ok(tmp === "<A NAME=\"undefined\"></A>", "''.anchor() = " + tmp);
321 tmp = "".anchor(3);
322 ok(tmp === "<A NAME=\"3\"></A>", "''.anchor(3) = " + tmp);
323 tmp = "".anchor("red");
324 ok(tmp === "<A NAME=\"red\"></A>", "''.anchor('red') = " + tmp);
325 tmp = "test".anchor();
326 ok(tmp === "<A NAME=\"undefined\">test</A>", "'test'.anchor() = " + tmp);
327 tmp = "test".anchor(3);
328 ok(tmp === "<A NAME=\"3\">test</A>", "'test'.anchor(3) = " + tmp);
329 tmp = "test".anchor("green");
330 ok(tmp === "<A NAME=\"green\">test</A>", "'test'.anchor('green') = " + tmp);
332 tmp = "".big();
333 ok(tmp === "<BIG></BIG>", "''.big() = " + tmp);
334 tmp = "".big(3);
335 ok(tmp === "<BIG></BIG>", "''.big(3) = " + tmp);
336 tmp = "test".big();
337 ok(tmp === "<BIG>test</BIG>", "'test'.big() = " + tmp);
338 tmp = "test".big(3);
339 ok(tmp === "<BIG>test</BIG>", "'test'.big(3) = " + tmp);
341 tmp = "".blink();
342 ok(tmp === "<BLINK></BLINK>", "''.blink() = " + tmp);
343 tmp = "".blink(3);
344 ok(tmp === "<BLINK></BLINK>", "''.blink(3) = " + tmp);
345 tmp = "test".blink();
346 ok(tmp === "<BLINK>test</BLINK>", "'test'.blink() = " + tmp);
347 tmp = "test".blink(3);
348 ok(tmp === "<BLINK>test</BLINK>", "'test'.blink(3) = " + tmp);
350 tmp = "".bold();
351 ok(tmp === "<B></B>", "''.bold() = " + tmp);
352 tmp = "".bold(3);
353 ok(tmp === "<B></B>", "''.bold(3) = " + tmp);
354 tmp = "test".bold();
355 ok(tmp === "<B>test</B>", "'test'.bold() = " + tmp);
356 tmp = "test".bold(3);
357 ok(tmp === "<B>test</B>", "'test'.bold(3) = " + tmp);
359 tmp = "".fixed();
360 ok(tmp === "<TT></TT>", "''.fixed() = " + tmp);
361 tmp = "".fixed(3);
362 ok(tmp === "<TT></TT>", "''.fixed(3) = " + tmp);
363 tmp = "test".fixed();
364 ok(tmp === "<TT>test</TT>", "'test'.fixed() = " + tmp);
365 tmp = "test".fixed(3);
366 ok(tmp === "<TT>test</TT>", "'test'.fixed(3) = " + tmp);
368 tmp = "".fontcolor();
369 ok(tmp === "<FONT COLOR=\"undefined\"></FONT>", "''.fontcolor() = " + tmp);
370 tmp = "".fontcolor(3);
371 ok(tmp === "<FONT COLOR=\"3\"></FONT>", "''.fontcolor(3) = " + tmp);
372 tmp = "".fontcolor("red");
373 ok(tmp === "<FONT COLOR=\"red\"></FONT>", "''.fontcolor('red') = " + tmp);
374 tmp = "test".fontcolor();
375 ok(tmp === "<FONT COLOR=\"undefined\">test</FONT>", "'test'.fontcolor() = " + tmp);
376 tmp = "test".fontcolor(3);
377 ok(tmp === "<FONT COLOR=\"3\">test</FONT>", "'test'.fontcolor(3) = " + tmp);
378 tmp = "test".fontcolor("green");
379 ok(tmp === "<FONT COLOR=\"green\">test</FONT>", "'test'.fontcolor('green') = " + tmp);
381 tmp = "".fontsize();
382 ok(tmp === "<FONT SIZE=\"undefined\"></FONT>", "''.fontsize() = " + tmp);
383 tmp = "".fontsize(3);
384 ok(tmp === "<FONT SIZE=\"3\"></FONT>", "''.fontsize(3) = " + tmp);
385 tmp = "".fontsize("red");
386 ok(tmp === "<FONT SIZE=\"red\"></FONT>", "''.fontsize('red') = " + tmp);
387 tmp = "test".fontsize();
388 ok(tmp === "<FONT SIZE=\"undefined\">test</FONT>", "'test'.fontsize() = " + tmp);
389 tmp = "test".fontsize(3);
390 ok(tmp === "<FONT SIZE=\"3\">test</FONT>", "'test'.fontsize(3) = " + tmp);
391 tmp = "test".fontsize("green");
392 ok(tmp === "<FONT SIZE=\"green\">test</FONT>", "'test'.fontsize('green') = " + tmp);
394 tmp = ("".fontcolor()).fontsize();
395 ok(tmp === "<FONT SIZE=\"undefined\"><FONT COLOR=\"undefined\"></FONT></FONT>", "(''.fontcolor()).fontsize() = " + tmp);
397 tmp = "".italics();
398 ok(tmp === "<I></I>", "''.italics() = " + tmp);
399 tmp = "".italics(3);
400 ok(tmp === "<I></I>", "''.italics(3) = " + tmp);
401 tmp = "test".italics();
402 ok(tmp === "<I>test</I>", "'test'.italics() = " + tmp);
403 tmp = "test".italics(3);
404 ok(tmp === "<I>test</I>", "'test'.italics(3) = " + tmp);
406 tmp = "".link();
407 ok(tmp === "<A HREF=\"undefined\"></A>", "''.link() = " + tmp);
408 tmp = "".link(3);
409 ok(tmp === "<A HREF=\"3\"></A>", "''.link(3) = " + tmp);
410 tmp = "".link("red");
411 ok(tmp === "<A HREF=\"red\"></A>", "''.link('red') = " + tmp);
412 tmp = "test".link();
413 ok(tmp === "<A HREF=\"undefined\">test</A>", "'test'.link() = " + tmp);
414 tmp = "test".link(3);
415 ok(tmp === "<A HREF=\"3\">test</A>", "'test'.link(3) = " + tmp);
416 tmp = "test".link("green");
417 ok(tmp === "<A HREF=\"green\">test</A>", "'test'.link('green') = " + tmp);
419 tmp = "".small();
420 ok(tmp === "<SMALL></SMALL>", "''.small() = " + tmp);
421 tmp = "".small(3);
422 ok(tmp === "<SMALL></SMALL>", "''.small(3) = " + tmp);
423 tmp = "test".small();
424 ok(tmp === "<SMALL>test</SMALL>", "'test'.small() = " + tmp);
425 tmp = "test".small(3);
426 ok(tmp === "<SMALL>test</SMALL>", "'test'.small(3) = " + tmp);
428 tmp = "".strike();
429 ok(tmp === "<STRIKE></STRIKE>", "''.strike() = " + tmp);
430 tmp = "".strike(3);
431 ok(tmp === "<STRIKE></STRIKE>", "''.strike(3) = " + tmp);
432 tmp = "test".strike();
433 ok(tmp === "<STRIKE>test</STRIKE>", "'test'.strike() = " + tmp);
434 tmp = "test".strike(3);
435 ok(tmp === "<STRIKE>test</STRIKE>", "'test'.strike(3) = " + tmp);
437 tmp = "".sub();
438 ok(tmp === "<SUB></SUB>", "''.sub() = " + tmp);
439 tmp = "".sub(3);
440 ok(tmp === "<SUB></SUB>", "''.sub(3) = " + tmp);
441 tmp = "test".sub();
442 ok(tmp === "<SUB>test</SUB>", "'test'.sub() = " + tmp);
443 tmp = "test".sub(3);
444 ok(tmp === "<SUB>test</SUB>", "'test'.sub(3) = " + tmp);
446 tmp = "".sup();
447 ok(tmp === "<SUP></SUP>", "''.sup() = " + tmp);
448 tmp = "".sup(3);
449 ok(tmp === "<SUP></SUP>", "''.sup(3) = " + tmp);
450 tmp = "test".sup();
451 ok(tmp === "<SUP>test</SUP>", "'test'.sup() = " + tmp);
452 tmp = "test".sup(3);
453 ok(tmp === "<SUP>test</SUP>", "'test'.sup(3) = " + tmp);
455 ok(String.fromCharCode() === "", "String.fromCharCode() = " + String.fromCharCode());
456 ok(String.fromCharCode(65,"66",67) === "ABC", "String.fromCharCode(65,'66',67) = " + String.fromCharCode(65,"66",67));
457 ok(String.fromCharCode(1024*64+65, -1024*64+65) === "AA",
458         "String.fromCharCode(1024*64+65, -1024*64+65) = " + String.fromCharCode(1024*64+65, -1024*64+65));
459 ok(String.fromCharCode(65, NaN, undefined).length === 3,
460         "String.fromCharCode(65, NaN, undefined).length = " + String.fromCharCode(65, NaN, undefined).length);
462 var arr = new Array();
463 ok(typeof(arr) === "object", "arr () is not object");
464 ok((arr.length === 0), "arr.length is not 0");
465 ok(arr["0"] === undefined, "arr[0] is not undefined");
467 var arr = new Array(1, 2, "test");
468 ok(typeof(arr) === "object", "arr (1,2,test) is not object");
469 ok((arr.length === 3), "arr.length is not 3");
470 ok(arr["0"] === 1, "arr[0] is not 1");
471 ok(arr["1"] === 2, "arr[1] is not 2");
472 ok(arr["2"] === "test", "arr[2] is not \"test\"");
474 arr["7"] = true;
475 ok((arr.length === 8), "arr.length is not 8");
477 tmp = "" + [];
478 ok(tmp === "", "'' + [] = " + tmp);
479 tmp = "" + [1,true];
480 ok(tmp === "1,true", "'' + [1,true] = " + tmp);
482 var arr = new Array(6);
483 ok(typeof(arr) === "object", "arr (6) is not object");
484 ok((arr.length === 6), "arr.length is not 6");
485 ok(arr["0"] === undefined, "arr[0] is not undefined");
487 ok(arr.push() === 6, "arr.push() !== 6");
488 ok(arr.push(1) === 7, "arr.push(1) !== 7");
489 ok(arr[6] === 1, "arr[6] != 1");
490 ok(arr.length === 7, "arr.length != 10");
491 ok(arr.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10");
492 ok(arr[8] === "b", "arr[8] != 'b'");
493 ok(arr.length === 10, "arr.length != 10");
495 arr = [3,4,5];
496 tmp = arr.pop();
497 ok(arr.length === 2, "arr.length = " + arr.length);
498 ok(tmp === 5, "pop() = " + tmp);
499 tmp = arr.pop(2);
500 ok(arr.length === 1, "arr.length = " + arr.length);
501 ok(tmp === 4, "pop() = " + tmp);
502 tmp = arr.pop();
503 ok(arr.length === 0, "arr.length = " + arr.length);
504 ok(tmp === 3, "pop() = " + tmp);
505 for(tmp in arr)
506     ok(false, "not deleted " + tmp);
507 tmp = arr.pop();
508 ok(arr.length === 0, "arr.length = " + arr.length);
509 ok(tmp === undefined, "tmp = " + tmp);
510 arr = [,,,,,];
511 tmp = arr.pop();
512 ok(arr.length === 5, "arr.length = " + arr.length);
513 ok(tmp === undefined, "tmp = " + tmp);
515 arr = [1,2,null,false,undefined,,"a"];
517 tmp = arr.join();
518 ok(tmp === "1,2,,false,,,a", "arr.join() = " + tmp);
519 tmp = arr.join(";");
520 ok(tmp === "1;2;;false;;;a", "arr.join(';') = " + tmp);
521 tmp = arr.join(";","test");
522 ok(tmp === "1;2;;false;;;a", "arr.join(';') = " + tmp);
523 tmp = arr.join("");
524 ok(tmp === "12falsea", "arr.join('') = " + tmp);
526 tmp = arr.toString();
527 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
528 tmp = arr.toString("test");
529 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
531 arr = [5,true,2,-1,3,false,"2.5"];
532 tmp = arr.sort(function(x,y) { return y-x; });
533 ok(tmp === arr, "tmp !== arr");
534 tmp = [5,3,"2.5",2,true,false,-1];
535 for(var i=0; i < arr.length; i++)
536     ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
538 arr = [5,false,2,0,"abc",3,"a",-1];
539 tmp = arr.sort();
540 ok(tmp === arr, "tmp !== arr");
541 tmp = [-1,0,2,3,5,"a","abc",false];
542 for(var i=0; i < arr.length; i++)
543     ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
545 arr = ["a", "b", "ab"];
546 tmp = ["a", "ab", "b"];
547 ok(arr.sort() === arr, "arr.sort() !== arr");
548 for(var i=0; i < arr.length; i++)
549     ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
551 arr = ["1", "2", "3"];
552 arr.length = 1;
553 ok(arr.length === 1, "arr.length = " + arr.length);
554 arr.length = 3;
555 ok(arr.length === 3, "arr.length = " + arr.length);
556 ok(arr.toString() === "1,,", "arr.toString() = " + arr.toString());
558 arr = Array("a","b","c");
559 ok(arr.toString() === "a,b,c", "arr.toString() = " + arr.toString());
561 ok(arr.valueOf === Object.prototype.valueOf, "arr.valueOf !== Object.prototype.valueOf");
562 ok(arr === arr.valueOf(), "arr !== arr.valueOf");
564 var num = new Number(6);
565 arr = [0,1,2];
566 tmp = arr.concat(3, [4,5], num);
567 ok(tmp !== arr, "tmp === arr");
568 for(var i=0; i<6; i++)
569     ok(tmp[i] === i, "tmp[" + i + "] = " + tmp[i]);
570 ok(tmp[6] === num, "tmp[6] !== num");
571 ok(tmp.length === 7, "tmp.length = " + tmp.length);
573 arr = [].concat();
574 ok(arr.length === 0, "arr.length = " + arr.length);
576 arr = [1,];
577 tmp = arr.concat([2]);
578 ok(tmp.length === 3, "tmp.length = " + tmp.length);
579 ok(tmp[1] === undefined, "tmp[1] = " + tmp[1]);
581 arr = [1,false,'a',null,undefined,'a'];
582 ok(arr.slice(0,6).toString() === "1,false,a,,,a", "arr.slice(0,6).toString() = " + arr.slice(0,6));
583 ok(arr.slice(0,6).length === 6, "arr.slice(0,6).length = " + arr.slice(0,6).length);
584 ok(arr.slice().toString() === "1,false,a,,,a", "arr.slice().toString() = " + arr.slice());
585 ok(arr.slice("abc").toString() === "1,false,a,,,a", "arr.slice(\"abc\").toString() = " + arr.slice("abc"));
586 ok(arr.slice(3,8).toString() === ",,a", "arr.slice(3,8).toString() = " + arr.slice(3,8));
587 ok(arr.slice(3,8).length === 3, "arr.slice(3,8).length = " + arr.slice(3,8).length);
588 ok(arr.slice(1).toString() === "false,a,,,a", "arr.slice(1).toString() = " + arr.slice(1));
589 ok(arr.slice(-2).toString() === ",a", "arr.slice(-2).toString() = " + arr.slice(-2));
590 ok(arr.slice(3,1).toString() === "", "arr.slice(3,1).toString() = " + arr.slice(3,1));
591 tmp = arr.slice(0,6);
592 for(var i=0; i < arr.length; i++)
593     ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
594 arr[12] = 2;
595 ok(arr.slice(5).toString() === "a,,,,,,,2", "arr.slice(5).toString() = " + arr.slice(5).toString());
596 ok(arr.slice(5).length === 8, "arr.slice(5).length = " + arr.slice(5).length);
598 var num = new Number(2);
599 ok(num.toString() === "2", "num(2).toString !== 2");
600 var num = new Number();
601 ok(num.toString() === "0", "num().toString !== 0");
603 ok(Number() === 0, "Number() = " + Number());
604 ok(Number(false) === 0, "Number(false) = " + Number(false));
605 ok(Number("43") === 43, "Number('43') = " + Number("43"));
607 tmp = (new Number(1)).valueOf();
608 ok(tmp === 1, "(new Number(1)).valueOf = " + tmp);
609 tmp = (new Number(1,2)).valueOf();
610 ok(tmp === 1, "(new Number(1,2)).valueOf = " + tmp);
611 tmp = (new Number()).valueOf();
612 ok(tmp === 0, "(new Number()).valueOf = " + tmp);
613 tmp = Number.prototype.valueOf();
614 ok(tmp === 0, "Number.prototype.valueOf = " + tmp);
616 function equals(val, base) {
617     var i;
618     var num = 0;
619     var str = val.toString(base);
621     for(i=0; i<str.length; i++) {
622         if(str.substring(i, i+1) == '(') break;
623         if(str.substring(i, i+1) == '.') break;
624         num = num*base + parseInt(str.substring(i, i+1));
625     }
627     if(str.substring(i, i+1) == '.') {
628         var mult = base;
629         for(i++; i<str.length; i++) {
630             if(str.substring(i, i+1) == '(') break;
631             num += parseInt(str.substring(i, i+1))/mult;
632             mult *= base;
633         }
634     }
636     if(str.substring(i, i+1) == '(') {
637         exp = parseInt(str.substring(i+2));
638         num *= Math.pow(base, exp);
639     }
641     ok(num>val-val/1000 && num<val+val/1000, "equals: num = " + num);
644 ok((10).toString(11) === "a", "(10).toString(11) = " + (10).toString(11));
645 ok((213213433).toString(17) === "8e2ddcb", "(213213433).toString(17) = " + (213213433).toString(17));
646 ok((-3254343).toString(33) === "-2oicf", "(-3254343).toString(33) = " + (-3254343).toString(33));
647 ok((NaN).toString(12) === "NaN", "(NaN).toString(11) = " + (NaN).toString(11));
648 ok((Infinity).toString(13) === "Infinity", "(Infinity).toString(11) = " + (Infinity).toString(11));
649 for(i=2; i<10; i++) {
650     equals(1.123, i);
651     equals(2305843009200000000, i);
652     equals(5.123, i);
653     equals(21711, i);
654     equals(1024*1024*1024*1024*1024*1024*1.9999, i);
655     equals(748382, i);
656     equals(0.6, i);
657     equals(4.65661287308e-10, i);
658     ok((0).toString(i) === "0", "(0).toString("+i+") = " + (0).toString(i));
661 ok(parseFloat('123') === 123, "parseFloat('123') = " + parseFloat('123'));
662 ok(parseFloat('-13.7') === -13.7, "parseFloat('-13.7') = " + parseFloat('-13.7'));
663 ok(parseFloat('-0.01e-2') === -0.01e-2, "parseFloat('-0.01e-2') = " + parseFloat('-0.01e-2'));
664 ok(parseFloat('-12e+5') === -12e+5, "parseFloat('-12e+5') = " + parseFloat('-12e+5'));
665 ok(parseFloat('1E5 not parsed') === 1E5, "parseFloat('1E5 not parsed') = " + parseFloat('1E5 not parsed'));
666 ok(isNaN(parseFloat('not a number')), "parseFloat('not a number') is not NaN");
667 ok(parseFloat('+13.2e-3') === 13.2e-3, "parseFloat('+13.2e-3') = " + parseFloat('+13.2e-3'));
668 ok(parseFloat('.12') === 0.12, "parseFloat('.12') = " + parseFloat('.12'));
669 ok(parseFloat('1e') === 1, "parseFloat('1e') = " + parseFloat('1e'));
671 tmp = Math.min(1);
672 ok(tmp === 1, "Math.min(1) = " + tmp);
674 tmp = Math.min(1, false);
675 ok(tmp === 0, "Math.min(1, false) = " + tmp);
677 tmp = Math.min();
678 ok(tmp === Infinity, "Math.min() = " + tmp);
680 tmp = Math.min(1, NaN, -Infinity, false);
681 ok(isNaN(tmp), "Math.min(1, NaN, -Infinity, false) is not NaN");
683 tmp = Math.min(1, false, true, null, -3);
684 ok(tmp === -3, "Math.min(1, false, true, null, -3) = " + tmp);
686 tmp = Math.max(1);
687 ok(tmp === 1, "Math.max(1) = " + tmp);
689 tmp = Math.max(true, 0);
690 ok(tmp === 1, "Math.max(true, 0) = " + tmp);
692 tmp = Math.max(-2, false, true, null, 1);
693 ok(tmp === 1, "Math.max(-2, false, true, null, 1) = " + tmp);
695 tmp = Math.max();
696 ok(tmp === -Infinity, "Math.max() = " + tmp);
698 tmp = Math.max(true, NaN, 0);
699 ok(isNaN(tmp), "Math.max(true, NaN, 0) is not NaN");
701 tmp = Math.round(0.5);
702 ok(tmp === 1, "Math.round(0.5) = " + tmp);
704 tmp = Math.round(-0.5);
705 ok(tmp === 0, "Math.round(-0.5) = " + tmp);
707 tmp = Math.round(1.1);
708 ok(tmp === 1, "Math.round(1.1) = " + tmp);
710 tmp = Math.round(true);
711 ok(tmp === 1, "Math.round(true) = " + tmp);
713 tmp = Math.round(1.1, 3, 4);
714 ok(tmp === 1, "Math.round(1.1, 3, 4) = " + tmp);
716 tmp = Math.round();
717 ok(isNaN(tmp), "Math.round() is not NaN");
719 tmp = Math.ceil(0.5);
720 ok(tmp === 1, "Math.ceil(0.5) = " + tmp);
722 tmp = Math.ceil(-0.5);
723 ok(tmp === 0, "Math.ceil(-0.5) = " + tmp);
725 tmp = Math.ceil(1.1);
726 ok(tmp === 2, "Math.round(1.1) = " + tmp);
728 tmp = Math.ceil(true);
729 ok(tmp === 1, "Math.ceil(true) = " + tmp);
731 tmp = Math.ceil(1.1, 3, 4);
732 ok(tmp === 2, "Math.ceil(1.1, 3, 4) = " + tmp);
734 tmp = Math.ceil();
735 ok(isNaN(tmp), "ceil() is not NaN");
737 tmp = Math.floor(0.5);
738 ok(tmp === 0, "Math.floor(0.5) = " + tmp);
740 tmp = Math.floor(-0.5);
741 ok(tmp === -1, "Math.floor(-0.5) = " + tmp);
743 tmp = Math.floor(1.1);
744 ok(tmp === 1, "Math.floor(1.1) = " + tmp);
746 tmp = Math.floor(true);
747 ok(tmp === 1, "Math.floor(true) = " + tmp);
749 tmp = Math.floor(1.1, 3, 4);
750 ok(tmp === 1, "Math.floor(1.1, 3, 4) = " + tmp);
752 tmp = Math.floor();
753 ok(isNaN(tmp), "floor is not NaN");
755 tmp = Math.abs(3);
756 ok(tmp === 3, "Math.abs(3) = " + tmp);
758 tmp = Math.abs(-3);
759 ok(tmp === 3, "Math.abs(-3) = " + tmp);
761 tmp = Math.abs(true);
762 ok(tmp === 1, "Math.abs(true) = " + tmp);
764 tmp = Math.abs();
765 ok(isNaN(tmp), "Math.abs() is not NaN");
767 tmp = Math.abs(NaN);
768 ok(isNaN(tmp), "Math.abs() is not NaN");
770 tmp = Math.abs(-Infinity);
771 ok(tmp === Infinity, "Math.abs(-Infinite) = " + tmp);
773 tmp = Math.abs(-3, 2);
774 ok(tmp === 3, "Math.abs(-3, 2) = " + tmp);
776 tmp = Math.cos(0);
777 ok(tmp === 1, "Math.cos(0) = " + tmp);
779 tmp = Math.cos(Math.PI/2);
780 ok(Math.floor(tmp*100) === 0, "Math.cos(Math.PI/2) = " + tmp);
782 tmp = Math.cos(-Math.PI/2);
783 ok(Math.floor(tmp*100) === 0, "Math.cos(-Math.PI/2) = " + tmp);
785 tmp = Math.cos(Math.PI/3, 2);
786 ok(Math.floor(tmp*100) === 50, "Math.cos(Math.PI/3, 2) = " + tmp);
788 tmp = Math.cos(true);
789 ok(Math.floor(tmp*100) === 54, "Math.cos(true) = " + tmp);
791 tmp = Math.cos(false);
792 ok(tmp === 1, "Math.cos(false) = " + tmp);
794 tmp = Math.cos();
795 ok(isNaN(tmp), "Math.cos() is not NaN");
797 tmp = Math.cos(NaN);
798 ok(isNaN(tmp), "Math.cos(NaN) is not NaN");
800 tmp = Math.cos(Infinity);
801 ok(isNaN(tmp), "Math.cos(Infinity) is not NaN");
803 tmp = Math.cos(-Infinity);
804 ok(isNaN(tmp), "Math.cos(-Infinity) is not NaN");
806 tmp = Math.pow(2, 2);
807 ok(tmp === 4, "Math.pow(2, 2) = " + tmp);
809 tmp = Math.pow(4, 0.5);
810 ok(tmp === 2, "Math.pow(2, 2) = " + tmp);
812 tmp = Math.pow(2, 2, 3);
813 ok(tmp === 4, "Math.pow(2, 2, 3) = " + tmp);
815 tmp = Math.pow(2);
816 ok(isNaN(tmp), "Math.pow(2) is not NaN");
818 tmp = Math.pow();
819 ok(isNaN(tmp), "Math.pow() is not NaN");
821 tmp = Math.random();
822 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
823 ok(0 <= tmp && tmp <= 1, "Math.random() = " + tmp);
825 tmp = Math.random(100);
826 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
827 ok(0 <= tmp && tmp <= 1, "Math.random(100) = " + tmp);
829 tmp = Math.acos(0);
830 ok(Math.floor(tmp*100) === 157, "Math.acos(0) = " + tmp);
832 tmp = Math.acos(1);
833 ok(Math.floor(tmp*100) === 0, "Math.acos(1) = " + tmp);
835 tmp = Math.acos(-1);
836 ok(Math.floor(tmp*100) === 314, "Math.acos(-1) = " + tmp);
838 tmp = Math.acos(Math.PI/4, 2);
839 ok(Math.floor(tmp*100) === 66, "Math.acos(Math.PI/4, 2) = " + tmp);
841 tmp = Math.acos(true);
842 ok(Math.floor(tmp*100) === 0, "Math.acos(true) = " + tmp);
844 tmp = Math.acos(false);
845 ok(Math.floor(tmp*100) === 157, "Math.acos(false) = " + tmp);
847 tmp = Math.acos(1.1);
848 ok(isNaN(tmp), "Math.acos(1.1) is not NaN");
850 tmp = Math.acos();
851 ok(isNaN(tmp), "Math.acos() is not NaN");
853 tmp = Math.acos(NaN);
854 ok(isNaN(tmp), "Math.acos(NaN) is not NaN");
856 tmp = Math.acos(Infinity);
857 ok(isNaN(tmp), "Math.acos(Infinity) is not NaN");
859 tmp = Math.acos(-Infinity);
860 ok(isNaN(tmp), "Math.acos(-Infinity) is not NaN");
862 tmp = Math.asin(0);
863 ok(Math.floor(tmp*100) === 0, "Math.asin(0) = " + tmp);
865 tmp = Math.asin(1);
866 ok(Math.floor(tmp*100) === 157, "Math.asin(1) = " + tmp);
868 tmp = Math.asin(-1);
869 ok(Math.floor(tmp*100) === -158, "Math.asin(-1) = " + tmp);
871 tmp = Math.asin(Math.PI/4, 2);
872 ok(Math.floor(tmp*100) === 90, "Math.asin(Math.PI/4, 2) = " + tmp);
874 tmp = Math.asin(true);
875 ok(Math.floor(tmp*100) === 157, "Math.asin(true) = " + tmp);
877 tmp = Math.asin(false);
878 ok(Math.floor(tmp*100) === 0, "Math.asin(false) = " + tmp);
880 tmp = Math.asin(1.1);
881 ok(isNaN(tmp), "Math.asin(1.1) is not NaN");
883 tmp = Math.asin();
884 ok(isNaN(tmp), "Math.asin() is not NaN");
886 tmp = Math.asin(NaN);
887 ok(isNaN(tmp), "Math.asin(NaN) is not NaN");
889 tmp = Math.asin(Infinity);
890 ok(isNaN(tmp), "Math.asin(Infinity) is not NaN");
892 tmp = Math.asin(-Infinity);
893 ok(isNaN(tmp), "Math.asin(-Infinity) is not NaN");
895 tmp = Math.atan(0);
896 ok(Math.floor(tmp*100) === 0, "Math.atan(0) = " + tmp);
898 tmp = Math.atan(1);
899 ok(Math.floor(tmp*100) === 78, "Math.atan(1) = " + tmp);
901 tmp = Math.atan(-1);
902 ok(Math.floor(tmp*100) === -79, "Math.atan(-1) = " + tmp);
904 tmp = Math.atan(true);
905 ok(Math.floor(tmp*100) === 78, "Math.atan(true) = " + tmp);
907 tmp = Math.atan(false);
908 ok(Math.floor(tmp*100) === 0, "Math.atan(false) = " + tmp);
910 tmp = Math.atan();
911 ok(isNaN(tmp), "Math.atan() is not NaN");
913 tmp = Math.atan(NaN);
914 ok(isNaN(tmp), "Math.atan(NaN) is not NaN");
916 tmp = Math.atan(Infinity);
917 ok(Math.floor(tmp*100) === 157, "Math.atan(Infinity) = " + tmp);
919 tmp = Math.atan(-Infinity);
920 ok(Math.floor(tmp*100) === -158, "Math.atan(Infinity) = " + tmp);
922 tmp = Math.atan2(0, 0);
923 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 0) = " + tmp);
925 tmp = Math.atan2(0, 1);
926 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 1) = " + tmp);
928 tmp = Math.atan2(0, Infinity);
929 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, Infinity) = " + tmp);
931 tmp = Math.atan2(0, -1);
932 ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -1) = " + tmp);
934 tmp = Math.atan2(0, -Infinity);
935 ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -Infinity) = " + tmp);
937 tmp = Math.atan2(1, 0);
938 ok(Math.floor(tmp*100) === 157, "Math.atan2(1, 0) = " + tmp);
940 tmp = Math.atan2(Infinity, 0);
941 ok(Math.floor(tmp*100) === 157, "Math.atan2(Infinity, 0) = " + tmp);
943 tmp = Math.atan2(-1, 0);
944 ok(Math.floor(tmp*100) === -158, "Math.atan2(-1, 0) = " + tmp);
946 tmp = Math.atan2(-Infinity, 0);
947 ok(Math.floor(tmp*100) === -158, "Math.atan2(-Infinity, 0) = " + tmp);
949 tmp = Math.atan2(1, 1);
950 ok(Math.floor(tmp*100) === 78, "Math.atan2(1, 1) = " + tmp);
952 tmp = Math.atan2(-1, -1);
953 ok(Math.floor(tmp*100) === -236, "Math.atan2(-1, -1) = " + tmp);
955 tmp = Math.atan2(-1, 1);
956 ok(Math.floor(tmp*100) === -79, "Math.atan2(-1, 1) = " + tmp);
958 tmp = Math.atan2(Infinity, Infinity);
959 ok(Math.floor(tmp*100) === 78, "Math.atan2(Infinity, Infinity) = " + tmp);
961 tmp = Math.atan2(Infinity, -Infinity, 1);
962 ok(Math.floor(tmp*100) === 235, "Math.atan2(Infinity, -Infinity, 1) = " + tmp);
964 tmp = Math.atan2();
965 ok(isNaN(tmp), "Math.atan2() is not NaN");
967 tmp = Math.atan2(1);
968 ok(isNaN(tmp), "Math.atan2(1) is not NaN");
970 tmp = Math.exp(0);
971 ok(tmp === 1, "Math.exp(0) = " + tmp);
973 tmp = Math.exp(1);
974 ok(Math.floor(tmp*100) === 271, "Math.exp(1) = " + tmp);
976 tmp = Math.exp(-1);
977 ok(Math.floor(tmp*100) === 36, "Math.exp(-1) = " + tmp);
979 tmp = Math.exp(true);
980 ok(Math.floor(tmp*100) === 271, "Math.exp(true) = " + tmp);
982 tmp = Math.exp(1, 1);
983 ok(Math.floor(tmp*100) === 271, "Math.exp(1, 1) = " + tmp);
985 tmp = Math.exp();
986 ok(isNaN(tmp), "Math.exp() is not NaN");
988 tmp = Math.exp(NaN);
989 ok(isNaN(tmp), "Math.exp(NaN) is not NaN");
991 tmp = Math.exp(Infinity);
992 ok(tmp === Infinity, "Math.exp(Infinity) = " + tmp);
994 tmp = Math.exp(-Infinity);
995 ok(tmp === 0, "Math.exp(-Infinity) = " + tmp);
997 tmp = Math.log(1);
998 ok(Math.floor(tmp*100) === 0, "Math.log(1) = " + tmp);
1000 tmp = Math.log(-1);
1001 ok(isNaN(tmp), "Math.log(-1) is not NaN");
1003 tmp = Math.log(true);
1004 ok(Math.floor(tmp*100) === 0, "Math.log(true) = " + tmp);
1006 tmp = Math.log(1, 1);
1007 ok(Math.floor(tmp*100) === 0, "Math.log(1, 1) = " + tmp);
1009 tmp = Math.log();
1010 ok(isNaN(tmp), "Math.log() is not NaN");
1012 tmp = Math.log(NaN);
1013 ok(isNaN(tmp), "Math.log(NaN) is not NaN");
1015 tmp = Math.log(Infinity);
1016 ok(tmp === Infinity, "Math.log(Infinity) = " + tmp);
1018 tmp = Math.log(-Infinity);
1019 ok(isNaN(tmp), "Math.log(-Infinity) is not NaN");
1021 tmp = Math.sin(0);
1022 ok(tmp === 0, "Math.sin(0) = " + tmp);
1024 tmp = Math.sin(Math.PI/2);
1025 ok(tmp === 1, "Math.sin(Math.PI/2) = " + tmp);
1027 tmp = Math.sin(-Math.PI/2);
1028 ok(tmp === -1, "Math.sin(-Math.PI/2) = " + tmp);
1030 tmp = Math.sin(Math.PI/3, 2);
1031 ok(Math.floor(tmp*100) === 86, "Math.sin(Math.PI/3, 2) = " + tmp);
1033 tmp = Math.sin(true);
1034 ok(Math.floor(tmp*100) === 84, "Math.sin(true) = " + tmp);
1036 tmp = Math.sin(false);
1037 ok(tmp === 0, "Math.sin(false) = " + tmp);
1039 tmp = Math.sin();
1040 ok(isNaN(tmp), "Math.sin() is not NaN");
1042 tmp = Math.sin(NaN);
1043 ok(isNaN(tmp), "Math.sin(NaN) is not NaN");
1045 tmp = Math.sin(Infinity);
1046 ok(isNaN(tmp), "Math.sin(Infinity) is not NaN");
1048 tmp = Math.sin(-Infinity);
1049 ok(isNaN(tmp), "Math.sin(-Infinity) is not NaN");
1051 tmp = Math.sqrt(0);
1052 ok(tmp === 0, "Math.sqrt(0) = " + tmp);
1054 tmp = Math.sqrt(4);
1055 ok(tmp === 2, "Math.sqrt(4) = " + tmp);
1057 tmp = Math.sqrt(-1);
1058 ok(isNaN(tmp), "Math.sqrt(-1) is not NaN");
1060 tmp = Math.sqrt(2, 2);
1061 ok(Math.floor(tmp*100) === 141, "Math.sqrt(2, 2) = " + tmp);
1063 tmp = Math.sqrt(true);
1064 ok(tmp === 1, "Math.sqrt(true) = " + tmp);
1066 tmp = Math.sqrt(false);
1067 ok(tmp === 0, "Math.sqrt(false) = " + tmp);
1069 tmp = Math.sqrt();
1070 ok(isNaN(tmp), "Math.sqrt() is not NaN");
1072 tmp = Math.sqrt(NaN);
1073 ok(isNaN(tmp), "Math.sqrt(NaN) is not NaN");
1075 tmp = Math.sqrt(Infinity);
1076 ok(tmp === Infinity, "Math.sqrt(Infinity) = " + tmp);
1078 tmp = Math.sqrt(-Infinity);
1079 ok(isNaN(tmp), "Math.sqrt(-Infinity) is not NaN");
1081 tmp = Math.tan(0);
1082 ok(tmp === 0, "Math.tan(0) = " + tmp);
1084 tmp = Math.tan(Math.PI);
1085 ok(Math.floor(tmp*100) === -1, "Math.tan(Math.PI) = " + tmp);
1087 tmp = Math.tan(2, 2);
1088 ok(Math.floor(tmp*100) === -219, "Math.tan(2, 2) = " + tmp);
1090 tmp = Math.tan(true);
1091 ok(Math.floor(tmp*100) === 155, "Math.tan(true) = " + tmp);
1093 tmp = Math.tan(false);
1094 ok(tmp === 0, "Math.tan(false) = " + tmp);
1096 tmp = Math.tan();
1097 ok(isNaN(tmp), "Math.tan() is not NaN");
1099 tmp = Math.tan(NaN);
1100 ok(isNaN(tmp), "Math.tan(NaN) is not NaN");
1102 tmp = Math.tan(Infinity);
1103 ok(isNaN(tmp), "Math.tan(Infinity) is not NaN");
1105 tmp = Math.tan(-Infinity);
1106 ok(isNaN(tmp), "Math.tan(-Infinity) is not NaN");
1108 var func = function  (a) {
1109         var a = 1;
1110         if(a) return;
1111     };
1112 ok(func.toString() === "function  (a) {\n        var a = 1;\n        if(a) return;\n    }",
1113    "func.toString() = " + func.toString());
1114 ok("" + func === "function  (a) {\n        var a = 1;\n        if(a) return;\n    }",
1115    "'' + func.toString() = " + func);
1117 ok(func.valueOf === Object.prototype.valueOf, "func.valueOf !== Object.prototype.valueOf");
1118 ok(func === func.valueOf(), "func !== func.valueOf()");
1120 function testFuncToString(x,y) {
1121     return x+y;
1123 ok(testFuncToString.toString() === "function testFuncToString(x,y) {\n    return x+y;\n}",
1124    "testFuncToString.toString() = " + testFuncToString.toString());
1125 ok("" + testFuncToString === "function testFuncToString(x,y) {\n    return x+y;\n}",
1126    "'' + testFuncToString = " + testFuncToString);
1128 var date = new Date();
1130 date = new Date(100);
1131 ok(date.getTime() === 100, "date.getTime() = " + date.getTime());
1132 ok(Date.prototype.getTime() === 0, "date.prototype.getTime() = " + Date.prototype.getTime());
1133 date = new Date(8.64e15);
1134 ok(date.getTime() === 8.64e15, "date.getTime() = " + date.getTime());
1135 date = new Date(8.64e15+1);
1136 ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
1137 date = new Date(Infinity);
1138 ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
1139 date = new Date("3 July 2009 22:28:00 UTC+0100");
1140 ok(date.getTime() === 1246656480000, "date.getTime() = " + date.getTime());
1141 date = new Date(1984, 11, 29, 13, 51, 24, 120);
1142 ok(date.getFullYear() === 1984, "date.getFullYear() = " + date.getFullYear());
1143 ok(date.getMonth() === 11, "date.getMonth() = " + date.getMonth());
1144 ok(date.getDate() === 29, "date.getDate() = " + date.getDate());
1145 ok(date.getHours() === 13, "date.getHours() = " + date.getHours());
1146 ok(date.getMinutes() === 51, "date.getMinutes() = " + date.getMinutes());
1147 ok(date.getSeconds() === 24, "date.getSeconds() = " + date.getSeconds());
1148 ok(date.getMilliseconds() === 120, "date.getMilliseconds() = " + date.getMilliseconds());
1149 date = new Date(731, -32, 40, -1, 70, 65, -13);
1150 ok(date.getFullYear() === 728, "date.getFullYear() = " + date.getFullYear());
1151 ok(date.getMonth() === 5, "date.getMonth() = " + date.getMonth());
1152 ok(date.getDate() === 9, "date.getDate() = " + date.getDate());
1153 ok(date.getHours() === 0, "date.getHours() = " + date.getHours());
1154 ok(date.getMinutes() === 11, "date.getMinutes() = " + date.getMinutes());
1155 ok(date.getSeconds() === 4, "date.getSeconds() = " + date.getSeconds());
1156 ok(date.getMilliseconds() === 987, "date.getMilliseconds() = " + date.getMilliseconds());
1158 ok(date.setTime(123) === 123, "date.setTime(123) !== 123");
1159 ok(date.setTime("123", NaN) === 123, "date.setTime(\"123\") !== 123");
1160 ok(isNaN(date.setTime(NaN)), "date.setTime(NaN) is not NaN");
1162 ok(date.setTime(0) === date.getTime(), "date.setTime(0) !== date.getTime()");
1163 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
1164 ok(date.getUTCMonth() === 0, "date.getUTCMonth() = " + date.getUTCMonth());
1165 ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
1166 ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
1167 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
1168 ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
1169 ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
1170 ok(date.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1171 date.setTime(60*24*60*60*1000);
1172 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
1173 ok(date.getUTCMonth() === 2, "date.getUTCMonth() = " + date.getUTCMonth());
1174 ok(date.getUTCDate() === 2, "date.getUTCDate() = " + date.getUTCDate());
1175 ok(date.getUTCDay() === 1, "date.getUTCDay() = " + date.getUTCDay());
1176 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
1177 ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
1178 ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
1179 ok(date.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1180 date.setTime(59*24*60*60*1000 + 4*365*24*60*60*1000 + 60*60*1000 + 2*60*1000 + 2*1000 + 640);
1181 ok(date.getUTCFullYear() === 1974, "date.getUTCFullYear() = " + date.getUTCFullYear());
1182 ok(date.getUTCMonth() === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1183 ok(date.getUTCMonth(123) === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1184 ok(date.getUTCDate() === 28, "date.getUTCDate() = " + date.getUTCDate());
1185 ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
1186 ok(date.getUTCHours() === 1, "date.getUTCHours() = " + date.getUTCHours());
1187 ok(date.getUTCMinutes() === 2, "date.getUTCMinutes() = " + date.getUTCMinutes());
1188 ok(date.getUTCSeconds() === 2, "date.getUTCSeconds() = " + date.getUTCSeconds());
1189 ok(date.getUTCMilliseconds() === 640, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1190 date.setTime(Infinity);
1191 ok(isNaN(date.getUTCFullYear()), "date.getUTCFullYear() is not NaN");
1192 ok(isNaN(date.getUTCMonth()), "date.getUTCMonth() is not NaN");
1193 ok(isNaN(date.getUTCDate()), "date.getUTCDate() is not NaN");
1194 ok(isNaN(date.getUTCDay()), "date.getUTCDay() is not NaN");
1195 ok(isNaN(date.getUTCHours()), "date.getUTCHours() is not NaN");
1196 ok(isNaN(date.getUTCMinutes()), "date.getUTCMinutes() is not NaN");
1197 ok(isNaN(date.getUTCSeconds()), "date.getUTCSeconds() is not NaN");
1198 ok(isNaN(date.getUTCMilliseconds()), "date.getUTCMilliseconds() is not NaN");
1199 ok(isNaN(date.setMilliseconds(0)), "date.setMilliseconds() is not NaN");
1201 date.setTime(0);
1202 date.setUTCMilliseconds(-10, 2);
1203 ok(date.getUTCMilliseconds() === 990, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1204 date.setUTCMilliseconds(10);
1205 ok(date.getUTCMilliseconds() === 10, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1206 date.setUTCSeconds(-10);
1207 ok(date.getUTCSeconds() === 50, "date.getUTCSeconds() = " + date.getUTCSeconds());
1208 date.setUTCMinutes(-10);
1209 ok(date.getUTCMinutes() === 50, "date.getUTCMinutes() = " + date.getUTCMinutes());
1210 date.setUTCHours(-10);
1211 ok(date.getUTCHours() === 14, "date.getUTCHours() = " + date.getUTCHours());
1212 date.setUTCHours(-123);
1213 ok(date.getTime() === -612549990, "date.getTime() = " + date.getTime());
1214 date.setUTCHours(20);
1215 ok(date.getUTCHours() === 20, "date.getUTCHours() = " + date.getUTCHours());
1216 date.setUTCDate(32);
1217 ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
1218 date.setUTCMonth(22, 37);
1219 ok(date.getTime() === 60987050010, "date.getTime() = " + date.getTime());
1220 date.setUTCFullYear(83, 21, 321);
1221 ok(date.getTime() === -59464984149990, "date.getTime() = " + date.getTime());
1222 ok(Math.abs(date) === 59464984149990, "Math.abs(date) = " + Math.abs(date));
1223 ok(getVT(date+1) === "VT_BSTR", "getVT(date+1) = " + getVT(date+1));
1225 ok(isNaN(Date.parse()), "Date.parse() is not NaN");
1226 ok(isNaN(Date.parse("")), "Date.parse(\"\") is not NaN");
1227 ok(isNaN(Date.parse("Jan Jan 20 2009")), "Date.parse(\"Jan Jan 20 2009\") is not NaN");
1228 ok(Date.parse("Jan 20 2009 UTC") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC\") = " + Date.parse("Jan 20 2009 UTC"));
1229 ok(Date.parse("Jan 20 2009 GMT") === 1232409600000, "Date.parse(\"Jan 20 2009 GMT\") = " + Date.parse("Jan 20 2009 GMT"));
1230 ok(Date.parse("Jan 20 2009 UTC-0") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC-0\") = " + Date.parse("Jan 20 2009 UTC-0"));
1231 ok(Date.parse("Jan 20 2009 UTC+0000") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC+0000\") = " + Date.parse("Jan 20 2009 UTC+0000"));
1232 ok(Date.parse("Ju 13 79 UTC") === 300672000000, "Date.parse(\"Ju 13 79 UTC\") = " + Date.parse("Ju 13 79 UTC"));
1233 ok(Date.parse("12Au91 UTC") === 681955200000, "Date.parse(\"12Au91 UTC\") = " + Date.parse("12Au91 UTC"));
1234 ok(Date.parse("7/02/17 UTC") === -1656806400000, "Date.parse(\"7/02/17 UTC\") = " + Date.parse("7/02/17 UTC"));
1235 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"));
1236 ok(Date.parse("February 31   UTC, 2000 12:31:17 PM") === 952000277000,
1237         "Date.parse(\"February 31   UTC, 2000 12:31:17 PM\") = " + Date.parse("February 31   UTC, 2000 12:31:17 PM"));
1238 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 "));
1239 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"));
1241 ok(typeof(Math.PI) === "number", "typeof(Math.PI) = " + typeof(Math.PI));
1242 ok(Math.floor(Math.PI*100) === 314, "Math.PI = " + Math.PI);
1243 Math.PI = "test";
1244 ok(Math.floor(Math.PI*100) === 314, "modified Math.PI = " + Math.PI);
1246 ok(typeof(Math.E) === "number", "typeof(Math.E) = " + typeof(Math.E));
1247 ok(Math.floor(Math.E*100) === 271, "Math.E = " + Math.E);
1248 Math.E = "test";
1249 ok(Math.floor(Math.E*100) === 271, "modified Math.E = " + Math.E);
1251 ok(typeof(Math.LOG2E) === "number", "typeof(Math.LOG2E) = " + typeof(Math.LOG2E));
1252 ok(Math.floor(Math.LOG2E*100) === 144, "Math.LOG2E = " + Math.LOG2E);
1253 Math.LOG2E = "test";
1254 ok(Math.floor(Math.LOG2E*100) === 144, "modified Math.LOG2E = " + Math.LOG2E);
1256 ok(typeof(Math.LOG10E) === "number", "typeof(Math.LOG10E) = " + typeof(Math.LOG10E));
1257 ok(Math.floor(Math.LOG10E*100) === 43, "Math.LOG10E = " + Math.LOG10E);
1258 Math.LOG10E = "test";
1259 ok(Math.floor(Math.LOG10E*100) === 43, "modified Math.LOG10E = " + Math.LOG10E);
1261 ok(typeof(Math.LN2) === "number", "typeof(Math.LN2) = " + typeof(Math.LN2));
1262 ok(Math.floor(Math.LN2*100) === 69, "Math.LN2 = " + Math.LN2);
1263 Math.LN2 = "test";
1264 ok(Math.floor(Math.LN2*100) === 69, "modified Math.LN2 = " + Math.LN2);
1266 ok(typeof(Math.LN10) === "number", "typeof(Math.LN10) = " + typeof(Math.LN10));
1267 ok(Math.floor(Math.LN10*100) === 230, "Math.LN10 = " + Math.LN10);
1268 Math.LN10 = "test";
1269 ok(Math.floor(Math.LN10*100) === 230, "modified Math.LN10 = " + Math.LN10);
1271 ok(typeof(Math.SQRT2) === "number", "typeof(Math.SQRT2) = " + typeof(Math.SQRT2));
1272 ok(Math.floor(Math.SQRT2*100) === 141, "Math.SQRT2 = " + Math.SQRT2);
1273 Math.SQRT2 = "test";
1274 ok(Math.floor(Math.SQRT2*100) === 141, "modified Math.SQRT2 = " + Math.SQRT2);
1276 ok(typeof(Math.SQRT1_2) === "number", "typeof(Math.SQRT1_2) = " + typeof(Math.SQRT1_2));
1277 ok(Math.floor(Math.SQRT1_2*100) === 70, "Math.SQRT1_2 = " + Math.SQRT1_2);
1278 Math.SQRT1_2 = "test";
1279 ok(Math.floor(Math.SQRT1_2*100) === 70, "modified Math.SQRT1_2 = " + Math.SQRT1_2);
1281 var bool = new Boolean();
1282 ok(bool.toString() === "false", "bool.toString() = " + bool.toString());
1283 var bool = new Boolean("false");
1284 ok(bool.toString() === "true", "bool.toString() = " + bool.toString());
1285 ok(bool.valueOf() === Boolean(1), "bool.valueOf() = " + bool.valueOf());
1286 ok(bool.toLocaleString() === bool.toString(), "bool.toLocaleString() = " + bool.toLocaleString());
1288 ok(Error.prototype !== TypeError.prototype, "Error.prototype === TypeError.prototype");
1289 ok(RangeError.prototype !== TypeError.prototype, "RangeError.prototype === TypeError.prototype");
1290 ok(Error.prototype.toLocaleString === Object.prototype.toLocaleString,
1291         "Error.prototype.toLocaleString !== Object.prototype.toLocaleString");
1292 err = new Error();
1293 ok(err.valueOf === Object.prototype.valueOf, "err.valueOf !== Object.prototype.valueOf");
1294 ok(Error.prototype.name === "Error", "Error.prototype.name = " + Error.prototype.name);
1295 ok(err.name === "Error", "err.name = " + err.name);
1296 EvalError.prototype.message = "test";
1297 ok(err.toString !== Object.prototype.toString, "err.toString === Object.prototype.toString");
1298 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1299 err = new EvalError();
1300 ok(EvalError.prototype.name === "EvalError", "EvalError.prototype.name = " + EvalError.prototype.name);
1301 ok(err.name === "EvalError", "err.name = " + err.name);
1302 ok(err.toString === Error.prototype.toString, "err.toString !== Error.prototype.toString");
1303 ok(err.message === "", "err.message != ''");
1304 err.message = date;
1305 ok(err.message === date, "err.message != date");
1306 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1307 ok(err.toString !== Object.prototype.toString, "err.toString === Object.prototype.toString");
1308 err = new RangeError();
1309 ok(RangeError.prototype.name === "RangeError", "RangeError.prototype.name = " + RangeError.prototype.name);
1310 ok(err.name === "RangeError", "err.name = " + err.name);
1311 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1312 err = new ReferenceError();
1313 ok(ReferenceError.prototype.name === "ReferenceError", "ReferenceError.prototype.name = " + ReferenceError.prototype.name);
1314 ok(err.name === "ReferenceError", "err.name = " + err.name);
1315 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1316 err = new SyntaxError();
1317 ok(SyntaxError.prototype.name === "SyntaxError", "SyntaxError.prototype.name = " + SyntaxError.prototype.name);
1318 ok(err.name === "SyntaxError", "err.name = " + err.name);
1319 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1320 err = new TypeError();
1321 ok(TypeError.prototype.name === "TypeError", "TypeError.prototype.name = " + TypeError.prototype.name);
1322 ok(err.name === "TypeError", "err.name = " + err.name);
1323 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1324 err = new URIError();
1325 ok(URIError.prototype.name === "URIError", "URIError.prototype.name = " + URIError.prototype.name);
1326 ok(err.name === "URIError", "err.name = " + err.name);
1327 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1328 err = new Error("message");
1329 ok(err.message === "message", "err.message !== 'message'");
1330 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1331 err = new Error(123);
1332 ok(err.number === 123, "err.number = " + err.number);
1333 err = new Error(0, "message");
1334 ok(err.number === 0, "err.number = " + err.number);
1335 ok(err.message === "message", "err.message = " + err.message);
1336 ok(err.description === "message", "err.description = " + err.description);
1338 function exception_test(func, type, number) {
1339     ret = "";
1340     num = "";
1341     try {
1342         func();
1343     } catch(e) {
1344         ret = e.name;
1345         num = e.number;
1346     }
1347     ok(ret === type, "Exception test, ret = " + ret + ", expected " + type +". Executed function: " + func.toString());
1348     ok(num === number, "Exception test, num = " + num + ", expected " + number + ". Executed function: " + func.toString());
1350 exception_test(function() {arr.toString = Date.prototype.toString; arr.toString();}, "TypeError", -2146823282);
1351 exception_test(function() {Array(-3);}, "RangeError", -2146823259);
1352 exception_test(function() {arr.toString = Boolean.prototype.toString; arr.toString();}, "TypeError", -2146823278);
1353 exception_test(function() {date.setTime();}, "TypeError", -2146827839);
1354 exception_test(function() {arr.test();}, "TypeError", -2146827850);
1355 exception_test(function() {arr.toString = Number.prototype.toString; arr.toString();}, "TypeError", -2146823287);
1356 exception_test(function() {(new Number(3)).toString(1);}, "TypeError", -2146828283);
1357 exception_test(function() {not_existing_variable.something();}, "TypeError", -2146823279);
1358 exception_test(function() {arr.toString = Function.prototype.toString; arr.toString();}, "TypeError", -2146823286);
1359 exception_test(function() {date();}, "TypeError", -2146823286);
1360 exception_test(function() {arr();}, "TypeError", -2146823286);
1361 exception_test(function() {eval("for(i=0;) {}");}, "SyntaxError", -2146827286);
1362 exception_test(function() {eval("function {};");}, "SyntaxError", -2146827283);
1363 exception_test(function() {eval("if");}, "SyntaxError", -2146827283);
1364 exception_test(function() {eval("do i=0; while");}, "SyntaxError", -2146827283);
1365 exception_test(function() {eval("while");}, "SyntaxError", -2146827283);
1366 exception_test(function() {eval("for");}, "SyntaxError", -2146827283);
1367 exception_test(function() {eval("with");}, "SyntaxError", -2146827283);
1368 exception_test(function() {eval("switch");}, "SyntaxError", -2146827283);
1369 exception_test(function() {eval("if(false");}, "SyntaxError", -2146827282);
1370 exception_test(function() {eval("for(i=0; i<10; i++");}, "SyntaxError", -2146827282);
1371 exception_test(function() {eval("while(true");}, "SyntaxError", -2146827282);
1372 exception_test(function() {test = function() {}}, "ReferenceError", -2146823280);
1373 exception_test(function() {eval("for(i=0")}, "SyntaxError", -2146827284);
1374 exception_test(function() {eval("for(i=0;i<10")}, "SyntaxError", -2146827284);
1375 exception_test(function() {eval("while(")}, "SyntaxError", -2146827286);
1376 exception_test(function() {eval("if(")}, "SyntaxError", -2146827286);
1377 exception_test(function() {eval("'unterminated")}, "SyntaxError", -2146827273);
1379 function testObjectInherit(obj, constr, ts, tls, vo) {
1380     ok(obj instanceof Object, "obj is not instance of Object");
1381     ok(obj instanceof constr, "obj is not instance of its constructor");
1383     ok(obj.hasOwnProperty === Object.prototype.hasOwnProperty,
1384        "obj.hasOwnProperty !== Object.prototype.hasOwnProprty");
1385     ok(obj.isPrototypeOf === Object.prototype.isPrototypeOf,
1386        "obj.isPrototypeOf !== Object.prototype.isPrototypeOf");
1387     ok(obj.propertyIsEnumerable === Object.prototype.propertyIsEnumerable,
1388        "obj.propertyIsEnumerable !== Object.prototype.propertyIsEnumerable");
1390     if(ts)
1391         ok(obj.toString === Object.prototype.toString,
1392            "obj.toString !== Object.prototype.toString");
1393     else
1394         ok(obj.toString != Object.prototype.toString,
1395            "obj.toString == Object.prototype.toString");
1397     if(tls)
1398         ok(obj.toLocaleString === Object.prototype.toLocaleString,
1399            "obj.toLocaleString !== Object.prototype.toLocaleString");
1400     else
1401         ok(obj.toLocaleString != Object.prototype.toLocaleString,
1402            "obj.toLocaleString == Object.prototype.toLocaleString");
1404     if(vo)
1405         ok(obj.valueOf === Object.prototype.valueOf,
1406            "obj.valueOf !== Object.prototype.valueOf");
1407     else
1408         ok(obj.valueOf != Object.prototype.valueOf,
1409            "obj.valueOf == Object.prototype.valueOf");
1411     ok(obj._test === "test", "obj.test = " + obj._test);
1414 Object.prototype._test = "test";
1415 testObjectInherit(new String("test"), String, false, true, false);
1416 testObjectInherit(/test/g, RegExp, false, true, true);
1417 testObjectInherit(new Number(1), Number, false, false, false);
1418 testObjectInherit(new Date(), Date, false, false, false);
1419 testObjectInherit(new Boolean(true), Boolean, false, true, false);
1420 testObjectInherit(new Array(), Array, false, false, true);
1421 testObjectInherit(new Error(), Error, false, true, true);
1422 testObjectInherit(testObjectInherit, Function, false, true, true);
1423 testObjectInherit(Math, Object, true, true, true);
1425 function testFunctions(obj, arr) {
1426     var l;
1428     for(var i=0; i<arr.length; i++) {
1429         l = obj[arr[i][0]].length;
1430         ok(l === arr[i][1], arr[i][0] + ".length = " + l);
1431     }
1434 testFunctions(Boolean.prototype, [
1435         ["valueOf", 0],
1436         ["toString", 0]
1437     ]);
1439 testFunctions(Number.prototype, [
1440         ["valueOf", 0],
1441         ["toString", 1],
1442         ["toExponential", 1],
1443         ["toLocaleString", 0],
1444         ["toPrecision", 1]
1445     ]);
1447 testFunctions(String.prototype, [
1448         ["valueOf", 0],
1449         ["toString", 0],
1450         ["anchor", 1],
1451         ["big", 0],
1452         ["blink", 0],
1453         ["bold", 0],
1454         ["charAt", 1],
1455         ["charCodeAt", 1],
1456         ["concat", 1],
1457         ["fixed", 0],
1458         ["fontcolor", 1],
1459         ["fontsize", 1],
1460         ["indexOf", 2],
1461         ["italics", 0],
1462         ["lastIndexOf", 2],
1463         ["link", 1],
1464         ["localeCompare", 1],
1465         ["match", 1],
1466         ["replace", 1],
1467         ["search", 0],
1468         ["slice", 0],
1469         ["small", 0],
1470         ["split", 2],
1471         ["strike", 0],
1472         ["sub", 0],
1473         ["substr", 2],
1474         ["substring", 2],
1475         ["sup", 0],
1476         ["toLocaleLowerCase", 0],
1477         ["toLocaleUpperCase", 0],
1478         ["toLowerCase", 0],
1479         ["toUpperCase", 0]
1480     ]);
1482 testFunctions(RegExp.prototype, [
1483         ["toString", 0],
1484         ["exec", 1],
1485         ["test", 1]
1486     ]);
1488 testFunctions(Date.prototype, [
1489         ["getDate", 0],
1490         ["getDay", 0],
1491         ["getFullYear", 0],
1492         ["getHours", 0],
1493         ["getMilliseconds", 0],
1494         ["getMinutes", 0],
1495         ["getMonth", 0],
1496         ["getSeconds", 0],
1497         ["getTime", 0],
1498         ["getTimezoneOffset", 0],
1499         ["getUTCDate", 0],
1500         ["getUTCDay", 0],
1501         ["getUTCFullYear", 0],
1502         ["getUTCHours", 0],
1503         ["getUTCMilliseconds", 0],
1504         ["getUTCMinutes", 0],
1505         ["getUTCMonth", 0],
1506         ["getUTCSeconds", 0],
1507         ["setDate", 1],
1508         ["setFullYear", 3],
1509         ["setHours", 4],
1510         ["setMilliseconds", 1],
1511         ["setMinutes", 3],
1512         ["setMonth", 2],
1513         ["setSeconds", 2],
1514         ["setTime", 1],
1515         ["setUTCDate", 1],
1516         ["setUTCFullYear", 3],
1517         ["setUTCHours", 4],
1518         ["setUTCMilliseconds", 1],
1519         ["setUTCMinutes", 3],
1520         ["setUTCMonth", 2],
1521         ["setUTCSeconds", 2],
1522         ["toDateString", 0],
1523         ["toLocaleDateString", 0],
1524         ["toLocaleString", 0],
1525         ["toLocaleTimeString", 0],
1526         ["toString", 0],
1527         ["toTimeString", 0],
1528         ["toUTCString", 0],
1529         ["valueOf", 0]
1530     ]);
1532 testFunctions(Array.prototype, [
1533         ["concat", 1],
1534         ["join", 1],
1535         ["push", 1],
1536         ["pop", 0],
1537         ["reverse", 0],
1538         ["shift", 0],
1539         ["slice", 2],
1540         ["sort", 1],
1541         ["splice", 2],
1542         ["toLocaleString", 0],
1543         ["toString", 0],
1544         ["unshift", 1]
1545     ]);
1547 testFunctions(Error.prototype, [
1548         ["toString", 0]
1549     ]);
1551 testFunctions(Math, [
1552         ["abs", 1],
1553         ["acos", 1],
1554         ["asin", 1],
1555         ["atan", 1],
1556         ["atan2", 2],
1557         ["ceil", 1],
1558         ["cos", 1],
1559         ["exp", 1],
1560         ["floor", 1],
1561         ["log", 1],
1562         ["max", 2],
1563         ["min", 2],
1564         ["pow", 2],
1565         ["random", 0],
1566         ["round", 1],
1567         ["sin", 1],
1568         ["sqrt", 1],
1569         ["tan", 1]
1570     ]);
1572 testFunctions(Object.prototype, [
1573         ["hasOwnProperty", 1],
1574         ["isPrototypeOf", 1],
1575         ["propertyIsEnumerable", 1],
1576         ["toLocaleString", 0],
1577         ["toString", 0],
1578         ["valueOf", 0]
1579     ]);
1581 testFunctions(Function.prototype, [
1582         ["apply", 2],
1583         ["call", 1],
1584         ["toString", 0]
1585     ]);
1587 reportSuccess();