2 * Copyright 2008 Jacek Caban for CodeWeavers
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.
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.
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
22 ok(i === 0, "parseInt('0') = " + i);
24 ok(i === 123, "parseInt('123') = " + i);
26 ok(i === -123, "parseInt('-123') = " + i);
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);
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);
57 ok(tmp === "undefined", "encodeURI() = " + tmp);
58 tmp = encodeURI("abc", "test");
59 ok(tmp === "abc", "encodeURI('abc') = " + tmp);
61 tmp = unescape("abc");
62 ok(tmp === "abc", "unescape('abc') = " + tmp);
64 ok(tmp === "", "unescape('') = " + tmp);
65 tmp = unescape("%%%");
66 ok(tmp === "%%%", "unescape('%%%') = " + tmp);
68 ok(tmp === "undefined", "unescape() = " + tmp);
69 tmp = unescape("%54%65s%u0074");
70 ok(tmp === "Test", "unescape('%54%65s%u0074') = " + tmp);
72 tmp = "" + new Object();
73 ok(tmp === "[object Object]", "'' + new Object() = " + tmp);
74 (tmp = new Array).f = Object.prototype.toString;
75 ok(tmp.f() === "[object Array]", "tmp.f() = " + tmp.f());
76 (tmp = new Boolean).f = Object.prototype.toString;
77 ok(tmp.f() === "[object Boolean]", "tmp.f() = " + tmp.f());
78 (tmp = new Date).f = Object.prototype.toString;
79 ok(tmp.f() === "[object Date]", "tmp.f() = " + tmp.f());
80 (tmp = function() {}).f = Object.prototype.toString;
81 ok(tmp.f() === "[object Function]", "tmp.f() = " + tmp.f());
82 Math.f = Object.prototype.toString;
83 ok(Math.f() === "[object Math]", "tmp.f() = " + tmp.f());
84 (tmp = new Number).f = Object.prototype.toString;
85 ok(tmp.f() === "[object Number]", "tmp.f() = " + tmp.f());
86 (tmp = new RegExp("")).f = Object.prototype.toString;
87 ok(tmp.f() === "[object RegExp]", "tmp.f() = " + tmp.f());
88 (tmp = new String).f = Object.prototype.toString;
89 ok(tmp.f() === "[object String]", "tmp.f() = " + tmp.f());
91 var obj = new Object();
92 obj.toString = function (x) {
93 ok(arguments.length === 0, "arguments.length = " + arguments.length);
96 ok((tmp = obj.toLocaleString()) === "test", "obj.toLocaleString() = " + tmp);
97 ok((tmp = obj.toLocaleString(1)) === "test", "obj.toLocaleString(1) = " + tmp);
99 ok("".length === 0, "\"\".length = " + "".length);
100 ok(getVT("".length) == "VT_I4", "\"\".length = " + "".length);
101 ok("abc".length === 3, "\"abc\".length = " + "abc".length);
102 ok(String.prototype.length === 0, "String.prototype.length = " + String.prototype.length);
105 ok(tmp === "", "''.toString() = " + tmp);
106 tmp = "test".toString();
107 ok(tmp === "test", "''.toString() = " + tmp);
108 tmp = "test".toString(3);
109 ok(tmp === "test", "''.toString(3) = " + tmp);
112 ok(tmp === "", "''.valueOf() = " + tmp);
113 tmp = "test".valueOf();
114 ok(tmp === "test", "''.valueOf() = " + tmp);
115 tmp = "test".valueOf(3);
116 ok(tmp === "test", "''.valueOf(3) = " + tmp);
118 var str = new String("test");
119 ok(str.toString() === "test", "str.toString() = " + str.toString());
120 var str = new String();
121 ok(str.toString() === "", "str.toString() = " + str.toString());
122 var str = new String("test", "abc");
123 ok(str.toString() === "test", "str.toString() = " + str.toString());
125 var strObj = new Object();
126 strObj.toString = function() { return "abcd" };
127 strObj.substr = String.prototype.substr;
128 strObj.lastIndexOf = String.prototype.lastIndexOf;
130 tmp = "value " + str;
131 ok(tmp === "value test", "'value ' + str = " + tmp);
134 ok(tmp === "", "String() = " + tmp);
136 ok(tmp === "false", "String(false) = " + tmp);
138 ok(tmp === "null", "String(null) = " + tmp);
139 tmp = String("test");
140 ok(tmp === "test", "String('test') = " + tmp);
141 tmp = String("test", "abc");
142 ok(tmp === "test", "String('test','abc') = " + tmp);
144 tmp = "abc".charAt(0);
145 ok(tmp === "a", "'abc',charAt(0) = " + tmp);
146 tmp = "abc".charAt(1);
147 ok(tmp === "b", "'abc',charAt(1) = " + tmp);
148 tmp = "abc".charAt(2);
149 ok(tmp === "c", "'abc',charAt(2) = " + tmp);
150 tmp = "abc".charAt(3);
151 ok(tmp === "", "'abc',charAt(3) = " + tmp);
152 tmp = "abc".charAt(4);
153 ok(tmp === "", "'abc',charAt(4) = " + tmp);
154 tmp = "abc".charAt();
155 ok(tmp === "a", "'abc',charAt() = " + tmp);
156 tmp = "abc".charAt(-1);
157 ok(tmp === "", "'abc',charAt(-1) = " + tmp);
158 tmp = "abc".charAt(0,2);
159 ok(tmp === "a", "'abc',charAt(0.2) = " + tmp);
161 tmp = "abc".charCodeAt(0);
162 ok(tmp === 0x61, "'abc'.charCodeAt(0) = " + tmp);
163 tmp = "abc".charCodeAt(1);
164 ok(tmp === 0x62, "'abc'.charCodeAt(1) = " + tmp);
165 tmp = "abc".charCodeAt(2);
166 ok(tmp === 0x63, "'abc'.charCodeAt(2) = " + tmp);
167 tmp = "abc".charCodeAt();
168 ok(tmp === 0x61, "'abc'.charCodeAt() = " + tmp);
169 tmp = "abc".charCodeAt(true);
170 ok(tmp === 0x62, "'abc'.charCodeAt(true) = " + tmp);
171 tmp = "abc".charCodeAt(0,2);
172 ok(tmp === 0x61, "'abc'.charCodeAt(0,2) = " + tmp);
174 tmp = "abcd".substring(1,3);
175 ok(tmp === "bc", "'abcd'.substring(1,3) = " + tmp);
176 tmp = "abcd".substring(-1,3);
177 ok(tmp === "abc", "'abcd'.substring(-1,3) = " + tmp);
178 tmp = "abcd".substring(1,6);
179 ok(tmp === "bcd", "'abcd'.substring(1,6) = " + tmp);
180 tmp = "abcd".substring(3,1);
181 ok(tmp === "bc", "'abcd'.substring(3,1) = " + tmp);
182 tmp = "abcd".substring(2,2);
183 ok(tmp === "", "'abcd'.substring(2,2) = " + tmp);
184 tmp = "abcd".substring(true,"3");
185 ok(tmp === "bc", "'abcd'.substring(true,'3') = " + tmp);
186 tmp = "abcd".substring(1,3,2);
187 ok(tmp === "bc", "'abcd'.substring(1,3,2) = " + tmp);
188 tmp = "abcd".substring();
189 ok(tmp === "abcd", "'abcd'.substring() = " + tmp);
191 tmp = "abcd".substr(1,3);
192 ok(tmp === "bcd", "'abcd'.substr(1,3) = " + tmp);
193 tmp = "abcd".substr(-1,3);
194 ok(tmp === "abc", "'abcd'.substr(-1,3) = " + tmp);
195 tmp = "abcd".substr(1,6);
196 ok(tmp === "bcd", "'abcd'.substr(1,6) = " + tmp);
197 tmp = "abcd".substr(2,-1);
198 ok(tmp === "", "'abcd'.substr(3,1) = " + tmp);
199 tmp = "abcd".substr(2,0);
200 ok(tmp === "", "'abcd'.substr(2,2) = " + tmp);
201 tmp = "abcd".substr(true,"3");
202 ok(tmp === "bcd", "'abcd'.substr(true,'3') = " + tmp);
203 tmp = "abcd".substr(1,3,2);
204 ok(tmp === "bcd", "'abcd'.substr(1,3,2) = " + tmp);
205 tmp = "abcd".substr();
206 ok(tmp === "abcd", "'abcd'.substr() = " + tmp);
207 tmp = strObj.substr(1,1);
208 ok(tmp === "b", "'abcd'.substr(1,3) = " + tmp);
210 tmp = "abcd".slice(1,3);
211 ok(tmp === "bc", "'abcd'.slice(1,3) = " + tmp);
212 tmp = "abcd".slice(1,-1);
213 ok(tmp === "bc", "'abcd'.slice(1,-1) = " + tmp);
214 tmp = "abcd".slice(-3,3);
215 ok(tmp === "bc", "'abcd'.slice(-3,3) = " + tmp);
216 tmp = "abcd".slice(-6,3);
217 ok(tmp === "abc", "'abcd'.slice(-6,3) = " + tmp);
218 tmp = "abcd".slice(3,1);
219 ok(tmp === "", "'abcd'.slice(3,1) = " + tmp);
220 tmp = "abcd".slice(true,3);
221 ok(tmp === "bc", "'abcd'.slice(true,3) = " + tmp);
222 tmp = "abcd".slice();
223 ok(tmp === "abcd", "'abcd'.slice() = " + tmp);
224 tmp = "abcd".slice(1);
225 ok(tmp === "bcd", "'abcd'.slice(1) = " + tmp);
227 tmp = "abc".concat(["d",1],2,false);
228 ok(tmp === "abcd,12false", "concat returned " + tmp);
229 var arr = new Array(2,"a");
230 arr.concat = String.prototype.concat;
231 tmp = arr.concat("d");
232 ok(tmp === "2,ad", "arr.concat = " + tmp);
234 m = "a+bcabc".match("a+");
235 ok(typeof(m) === "object", "typeof m is not object");
236 ok(m.length === 1, "m.length is not 1");
237 ok(m["0"] === "a", "m[0] is not \"ab\"");
239 r = "- [test] -".replace("[test]", "success");
240 ok(r === "- success -", "r = " + r + " expected '- success -'");
242 r = "- [test] -".replace("[test]", "success", "test");
243 ok(r === "- success -", "r = " + r + " expected '- success -'");
245 r = "test".replace();
246 ok(r === "test", "r = " + r + " expected 'test'");
248 function replaceFunc3(m, off, str) {
249 ok(arguments.length === 3, "arguments.length = " + arguments.length);
250 ok(m === "[test]", "m = " + m + " expected [test1]");
251 ok(off === 1, "off = " + off + " expected 0");
252 ok(str === "-[test]-", "str = " + arguments[3]);
256 r = "-[test]-".replace("[test]", replaceFunc3);
257 ok(r === "-ret-", "r = " + r + " expected '-ret-'");
259 r = "-[test]-".replace("[test]", replaceFunc3, "test");
260 ok(r === "-ret-", "r = " + r + " expected '-ret-'");
262 r = "1,2,3".split(",");
263 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
264 ok(r.length === 3, "r.length = " + r.length);
265 ok(r[0] === "1", "r[0] = " + r[0]);
266 ok(r[1] === "2", "r[1] = " + r[1]);
267 ok(r[2] === "3", "r[2] = " + r[2]);
270 r = "1,2,3".split(",*");
271 ok(r.length === 1, "r.length = " + r.length);
272 ok(r[0] === "1,2,3", "r[0] = " + r[0]);
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] === "3", "r[2] = " + r[2]);
281 ok(r.length === 2, "r.length = " + r.length);
282 ok(r[0] === "1", "r[0] = " + r[0]);
283 ok(r[1] === "3", "r[1] = " + r[1]);
285 r = "1,2,".split(",");
286 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
287 ok(r.length === 3, "r.length = " + r.length);
288 ok(r[0] === "1", "r[0] = " + r[0]);
289 ok(r[1] === "2", "r[1] = " + r[1]);
290 ok(r[2] === "", "r[2] = " + r[2]);
292 tmp = "abcd".indexOf("bc",0);
293 ok(tmp === 1, "indexOf = " + tmp);
294 tmp = "abcd".indexOf("bc",1);
295 ok(tmp === 1, "indexOf = " + tmp);
296 tmp = "abcd".indexOf("bc");
297 ok(tmp === 1, "indexOf = " + tmp);
298 tmp = "abcd".indexOf("ac");
299 ok(tmp === -1, "indexOf = " + tmp);
300 tmp = "abcd".indexOf("bc",2);
301 ok(tmp === -1, "indexOf = " + tmp);
302 tmp = "abcd".indexOf("a",0);
303 ok(tmp === 0, "indexOf = " + tmp);
304 tmp = "abcd".indexOf("bc",0,"test");
305 ok(tmp === 1, "indexOf = " + tmp);
306 tmp = "abcd".indexOf();
307 ok(tmp == -1, "indexOf = " + tmp);
309 tmp = "abcd".lastIndexOf("bc",1);
310 ok(tmp === 1, "lastIndexOf = " + tmp);
311 tmp = "abcd".lastIndexOf("bc",2);
312 ok(tmp === 1, "lastIndexOf = " + tmp);
313 tmp = "abcd".lastIndexOf("bc");
314 ok(tmp === 1, "lastIndexOf = " + tmp);
315 tmp = "abcd".lastIndexOf("ac");
316 ok(tmp === -1, "lastIndexOf = " + tmp);
317 tmp = "abcd".lastIndexOf("d",10);
318 ok(tmp === 3, "lastIndexOf = " + tmp);
319 tmp = "abcd".lastIndexOf("bc",0,"test");
320 ok(tmp === -1, "lastIndexOf = " + tmp);
321 tmp = "abcd".lastIndexOf();
322 ok(tmp === -1, "lastIndexOf = " + tmp);
323 tmp = "aaaa".lastIndexOf("a",2);
324 ok(tmp == 2, "lastIndexOf = " + tmp);
325 tmp = strObj.lastIndexOf("b");
326 ok(tmp === 1, "lastIndexOf = " + tmp);
328 tmp = "".toLowerCase();
329 ok(tmp === "", "''.toLowerCase() = " + tmp);
330 tmp = "test".toLowerCase();
331 ok(tmp === "test", "''.toLowerCase() = " + tmp);
332 tmp = "test".toLowerCase(3);
333 ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
334 tmp = "tEsT".toLowerCase();
335 ok(tmp === "test", "''.toLowerCase() = " + tmp);
336 tmp = "tEsT".toLowerCase(3);
337 ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
339 tmp = "".toUpperCase();
340 ok(tmp === "", "''.toUpperCase() = " + tmp);
341 tmp = "TEST".toUpperCase();
342 ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
343 tmp = "TEST".toUpperCase(3);
344 ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
345 tmp = "tEsT".toUpperCase();
346 ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
347 tmp = "tEsT".toUpperCase(3);
348 ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
351 ok(tmp === "<A NAME=\"undefined\"></A>", "''.anchor() = " + tmp);
353 ok(tmp === "<A NAME=\"3\"></A>", "''.anchor(3) = " + tmp);
354 tmp = "".anchor("red");
355 ok(tmp === "<A NAME=\"red\"></A>", "''.anchor('red') = " + tmp);
356 tmp = "test".anchor();
357 ok(tmp === "<A NAME=\"undefined\">test</A>", "'test'.anchor() = " + tmp);
358 tmp = "test".anchor(3);
359 ok(tmp === "<A NAME=\"3\">test</A>", "'test'.anchor(3) = " + tmp);
360 tmp = "test".anchor("green");
361 ok(tmp === "<A NAME=\"green\">test</A>", "'test'.anchor('green') = " + tmp);
364 ok(tmp === "<BIG></BIG>", "''.big() = " + tmp);
366 ok(tmp === "<BIG></BIG>", "''.big(3) = " + tmp);
368 ok(tmp === "<BIG>test</BIG>", "'test'.big() = " + tmp);
370 ok(tmp === "<BIG>test</BIG>", "'test'.big(3) = " + tmp);
373 ok(tmp === "<BLINK></BLINK>", "''.blink() = " + tmp);
375 ok(tmp === "<BLINK></BLINK>", "''.blink(3) = " + tmp);
376 tmp = "test".blink();
377 ok(tmp === "<BLINK>test</BLINK>", "'test'.blink() = " + tmp);
378 tmp = "test".blink(3);
379 ok(tmp === "<BLINK>test</BLINK>", "'test'.blink(3) = " + tmp);
382 ok(tmp === "<B></B>", "''.bold() = " + tmp);
384 ok(tmp === "<B></B>", "''.bold(3) = " + tmp);
386 ok(tmp === "<B>test</B>", "'test'.bold() = " + tmp);
387 tmp = "test".bold(3);
388 ok(tmp === "<B>test</B>", "'test'.bold(3) = " + tmp);
391 ok(tmp === "<TT></TT>", "''.fixed() = " + tmp);
393 ok(tmp === "<TT></TT>", "''.fixed(3) = " + tmp);
394 tmp = "test".fixed();
395 ok(tmp === "<TT>test</TT>", "'test'.fixed() = " + tmp);
396 tmp = "test".fixed(3);
397 ok(tmp === "<TT>test</TT>", "'test'.fixed(3) = " + tmp);
399 tmp = "".fontcolor();
400 ok(tmp === "<FONT COLOR=\"undefined\"></FONT>", "''.fontcolor() = " + tmp);
401 tmp = "".fontcolor(3);
402 ok(tmp === "<FONT COLOR=\"3\"></FONT>", "''.fontcolor(3) = " + tmp);
403 tmp = "".fontcolor("red");
404 ok(tmp === "<FONT COLOR=\"red\"></FONT>", "''.fontcolor('red') = " + tmp);
405 tmp = "test".fontcolor();
406 ok(tmp === "<FONT COLOR=\"undefined\">test</FONT>", "'test'.fontcolor() = " + tmp);
407 tmp = "test".fontcolor(3);
408 ok(tmp === "<FONT COLOR=\"3\">test</FONT>", "'test'.fontcolor(3) = " + tmp);
409 tmp = "test".fontcolor("green");
410 ok(tmp === "<FONT COLOR=\"green\">test</FONT>", "'test'.fontcolor('green') = " + tmp);
413 ok(tmp === "<FONT SIZE=\"undefined\"></FONT>", "''.fontsize() = " + tmp);
414 tmp = "".fontsize(3);
415 ok(tmp === "<FONT SIZE=\"3\"></FONT>", "''.fontsize(3) = " + tmp);
416 tmp = "".fontsize("red");
417 ok(tmp === "<FONT SIZE=\"red\"></FONT>", "''.fontsize('red') = " + tmp);
418 tmp = "test".fontsize();
419 ok(tmp === "<FONT SIZE=\"undefined\">test</FONT>", "'test'.fontsize() = " + tmp);
420 tmp = "test".fontsize(3);
421 ok(tmp === "<FONT SIZE=\"3\">test</FONT>", "'test'.fontsize(3) = " + tmp);
422 tmp = "test".fontsize("green");
423 ok(tmp === "<FONT SIZE=\"green\">test</FONT>", "'test'.fontsize('green') = " + tmp);
425 tmp = ("".fontcolor()).fontsize();
426 ok(tmp === "<FONT SIZE=\"undefined\"><FONT COLOR=\"undefined\"></FONT></FONT>", "(''.fontcolor()).fontsize() = " + tmp);
429 ok(tmp === "<I></I>", "''.italics() = " + tmp);
431 ok(tmp === "<I></I>", "''.italics(3) = " + tmp);
432 tmp = "test".italics();
433 ok(tmp === "<I>test</I>", "'test'.italics() = " + tmp);
434 tmp = "test".italics(3);
435 ok(tmp === "<I>test</I>", "'test'.italics(3) = " + tmp);
438 ok(tmp === "<A HREF=\"undefined\"></A>", "''.link() = " + tmp);
440 ok(tmp === "<A HREF=\"3\"></A>", "''.link(3) = " + tmp);
441 tmp = "".link("red");
442 ok(tmp === "<A HREF=\"red\"></A>", "''.link('red') = " + tmp);
444 ok(tmp === "<A HREF=\"undefined\">test</A>", "'test'.link() = " + tmp);
445 tmp = "test".link(3);
446 ok(tmp === "<A HREF=\"3\">test</A>", "'test'.link(3) = " + tmp);
447 tmp = "test".link("green");
448 ok(tmp === "<A HREF=\"green\">test</A>", "'test'.link('green') = " + tmp);
451 ok(tmp === "<SMALL></SMALL>", "''.small() = " + tmp);
453 ok(tmp === "<SMALL></SMALL>", "''.small(3) = " + tmp);
454 tmp = "test".small();
455 ok(tmp === "<SMALL>test</SMALL>", "'test'.small() = " + tmp);
456 tmp = "test".small(3);
457 ok(tmp === "<SMALL>test</SMALL>", "'test'.small(3) = " + tmp);
460 ok(tmp === "<STRIKE></STRIKE>", "''.strike() = " + tmp);
462 ok(tmp === "<STRIKE></STRIKE>", "''.strike(3) = " + tmp);
463 tmp = "test".strike();
464 ok(tmp === "<STRIKE>test</STRIKE>", "'test'.strike() = " + tmp);
465 tmp = "test".strike(3);
466 ok(tmp === "<STRIKE>test</STRIKE>", "'test'.strike(3) = " + tmp);
469 ok(tmp === "<SUB></SUB>", "''.sub() = " + tmp);
471 ok(tmp === "<SUB></SUB>", "''.sub(3) = " + tmp);
473 ok(tmp === "<SUB>test</SUB>", "'test'.sub() = " + tmp);
475 ok(tmp === "<SUB>test</SUB>", "'test'.sub(3) = " + tmp);
478 ok(tmp === "<SUP></SUP>", "''.sup() = " + tmp);
480 ok(tmp === "<SUP></SUP>", "''.sup(3) = " + tmp);
482 ok(tmp === "<SUP>test</SUP>", "'test'.sup() = " + tmp);
484 ok(tmp === "<SUP>test</SUP>", "'test'.sup(3) = " + tmp);
486 ok(String.fromCharCode() === "", "String.fromCharCode() = " + String.fromCharCode());
487 ok(String.fromCharCode(65,"66",67) === "ABC", "String.fromCharCode(65,'66',67) = " + String.fromCharCode(65,"66",67));
488 ok(String.fromCharCode(1024*64+65, -1024*64+65) === "AA",
489 "String.fromCharCode(1024*64+65, -1024*64+65) = " + String.fromCharCode(1024*64+65, -1024*64+65));
490 ok(String.fromCharCode(65, NaN, undefined).length === 3,
491 "String.fromCharCode(65, NaN, undefined).length = " + String.fromCharCode(65, NaN, undefined).length);
493 var arr = new Array();
494 ok(typeof(arr) === "object", "arr () is not object");
495 ok((arr.length === 0), "arr.length is not 0");
496 ok(arr["0"] === undefined, "arr[0] is not undefined");
498 var arr = new Array(1, 2, "test");
499 ok(typeof(arr) === "object", "arr (1,2,test) is not object");
500 ok((arr.length === 3), "arr.length is not 3");
501 ok(arr["0"] === 1, "arr[0] is not 1");
502 ok(arr["1"] === 2, "arr[1] is not 2");
503 ok(arr["2"] === "test", "arr[2] is not \"test\"");
506 ok((arr.length === 8), "arr.length is not 8");
509 ok(tmp === "", "'' + [] = " + tmp);
511 ok(tmp === "1,true", "'' + [1,true] = " + tmp);
513 var arr = new Array(6);
514 ok(typeof(arr) === "object", "arr (6) is not object");
515 ok((arr.length === 6), "arr.length is not 6");
516 ok(arr["0"] === undefined, "arr[0] is not undefined");
518 ok(arr.push() === 6, "arr.push() !== 6");
519 ok(arr.push(1) === 7, "arr.push(1) !== 7");
520 ok(arr[6] === 1, "arr[6] != 1");
521 ok(arr.length === 7, "arr.length != 10");
522 ok(arr.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10");
523 ok(arr[8] === "b", "arr[8] != 'b'");
524 ok(arr.length === 10, "arr.length != 10");
526 var arr = new Object();
527 arr.push = Array.prototype.push;
531 ok(arr.push() === 6, "arr.push() !== 6");
532 ok(arr.push(1) === 7, "arr.push(1) !== 7");
533 ok(arr[6] === 1, "arr[6] != 1");
534 ok(arr.length === 7, "arr.length != 10");
535 ok(arr.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10");
536 ok(arr[8] === "b", "arr[8] != 'b'");
537 ok(arr.length === 10, "arr.length != 10");
541 ok(arr.length === 2, "arr.length = " + arr.length);
542 ok(tmp === 5, "pop() = " + tmp);
544 ok(arr.length === 1, "arr.length = " + arr.length);
545 ok(tmp === 4, "pop() = " + tmp);
547 ok(arr.length === 0, "arr.length = " + arr.length);
548 ok(tmp === 3, "pop() = " + tmp);
550 ok(false, "not deleted " + tmp);
552 ok(arr.length === 0, "arr.length = " + arr.length);
553 ok(tmp === undefined, "tmp = " + tmp);
556 ok(arr.length === 5, "arr.length = " + arr.length);
557 ok(tmp === undefined, "tmp = " + tmp);
559 arr = [1,2,null,false,undefined,,"a"];
562 ok(tmp === "1,2,,false,,,a", "arr.join() = " + tmp);
564 ok(tmp === "1;2;;false;;;a", "arr.join(';') = " + tmp);
565 tmp = arr.join(";","test");
566 ok(tmp === "1;2;;false;;;a", "arr.join(';') = " + tmp);
568 ok(tmp === "12falsea", "arr.join('') = " + tmp);
570 tmp = arr.toString();
571 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
572 tmp = arr.toString("test");
573 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
575 arr = [5,true,2,-1,3,false,"2.5"];
576 tmp = arr.sort(function(x,y) { return y-x; });
577 ok(tmp === arr, "tmp !== arr");
578 tmp = [5,3,"2.5",2,true,false,-1];
579 for(var i=0; i < arr.length; i++)
580 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
582 arr = [5,false,2,0,"abc",3,"a",-1];
584 ok(tmp === arr, "tmp !== arr");
585 tmp = [-1,0,2,3,5,"a","abc",false];
586 for(var i=0; i < arr.length; i++)
587 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
589 arr = ["a", "b", "ab"];
590 tmp = ["a", "ab", "b"];
591 ok(arr.sort() === arr, "arr.sort() !== arr");
592 for(var i=0; i < arr.length; i++)
593 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
595 arr = ["1", "2", "3"];
597 ok(arr.length === 1, "arr.length = " + arr.length);
599 ok(arr.length === 3, "arr.length = " + arr.length);
600 ok(arr.toString() === "1,,", "arr.toString() = " + arr.toString());
602 arr = Array("a","b","c");
603 ok(arr.toString() === "a,b,c", "arr.toString() = " + arr.toString());
605 ok(arr.valueOf === Object.prototype.valueOf, "arr.valueOf !== Object.prototype.valueOf");
606 ok(arr === arr.valueOf(), "arr !== arr.valueOf");
609 tmp = arr.unshift(0);
610 ok(tmp === undefined, "[1,2,3].unshift(0) returned " +tmp);
611 ok(arr.length === 4, "arr.length = " + arr.length);
612 ok(arr.toString() === "0,1,2,3", "arr.toString() = " + arr.toString());
617 tmp = arr.unshift(-1,0);
618 ok(tmp === undefined, "unshift returned " +tmp);
619 ok(arr.length === 5, "arr.length = " + arr.length);
620 ok(arr.toString() === "-1,0,1,,3", "arr.toString() = " + arr.toString());
624 ok(tmp === undefined, "unshift returned " +tmp);
625 ok(arr.length === 3, "arr.length = " + arr.length);
626 ok(arr.toString() === "1,2,3", "arr.toString() = " + arr.toString());
632 tmp = Array.prototype.unshift.call(arr, 0);
633 ok(tmp === undefined, "unshift returned " +tmp);
634 ok(arr.length === 3, "arr.length = " + arr.length);
635 ok(arr[0] === 0 && arr[1] === 1 && arr[2] === 2, "unexpected array");
637 var num = new Number(6);
639 tmp = arr.concat(3, [4,5], num);
640 ok(tmp !== arr, "tmp === arr");
641 for(var i=0; i<6; i++)
642 ok(tmp[i] === i, "tmp[" + i + "] = " + tmp[i]);
643 ok(tmp[6] === num, "tmp[6] !== num");
644 ok(tmp.length === 7, "tmp.length = " + tmp.length);
647 ok(arr.length === 0, "arr.length = " + arr.length);
650 tmp = arr.concat([2]);
651 ok(tmp.length === 3, "tmp.length = " + tmp.length);
652 ok(tmp[1] === undefined, "tmp[1] = " + tmp[1]);
654 arr = [1,false,'a',null,undefined,'a'];
655 ok(arr.slice(0,6).toString() === "1,false,a,,,a", "arr.slice(0,6).toString() = " + arr.slice(0,6));
656 ok(arr.slice(0,6).length === 6, "arr.slice(0,6).length = " + arr.slice(0,6).length);
657 ok(arr.slice().toString() === "1,false,a,,,a", "arr.slice().toString() = " + arr.slice());
658 ok(arr.slice("abc").toString() === "1,false,a,,,a", "arr.slice(\"abc\").toString() = " + arr.slice("abc"));
659 ok(arr.slice(3,8).toString() === ",,a", "arr.slice(3,8).toString() = " + arr.slice(3,8));
660 ok(arr.slice(3,8).length === 3, "arr.slice(3,8).length = " + arr.slice(3,8).length);
661 ok(arr.slice(1).toString() === "false,a,,,a", "arr.slice(1).toString() = " + arr.slice(1));
662 ok(arr.slice(-2).toString() === ",a", "arr.slice(-2).toString() = " + arr.slice(-2));
663 ok(arr.slice(3,1).toString() === "", "arr.slice(3,1).toString() = " + arr.slice(3,1));
664 tmp = arr.slice(0,6);
665 for(var i=0; i < arr.length; i++)
666 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
668 ok(arr.slice(5).toString() === "a,,,,,,,2", "arr.slice(5).toString() = " + arr.slice(5).toString());
669 ok(arr.slice(5).length === 8, "arr.slice(5).length = " + arr.slice(5).length);
676 tmp = Array.prototype.slice.call(obj, 1, 2);
677 ok(tmp.length === 1, "tmp.length = " + tmp.length);
678 ok(tmp[0] === 2, "tmp[0] = " + tmp[0]);
680 var num = new Number(2);
681 ok(num.toString() === "2", "num(2).toString !== 2");
682 var num = new Number();
683 ok(num.toString() === "0", "num().toString !== 0");
685 ok(Number() === 0, "Number() = " + Number());
686 ok(Number(false) === 0, "Number(false) = " + Number(false));
687 ok(Number("43") === 43, "Number('43') = " + Number("43"));
689 tmp = (new Number(1)).valueOf();
690 ok(tmp === 1, "(new Number(1)).valueOf = " + tmp);
691 tmp = (new Number(1,2)).valueOf();
692 ok(tmp === 1, "(new Number(1,2)).valueOf = " + tmp);
693 tmp = (new Number()).valueOf();
694 ok(tmp === 0, "(new Number()).valueOf = " + tmp);
695 tmp = Number.prototype.valueOf();
696 ok(tmp === 0, "Number.prototype.valueOf = " + tmp);
698 function equals(val, base) {
701 var str = val.toString(base);
703 for(i=0; i<str.length; i++) {
704 if(str.substring(i, i+1) == '(') break;
705 if(str.substring(i, i+1) == '.') break;
706 num = num*base + parseInt(str.substring(i, i+1));
709 if(str.substring(i, i+1) == '.') {
711 for(i++; i<str.length; i++) {
712 if(str.substring(i, i+1) == '(') break;
713 num += parseInt(str.substring(i, i+1))/mult;
718 if(str.substring(i, i+1) == '(') {
719 exp = parseInt(str.substring(i+2));
720 num *= Math.pow(base, exp);
723 ok(num>val-val/1000 && num<val+val/1000, "equals: num = " + num);
726 ok((10).toString(11) === "a", "(10).toString(11) = " + (10).toString(11));
727 ok((213213433).toString(17) === "8e2ddcb", "(213213433).toString(17) = " + (213213433).toString(17));
728 ok((-3254343).toString(33) === "-2oicf", "(-3254343).toString(33) = " + (-3254343).toString(33));
729 ok((NaN).toString(12) === "NaN", "(NaN).toString(11) = " + (NaN).toString(11));
730 ok((Infinity).toString(13) === "Infinity", "(Infinity).toString(11) = " + (Infinity).toString(11));
731 for(i=2; i<10; i++) {
733 equals(2305843009200000000, i);
736 equals(1024*1024*1024*1024*1024*1024*1.9999, i);
739 equals(4.65661287308e-10, i);
740 ok((0).toString(i) === "0", "(0).toString("+i+") = " + (0).toString(i));
743 ok(parseFloat('123') === 123, "parseFloat('123') = " + parseFloat('123'));
744 ok(parseFloat('-13.7') === -13.7, "parseFloat('-13.7') = " + parseFloat('-13.7'));
745 ok(parseFloat('-0.01e-2') === -0.01e-2, "parseFloat('-0.01e-2') = " + parseFloat('-0.01e-2'));
746 ok(parseFloat('-12e+5') === -12e+5, "parseFloat('-12e+5') = " + parseFloat('-12e+5'));
747 ok(parseFloat('1E5 not parsed') === 1E5, "parseFloat('1E5 not parsed') = " + parseFloat('1E5 not parsed'));
748 ok(isNaN(parseFloat('not a number')), "parseFloat('not a number') is not NaN");
749 ok(parseFloat('+13.2e-3') === 13.2e-3, "parseFloat('+13.2e-3') = " + parseFloat('+13.2e-3'));
750 ok(parseFloat('.12') === 0.12, "parseFloat('.12') = " + parseFloat('.12'));
751 ok(parseFloat('1e') === 1, "parseFloat('1e') = " + parseFloat('1e'));
754 ok(tmp === 1, "Math.min(1) = " + tmp);
756 tmp = Math.min(1, false);
757 ok(tmp === 0, "Math.min(1, false) = " + tmp);
760 ok(tmp === Infinity, "Math.min() = " + tmp);
762 tmp = Math.min(1, NaN, -Infinity, false);
763 ok(isNaN(tmp), "Math.min(1, NaN, -Infinity, false) is not NaN");
765 tmp = Math.min(1, false, true, null, -3);
766 ok(tmp === -3, "Math.min(1, false, true, null, -3) = " + tmp);
769 ok(tmp === 1, "Math.max(1) = " + tmp);
771 tmp = Math.max(true, 0);
772 ok(tmp === 1, "Math.max(true, 0) = " + tmp);
774 tmp = Math.max(-2, false, true, null, 1);
775 ok(tmp === 1, "Math.max(-2, false, true, null, 1) = " + tmp);
778 ok(tmp === -Infinity, "Math.max() = " + tmp);
780 tmp = Math.max(true, NaN, 0);
781 ok(isNaN(tmp), "Math.max(true, NaN, 0) is not NaN");
783 tmp = Math.round(0.5);
784 ok(tmp === 1, "Math.round(0.5) = " + tmp);
786 tmp = Math.round(-0.5);
787 ok(tmp === 0, "Math.round(-0.5) = " + tmp);
789 tmp = Math.round(1.1);
790 ok(tmp === 1, "Math.round(1.1) = " + tmp);
792 tmp = Math.round(true);
793 ok(tmp === 1, "Math.round(true) = " + tmp);
795 tmp = Math.round(1.1, 3, 4);
796 ok(tmp === 1, "Math.round(1.1, 3, 4) = " + tmp);
799 ok(isNaN(tmp), "Math.round() is not NaN");
801 tmp = Math.ceil(0.5);
802 ok(tmp === 1, "Math.ceil(0.5) = " + tmp);
804 tmp = Math.ceil(-0.5);
805 ok(tmp === 0, "Math.ceil(-0.5) = " + tmp);
807 tmp = Math.ceil(1.1);
808 ok(tmp === 2, "Math.round(1.1) = " + tmp);
810 tmp = Math.ceil(true);
811 ok(tmp === 1, "Math.ceil(true) = " + tmp);
813 tmp = Math.ceil(1.1, 3, 4);
814 ok(tmp === 2, "Math.ceil(1.1, 3, 4) = " + tmp);
817 ok(isNaN(tmp), "ceil() is not NaN");
819 tmp = Math.floor(0.5);
820 ok(tmp === 0, "Math.floor(0.5) = " + tmp);
822 tmp = Math.floor(-0.5);
823 ok(tmp === -1, "Math.floor(-0.5) = " + tmp);
825 tmp = Math.floor(1.1);
826 ok(tmp === 1, "Math.floor(1.1) = " + tmp);
828 tmp = Math.floor(true);
829 ok(tmp === 1, "Math.floor(true) = " + tmp);
831 tmp = Math.floor(1.1, 3, 4);
832 ok(tmp === 1, "Math.floor(1.1, 3, 4) = " + tmp);
835 ok(isNaN(tmp), "floor is not NaN");
838 ok(tmp === 3, "Math.abs(3) = " + tmp);
841 ok(tmp === 3, "Math.abs(-3) = " + tmp);
843 tmp = Math.abs(true);
844 ok(tmp === 1, "Math.abs(true) = " + tmp);
847 ok(isNaN(tmp), "Math.abs() is not NaN");
850 ok(isNaN(tmp), "Math.abs() is not NaN");
852 tmp = Math.abs(-Infinity);
853 ok(tmp === Infinity, "Math.abs(-Infinite) = " + tmp);
855 tmp = Math.abs(-3, 2);
856 ok(tmp === 3, "Math.abs(-3, 2) = " + tmp);
859 ok(tmp === 1, "Math.cos(0) = " + tmp);
861 tmp = Math.cos(Math.PI/2);
862 ok(Math.floor(tmp*100) === 0, "Math.cos(Math.PI/2) = " + tmp);
864 tmp = Math.cos(-Math.PI/2);
865 ok(Math.floor(tmp*100) === 0, "Math.cos(-Math.PI/2) = " + tmp);
867 tmp = Math.cos(Math.PI/3, 2);
868 ok(Math.floor(tmp*100) === 50, "Math.cos(Math.PI/3, 2) = " + tmp);
870 tmp = Math.cos(true);
871 ok(Math.floor(tmp*100) === 54, "Math.cos(true) = " + tmp);
873 tmp = Math.cos(false);
874 ok(tmp === 1, "Math.cos(false) = " + tmp);
877 ok(isNaN(tmp), "Math.cos() is not NaN");
880 ok(isNaN(tmp), "Math.cos(NaN) is not NaN");
882 tmp = Math.cos(Infinity);
883 ok(isNaN(tmp), "Math.cos(Infinity) is not NaN");
885 tmp = Math.cos(-Infinity);
886 ok(isNaN(tmp), "Math.cos(-Infinity) is not NaN");
888 tmp = Math.pow(2, 2);
889 ok(tmp === 4, "Math.pow(2, 2) = " + tmp);
891 tmp = Math.pow(4, 0.5);
892 ok(tmp === 2, "Math.pow(2, 2) = " + tmp);
894 tmp = Math.pow(2, 2, 3);
895 ok(tmp === 4, "Math.pow(2, 2, 3) = " + tmp);
898 ok(isNaN(tmp), "Math.pow(2) is not NaN");
901 ok(isNaN(tmp), "Math.pow() is not NaN");
904 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
905 ok(0 <= tmp && tmp <= 1, "Math.random() = " + tmp);
907 tmp = Math.random(100);
908 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
909 ok(0 <= tmp && tmp <= 1, "Math.random(100) = " + tmp);
912 ok(Math.floor(tmp*100) === 157, "Math.acos(0) = " + tmp);
915 ok(Math.floor(tmp*100) === 0, "Math.acos(1) = " + tmp);
918 ok(Math.floor(tmp*100) === 314, "Math.acos(-1) = " + tmp);
920 tmp = Math.acos(Math.PI/4, 2);
921 ok(Math.floor(tmp*100) === 66, "Math.acos(Math.PI/4, 2) = " + tmp);
923 tmp = Math.acos(true);
924 ok(Math.floor(tmp*100) === 0, "Math.acos(true) = " + tmp);
926 tmp = Math.acos(false);
927 ok(Math.floor(tmp*100) === 157, "Math.acos(false) = " + tmp);
929 tmp = Math.acos(1.1);
930 ok(isNaN(tmp), "Math.acos(1.1) is not NaN");
933 ok(isNaN(tmp), "Math.acos() is not NaN");
935 tmp = Math.acos(NaN);
936 ok(isNaN(tmp), "Math.acos(NaN) is not NaN");
938 tmp = Math.acos(Infinity);
939 ok(isNaN(tmp), "Math.acos(Infinity) is not NaN");
941 tmp = Math.acos(-Infinity);
942 ok(isNaN(tmp), "Math.acos(-Infinity) is not NaN");
945 ok(Math.floor(tmp*100) === 0, "Math.asin(0) = " + tmp);
948 ok(Math.floor(tmp*100) === 157, "Math.asin(1) = " + tmp);
951 ok(Math.floor(tmp*100) === -158, "Math.asin(-1) = " + tmp);
953 tmp = Math.asin(Math.PI/4, 2);
954 ok(Math.floor(tmp*100) === 90, "Math.asin(Math.PI/4, 2) = " + tmp);
956 tmp = Math.asin(true);
957 ok(Math.floor(tmp*100) === 157, "Math.asin(true) = " + tmp);
959 tmp = Math.asin(false);
960 ok(Math.floor(tmp*100) === 0, "Math.asin(false) = " + tmp);
962 tmp = Math.asin(1.1);
963 ok(isNaN(tmp), "Math.asin(1.1) is not NaN");
966 ok(isNaN(tmp), "Math.asin() is not NaN");
968 tmp = Math.asin(NaN);
969 ok(isNaN(tmp), "Math.asin(NaN) is not NaN");
971 tmp = Math.asin(Infinity);
972 ok(isNaN(tmp), "Math.asin(Infinity) is not NaN");
974 tmp = Math.asin(-Infinity);
975 ok(isNaN(tmp), "Math.asin(-Infinity) is not NaN");
978 ok(Math.floor(tmp*100) === 0, "Math.atan(0) = " + tmp);
981 ok(Math.floor(tmp*100) === 78, "Math.atan(1) = " + tmp);
984 ok(Math.floor(tmp*100) === -79, "Math.atan(-1) = " + tmp);
986 tmp = Math.atan(true);
987 ok(Math.floor(tmp*100) === 78, "Math.atan(true) = " + tmp);
989 tmp = Math.atan(false);
990 ok(Math.floor(tmp*100) === 0, "Math.atan(false) = " + tmp);
993 ok(isNaN(tmp), "Math.atan() is not NaN");
995 tmp = Math.atan(NaN);
996 ok(isNaN(tmp), "Math.atan(NaN) is not NaN");
998 tmp = Math.atan(Infinity);
999 ok(Math.floor(tmp*100) === 157, "Math.atan(Infinity) = " + tmp);
1001 tmp = Math.atan(-Infinity);
1002 ok(Math.floor(tmp*100) === -158, "Math.atan(Infinity) = " + tmp);
1004 tmp = Math.atan2(0, 0);
1005 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 0) = " + tmp);
1007 tmp = Math.atan2(0, 1);
1008 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 1) = " + tmp);
1010 tmp = Math.atan2(0, Infinity);
1011 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, Infinity) = " + tmp);
1013 tmp = Math.atan2(0, -1);
1014 ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -1) = " + tmp);
1016 tmp = Math.atan2(0, -Infinity);
1017 ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -Infinity) = " + tmp);
1019 tmp = Math.atan2(1, 0);
1020 ok(Math.floor(tmp*100) === 157, "Math.atan2(1, 0) = " + tmp);
1022 tmp = Math.atan2(Infinity, 0);
1023 ok(Math.floor(tmp*100) === 157, "Math.atan2(Infinity, 0) = " + tmp);
1025 tmp = Math.atan2(-1, 0);
1026 ok(Math.floor(tmp*100) === -158, "Math.atan2(-1, 0) = " + tmp);
1028 tmp = Math.atan2(-Infinity, 0);
1029 ok(Math.floor(tmp*100) === -158, "Math.atan2(-Infinity, 0) = " + tmp);
1031 tmp = Math.atan2(1, 1);
1032 ok(Math.floor(tmp*100) === 78, "Math.atan2(1, 1) = " + tmp);
1034 tmp = Math.atan2(-1, -1);
1035 ok(Math.floor(tmp*100) === -236, "Math.atan2(-1, -1) = " + tmp);
1037 tmp = Math.atan2(-1, 1);
1038 ok(Math.floor(tmp*100) === -79, "Math.atan2(-1, 1) = " + tmp);
1040 tmp = Math.atan2(Infinity, Infinity);
1041 ok(Math.floor(tmp*100) === 78, "Math.atan2(Infinity, Infinity) = " + tmp);
1043 tmp = Math.atan2(Infinity, -Infinity, 1);
1044 ok(Math.floor(tmp*100) === 235, "Math.atan2(Infinity, -Infinity, 1) = " + tmp);
1047 ok(isNaN(tmp), "Math.atan2() is not NaN");
1049 tmp = Math.atan2(1);
1050 ok(isNaN(tmp), "Math.atan2(1) is not NaN");
1053 ok(tmp === 1, "Math.exp(0) = " + tmp);
1056 ok(Math.floor(tmp*100) === 271, "Math.exp(1) = " + tmp);
1059 ok(Math.floor(tmp*100) === 36, "Math.exp(-1) = " + tmp);
1061 tmp = Math.exp(true);
1062 ok(Math.floor(tmp*100) === 271, "Math.exp(true) = " + tmp);
1064 tmp = Math.exp(1, 1);
1065 ok(Math.floor(tmp*100) === 271, "Math.exp(1, 1) = " + tmp);
1068 ok(isNaN(tmp), "Math.exp() is not NaN");
1070 tmp = Math.exp(NaN);
1071 ok(isNaN(tmp), "Math.exp(NaN) is not NaN");
1073 tmp = Math.exp(Infinity);
1074 ok(tmp === Infinity, "Math.exp(Infinity) = " + tmp);
1076 tmp = Math.exp(-Infinity);
1077 ok(tmp === 0, "Math.exp(-Infinity) = " + tmp);
1080 ok(Math.floor(tmp*100) === 0, "Math.log(1) = " + tmp);
1083 ok(isNaN(tmp), "Math.log(-1) is not NaN");
1085 tmp = Math.log(true);
1086 ok(Math.floor(tmp*100) === 0, "Math.log(true) = " + tmp);
1088 tmp = Math.log(1, 1);
1089 ok(Math.floor(tmp*100) === 0, "Math.log(1, 1) = " + tmp);
1092 ok(isNaN(tmp), "Math.log() is not NaN");
1094 tmp = Math.log(NaN);
1095 ok(isNaN(tmp), "Math.log(NaN) is not NaN");
1097 tmp = Math.log(Infinity);
1098 ok(tmp === Infinity, "Math.log(Infinity) = " + tmp);
1100 tmp = Math.log(-Infinity);
1101 ok(isNaN(tmp), "Math.log(-Infinity) is not NaN");
1104 ok(tmp === 0, "Math.sin(0) = " + tmp);
1106 tmp = Math.sin(Math.PI/2);
1107 ok(tmp === 1, "Math.sin(Math.PI/2) = " + tmp);
1109 tmp = Math.sin(-Math.PI/2);
1110 ok(tmp === -1, "Math.sin(-Math.PI/2) = " + tmp);
1112 tmp = Math.sin(Math.PI/3, 2);
1113 ok(Math.floor(tmp*100) === 86, "Math.sin(Math.PI/3, 2) = " + tmp);
1115 tmp = Math.sin(true);
1116 ok(Math.floor(tmp*100) === 84, "Math.sin(true) = " + tmp);
1118 tmp = Math.sin(false);
1119 ok(tmp === 0, "Math.sin(false) = " + tmp);
1122 ok(isNaN(tmp), "Math.sin() is not NaN");
1124 tmp = Math.sin(NaN);
1125 ok(isNaN(tmp), "Math.sin(NaN) is not NaN");
1127 tmp = Math.sin(Infinity);
1128 ok(isNaN(tmp), "Math.sin(Infinity) is not NaN");
1130 tmp = Math.sin(-Infinity);
1131 ok(isNaN(tmp), "Math.sin(-Infinity) is not NaN");
1134 ok(tmp === 0, "Math.sqrt(0) = " + tmp);
1137 ok(tmp === 2, "Math.sqrt(4) = " + tmp);
1139 tmp = Math.sqrt(-1);
1140 ok(isNaN(tmp), "Math.sqrt(-1) is not NaN");
1142 tmp = Math.sqrt(2, 2);
1143 ok(Math.floor(tmp*100) === 141, "Math.sqrt(2, 2) = " + tmp);
1145 tmp = Math.sqrt(true);
1146 ok(tmp === 1, "Math.sqrt(true) = " + tmp);
1148 tmp = Math.sqrt(false);
1149 ok(tmp === 0, "Math.sqrt(false) = " + tmp);
1152 ok(isNaN(tmp), "Math.sqrt() is not NaN");
1154 tmp = Math.sqrt(NaN);
1155 ok(isNaN(tmp), "Math.sqrt(NaN) is not NaN");
1157 tmp = Math.sqrt(Infinity);
1158 ok(tmp === Infinity, "Math.sqrt(Infinity) = " + tmp);
1160 tmp = Math.sqrt(-Infinity);
1161 ok(isNaN(tmp), "Math.sqrt(-Infinity) is not NaN");
1164 ok(tmp === 0, "Math.tan(0) = " + tmp);
1166 tmp = Math.tan(Math.PI);
1167 ok(Math.floor(tmp*100) === -1, "Math.tan(Math.PI) = " + tmp);
1169 tmp = Math.tan(2, 2);
1170 ok(Math.floor(tmp*100) === -219, "Math.tan(2, 2) = " + tmp);
1172 tmp = Math.tan(true);
1173 ok(Math.floor(tmp*100) === 155, "Math.tan(true) = " + tmp);
1175 tmp = Math.tan(false);
1176 ok(tmp === 0, "Math.tan(false) = " + tmp);
1179 ok(isNaN(tmp), "Math.tan() is not NaN");
1181 tmp = Math.tan(NaN);
1182 ok(isNaN(tmp), "Math.tan(NaN) is not NaN");
1184 tmp = Math.tan(Infinity);
1185 ok(isNaN(tmp), "Math.tan(Infinity) is not NaN");
1187 tmp = Math.tan(-Infinity);
1188 ok(isNaN(tmp), "Math.tan(-Infinity) is not NaN");
1190 var func = function (a) {
1194 ok(func.toString() === "function (a) {\n var a = 1;\n if(a) return;\n }",
1195 "func.toString() = " + func.toString());
1196 ok("" + func === "function (a) {\n var a = 1;\n if(a) return;\n }",
1197 "'' + func.toString() = " + func);
1199 ok(func.valueOf === Object.prototype.valueOf, "func.valueOf !== Object.prototype.valueOf");
1200 ok(func === func.valueOf(), "func !== func.valueOf()");
1202 function testFuncToString(x,y) {
1205 ok(testFuncToString.toString() === "function testFuncToString(x,y) {\n return x+y;\n}",
1206 "testFuncToString.toString() = " + testFuncToString.toString());
1207 ok("" + testFuncToString === "function testFuncToString(x,y) {\n return x+y;\n}",
1208 "'' + testFuncToString = " + testFuncToString);
1212 function callTest(argc) {
1213 ok(this === tmp, "this !== tmp\n");
1214 ok(arguments.length === argc+1, "arguments.length = " + arguments.length + " expected " + (argc+1));
1215 for(var i=1; i <= argc; i++)
1216 ok(arguments[i] === i, "arguments[i] = " + arguments[i]);
1219 callTest.call(tmp, 1, 1);
1220 callTest.call(tmp, 2, 1, 2);
1222 callTest.apply(tmp, [1, 1]);
1223 callTest.apply(tmp, [2, 1, 2]);
1224 (function () { callTest.apply(tmp, arguments); })(2,1,2);
1226 function callTest2() {
1227 ok(this === tmp, "this !== tmp\n");
1228 ok(arguments.length === 0, "callTest2: arguments.length = " + arguments.length + " expected 0");
1231 callTest2.call(tmp);
1232 callTest2.apply(tmp, []);
1233 callTest2.apply(tmp);
1234 (function () { callTest2.apply(tmp, arguments); })();
1236 function callTest3() {
1237 ok(arguments.length === 0, "arguments.length = " + arguments.length + " expected 0");
1242 tmp = Number.prototype.toString.call(3);
1243 ok(tmp === "3", "Number.prototype.toString.call(3) = " + tmp);
1245 var date = new Date();
1247 date = new Date(100);
1248 ok(date.getTime() === 100, "date.getTime() = " + date.getTime());
1249 ok(Date.prototype.getTime() === 0, "date.prototype.getTime() = " + Date.prototype.getTime());
1250 date = new Date(8.64e15);
1251 ok(date.getTime() === 8.64e15, "date.getTime() = " + date.getTime());
1252 date = new Date(8.64e15+1);
1253 ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
1254 date = new Date(Infinity);
1255 ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
1256 date = new Date("3 July 2009 22:28:00 UTC+0100");
1257 ok(date.getTime() === 1246656480000, "date.getTime() = " + date.getTime());
1258 date = new Date(1984, 11, 29, 13, 51, 24, 120);
1259 ok(date.getFullYear() === 1984, "date.getFullYear() = " + date.getFullYear());
1260 ok(date.getMonth() === 11, "date.getMonth() = " + date.getMonth());
1261 ok(date.getDate() === 29, "date.getDate() = " + date.getDate());
1262 ok(date.getHours() === 13, "date.getHours() = " + date.getHours());
1263 ok(date.getMinutes() === 51, "date.getMinutes() = " + date.getMinutes());
1264 ok(date.getSeconds() === 24, "date.getSeconds() = " + date.getSeconds());
1265 ok(date.getMilliseconds() === 120, "date.getMilliseconds() = " + date.getMilliseconds());
1266 date = new Date(731, -32, 40, -1, 70, 65, -13);
1267 ok(date.getFullYear() === 728, "date.getFullYear() = " + date.getFullYear());
1268 ok(date.getMonth() === 5, "date.getMonth() = " + date.getMonth());
1269 ok(date.getDate() === 9, "date.getDate() = " + date.getDate());
1270 ok(date.getHours() === 0, "date.getHours() = " + date.getHours());
1271 ok(date.getMinutes() === 11, "date.getMinutes() = " + date.getMinutes());
1272 ok(date.getSeconds() === 4, "date.getSeconds() = " + date.getSeconds());
1273 ok(date.getMilliseconds() === 987, "date.getMilliseconds() = " + date.getMilliseconds());
1275 ok(date.setTime(123) === 123, "date.setTime(123) !== 123");
1276 ok(date.setTime("123", NaN) === 123, "date.setTime(\"123\") !== 123");
1277 ok(isNaN(date.setTime(NaN)), "date.setTime(NaN) is not NaN");
1279 ok(date.setTime(0) === date.getTime(), "date.setTime(0) !== date.getTime()");
1280 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
1281 ok(date.getUTCMonth() === 0, "date.getUTCMonth() = " + date.getUTCMonth());
1282 ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
1283 ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
1284 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
1285 ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
1286 ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
1287 ok(date.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1288 date.setTime(60*24*60*60*1000);
1289 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
1290 ok(date.getUTCMonth() === 2, "date.getUTCMonth() = " + date.getUTCMonth());
1291 ok(date.getUTCDate() === 2, "date.getUTCDate() = " + date.getUTCDate());
1292 ok(date.getUTCDay() === 1, "date.getUTCDay() = " + date.getUTCDay());
1293 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
1294 ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
1295 ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
1296 ok(date.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1297 date.setTime(59*24*60*60*1000 + 4*365*24*60*60*1000 + 60*60*1000 + 2*60*1000 + 2*1000 + 640);
1298 ok(date.getUTCFullYear() === 1974, "date.getUTCFullYear() = " + date.getUTCFullYear());
1299 ok(date.getUTCMonth() === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1300 ok(date.getUTCMonth(123) === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1301 ok(date.getUTCDate() === 28, "date.getUTCDate() = " + date.getUTCDate());
1302 ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
1303 ok(date.getUTCHours() === 1, "date.getUTCHours() = " + date.getUTCHours());
1304 ok(date.getUTCMinutes() === 2, "date.getUTCMinutes() = " + date.getUTCMinutes());
1305 ok(date.getUTCSeconds() === 2, "date.getUTCSeconds() = " + date.getUTCSeconds());
1306 ok(date.getUTCMilliseconds() === 640, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1307 date.setTime(Infinity);
1308 ok(isNaN(date.getUTCFullYear()), "date.getUTCFullYear() is not NaN");
1309 ok(isNaN(date.getUTCMonth()), "date.getUTCMonth() is not NaN");
1310 ok(isNaN(date.getUTCDate()), "date.getUTCDate() is not NaN");
1311 ok(isNaN(date.getUTCDay()), "date.getUTCDay() is not NaN");
1312 ok(isNaN(date.getUTCHours()), "date.getUTCHours() is not NaN");
1313 ok(isNaN(date.getUTCMinutes()), "date.getUTCMinutes() is not NaN");
1314 ok(isNaN(date.getUTCSeconds()), "date.getUTCSeconds() is not NaN");
1315 ok(isNaN(date.getUTCMilliseconds()), "date.getUTCMilliseconds() is not NaN");
1316 ok(isNaN(date.setMilliseconds(0)), "date.setMilliseconds() is not NaN");
1319 date.setUTCMilliseconds(-10, 2);
1320 ok(date.getUTCMilliseconds() === 990, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1321 date.setUTCMilliseconds(10);
1322 ok(date.getUTCMilliseconds() === 10, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1323 date.setUTCSeconds(-10);
1324 ok(date.getUTCSeconds() === 50, "date.getUTCSeconds() = " + date.getUTCSeconds());
1325 date.setUTCMinutes(-10);
1326 ok(date.getUTCMinutes() === 50, "date.getUTCMinutes() = " + date.getUTCMinutes());
1327 date.setUTCHours(-10);
1328 ok(date.getUTCHours() === 14, "date.getUTCHours() = " + date.getUTCHours());
1329 date.setUTCHours(-123);
1330 ok(date.getTime() === -612549990, "date.getTime() = " + date.getTime());
1331 date.setUTCHours(20);
1332 ok(date.getUTCHours() === 20, "date.getUTCHours() = " + date.getUTCHours());
1333 date.setUTCDate(32);
1334 ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
1335 date.setUTCMonth(22, 37);
1336 ok(date.getTime() === 60987050010, "date.getTime() = " + date.getTime());
1337 date.setUTCFullYear(83, 21, 321);
1338 ok(date.getTime() === -59464984149990, "date.getTime() = " + date.getTime());
1339 ok(Math.abs(date) === 59464984149990, "Math.abs(date) = " + Math.abs(date));
1340 ok(getVT(date+1) === "VT_BSTR", "getVT(date+1) = " + getVT(date+1));
1342 ok(isNaN(Date.parse()), "Date.parse() is not NaN");
1343 ok(isNaN(Date.parse("")), "Date.parse(\"\") is not NaN");
1344 ok(isNaN(Date.parse("Jan Jan 20 2009")), "Date.parse(\"Jan Jan 20 2009\") is not NaN");
1345 ok(Date.parse("Jan 20 2009 UTC") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC\") = " + Date.parse("Jan 20 2009 UTC"));
1346 ok(Date.parse("Jan 20 2009 GMT") === 1232409600000, "Date.parse(\"Jan 20 2009 GMT\") = " + Date.parse("Jan 20 2009 GMT"));
1347 ok(Date.parse("Jan 20 2009 UTC-0") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC-0\") = " + Date.parse("Jan 20 2009 UTC-0"));
1348 ok(Date.parse("Jan 20 2009 UTC+0000") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC+0000\") = " + Date.parse("Jan 20 2009 UTC+0000"));
1349 ok(Date.parse("Ju 13 79 UTC") === 300672000000, "Date.parse(\"Ju 13 79 UTC\") = " + Date.parse("Ju 13 79 UTC"));
1350 ok(Date.parse("12Au91 UTC") === 681955200000, "Date.parse(\"12Au91 UTC\") = " + Date.parse("12Au91 UTC"));
1351 ok(Date.parse("7/02/17 UTC") === -1656806400000, "Date.parse(\"7/02/17 UTC\") = " + Date.parse("7/02/17 UTC"));
1352 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"));
1353 ok(Date.parse("February 31 UTC, 2000 12:31:17 PM") === 952000277000,
1354 "Date.parse(\"February 31 UTC, 2000 12:31:17 PM\") = " + Date.parse("February 31 UTC, 2000 12:31:17 PM"));
1355 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 "));
1356 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"));
1358 ok(typeof(Math.PI) === "number", "typeof(Math.PI) = " + typeof(Math.PI));
1359 ok(Math.floor(Math.PI*100) === 314, "Math.PI = " + Math.PI);
1361 ok(Math.floor(Math.PI*100) === 314, "modified Math.PI = " + Math.PI);
1363 ok(typeof(Math.E) === "number", "typeof(Math.E) = " + typeof(Math.E));
1364 ok(Math.floor(Math.E*100) === 271, "Math.E = " + Math.E);
1366 ok(Math.floor(Math.E*100) === 271, "modified Math.E = " + Math.E);
1368 ok(typeof(Math.LOG2E) === "number", "typeof(Math.LOG2E) = " + typeof(Math.LOG2E));
1369 ok(Math.floor(Math.LOG2E*100) === 144, "Math.LOG2E = " + Math.LOG2E);
1370 Math.LOG2E = "test";
1371 ok(Math.floor(Math.LOG2E*100) === 144, "modified Math.LOG2E = " + Math.LOG2E);
1373 ok(typeof(Math.LOG10E) === "number", "typeof(Math.LOG10E) = " + typeof(Math.LOG10E));
1374 ok(Math.floor(Math.LOG10E*100) === 43, "Math.LOG10E = " + Math.LOG10E);
1375 Math.LOG10E = "test";
1376 ok(Math.floor(Math.LOG10E*100) === 43, "modified Math.LOG10E = " + Math.LOG10E);
1378 ok(typeof(Math.LN2) === "number", "typeof(Math.LN2) = " + typeof(Math.LN2));
1379 ok(Math.floor(Math.LN2*100) === 69, "Math.LN2 = " + Math.LN2);
1381 ok(Math.floor(Math.LN2*100) === 69, "modified Math.LN2 = " + Math.LN2);
1383 ok(typeof(Math.LN10) === "number", "typeof(Math.LN10) = " + typeof(Math.LN10));
1384 ok(Math.floor(Math.LN10*100) === 230, "Math.LN10 = " + Math.LN10);
1386 ok(Math.floor(Math.LN10*100) === 230, "modified Math.LN10 = " + Math.LN10);
1388 ok(typeof(Math.SQRT2) === "number", "typeof(Math.SQRT2) = " + typeof(Math.SQRT2));
1389 ok(Math.floor(Math.SQRT2*100) === 141, "Math.SQRT2 = " + Math.SQRT2);
1390 Math.SQRT2 = "test";
1391 ok(Math.floor(Math.SQRT2*100) === 141, "modified Math.SQRT2 = " + Math.SQRT2);
1393 ok(typeof(Math.SQRT1_2) === "number", "typeof(Math.SQRT1_2) = " + typeof(Math.SQRT1_2));
1394 ok(Math.floor(Math.SQRT1_2*100) === 70, "Math.SQRT1_2 = " + Math.SQRT1_2);
1395 Math.SQRT1_2 = "test";
1396 ok(Math.floor(Math.SQRT1_2*100) === 70, "modified Math.SQRT1_2 = " + Math.SQRT1_2);
1398 var bool = new Boolean();
1399 ok(bool.toString() === "false", "bool.toString() = " + bool.toString());
1400 var bool = new Boolean("false");
1401 ok(bool.toString() === "true", "bool.toString() = " + bool.toString());
1402 ok(bool.valueOf() === Boolean(1), "bool.valueOf() = " + bool.valueOf());
1403 ok(bool.toLocaleString() === bool.toString(), "bool.toLocaleString() = " + bool.toLocaleString());
1405 ok(Error.prototype !== TypeError.prototype, "Error.prototype === TypeError.prototype");
1406 ok(RangeError.prototype !== TypeError.prototype, "RangeError.prototype === TypeError.prototype");
1407 ok(Error.prototype.toLocaleString === Object.prototype.toLocaleString,
1408 "Error.prototype.toLocaleString !== Object.prototype.toLocaleString");
1410 ok(err.valueOf === Object.prototype.valueOf, "err.valueOf !== Object.prototype.valueOf");
1411 ok(Error.prototype.name === "Error", "Error.prototype.name = " + Error.prototype.name);
1412 ok(err.name === "Error", "err.name = " + err.name);
1413 EvalError.prototype.message = "test";
1414 ok(err.toString !== Object.prototype.toString, "err.toString === Object.prototype.toString");
1415 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1416 err = new EvalError();
1417 ok(EvalError.prototype.name === "EvalError", "EvalError.prototype.name = " + EvalError.prototype.name);
1418 ok(err.name === "EvalError", "err.name = " + err.name);
1419 ok(err.toString === Error.prototype.toString, "err.toString !== Error.prototype.toString");
1420 ok(err.message === "", "err.message != ''");
1422 ok(err.message === date, "err.message != date");
1423 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1424 ok(err.toString !== Object.prototype.toString, "err.toString === Object.prototype.toString");
1425 err = new RangeError();
1426 ok(RangeError.prototype.name === "RangeError", "RangeError.prototype.name = " + RangeError.prototype.name);
1427 ok(err.name === "RangeError", "err.name = " + err.name);
1428 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1429 err = new ReferenceError();
1430 ok(ReferenceError.prototype.name === "ReferenceError", "ReferenceError.prototype.name = " + ReferenceError.prototype.name);
1431 ok(err.name === "ReferenceError", "err.name = " + err.name);
1432 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1433 err = new SyntaxError();
1434 ok(SyntaxError.prototype.name === "SyntaxError", "SyntaxError.prototype.name = " + SyntaxError.prototype.name);
1435 ok(err.name === "SyntaxError", "err.name = " + err.name);
1436 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1437 err = new TypeError();
1438 ok(TypeError.prototype.name === "TypeError", "TypeError.prototype.name = " + TypeError.prototype.name);
1439 ok(err.name === "TypeError", "err.name = " + err.name);
1440 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1441 err = new URIError();
1442 ok(URIError.prototype.name === "URIError", "URIError.prototype.name = " + URIError.prototype.name);
1443 ok(err.name === "URIError", "err.name = " + err.name);
1444 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1445 err = new Error("message");
1446 ok(err.message === "message", "err.message !== 'message'");
1447 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1448 err = new Error(123);
1449 ok(err.number === 123, "err.number = " + err.number);
1450 err = new Error(0, "message");
1451 ok(err.number === 0, "err.number = " + err.number);
1452 ok(err.message === "message", "err.message = " + err.message);
1453 ok(err.description === "message", "err.description = " + err.description);
1455 function exception_test(func, type, number) {
1464 ok(ret === type, "Exception test, ret = " + ret + ", expected " + type +". Executed function: " + func.toString());
1465 ok(num === number, "Exception test, num = " + num + ", expected " + number + ". Executed function: " + func.toString());
1467 exception_test(function() {arr.toString = Date.prototype.toString; arr.toString();}, "TypeError", -2146823282);
1468 exception_test(function() {Array(-3);}, "RangeError", -2146823259);
1469 exception_test(function() {arr.toString = Boolean.prototype.toString; arr.toString();}, "TypeError", -2146823278);
1470 exception_test(function() {date.setTime();}, "TypeError", -2146827839);
1471 exception_test(function() {arr.test();}, "TypeError", -2146827850);
1472 exception_test(function() {arr.toString = Number.prototype.toString; arr.toString();}, "TypeError", -2146823287);
1473 exception_test(function() {(new Number(3)).toString(1);}, "TypeError", -2146828283);
1474 exception_test(function() {not_existing_variable.something();}, "TypeError", -2146823279);
1475 exception_test(function() {arr.toString = Function.prototype.toString; arr.toString();}, "TypeError", -2146823286);
1476 exception_test(function() {date();}, "TypeError", -2146823286);
1477 exception_test(function() {arr();}, "TypeError", -2146823286);
1478 exception_test(function() {eval("for(i=0;) {}");}, "SyntaxError", -2146827286);
1479 exception_test(function() {eval("function {};");}, "SyntaxError", -2146827283);
1480 exception_test(function() {eval("if");}, "SyntaxError", -2146827283);
1481 exception_test(function() {eval("do i=0; while");}, "SyntaxError", -2146827283);
1482 exception_test(function() {eval("while");}, "SyntaxError", -2146827283);
1483 exception_test(function() {eval("for");}, "SyntaxError", -2146827283);
1484 exception_test(function() {eval("with");}, "SyntaxError", -2146827283);
1485 exception_test(function() {eval("switch");}, "SyntaxError", -2146827283);
1486 exception_test(function() {eval("if(false");}, "SyntaxError", -2146827282);
1487 exception_test(function() {eval("for(i=0; i<10; i++");}, "SyntaxError", -2146827282);
1488 exception_test(function() {eval("while(true");}, "SyntaxError", -2146827282);
1489 exception_test(function() {test = function() {}}, "ReferenceError", -2146823280);
1490 exception_test(function() {eval("for(i=0")}, "SyntaxError", -2146827284);
1491 exception_test(function() {eval("for(i=0;i<10")}, "SyntaxError", -2146827284);
1492 exception_test(function() {eval("while(")}, "SyntaxError", -2146827286);
1493 exception_test(function() {eval("if(")}, "SyntaxError", -2146827286);
1494 exception_test(function() {eval("'unterminated")}, "SyntaxError", -2146827273);
1495 exception_test(function() {eval("nonexistingfunc()")}, "TypeError", -2146823537);
1497 function testObjectInherit(obj, constr, ts, tls, vo) {
1498 ok(obj instanceof Object, "obj is not instance of Object");
1499 ok(obj instanceof constr, "obj is not instance of its constructor");
1501 ok(obj.hasOwnProperty === Object.prototype.hasOwnProperty,
1502 "obj.hasOwnProperty !== Object.prototype.hasOwnProprty");
1503 ok(obj.isPrototypeOf === Object.prototype.isPrototypeOf,
1504 "obj.isPrototypeOf !== Object.prototype.isPrototypeOf");
1505 ok(obj.propertyIsEnumerable === Object.prototype.propertyIsEnumerable,
1506 "obj.propertyIsEnumerable !== Object.prototype.propertyIsEnumerable");
1509 ok(obj.toString === Object.prototype.toString,
1510 "obj.toString !== Object.prototype.toString");
1512 ok(obj.toString != Object.prototype.toString,
1513 "obj.toString == Object.prototype.toString");
1516 ok(obj.toLocaleString === Object.prototype.toLocaleString,
1517 "obj.toLocaleString !== Object.prototype.toLocaleString");
1519 ok(obj.toLocaleString != Object.prototype.toLocaleString,
1520 "obj.toLocaleString == Object.prototype.toLocaleString");
1523 ok(obj.valueOf === Object.prototype.valueOf,
1524 "obj.valueOf !== Object.prototype.valueOf");
1526 ok(obj.valueOf != Object.prototype.valueOf,
1527 "obj.valueOf == Object.prototype.valueOf");
1529 ok(obj._test === "test", "obj.test = " + obj._test);
1532 Object.prototype._test = "test";
1533 testObjectInherit(new String("test"), String, false, true, false);
1534 testObjectInherit(/test/g, RegExp, false, true, true);
1535 testObjectInherit(new Number(1), Number, false, false, false);
1536 testObjectInherit(new Date(), Date, false, false, false);
1537 testObjectInherit(new Boolean(true), Boolean, false, true, false);
1538 testObjectInherit(new Array(), Array, false, false, true);
1539 testObjectInherit(new Error(), Error, false, true, true);
1540 testObjectInherit(testObjectInherit, Function, false, true, true);
1541 testObjectInherit(Math, Object, true, true, true);
1543 (function() { testObjectInherit(arguments, Object, true, true, true); })();
1545 function testFunctions(obj, arr) {
1548 for(var i=0; i<arr.length; i++) {
1549 l = obj[arr[i][0]].length;
1550 ok(l === arr[i][1], arr[i][0] + ".length = " + l);
1554 testFunctions(Boolean.prototype, [
1559 testFunctions(Number.prototype, [
1562 ["toExponential", 1],
1563 ["toLocaleString", 0],
1567 testFunctions(String.prototype, [
1584 ["localeCompare", 1],
1596 ["toLocaleLowerCase", 0],
1597 ["toLocaleUpperCase", 0],
1602 testFunctions(RegExp.prototype, [
1608 testFunctions(Date.prototype, [
1613 ["getMilliseconds", 0],
1618 ["getTimezoneOffset", 0],
1621 ["getUTCFullYear", 0],
1623 ["getUTCMilliseconds", 0],
1624 ["getUTCMinutes", 0],
1626 ["getUTCSeconds", 0],
1630 ["setMilliseconds", 1],
1636 ["setUTCFullYear", 3],
1638 ["setUTCMilliseconds", 1],
1639 ["setUTCMinutes", 3],
1641 ["setUTCSeconds", 2],
1642 ["toDateString", 0],
1643 ["toLocaleDateString", 0],
1644 ["toLocaleString", 0],
1645 ["toLocaleTimeString", 0],
1647 ["toTimeString", 0],
1652 testFunctions(Array.prototype, [
1662 ["toLocaleString", 0],
1667 testFunctions(Error.prototype, [
1671 testFunctions(Math, [
1692 testFunctions(Object.prototype, [
1693 ["hasOwnProperty", 1],
1694 ["isPrototypeOf", 1],
1695 ["propertyIsEnumerable", 1],
1696 ["toLocaleString", 0],
1701 testFunctions(Function.prototype, [