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);
62 ok(tmp === "abc", "escape('abc') = " + tmp);
64 ok(tmp === "", "escape('') = " + tmp);
65 tmp = escape("a1b c!d+e@*-_+./,");
66 ok(tmp === "a1b%20c%21d+e@*-_+./%2C", "escape('a1b c!d+e@*-_+./,') = " + tmp);
68 ok(tmp === "undefined", "escape() = " + tmp);
70 tmp = unescape("abc");
71 ok(tmp === "abc", "unescape('abc') = " + tmp);
73 ok(tmp === "", "unescape('') = " + tmp);
74 tmp = unescape("%%%");
75 ok(tmp === "%%%", "unescape('%%%') = " + tmp);
77 ok(tmp === "undefined", "unescape() = " + tmp);
78 tmp = unescape("%54%65s%u0074");
79 ok(tmp === "Test", "unescape('%54%65s%u0074') = " + tmp);
81 tmp = "aA1~`!@#$%^&*()_+=-][{}';:/.,<>?\|";
82 ok(escape(tmp) === "aA1%7E%60%21@%23%24%25%5E%26*%28%29_+%3D-%5D%5B%7B%7D%27%3B%3A/.%2C%3C%3E%3F%7C", "escape('" + tmp + "') = " + escape(tmp));
83 ok(unescape(escape(tmp)) === tmp, "unescape(escape('" + tmp + "')) = " + unescape(escape(tmp)));
85 tmp = "" + new Object();
86 ok(tmp === "[object Object]", "'' + new Object() = " + tmp);
87 (tmp = new Array).f = Object.prototype.toString;
88 ok(tmp.f() === "[object Array]", "tmp.f() = " + tmp.f());
89 (tmp = new Boolean).f = Object.prototype.toString;
90 ok(tmp.f() === "[object Boolean]", "tmp.f() = " + tmp.f());
91 (tmp = new Date).f = Object.prototype.toString;
92 ok(tmp.f() === "[object Date]", "tmp.f() = " + tmp.f());
93 (tmp = function() {}).f = Object.prototype.toString;
94 ok(tmp.f() === "[object Function]", "tmp.f() = " + tmp.f());
95 Math.f = Object.prototype.toString;
96 ok(Math.f() === "[object Math]", "tmp.f() = " + tmp.f());
97 (tmp = new Number).f = Object.prototype.toString;
98 ok(tmp.f() === "[object Number]", "tmp.f() = " + tmp.f());
99 (tmp = new RegExp("")).f = Object.prototype.toString;
100 ok(tmp.f() === "[object RegExp]", "tmp.f() = " + tmp.f());
101 (tmp = new String).f = Object.prototype.toString;
102 ok(tmp.f() === "[object String]", "tmp.f() = " + tmp.f());
103 tmp = Object.prototype.toString.call(testObj);
104 ok(tmp === "[object Object]", "toString.call(testObj) = " + tmp);
105 tmp = Object.prototype.toString.call(this);
106 ok(tmp === "[object Object]", "toString.call(this) = " + tmp);
107 (function () { tmp = Object.prototype.toString.call(arguments); })();
108 ok(tmp === "[object Object]", "toString.call(arguments) = " + tmp);
110 ok(Object(1) instanceof Number, "Object(1) is not instance of Number");
111 ok(Object("") instanceof String, "Object('') is not instance of String");
112 ok(Object(false) instanceof Boolean, "Object(false) is not instance of Boolean");
115 ok(Object(obj) === obj, "Object(obj) !== obj");
117 ok(typeof(Object()) === "object", "typeof(Object()) !== 'object'");
118 ok(typeof(Object(undefined)) === "object", "typeof(Object(undefined)) !== 'object'");
119 ok(typeof(Object(null)) === "object", "typeof(Object(null)) !== 'object'");
121 var obj = new Object();
122 obj.toString = function (x) {
123 ok(arguments.length === 0, "arguments.length = " + arguments.length);
126 ok((tmp = obj.toLocaleString()) === "test", "obj.toLocaleString() = " + tmp);
127 ok((tmp = obj.toLocaleString(1)) === "test", "obj.toLocaleString(1) = " + tmp);
128 ok(obj === obj.valueOf(), "obj !== obj.valueOf");
130 ok("".length === 0, "\"\".length = " + "".length);
131 ok(getVT("".length) == "VT_I4", "\"\".length = " + "".length);
132 ok("abc".length === 3, "\"abc\".length = " + "abc".length);
133 ok(String.prototype.length === 0, "String.prototype.length = " + String.prototype.length);
136 ok(tmp === "", "''.toString() = " + tmp);
137 tmp = "test".toString();
138 ok(tmp === "test", "''.toString() = " + tmp);
139 tmp = "test".toString(3);
140 ok(tmp === "test", "''.toString(3) = " + tmp);
143 ok(tmp === "", "''.valueOf() = " + tmp);
144 tmp = "test".valueOf();
145 ok(tmp === "test", "''.valueOf() = " + tmp);
146 tmp = "test".valueOf(3);
147 ok(tmp === "test", "''.valueOf(3) = " + tmp);
149 var str = new String("test");
150 ok(str.toString() === "test", "str.toString() = " + str.toString());
151 var str = new String();
152 ok(str.toString() === "", "str.toString() = " + str.toString());
153 var str = new String("test", "abc");
154 ok(str.toString() === "test", "str.toString() = " + str.toString());
156 var strObj = new Object();
157 strObj.toString = function() { return "abcd" };
158 strObj.substr = String.prototype.substr;
159 strObj.lastIndexOf = String.prototype.lastIndexOf;
161 tmp = "value " + str;
162 ok(tmp === "value test", "'value ' + str = " + tmp);
165 ok(tmp === "", "String() = " + tmp);
167 ok(tmp === "false", "String(false) = " + tmp);
169 ok(tmp === "null", "String(null) = " + tmp);
170 tmp = String("test");
171 ok(tmp === "test", "String('test') = " + tmp);
172 tmp = String("test", "abc");
173 ok(tmp === "test", "String('test','abc') = " + tmp);
175 tmp = "abc".charAt(0);
176 ok(tmp === "a", "'abc',charAt(0) = " + tmp);
177 tmp = "abc".charAt(1);
178 ok(tmp === "b", "'abc',charAt(1) = " + tmp);
179 tmp = "abc".charAt(2);
180 ok(tmp === "c", "'abc',charAt(2) = " + tmp);
181 tmp = "abc".charAt(3);
182 ok(tmp === "", "'abc',charAt(3) = " + tmp);
183 tmp = "abc".charAt(4);
184 ok(tmp === "", "'abc',charAt(4) = " + tmp);
185 tmp = "abc".charAt();
186 ok(tmp === "a", "'abc',charAt() = " + tmp);
187 tmp = "abc".charAt(-1);
188 ok(tmp === "", "'abc',charAt(-1) = " + tmp);
189 tmp = "abc".charAt(0,2);
190 ok(tmp === "a", "'abc',charAt(0.2) = " + tmp);
192 tmp = "abc".charCodeAt(0);
193 ok(tmp === 0x61, "'abc'.charCodeAt(0) = " + tmp);
194 tmp = "abc".charCodeAt(1);
195 ok(tmp === 0x62, "'abc'.charCodeAt(1) = " + tmp);
196 tmp = "abc".charCodeAt(2);
197 ok(tmp === 0x63, "'abc'.charCodeAt(2) = " + tmp);
198 tmp = "abc".charCodeAt();
199 ok(tmp === 0x61, "'abc'.charCodeAt() = " + tmp);
200 tmp = "abc".charCodeAt(true);
201 ok(tmp === 0x62, "'abc'.charCodeAt(true) = " + tmp);
202 tmp = "abc".charCodeAt(0,2);
203 ok(tmp === 0x61, "'abc'.charCodeAt(0,2) = " + tmp);
205 tmp = "abcd".substring(1,3);
206 ok(tmp === "bc", "'abcd'.substring(1,3) = " + tmp);
207 tmp = "abcd".substring(-1,3);
208 ok(tmp === "abc", "'abcd'.substring(-1,3) = " + tmp);
209 tmp = "abcd".substring(1,6);
210 ok(tmp === "bcd", "'abcd'.substring(1,6) = " + tmp);
211 tmp = "abcd".substring(3,1);
212 ok(tmp === "bc", "'abcd'.substring(3,1) = " + tmp);
213 tmp = "abcd".substring(2,2);
214 ok(tmp === "", "'abcd'.substring(2,2) = " + tmp);
215 tmp = "abcd".substring(true,"3");
216 ok(tmp === "bc", "'abcd'.substring(true,'3') = " + tmp);
217 tmp = "abcd".substring(1,3,2);
218 ok(tmp === "bc", "'abcd'.substring(1,3,2) = " + tmp);
219 tmp = "abcd".substring();
220 ok(tmp === "abcd", "'abcd'.substring() = " + tmp);
222 tmp = "abcd".substr(1,3);
223 ok(tmp === "bcd", "'abcd'.substr(1,3) = " + tmp);
224 tmp = "abcd".substr(-1,3);
225 ok(tmp === "abc", "'abcd'.substr(-1,3) = " + tmp);
226 tmp = "abcd".substr(1,6);
227 ok(tmp === "bcd", "'abcd'.substr(1,6) = " + tmp);
228 tmp = "abcd".substr(2,-1);
229 ok(tmp === "", "'abcd'.substr(3,1) = " + tmp);
230 tmp = "abcd".substr(2,0);
231 ok(tmp === "", "'abcd'.substr(2,2) = " + tmp);
232 tmp = "abcd".substr(true,"3");
233 ok(tmp === "bcd", "'abcd'.substr(true,'3') = " + tmp);
234 tmp = "abcd".substr(1,3,2);
235 ok(tmp === "bcd", "'abcd'.substr(1,3,2) = " + tmp);
236 tmp = "abcd".substr();
237 ok(tmp === "abcd", "'abcd'.substr() = " + tmp);
238 tmp = strObj.substr(1,1);
239 ok(tmp === "b", "'abcd'.substr(1,3) = " + tmp);
241 tmp = "abcd".slice(1,3);
242 ok(tmp === "bc", "'abcd'.slice(1,3) = " + tmp);
243 tmp = "abcd".slice(1,-1);
244 ok(tmp === "bc", "'abcd'.slice(1,-1) = " + tmp);
245 tmp = "abcd".slice(-3,3);
246 ok(tmp === "bc", "'abcd'.slice(-3,3) = " + tmp);
247 tmp = "abcd".slice(-6,3);
248 ok(tmp === "abc", "'abcd'.slice(-6,3) = " + tmp);
249 tmp = "abcd".slice(3,1);
250 ok(tmp === "", "'abcd'.slice(3,1) = " + tmp);
251 tmp = "abcd".slice(true,3);
252 ok(tmp === "bc", "'abcd'.slice(true,3) = " + tmp);
253 tmp = "abcd".slice();
254 ok(tmp === "abcd", "'abcd'.slice() = " + tmp);
255 tmp = "abcd".slice(1);
256 ok(tmp === "bcd", "'abcd'.slice(1) = " + tmp);
258 tmp = "abc".concat(["d",1],2,false);
259 ok(tmp === "abcd,12false", "concat returned " + tmp);
260 var arr = new Array(2,"a");
261 arr.concat = String.prototype.concat;
262 tmp = arr.concat("d");
263 ok(tmp === "2,ad", "arr.concat = " + tmp);
265 m = "a+bcabc".match("a+");
266 ok(typeof(m) === "object", "typeof m is not object");
267 ok(m.length === 1, "m.length is not 1");
268 ok(m["0"] === "a", "m[0] is not \"ab\"");
270 r = "- [test] -".replace("[test]", "success");
271 ok(r === "- success -", "r = " + r + " expected '- success -'");
273 r = "- [test] -".replace("[test]", "success", "test");
274 ok(r === "- success -", "r = " + r + " expected '- success -'");
276 r = "test".replace();
277 ok(r === "test", "r = " + r + " expected 'test'");
279 function replaceFunc3(m, off, str) {
280 ok(arguments.length === 3, "arguments.length = " + arguments.length);
281 ok(m === "[test]", "m = " + m + " expected [test1]");
282 ok(off === 1, "off = " + off + " expected 0");
283 ok(str === "-[test]-", "str = " + arguments[3]);
287 r = "-[test]-".replace("[test]", replaceFunc3);
288 ok(r === "-ret-", "r = " + r + " expected '-ret-'");
290 r = "-[test]-".replace("[test]", replaceFunc3, "test");
291 ok(r === "-ret-", "r = " + r + " expected '-ret-'");
293 r = "1,2,3".split(",");
294 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
295 ok(r.length === 3, "r.length = " + r.length);
296 ok(r[0] === "1", "r[0] = " + r[0]);
297 ok(r[1] === "2", "r[1] = " + r[1]);
298 ok(r[2] === "3", "r[2] = " + r[2]);
301 r = "1,2,3".split(",*");
302 ok(r.length === 1, "r.length = " + r.length);
303 ok(r[0] === "1,2,3", "r[0] = " + r[0]);
306 ok(r.length === 3, "r.length = " + r.length);
307 ok(r[0] === "1", "r[0] = " + r[0]);
308 ok(r[1] === "2", "r[1] = " + r[1]);
309 ok(r[2] === "3", "r[2] = " + r[2]);
312 ok(r.length === 2, "r.length = " + r.length);
313 ok(r[0] === "1", "r[0] = " + r[0]);
314 ok(r[1] === "3", "r[1] = " + r[1]);
316 r = "1,2,".split(",");
317 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
318 ok(r.length === 3, "r.length = " + r.length);
319 ok(r[0] === "1", "r[0] = " + r[0]);
320 ok(r[1] === "2", "r[1] = " + r[1]);
321 ok(r[2] === "", "r[2] = " + r[2]);
323 tmp = "abcd".indexOf("bc",0);
324 ok(tmp === 1, "indexOf = " + tmp);
325 tmp = "abcd".indexOf("bc",1);
326 ok(tmp === 1, "indexOf = " + tmp);
327 tmp = "abcd".indexOf("bc");
328 ok(tmp === 1, "indexOf = " + tmp);
329 tmp = "abcd".indexOf("ac");
330 ok(tmp === -1, "indexOf = " + tmp);
331 tmp = "abcd".indexOf("bc",2);
332 ok(tmp === -1, "indexOf = " + tmp);
333 tmp = "abcd".indexOf("a",0);
334 ok(tmp === 0, "indexOf = " + tmp);
335 tmp = "abcd".indexOf("bc",0,"test");
336 ok(tmp === 1, "indexOf = " + tmp);
337 tmp = "abcd".indexOf();
338 ok(tmp == -1, "indexOf = " + tmp);
340 tmp = "abcd".lastIndexOf("bc",1);
341 ok(tmp === 1, "lastIndexOf = " + tmp);
342 tmp = "abcd".lastIndexOf("bc",2);
343 ok(tmp === 1, "lastIndexOf = " + tmp);
344 tmp = "abcd".lastIndexOf("bc");
345 ok(tmp === 1, "lastIndexOf = " + tmp);
346 tmp = "abcd".lastIndexOf("ac");
347 ok(tmp === -1, "lastIndexOf = " + tmp);
348 tmp = "abcd".lastIndexOf("d",10);
349 ok(tmp === 3, "lastIndexOf = " + tmp);
350 tmp = "abcd".lastIndexOf("bc",0,"test");
351 ok(tmp === -1, "lastIndexOf = " + tmp);
352 tmp = "abcd".lastIndexOf();
353 ok(tmp === -1, "lastIndexOf = " + tmp);
354 tmp = "aaaa".lastIndexOf("a",2);
355 ok(tmp == 2, "lastIndexOf = " + tmp);
356 tmp = strObj.lastIndexOf("b");
357 ok(tmp === 1, "lastIndexOf = " + tmp);
359 tmp = "".toLowerCase();
360 ok(tmp === "", "''.toLowerCase() = " + tmp);
361 tmp = "test".toLowerCase();
362 ok(tmp === "test", "''.toLowerCase() = " + tmp);
363 tmp = "test".toLowerCase(3);
364 ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
365 tmp = "tEsT".toLowerCase();
366 ok(tmp === "test", "''.toLowerCase() = " + tmp);
367 tmp = "tEsT".toLowerCase(3);
368 ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
370 tmp = "".toUpperCase();
371 ok(tmp === "", "''.toUpperCase() = " + tmp);
372 tmp = "TEST".toUpperCase();
373 ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
374 tmp = "TEST".toUpperCase(3);
375 ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
376 tmp = "tEsT".toUpperCase();
377 ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
378 tmp = "tEsT".toUpperCase(3);
379 ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
382 ok(tmp === "<A NAME=\"undefined\"></A>", "''.anchor() = " + tmp);
384 ok(tmp === "<A NAME=\"3\"></A>", "''.anchor(3) = " + tmp);
385 tmp = "".anchor("red");
386 ok(tmp === "<A NAME=\"red\"></A>", "''.anchor('red') = " + tmp);
387 tmp = "test".anchor();
388 ok(tmp === "<A NAME=\"undefined\">test</A>", "'test'.anchor() = " + tmp);
389 tmp = "test".anchor(3);
390 ok(tmp === "<A NAME=\"3\">test</A>", "'test'.anchor(3) = " + tmp);
391 tmp = "test".anchor("green");
392 ok(tmp === "<A NAME=\"green\">test</A>", "'test'.anchor('green') = " + tmp);
395 ok(tmp === "<BIG></BIG>", "''.big() = " + tmp);
397 ok(tmp === "<BIG></BIG>", "''.big(3) = " + tmp);
399 ok(tmp === "<BIG>test</BIG>", "'test'.big() = " + tmp);
401 ok(tmp === "<BIG>test</BIG>", "'test'.big(3) = " + tmp);
404 ok(tmp === "<BLINK></BLINK>", "''.blink() = " + tmp);
406 ok(tmp === "<BLINK></BLINK>", "''.blink(3) = " + tmp);
407 tmp = "test".blink();
408 ok(tmp === "<BLINK>test</BLINK>", "'test'.blink() = " + tmp);
409 tmp = "test".blink(3);
410 ok(tmp === "<BLINK>test</BLINK>", "'test'.blink(3) = " + tmp);
413 ok(tmp === "<B></B>", "''.bold() = " + tmp);
415 ok(tmp === "<B></B>", "''.bold(3) = " + tmp);
417 ok(tmp === "<B>test</B>", "'test'.bold() = " + tmp);
418 tmp = "test".bold(3);
419 ok(tmp === "<B>test</B>", "'test'.bold(3) = " + tmp);
422 ok(tmp === "<TT></TT>", "''.fixed() = " + tmp);
424 ok(tmp === "<TT></TT>", "''.fixed(3) = " + tmp);
425 tmp = "test".fixed();
426 ok(tmp === "<TT>test</TT>", "'test'.fixed() = " + tmp);
427 tmp = "test".fixed(3);
428 ok(tmp === "<TT>test</TT>", "'test'.fixed(3) = " + tmp);
430 tmp = "".fontcolor();
431 ok(tmp === "<FONT COLOR=\"undefined\"></FONT>", "''.fontcolor() = " + tmp);
432 tmp = "".fontcolor(3);
433 ok(tmp === "<FONT COLOR=\"3\"></FONT>", "''.fontcolor(3) = " + tmp);
434 tmp = "".fontcolor("red");
435 ok(tmp === "<FONT COLOR=\"red\"></FONT>", "''.fontcolor('red') = " + tmp);
436 tmp = "test".fontcolor();
437 ok(tmp === "<FONT COLOR=\"undefined\">test</FONT>", "'test'.fontcolor() = " + tmp);
438 tmp = "test".fontcolor(3);
439 ok(tmp === "<FONT COLOR=\"3\">test</FONT>", "'test'.fontcolor(3) = " + tmp);
440 tmp = "test".fontcolor("green");
441 ok(tmp === "<FONT COLOR=\"green\">test</FONT>", "'test'.fontcolor('green') = " + tmp);
444 ok(tmp === "<FONT SIZE=\"undefined\"></FONT>", "''.fontsize() = " + tmp);
445 tmp = "".fontsize(3);
446 ok(tmp === "<FONT SIZE=\"3\"></FONT>", "''.fontsize(3) = " + tmp);
447 tmp = "".fontsize("red");
448 ok(tmp === "<FONT SIZE=\"red\"></FONT>", "''.fontsize('red') = " + tmp);
449 tmp = "test".fontsize();
450 ok(tmp === "<FONT SIZE=\"undefined\">test</FONT>", "'test'.fontsize() = " + tmp);
451 tmp = "test".fontsize(3);
452 ok(tmp === "<FONT SIZE=\"3\">test</FONT>", "'test'.fontsize(3) = " + tmp);
453 tmp = "test".fontsize("green");
454 ok(tmp === "<FONT SIZE=\"green\">test</FONT>", "'test'.fontsize('green') = " + tmp);
456 tmp = ("".fontcolor()).fontsize();
457 ok(tmp === "<FONT SIZE=\"undefined\"><FONT COLOR=\"undefined\"></FONT></FONT>", "(''.fontcolor()).fontsize() = " + tmp);
460 ok(tmp === "<I></I>", "''.italics() = " + tmp);
462 ok(tmp === "<I></I>", "''.italics(3) = " + tmp);
463 tmp = "test".italics();
464 ok(tmp === "<I>test</I>", "'test'.italics() = " + tmp);
465 tmp = "test".italics(3);
466 ok(tmp === "<I>test</I>", "'test'.italics(3) = " + tmp);
469 ok(tmp === "<A HREF=\"undefined\"></A>", "''.link() = " + tmp);
471 ok(tmp === "<A HREF=\"3\"></A>", "''.link(3) = " + tmp);
472 tmp = "".link("red");
473 ok(tmp === "<A HREF=\"red\"></A>", "''.link('red') = " + tmp);
475 ok(tmp === "<A HREF=\"undefined\">test</A>", "'test'.link() = " + tmp);
476 tmp = "test".link(3);
477 ok(tmp === "<A HREF=\"3\">test</A>", "'test'.link(3) = " + tmp);
478 tmp = "test".link("green");
479 ok(tmp === "<A HREF=\"green\">test</A>", "'test'.link('green') = " + tmp);
482 ok(tmp === "<SMALL></SMALL>", "''.small() = " + tmp);
484 ok(tmp === "<SMALL></SMALL>", "''.small(3) = " + tmp);
485 tmp = "test".small();
486 ok(tmp === "<SMALL>test</SMALL>", "'test'.small() = " + tmp);
487 tmp = "test".small(3);
488 ok(tmp === "<SMALL>test</SMALL>", "'test'.small(3) = " + tmp);
491 ok(tmp === "<STRIKE></STRIKE>", "''.strike() = " + tmp);
493 ok(tmp === "<STRIKE></STRIKE>", "''.strike(3) = " + tmp);
494 tmp = "test".strike();
495 ok(tmp === "<STRIKE>test</STRIKE>", "'test'.strike() = " + tmp);
496 tmp = "test".strike(3);
497 ok(tmp === "<STRIKE>test</STRIKE>", "'test'.strike(3) = " + tmp);
500 ok(tmp === "<SUB></SUB>", "''.sub() = " + tmp);
502 ok(tmp === "<SUB></SUB>", "''.sub(3) = " + tmp);
504 ok(tmp === "<SUB>test</SUB>", "'test'.sub() = " + tmp);
506 ok(tmp === "<SUB>test</SUB>", "'test'.sub(3) = " + tmp);
509 ok(tmp === "<SUP></SUP>", "''.sup() = " + tmp);
511 ok(tmp === "<SUP></SUP>", "''.sup(3) = " + tmp);
513 ok(tmp === "<SUP>test</SUP>", "'test'.sup() = " + tmp);
515 ok(tmp === "<SUP>test</SUP>", "'test'.sup(3) = " + tmp);
517 ok(String.fromCharCode() === "", "String.fromCharCode() = " + String.fromCharCode());
518 ok(String.fromCharCode(65,"66",67) === "ABC", "String.fromCharCode(65,'66',67) = " + String.fromCharCode(65,"66",67));
519 ok(String.fromCharCode(1024*64+65, -1024*64+65) === "AA",
520 "String.fromCharCode(1024*64+65, -1024*64+65) = " + String.fromCharCode(1024*64+65, -1024*64+65));
521 ok(String.fromCharCode(65, NaN, undefined).length === 3,
522 "String.fromCharCode(65, NaN, undefined).length = " + String.fromCharCode(65, NaN, undefined).length);
524 var arr = new Array();
525 ok(typeof(arr) === "object", "arr () is not object");
526 ok((arr.length === 0), "arr.length is not 0");
527 ok(arr["0"] === undefined, "arr[0] is not undefined");
529 var arr = new Array(1, 2, "test");
530 ok(typeof(arr) === "object", "arr (1,2,test) is not object");
531 ok((arr.length === 3), "arr.length is not 3");
532 ok(arr["0"] === 1, "arr[0] is not 1");
533 ok(arr["1"] === 2, "arr[1] is not 2");
534 ok(arr["2"] === "test", "arr[2] is not \"test\"");
537 ok((arr.length === 8), "arr.length is not 8");
540 ok(tmp === "", "'' + [] = " + tmp);
542 ok(tmp === "1,true", "'' + [1,true] = " + tmp);
544 var arr = new Array(6);
545 ok(typeof(arr) === "object", "arr (6) is not object");
546 ok((arr.length === 6), "arr.length is not 6");
547 ok(arr["0"] === undefined, "arr[0] is not undefined");
549 ok(arr.push() === 6, "arr.push() !== 6");
550 ok(arr.push(1) === 7, "arr.push(1) !== 7");
551 ok(arr[6] === 1, "arr[6] != 1");
552 ok(arr.length === 7, "arr.length != 10");
553 ok(arr.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10");
554 ok(arr[8] === "b", "arr[8] != 'b'");
555 ok(arr.length === 10, "arr.length != 10");
557 var arr = new Object();
558 arr.push = Array.prototype.push;
562 ok(arr.push() === 6, "arr.push() !== 6");
563 ok(arr.push(1) === 7, "arr.push(1) !== 7");
564 ok(arr[6] === 1, "arr[6] != 1");
565 ok(arr.length === 7, "arr.length != 10");
566 ok(arr.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10");
567 ok(arr[8] === "b", "arr[8] != 'b'");
568 ok(arr.length === 10, "arr.length != 10");
572 ok(arr.length === 2, "arr.length = " + arr.length);
573 ok(tmp === 5, "pop() = " + tmp);
575 ok(arr.length === 1, "arr.length = " + arr.length);
576 ok(tmp === 4, "pop() = " + tmp);
578 ok(arr.length === 0, "arr.length = " + arr.length);
579 ok(tmp === 3, "pop() = " + tmp);
581 ok(false, "not deleted " + tmp);
583 ok(arr.length === 0, "arr.length = " + arr.length);
584 ok(tmp === undefined, "tmp = " + tmp);
587 ok(arr.length === 5, "arr.length = " + arr.length);
588 ok(tmp === undefined, "tmp = " + tmp);
590 arr = [1,2,null,false,undefined,,"a"];
593 ok(tmp === "1,2,,false,,,a", "arr.join() = " + tmp);
595 ok(tmp === "1;2;;false;;;a", "arr.join(';') = " + tmp);
596 tmp = arr.join(";","test");
597 ok(tmp === "1;2;;false;;;a", "arr.join(';') = " + tmp);
599 ok(tmp === "12falsea", "arr.join('') = " + tmp);
601 tmp = arr.toString();
602 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
603 tmp = arr.toString("test");
604 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
606 arr = [5,true,2,-1,3,false,"2.5"];
607 tmp = arr.sort(function(x,y) { return y-x; });
608 ok(tmp === arr, "tmp !== arr");
609 tmp = [5,3,"2.5",2,true,false,-1];
610 for(var i=0; i < arr.length; i++)
611 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
613 arr = [5,false,2,0,"abc",3,"a",-1];
615 ok(tmp === arr, "tmp !== arr");
616 tmp = [-1,0,2,3,5,"a","abc",false];
617 for(var i=0; i < arr.length; i++)
618 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
620 arr = ["a", "b", "ab"];
621 tmp = ["a", "ab", "b"];
622 ok(arr.sort() === arr, "arr.sort() !== arr");
623 for(var i=0; i < arr.length; i++)
624 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
626 arr = ["1", "2", "3"];
628 ok(arr.length === 1, "arr.length = " + arr.length);
630 ok(arr.length === 3, "arr.length = " + arr.length);
631 ok(arr.toString() === "1,,", "arr.toString() = " + arr.toString());
633 arr = Array("a","b","c");
634 ok(arr.toString() === "a,b,c", "arr.toString() = " + arr.toString());
636 ok(arr.valueOf === Object.prototype.valueOf, "arr.valueOf !== Object.prototype.valueOf");
637 ok(arr === arr.valueOf(), "arr !== arr.valueOf");
640 tmp = arr.unshift(0);
641 ok(tmp === undefined, "[1,2,3].unshift(0) returned " +tmp);
642 ok(arr.length === 4, "arr.length = " + arr.length);
643 ok(arr.toString() === "0,1,2,3", "arr.toString() = " + arr.toString());
648 tmp = arr.unshift(-1,0);
649 ok(tmp === undefined, "unshift returned " +tmp);
650 ok(arr.length === 5, "arr.length = " + arr.length);
651 ok(arr.toString() === "-1,0,1,,3", "arr.toString() = " + arr.toString());
655 ok(tmp === undefined, "unshift returned " +tmp);
656 ok(arr.length === 3, "arr.length = " + arr.length);
657 ok(arr.toString() === "1,2,3", "arr.toString() = " + arr.toString());
663 tmp = Array.prototype.unshift.call(arr, 0);
664 ok(tmp === undefined, "unshift returned " +tmp);
665 ok(arr.length === 3, "arr.length = " + arr.length);
666 ok(arr[0] === 0 && arr[1] === 1 && arr[2] === 2, "unexpected array");
670 ok(tmp === 1, "[1,2,,4].shift() = " + tmp);
671 ok(arr.toString() === "2,,4", "arr = " + arr.toString());
675 ok(tmp === undefined, "[].shift() = " + tmp);
676 ok(arr.toString() === "", "arr = " + arr.toString());
680 ok(tmp === 1, "[1,2,,4].shift(2) = " + tmp);
681 ok(arr.toString() === "2,,4", "arr = " + arr.toString());
685 ok(tmp === 1, "[1,].shift() = " + tmp);
686 ok(arr.toString() === "", "arr = " + arr.toString());
692 tmp = Array.prototype.shift.call(obj);
693 ok(tmp === "test", "obj.shift() = " + tmp);
694 ok(obj.length == 2, "obj.length = " + obj.length);
695 ok(obj[1] === 3, "obj[1] = " + obj[1]);
697 var num = new Number(6);
699 tmp = arr.concat(3, [4,5], num);
700 ok(tmp !== arr, "tmp === arr");
701 for(var i=0; i<6; i++)
702 ok(tmp[i] === i, "tmp[" + i + "] = " + tmp[i]);
703 ok(tmp[6] === num, "tmp[6] !== num");
704 ok(tmp.length === 7, "tmp.length = " + tmp.length);
707 ok(arr.length === 0, "arr.length = " + arr.length);
710 tmp = arr.concat([2]);
711 ok(tmp.length === 3, "tmp.length = " + tmp.length);
712 ok(tmp[1] === undefined, "tmp[1] = " + tmp[1]);
714 arr = [1,false,'a',null,undefined,'a'];
715 ok(arr.slice(0,6).toString() === "1,false,a,,,a", "arr.slice(0,6).toString() = " + arr.slice(0,6));
716 ok(arr.slice(0,6).length === 6, "arr.slice(0,6).length = " + arr.slice(0,6).length);
717 ok(arr.slice().toString() === "1,false,a,,,a", "arr.slice().toString() = " + arr.slice());
718 ok(arr.slice("abc").toString() === "1,false,a,,,a", "arr.slice(\"abc\").toString() = " + arr.slice("abc"));
719 ok(arr.slice(3,8).toString() === ",,a", "arr.slice(3,8).toString() = " + arr.slice(3,8));
720 ok(arr.slice(3,8).length === 3, "arr.slice(3,8).length = " + arr.slice(3,8).length);
721 ok(arr.slice(1).toString() === "false,a,,,a", "arr.slice(1).toString() = " + arr.slice(1));
722 ok(arr.slice(-2).toString() === ",a", "arr.slice(-2).toString() = " + arr.slice(-2));
723 ok(arr.slice(3,1).toString() === "", "arr.slice(3,1).toString() = " + arr.slice(3,1));
724 tmp = arr.slice(0,6);
725 for(var i=0; i < arr.length; i++)
726 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
728 ok(arr.slice(5).toString() === "a,,,,,,,2", "arr.slice(5).toString() = " + arr.slice(5).toString());
729 ok(arr.slice(5).length === 8, "arr.slice(5).length = " + arr.slice(5).length);
732 tmp = arr.splice(2,2);
733 ok(tmp.toString() == "3,4", "arr.splice(2,2) returned " + tmp.toString());
734 ok(arr.toString() == "1,2,5", "arr.splice(2,2) is " + arr.toString());
737 tmp = arr.splice(2,2,"a");
738 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a') returned " + tmp.toString());
739 ok(arr.toString() == "1,2,a,5", "arr.splice(2,2,'a') is " + arr.toString());
742 tmp = arr.splice(2,2,'a','b','c');
743 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a','b','c') returned " + tmp.toString());
744 ok(arr.toString() == "1,2,a,b,c,5", "arr.splice(2,2,'a','b','c') is " + arr.toString());
747 tmp = arr.splice(2,2,'a','b','c');
748 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a','b','c') returned " + tmp.toString());
749 ok(arr.toString() == "1,2,a,b,c,", "arr.splice(2,2,'a','b','c') is " + arr.toString());
752 arr.splice(2,2,'a','b','c');
753 ok(arr.toString() == "1,2,a,b,c,", "arr.splice(2,2,'a','b','c') is " + arr.toString());
756 tmp = arr.splice(2,2,'a','b');
757 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a','b') returned " + tmp.toString());
758 ok(arr.toString() == "1,2,a,b,5", "arr.splice(2,2,'a','b') is " + arr.toString());
761 tmp = arr.splice(-1,2);
762 ok(tmp.toString() == "5", "arr.splice(-1,2) returned " + tmp.toString());
763 ok(arr.toString() == "1,2,3,4", "arr.splice(-1,2) is " + arr.toString());
766 tmp = arr.splice(-10,3);
767 ok(tmp.toString() == "1,2,3", "arr.splice(-10,3) returned " + tmp.toString());
768 ok(arr.toString() == "4,5", "arr.splice(-10,3) is " + arr.toString());
771 tmp = arr.splice(-10,100);
772 ok(tmp.toString() == "1,2,3,4,5", "arr.splice(-10,100) returned " + tmp.toString());
773 ok(arr.toString() == "", "arr.splice(-10,100) is " + arr.toString());
776 tmp = arr.splice(2,-1);
777 ok(tmp.toString() == "", "arr.splice(2,-1) returned " + tmp.toString());
778 ok(arr.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr.toString());
782 ok(tmp.toString() == "", "arr.splice(2,-1) returned " + tmp.toString());
783 ok(arr.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr.toString());
787 ok(tmp.toString() == "", "arr.splice(2,-1) returned " + tmp.toString());
788 ok(arr.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr.toString());
795 tmp = Array.prototype.splice.call(obj, 1, 1, 'a', 'b');
796 ok(tmp.toString() === "2", "obj.splice returned " + tmp);
797 ok(obj.length === 4, "obj.length = " + obj.length);
798 ok(obj[0] === 1, "obj[0] = " + obj[0]);
799 ok(obj[1] === 'a', "obj[1] = " + obj[1]);
800 ok(obj[2] === 'b', "obj[2] = " + obj[2]);
801 ok(obj[3] === 3, "obj[3] = " + obj[3]);
808 tmp = Array.prototype.slice.call(obj, 1, 2);
809 ok(tmp.length === 1, "tmp.length = " + tmp.length);
810 ok(tmp[0] === 2, "tmp[0] = " + tmp[0]);
812 var num = new Number(2);
813 ok(num.toString() === "2", "num(2).toString !== 2");
814 var num = new Number();
815 ok(num.toString() === "0", "num().toString !== 0");
817 ok(Number() === 0, "Number() = " + Number());
818 ok(Number(false) === 0, "Number(false) = " + Number(false));
819 ok(Number("43") === 43, "Number('43') = " + Number("43"));
821 tmp = (new Number(1)).valueOf();
822 ok(tmp === 1, "(new Number(1)).valueOf = " + tmp);
823 tmp = (new Number(1,2)).valueOf();
824 ok(tmp === 1, "(new Number(1,2)).valueOf = " + tmp);
825 tmp = (new Number()).valueOf();
826 ok(tmp === 0, "(new Number()).valueOf = " + tmp);
827 tmp = Number.prototype.valueOf();
828 ok(tmp === 0, "Number.prototype.valueOf = " + tmp);
830 function equals(val, base) {
833 var str = val.toString(base);
835 for(i=0; i<str.length; i++) {
836 if(str.substring(i, i+1) == '(') break;
837 if(str.substring(i, i+1) == '.') break;
838 num = num*base + parseInt(str.substring(i, i+1));
841 if(str.substring(i, i+1) == '.') {
843 for(i++; i<str.length; i++) {
844 if(str.substring(i, i+1) == '(') break;
845 num += parseInt(str.substring(i, i+1))/mult;
850 if(str.substring(i, i+1) == '(') {
851 exp = parseInt(str.substring(i+2));
852 num *= Math.pow(base, exp);
855 ok(num>val-val/1000 && num<val+val/1000, "equals: num = " + num);
858 ok((10).toString(11) === "a", "(10).toString(11) = " + (10).toString(11));
859 ok((213213433).toString(17) === "8e2ddcb", "(213213433).toString(17) = " + (213213433).toString(17));
860 ok((-3254343).toString(33) === "-2oicf", "(-3254343).toString(33) = " + (-3254343).toString(33));
861 ok((NaN).toString(12) === "NaN", "(NaN).toString(11) = " + (NaN).toString(11));
862 ok((Infinity).toString(13) === "Infinity", "(Infinity).toString(11) = " + (Infinity).toString(11));
863 for(i=2; i<10; i++) {
865 equals(2305843009200000000, i);
868 equals(1024*1024*1024*1024*1024*1024*1.9999, i);
871 equals(4.65661287308e-10, i);
872 ok((0).toString(i) === "0", "(0).toString("+i+") = " + (0).toString(i));
875 ok(parseFloat('123') === 123, "parseFloat('123') = " + parseFloat('123'));
876 ok(parseFloat('-13.7') === -13.7, "parseFloat('-13.7') = " + parseFloat('-13.7'));
877 ok(parseFloat('-0.01e-2') === -0.01e-2, "parseFloat('-0.01e-2') = " + parseFloat('-0.01e-2'));
878 ok(parseFloat('-12e+5') === -12e+5, "parseFloat('-12e+5') = " + parseFloat('-12e+5'));
879 ok(parseFloat('1E5 not parsed') === 1E5, "parseFloat('1E5 not parsed') = " + parseFloat('1E5 not parsed'));
880 ok(isNaN(parseFloat('not a number')), "parseFloat('not a number') is not NaN");
881 ok(parseFloat('+13.2e-3') === 13.2e-3, "parseFloat('+13.2e-3') = " + parseFloat('+13.2e-3'));
882 ok(parseFloat('.12') === 0.12, "parseFloat('.12') = " + parseFloat('.12'));
883 ok(parseFloat('1e') === 1, "parseFloat('1e') = " + parseFloat('1e'));
886 ok(tmp === 1, "Math.min(1) = " + tmp);
888 tmp = Math.min(1, false);
889 ok(tmp === 0, "Math.min(1, false) = " + tmp);
892 ok(tmp === Infinity, "Math.min() = " + tmp);
894 tmp = Math.min(1, NaN, -Infinity, false);
895 ok(isNaN(tmp), "Math.min(1, NaN, -Infinity, false) is not NaN");
897 tmp = Math.min(1, false, true, null, -3);
898 ok(tmp === -3, "Math.min(1, false, true, null, -3) = " + tmp);
901 ok(tmp === 1, "Math.max(1) = " + tmp);
903 tmp = Math.max(true, 0);
904 ok(tmp === 1, "Math.max(true, 0) = " + tmp);
906 tmp = Math.max(-2, false, true, null, 1);
907 ok(tmp === 1, "Math.max(-2, false, true, null, 1) = " + tmp);
910 ok(tmp === -Infinity, "Math.max() = " + tmp);
912 tmp = Math.max(true, NaN, 0);
913 ok(isNaN(tmp), "Math.max(true, NaN, 0) is not NaN");
915 tmp = Math.round(0.5);
916 ok(tmp === 1, "Math.round(0.5) = " + tmp);
918 tmp = Math.round(-0.5);
919 ok(tmp === 0, "Math.round(-0.5) = " + tmp);
921 tmp = Math.round(1.1);
922 ok(tmp === 1, "Math.round(1.1) = " + tmp);
924 tmp = Math.round(true);
925 ok(tmp === 1, "Math.round(true) = " + tmp);
927 tmp = Math.round(1.1, 3, 4);
928 ok(tmp === 1, "Math.round(1.1, 3, 4) = " + tmp);
931 ok(isNaN(tmp), "Math.round() is not NaN");
933 tmp = Math.ceil(0.5);
934 ok(tmp === 1, "Math.ceil(0.5) = " + tmp);
936 tmp = Math.ceil(-0.5);
937 ok(tmp === 0, "Math.ceil(-0.5) = " + tmp);
939 tmp = Math.ceil(1.1);
940 ok(tmp === 2, "Math.round(1.1) = " + tmp);
942 tmp = Math.ceil(true);
943 ok(tmp === 1, "Math.ceil(true) = " + tmp);
945 tmp = Math.ceil(1.1, 3, 4);
946 ok(tmp === 2, "Math.ceil(1.1, 3, 4) = " + tmp);
949 ok(isNaN(tmp), "ceil() is not NaN");
951 tmp = Math.floor(0.5);
952 ok(tmp === 0, "Math.floor(0.5) = " + tmp);
954 tmp = Math.floor(-0.5);
955 ok(tmp === -1, "Math.floor(-0.5) = " + tmp);
957 tmp = Math.floor(1.1);
958 ok(tmp === 1, "Math.floor(1.1) = " + tmp);
960 tmp = Math.floor(true);
961 ok(tmp === 1, "Math.floor(true) = " + tmp);
963 tmp = Math.floor(1.1, 3, 4);
964 ok(tmp === 1, "Math.floor(1.1, 3, 4) = " + tmp);
967 ok(isNaN(tmp), "floor is not NaN");
970 ok(tmp === 3, "Math.abs(3) = " + tmp);
973 ok(tmp === 3, "Math.abs(-3) = " + tmp);
975 tmp = Math.abs(true);
976 ok(tmp === 1, "Math.abs(true) = " + tmp);
979 ok(isNaN(tmp), "Math.abs() is not NaN");
982 ok(isNaN(tmp), "Math.abs() is not NaN");
984 tmp = Math.abs(-Infinity);
985 ok(tmp === Infinity, "Math.abs(-Infinite) = " + tmp);
987 tmp = Math.abs(-3, 2);
988 ok(tmp === 3, "Math.abs(-3, 2) = " + tmp);
991 ok(tmp === 1, "Math.cos(0) = " + tmp);
993 tmp = Math.cos(Math.PI/2);
994 ok(Math.floor(tmp*100) === 0, "Math.cos(Math.PI/2) = " + tmp);
996 tmp = Math.cos(-Math.PI/2);
997 ok(Math.floor(tmp*100) === 0, "Math.cos(-Math.PI/2) = " + tmp);
999 tmp = Math.cos(Math.PI/3, 2);
1000 ok(Math.floor(tmp*100) === 50, "Math.cos(Math.PI/3, 2) = " + tmp);
1002 tmp = Math.cos(true);
1003 ok(Math.floor(tmp*100) === 54, "Math.cos(true) = " + tmp);
1005 tmp = Math.cos(false);
1006 ok(tmp === 1, "Math.cos(false) = " + tmp);
1009 ok(isNaN(tmp), "Math.cos() is not NaN");
1011 tmp = Math.cos(NaN);
1012 ok(isNaN(tmp), "Math.cos(NaN) is not NaN");
1014 tmp = Math.cos(Infinity);
1015 ok(isNaN(tmp), "Math.cos(Infinity) is not NaN");
1017 tmp = Math.cos(-Infinity);
1018 ok(isNaN(tmp), "Math.cos(-Infinity) is not NaN");
1020 tmp = Math.pow(2, 2);
1021 ok(tmp === 4, "Math.pow(2, 2) = " + tmp);
1023 tmp = Math.pow(4, 0.5);
1024 ok(tmp === 2, "Math.pow(2, 2) = " + tmp);
1026 tmp = Math.pow(2, 2, 3);
1027 ok(tmp === 4, "Math.pow(2, 2, 3) = " + tmp);
1030 ok(isNaN(tmp), "Math.pow(2) is not NaN");
1033 ok(isNaN(tmp), "Math.pow() is not NaN");
1035 tmp = Math.random();
1036 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
1037 ok(0 <= tmp && tmp <= 1, "Math.random() = " + tmp);
1039 tmp = Math.random(100);
1040 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
1041 ok(0 <= tmp && tmp <= 1, "Math.random(100) = " + tmp);
1044 ok(Math.floor(tmp*100) === 157, "Math.acos(0) = " + tmp);
1047 ok(Math.floor(tmp*100) === 0, "Math.acos(1) = " + tmp);
1049 tmp = Math.acos(-1);
1050 ok(Math.floor(tmp*100) === 314, "Math.acos(-1) = " + tmp);
1052 tmp = Math.acos(Math.PI/4, 2);
1053 ok(Math.floor(tmp*100) === 66, "Math.acos(Math.PI/4, 2) = " + tmp);
1055 tmp = Math.acos(true);
1056 ok(Math.floor(tmp*100) === 0, "Math.acos(true) = " + tmp);
1058 tmp = Math.acos(false);
1059 ok(Math.floor(tmp*100) === 157, "Math.acos(false) = " + tmp);
1061 tmp = Math.acos(1.1);
1062 ok(isNaN(tmp), "Math.acos(1.1) is not NaN");
1065 ok(isNaN(tmp), "Math.acos() is not NaN");
1067 tmp = Math.acos(NaN);
1068 ok(isNaN(tmp), "Math.acos(NaN) is not NaN");
1070 tmp = Math.acos(Infinity);
1071 ok(isNaN(tmp), "Math.acos(Infinity) is not NaN");
1073 tmp = Math.acos(-Infinity);
1074 ok(isNaN(tmp), "Math.acos(-Infinity) is not NaN");
1077 ok(Math.floor(tmp*100) === 0, "Math.asin(0) = " + tmp);
1080 ok(Math.floor(tmp*100) === 157, "Math.asin(1) = " + tmp);
1082 tmp = Math.asin(-1);
1083 ok(Math.floor(tmp*100) === -158, "Math.asin(-1) = " + tmp);
1085 tmp = Math.asin(Math.PI/4, 2);
1086 ok(Math.floor(tmp*100) === 90, "Math.asin(Math.PI/4, 2) = " + tmp);
1088 tmp = Math.asin(true);
1089 ok(Math.floor(tmp*100) === 157, "Math.asin(true) = " + tmp);
1091 tmp = Math.asin(false);
1092 ok(Math.floor(tmp*100) === 0, "Math.asin(false) = " + tmp);
1094 tmp = Math.asin(1.1);
1095 ok(isNaN(tmp), "Math.asin(1.1) is not NaN");
1098 ok(isNaN(tmp), "Math.asin() is not NaN");
1100 tmp = Math.asin(NaN);
1101 ok(isNaN(tmp), "Math.asin(NaN) is not NaN");
1103 tmp = Math.asin(Infinity);
1104 ok(isNaN(tmp), "Math.asin(Infinity) is not NaN");
1106 tmp = Math.asin(-Infinity);
1107 ok(isNaN(tmp), "Math.asin(-Infinity) is not NaN");
1110 ok(Math.floor(tmp*100) === 0, "Math.atan(0) = " + tmp);
1113 ok(Math.floor(tmp*100) === 78, "Math.atan(1) = " + tmp);
1115 tmp = Math.atan(-1);
1116 ok(Math.floor(tmp*100) === -79, "Math.atan(-1) = " + tmp);
1118 tmp = Math.atan(true);
1119 ok(Math.floor(tmp*100) === 78, "Math.atan(true) = " + tmp);
1121 tmp = Math.atan(false);
1122 ok(Math.floor(tmp*100) === 0, "Math.atan(false) = " + tmp);
1125 ok(isNaN(tmp), "Math.atan() is not NaN");
1127 tmp = Math.atan(NaN);
1128 ok(isNaN(tmp), "Math.atan(NaN) is not NaN");
1130 tmp = Math.atan(Infinity);
1131 ok(Math.floor(tmp*100) === 157, "Math.atan(Infinity) = " + tmp);
1133 tmp = Math.atan(-Infinity);
1134 ok(Math.floor(tmp*100) === -158, "Math.atan(Infinity) = " + tmp);
1136 tmp = Math.atan2(0, 0);
1137 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 0) = " + tmp);
1139 tmp = Math.atan2(0, 1);
1140 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 1) = " + tmp);
1142 tmp = Math.atan2(0, Infinity);
1143 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, Infinity) = " + tmp);
1145 tmp = Math.atan2(0, -1);
1146 ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -1) = " + tmp);
1148 tmp = Math.atan2(0, -Infinity);
1149 ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -Infinity) = " + tmp);
1151 tmp = Math.atan2(1, 0);
1152 ok(Math.floor(tmp*100) === 157, "Math.atan2(1, 0) = " + tmp);
1154 tmp = Math.atan2(Infinity, 0);
1155 ok(Math.floor(tmp*100) === 157, "Math.atan2(Infinity, 0) = " + tmp);
1157 tmp = Math.atan2(-1, 0);
1158 ok(Math.floor(tmp*100) === -158, "Math.atan2(-1, 0) = " + tmp);
1160 tmp = Math.atan2(-Infinity, 0);
1161 ok(Math.floor(tmp*100) === -158, "Math.atan2(-Infinity, 0) = " + tmp);
1163 tmp = Math.atan2(1, 1);
1164 ok(Math.floor(tmp*100) === 78, "Math.atan2(1, 1) = " + tmp);
1166 tmp = Math.atan2(-1, -1);
1167 ok(Math.floor(tmp*100) === -236, "Math.atan2(-1, -1) = " + tmp);
1169 tmp = Math.atan2(-1, 1);
1170 ok(Math.floor(tmp*100) === -79, "Math.atan2(-1, 1) = " + tmp);
1172 tmp = Math.atan2(Infinity, Infinity);
1173 ok(Math.floor(tmp*100) === 78, "Math.atan2(Infinity, Infinity) = " + tmp);
1175 tmp = Math.atan2(Infinity, -Infinity, 1);
1176 ok(Math.floor(tmp*100) === 235, "Math.atan2(Infinity, -Infinity, 1) = " + tmp);
1179 ok(isNaN(tmp), "Math.atan2() is not NaN");
1181 tmp = Math.atan2(1);
1182 ok(isNaN(tmp), "Math.atan2(1) is not NaN");
1185 ok(tmp === 1, "Math.exp(0) = " + tmp);
1188 ok(Math.floor(tmp*100) === 271, "Math.exp(1) = " + tmp);
1191 ok(Math.floor(tmp*100) === 36, "Math.exp(-1) = " + tmp);
1193 tmp = Math.exp(true);
1194 ok(Math.floor(tmp*100) === 271, "Math.exp(true) = " + tmp);
1196 tmp = Math.exp(1, 1);
1197 ok(Math.floor(tmp*100) === 271, "Math.exp(1, 1) = " + tmp);
1200 ok(isNaN(tmp), "Math.exp() is not NaN");
1202 tmp = Math.exp(NaN);
1203 ok(isNaN(tmp), "Math.exp(NaN) is not NaN");
1205 tmp = Math.exp(Infinity);
1206 ok(tmp === Infinity, "Math.exp(Infinity) = " + tmp);
1208 tmp = Math.exp(-Infinity);
1209 ok(tmp === 0, "Math.exp(-Infinity) = " + tmp);
1212 ok(Math.floor(tmp*100) === 0, "Math.log(1) = " + tmp);
1215 ok(isNaN(tmp), "Math.log(-1) is not NaN");
1217 tmp = Math.log(true);
1218 ok(Math.floor(tmp*100) === 0, "Math.log(true) = " + tmp);
1220 tmp = Math.log(1, 1);
1221 ok(Math.floor(tmp*100) === 0, "Math.log(1, 1) = " + tmp);
1224 ok(isNaN(tmp), "Math.log() is not NaN");
1226 tmp = Math.log(NaN);
1227 ok(isNaN(tmp), "Math.log(NaN) is not NaN");
1229 tmp = Math.log(Infinity);
1230 ok(tmp === Infinity, "Math.log(Infinity) = " + tmp);
1232 tmp = Math.log(-Infinity);
1233 ok(isNaN(tmp), "Math.log(-Infinity) is not NaN");
1236 ok(tmp === 0, "Math.sin(0) = " + tmp);
1238 tmp = Math.sin(Math.PI/2);
1239 ok(tmp === 1, "Math.sin(Math.PI/2) = " + tmp);
1241 tmp = Math.sin(-Math.PI/2);
1242 ok(tmp === -1, "Math.sin(-Math.PI/2) = " + tmp);
1244 tmp = Math.sin(Math.PI/3, 2);
1245 ok(Math.floor(tmp*100) === 86, "Math.sin(Math.PI/3, 2) = " + tmp);
1247 tmp = Math.sin(true);
1248 ok(Math.floor(tmp*100) === 84, "Math.sin(true) = " + tmp);
1250 tmp = Math.sin(false);
1251 ok(tmp === 0, "Math.sin(false) = " + tmp);
1254 ok(isNaN(tmp), "Math.sin() is not NaN");
1256 tmp = Math.sin(NaN);
1257 ok(isNaN(tmp), "Math.sin(NaN) is not NaN");
1259 tmp = Math.sin(Infinity);
1260 ok(isNaN(tmp), "Math.sin(Infinity) is not NaN");
1262 tmp = Math.sin(-Infinity);
1263 ok(isNaN(tmp), "Math.sin(-Infinity) is not NaN");
1266 ok(tmp === 0, "Math.sqrt(0) = " + tmp);
1269 ok(tmp === 2, "Math.sqrt(4) = " + tmp);
1271 tmp = Math.sqrt(-1);
1272 ok(isNaN(tmp), "Math.sqrt(-1) is not NaN");
1274 tmp = Math.sqrt(2, 2);
1275 ok(Math.floor(tmp*100) === 141, "Math.sqrt(2, 2) = " + tmp);
1277 tmp = Math.sqrt(true);
1278 ok(tmp === 1, "Math.sqrt(true) = " + tmp);
1280 tmp = Math.sqrt(false);
1281 ok(tmp === 0, "Math.sqrt(false) = " + tmp);
1284 ok(isNaN(tmp), "Math.sqrt() is not NaN");
1286 tmp = Math.sqrt(NaN);
1287 ok(isNaN(tmp), "Math.sqrt(NaN) is not NaN");
1289 tmp = Math.sqrt(Infinity);
1290 ok(tmp === Infinity, "Math.sqrt(Infinity) = " + tmp);
1292 tmp = Math.sqrt(-Infinity);
1293 ok(isNaN(tmp), "Math.sqrt(-Infinity) is not NaN");
1296 ok(tmp === 0, "Math.tan(0) = " + tmp);
1298 tmp = Math.tan(Math.PI);
1299 ok(Math.floor(tmp*100) === -1, "Math.tan(Math.PI) = " + tmp);
1301 tmp = Math.tan(2, 2);
1302 ok(Math.floor(tmp*100) === -219, "Math.tan(2, 2) = " + tmp);
1304 tmp = Math.tan(true);
1305 ok(Math.floor(tmp*100) === 155, "Math.tan(true) = " + tmp);
1307 tmp = Math.tan(false);
1308 ok(tmp === 0, "Math.tan(false) = " + tmp);
1311 ok(isNaN(tmp), "Math.tan() is not NaN");
1313 tmp = Math.tan(NaN);
1314 ok(isNaN(tmp), "Math.tan(NaN) is not NaN");
1316 tmp = Math.tan(Infinity);
1317 ok(isNaN(tmp), "Math.tan(Infinity) is not NaN");
1319 tmp = Math.tan(-Infinity);
1320 ok(isNaN(tmp), "Math.tan(-Infinity) is not NaN");
1322 var func = function (a) {
1326 ok(func.toString() === "function (a) {\n var a = 1;\n if(a) return;\n }",
1327 "func.toString() = " + func.toString());
1328 ok("" + func === "function (a) {\n var a = 1;\n if(a) return;\n }",
1329 "'' + func.toString() = " + func);
1331 ok(func.valueOf === Object.prototype.valueOf, "func.valueOf !== Object.prototype.valueOf");
1332 ok(func === func.valueOf(), "func !== func.valueOf()");
1334 function testFuncToString(x,y) {
1337 ok(testFuncToString.toString() === "function testFuncToString(x,y) {\n return x+y;\n}",
1338 "testFuncToString.toString() = " + testFuncToString.toString());
1339 ok("" + testFuncToString === "function testFuncToString(x,y) {\n return x+y;\n}",
1340 "'' + testFuncToString = " + testFuncToString);
1344 function callTest(argc) {
1345 ok(this === tmp, "this !== tmp\n");
1346 ok(arguments.length === argc+1, "arguments.length = " + arguments.length + " expected " + (argc+1));
1347 for(var i=1; i <= argc; i++)
1348 ok(arguments[i] === i, "arguments[i] = " + arguments[i]);
1351 callTest.call(tmp, 1, 1);
1352 callTest.call(tmp, 2, 1, 2);
1354 callTest.apply(tmp, [1, 1]);
1355 callTest.apply(tmp, [2, 1, 2]);
1356 (function () { callTest.apply(tmp, arguments); })(2,1,2);
1358 function callTest2() {
1359 ok(this === tmp, "this !== tmp\n");
1360 ok(arguments.length === 0, "callTest2: arguments.length = " + arguments.length + " expected 0");
1363 callTest2.call(tmp);
1364 callTest2.apply(tmp, []);
1365 callTest2.apply(tmp);
1366 (function () { callTest2.apply(tmp, arguments); })();
1368 function callTest3() {
1369 ok(arguments.length === 0, "arguments.length = " + arguments.length + " expected 0");
1374 tmp = Number.prototype.toString.call(3);
1375 ok(tmp === "3", "Number.prototype.toString.call(3) = " + tmp);
1377 var date = new Date();
1379 date = new Date(100);
1380 ok(date.getTime() === 100, "date.getTime() = " + date.getTime());
1381 ok(Date.prototype.getTime() === 0, "date.prototype.getTime() = " + Date.prototype.getTime());
1382 date = new Date(8.64e15);
1383 ok(date.getTime() === 8.64e15, "date.getTime() = " + date.getTime());
1384 date = new Date(8.64e15+1);
1385 ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
1386 date = new Date(Infinity);
1387 ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
1388 date = new Date("3 July 2009 22:28:00 UTC+0100");
1389 ok(date.getTime() === 1246656480000, "date.getTime() = " + date.getTime());
1390 date = new Date(1984, 11, 29, 13, 51, 24, 120);
1391 ok(date.getFullYear() === 1984, "date.getFullYear() = " + date.getFullYear());
1392 ok(date.getMonth() === 11, "date.getMonth() = " + date.getMonth());
1393 ok(date.getDate() === 29, "date.getDate() = " + date.getDate());
1394 ok(date.getHours() === 13, "date.getHours() = " + date.getHours());
1395 ok(date.getMinutes() === 51, "date.getMinutes() = " + date.getMinutes());
1396 ok(date.getSeconds() === 24, "date.getSeconds() = " + date.getSeconds());
1397 ok(date.getMilliseconds() === 120, "date.getMilliseconds() = " + date.getMilliseconds());
1398 date = new Date(731, -32, 40, -1, 70, 65, -13);
1399 ok(date.getFullYear() === 728, "date.getFullYear() = " + date.getFullYear());
1400 ok(date.getMonth() === 5, "date.getMonth() = " + date.getMonth());
1401 ok(date.getDate() === 9, "date.getDate() = " + date.getDate());
1402 ok(date.getHours() === 0, "date.getHours() = " + date.getHours());
1403 ok(date.getMinutes() === 11, "date.getMinutes() = " + date.getMinutes());
1404 ok(date.getSeconds() === 4, "date.getSeconds() = " + date.getSeconds());
1405 ok(date.getMilliseconds() === 987, "date.getMilliseconds() = " + date.getMilliseconds());
1407 ok(date.setTime(123) === 123, "date.setTime(123) !== 123");
1408 ok(date.setTime("123", NaN) === 123, "date.setTime(\"123\") !== 123");
1409 ok(isNaN(date.setTime(NaN)), "date.setTime(NaN) is not NaN");
1411 ok(date.setTime(0) === date.getTime(), "date.setTime(0) !== date.getTime()");
1412 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
1413 ok(date.getUTCMonth() === 0, "date.getUTCMonth() = " + date.getUTCMonth());
1414 ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
1415 ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
1416 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
1417 ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
1418 ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
1419 ok(date.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1420 date.setTime(60*24*60*60*1000);
1421 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
1422 ok(date.getUTCMonth() === 2, "date.getUTCMonth() = " + date.getUTCMonth());
1423 ok(date.getUTCDate() === 2, "date.getUTCDate() = " + date.getUTCDate());
1424 ok(date.getUTCDay() === 1, "date.getUTCDay() = " + date.getUTCDay());
1425 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
1426 ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
1427 ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
1428 ok(date.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1429 date.setTime(59*24*60*60*1000 + 4*365*24*60*60*1000 + 60*60*1000 + 2*60*1000 + 2*1000 + 640);
1430 ok(date.getUTCFullYear() === 1974, "date.getUTCFullYear() = " + date.getUTCFullYear());
1431 ok(date.getUTCMonth() === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1432 ok(date.getUTCMonth(123) === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1433 ok(date.getUTCDate() === 28, "date.getUTCDate() = " + date.getUTCDate());
1434 ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
1435 ok(date.getUTCHours() === 1, "date.getUTCHours() = " + date.getUTCHours());
1436 ok(date.getUTCMinutes() === 2, "date.getUTCMinutes() = " + date.getUTCMinutes());
1437 ok(date.getUTCSeconds() === 2, "date.getUTCSeconds() = " + date.getUTCSeconds());
1438 ok(date.getUTCMilliseconds() === 640, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1439 date.setTime(Infinity);
1440 ok(isNaN(date.getUTCFullYear()), "date.getUTCFullYear() is not NaN");
1441 ok(isNaN(date.getUTCMonth()), "date.getUTCMonth() is not NaN");
1442 ok(isNaN(date.getUTCDate()), "date.getUTCDate() is not NaN");
1443 ok(isNaN(date.getUTCDay()), "date.getUTCDay() is not NaN");
1444 ok(isNaN(date.getUTCHours()), "date.getUTCHours() is not NaN");
1445 ok(isNaN(date.getUTCMinutes()), "date.getUTCMinutes() is not NaN");
1446 ok(isNaN(date.getUTCSeconds()), "date.getUTCSeconds() is not NaN");
1447 ok(isNaN(date.getUTCMilliseconds()), "date.getUTCMilliseconds() is not NaN");
1448 ok(isNaN(date.setMilliseconds(0)), "date.setMilliseconds() is not NaN");
1451 date.setUTCMilliseconds(-10, 2);
1452 ok(date.getUTCMilliseconds() === 990, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1453 date.setUTCMilliseconds(10);
1454 ok(date.getUTCMilliseconds() === 10, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1455 date.setUTCSeconds(-10);
1456 ok(date.getUTCSeconds() === 50, "date.getUTCSeconds() = " + date.getUTCSeconds());
1457 date.setUTCMinutes(-10);
1458 ok(date.getUTCMinutes() === 50, "date.getUTCMinutes() = " + date.getUTCMinutes());
1459 date.setUTCHours(-10);
1460 ok(date.getUTCHours() === 14, "date.getUTCHours() = " + date.getUTCHours());
1461 date.setUTCHours(-123);
1462 ok(date.getTime() === -612549990, "date.getTime() = " + date.getTime());
1463 date.setUTCHours(20);
1464 ok(date.getUTCHours() === 20, "date.getUTCHours() = " + date.getUTCHours());
1465 date.setUTCDate(32);
1466 ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
1467 date.setUTCMonth(22, 37);
1468 ok(date.getTime() === 60987050010, "date.getTime() = " + date.getTime());
1469 date.setUTCFullYear(83, 21, 321);
1470 ok(date.getTime() === -59464984149990, "date.getTime() = " + date.getTime());
1471 ok(Math.abs(date) === 59464984149990, "Math.abs(date) = " + Math.abs(date));
1472 ok(getVT(date+1) === "VT_BSTR", "getVT(date+1) = " + getVT(date+1));
1474 ok(isNaN(Date.parse()), "Date.parse() is not NaN");
1475 ok(isNaN(Date.parse("")), "Date.parse(\"\") is not NaN");
1476 ok(isNaN(Date.parse("Jan Jan 20 2009")), "Date.parse(\"Jan Jan 20 2009\") is not NaN");
1477 ok(Date.parse("Jan 20 2009 UTC") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC\") = " + Date.parse("Jan 20 2009 UTC"));
1478 ok(Date.parse("Jan 20 2009 GMT") === 1232409600000, "Date.parse(\"Jan 20 2009 GMT\") = " + Date.parse("Jan 20 2009 GMT"));
1479 ok(Date.parse("Jan 20 2009 UTC-0") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC-0\") = " + Date.parse("Jan 20 2009 UTC-0"));
1480 ok(Date.parse("Jan 20 2009 UTC+0000") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC+0000\") = " + Date.parse("Jan 20 2009 UTC+0000"));
1481 ok(Date.parse("Ju 13 79 UTC") === 300672000000, "Date.parse(\"Ju 13 79 UTC\") = " + Date.parse("Ju 13 79 UTC"));
1482 ok(Date.parse("12Au91 UTC") === 681955200000, "Date.parse(\"12Au91 UTC\") = " + Date.parse("12Au91 UTC"));
1483 ok(Date.parse("7/02/17 UTC") === -1656806400000, "Date.parse(\"7/02/17 UTC\") = " + Date.parse("7/02/17 UTC"));
1484 ok(Date.parse("Se001 70 12:31:17 UTC") === 21040277000, "Date.parse(\"Se001 70 12:31:17 UTC\") = " + Date.parse("Se001 70 12:31:17 UTC"));
1485 ok(Date.parse("February 31 UTC, 2000 12:31:17 PM") === 952000277000,
1486 "Date.parse(\"February 31 UTC, 2000 12:31:17 PM\") = " + Date.parse("February 31 UTC, 2000 12:31:17 PM"));
1487 ok(Date.parse("71 11:32AM Dec 12 UTC BC ") === -64346358480000, "Date.parse(\"71 11:32AM Dec 12 UTC BC \") = " + Date.parse("71 11:32AM Dec 12 UTC BC "));
1488 ok(Date.parse("23/71/2000 11::32::UTC") === 1010662320000, "Date.parse(\"23/71/2000 11::32::UTC\") = " + Date.parse("23/71/2000 11::32::UTC"));
1490 ok(typeof(Math.PI) === "number", "typeof(Math.PI) = " + typeof(Math.PI));
1491 ok(Math.floor(Math.PI*100) === 314, "Math.PI = " + Math.PI);
1493 ok(Math.floor(Math.PI*100) === 314, "modified Math.PI = " + Math.PI);
1495 ok(typeof(Math.E) === "number", "typeof(Math.E) = " + typeof(Math.E));
1496 ok(Math.floor(Math.E*100) === 271, "Math.E = " + Math.E);
1498 ok(Math.floor(Math.E*100) === 271, "modified Math.E = " + Math.E);
1500 ok(typeof(Math.LOG2E) === "number", "typeof(Math.LOG2E) = " + typeof(Math.LOG2E));
1501 ok(Math.floor(Math.LOG2E*100) === 144, "Math.LOG2E = " + Math.LOG2E);
1502 Math.LOG2E = "test";
1503 ok(Math.floor(Math.LOG2E*100) === 144, "modified Math.LOG2E = " + Math.LOG2E);
1505 ok(typeof(Math.LOG10E) === "number", "typeof(Math.LOG10E) = " + typeof(Math.LOG10E));
1506 ok(Math.floor(Math.LOG10E*100) === 43, "Math.LOG10E = " + Math.LOG10E);
1507 Math.LOG10E = "test";
1508 ok(Math.floor(Math.LOG10E*100) === 43, "modified Math.LOG10E = " + Math.LOG10E);
1510 ok(typeof(Math.LN2) === "number", "typeof(Math.LN2) = " + typeof(Math.LN2));
1511 ok(Math.floor(Math.LN2*100) === 69, "Math.LN2 = " + Math.LN2);
1513 ok(Math.floor(Math.LN2*100) === 69, "modified Math.LN2 = " + Math.LN2);
1515 ok(typeof(Math.LN10) === "number", "typeof(Math.LN10) = " + typeof(Math.LN10));
1516 ok(Math.floor(Math.LN10*100) === 230, "Math.LN10 = " + Math.LN10);
1518 ok(Math.floor(Math.LN10*100) === 230, "modified Math.LN10 = " + Math.LN10);
1520 ok(typeof(Math.SQRT2) === "number", "typeof(Math.SQRT2) = " + typeof(Math.SQRT2));
1521 ok(Math.floor(Math.SQRT2*100) === 141, "Math.SQRT2 = " + Math.SQRT2);
1522 Math.SQRT2 = "test";
1523 ok(Math.floor(Math.SQRT2*100) === 141, "modified Math.SQRT2 = " + Math.SQRT2);
1525 ok(typeof(Math.SQRT1_2) === "number", "typeof(Math.SQRT1_2) = " + typeof(Math.SQRT1_2));
1526 ok(Math.floor(Math.SQRT1_2*100) === 70, "Math.SQRT1_2 = " + Math.SQRT1_2);
1527 Math.SQRT1_2 = "test";
1528 ok(Math.floor(Math.SQRT1_2*100) === 70, "modified Math.SQRT1_2 = " + Math.SQRT1_2);
1530 ok(isNaN.toString() === "\nfunction isNaN() {\n [native code]\n}\n",
1531 "isNaN.toString = '" + isNaN.toString() + "'");
1532 ok(Array.toString() === "\nfunction Array() {\n [native code]\n}\n",
1533 "isNaN.toString = '" + Array.toString() + "'");
1534 ok(Function.toString() === "\nfunction Function() {\n [native code]\n}\n",
1535 "isNaN.toString = '" + Function.toString() + "'");
1536 ok(Function.prototype.toString() === "\nfunction prototype() {\n [native code]\n}\n",
1537 "isNaN.toString = '" + Function.prototype.toString() + "'");
1538 ok("".substr.toString() === "\nfunction substr() {\n [native code]\n}\n",
1539 "''.substr.toString = '" + "".substr.toString() + "'");
1541 var bool = new Boolean();
1542 ok(bool.toString() === "false", "bool.toString() = " + bool.toString());
1543 var bool = new Boolean("false");
1544 ok(bool.toString() === "true", "bool.toString() = " + bool.toString());
1545 ok(bool.valueOf() === Boolean(1), "bool.valueOf() = " + bool.valueOf());
1546 ok(bool.toLocaleString() === bool.toString(), "bool.toLocaleString() = " + bool.toLocaleString());
1548 ok(ActiveXObject instanceof Function, "ActiveXObject is not instance of Function");
1549 ok(ActiveXObject.prototype instanceof Object, "ActiveXObject.prototype is not instance of Object");
1551 ok(Error.prototype !== TypeError.prototype, "Error.prototype === TypeError.prototype");
1552 ok(RangeError.prototype !== TypeError.prototype, "RangeError.prototype === TypeError.prototype");
1553 ok(Error.prototype.toLocaleString === Object.prototype.toLocaleString,
1554 "Error.prototype.toLocaleString !== Object.prototype.toLocaleString");
1556 ok(err.valueOf === Object.prototype.valueOf, "err.valueOf !== Object.prototype.valueOf");
1557 ok(Error.prototype.name === "Error", "Error.prototype.name = " + Error.prototype.name);
1558 ok(err.name === "Error", "err.name = " + err.name);
1559 EvalError.prototype.message = "test";
1560 ok(err.toString !== Object.prototype.toString, "err.toString === Object.prototype.toString");
1561 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1562 err = new EvalError();
1563 ok(EvalError.prototype.name === "EvalError", "EvalError.prototype.name = " + EvalError.prototype.name);
1564 ok(err.name === "EvalError", "err.name = " + err.name);
1565 ok(err.toString === Error.prototype.toString, "err.toString !== Error.prototype.toString");
1566 ok(err.message === "", "err.message != ''");
1568 ok(err.message === date, "err.message != date");
1569 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1570 ok(err.toString !== Object.prototype.toString, "err.toString === Object.prototype.toString");
1571 err = new RangeError();
1572 ok(RangeError.prototype.name === "RangeError", "RangeError.prototype.name = " + RangeError.prototype.name);
1573 ok(err.name === "RangeError", "err.name = " + err.name);
1574 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1575 err = new ReferenceError();
1576 ok(ReferenceError.prototype.name === "ReferenceError", "ReferenceError.prototype.name = " + ReferenceError.prototype.name);
1577 ok(err.name === "ReferenceError", "err.name = " + err.name);
1578 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1579 err = new SyntaxError();
1580 ok(SyntaxError.prototype.name === "SyntaxError", "SyntaxError.prototype.name = " + SyntaxError.prototype.name);
1581 ok(err.name === "SyntaxError", "err.name = " + err.name);
1582 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1583 err = new TypeError();
1584 ok(TypeError.prototype.name === "TypeError", "TypeError.prototype.name = " + TypeError.prototype.name);
1585 ok(err.name === "TypeError", "err.name = " + err.name);
1586 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1587 err = new URIError();
1588 ok(URIError.prototype.name === "URIError", "URIError.prototype.name = " + URIError.prototype.name);
1589 ok(err.name === "URIError", "err.name = " + err.name);
1590 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1591 err = new Error("message");
1592 ok(err.message === "message", "err.message !== 'message'");
1593 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1594 err = new Error(123);
1595 ok(err.number === 123, "err.number = " + err.number);
1596 err = new Error(0, "message");
1597 ok(err.number === 0, "err.number = " + err.number);
1598 ok(err.message === "message", "err.message = " + err.message);
1599 ok(err.description === "message", "err.description = " + err.description);
1601 function exception_test(func, type, number) {
1610 ok(ret === type, "Exception test, ret = " + ret + ", expected " + type +". Executed function: " + func.toString());
1611 ok(num === number, "Exception test, num = " + num + ", expected " + number + ". Executed function: " + func.toString());
1613 exception_test(function() {arr.toString = Date.prototype.toString; arr.toString();}, "TypeError", -2146823282);
1614 exception_test(function() {Array(-3);}, "RangeError", -2146823259);
1615 exception_test(function() {arr.toString = Boolean.prototype.toString; arr.toString();}, "TypeError", -2146823278);
1616 exception_test(function() {date.setTime();}, "TypeError", -2146827839);
1617 exception_test(function() {arr.test();}, "TypeError", -2146827850);
1618 exception_test(function() {arr.toString = Number.prototype.toString; arr.toString();}, "TypeError", -2146823287);
1619 exception_test(function() {(new Number(3)).toString(1);}, "TypeError", -2146828283);
1620 exception_test(function() {not_existing_variable.something();}, "TypeError", -2146823279);
1621 exception_test(function() {arr.toString = Function.prototype.toString; arr.toString();}, "TypeError", -2146823286);
1622 exception_test(function() {date();}, "TypeError", -2146823286);
1623 exception_test(function() {arr();}, "TypeError", -2146823286);
1624 exception_test(function() {eval("for(i=0;) {}");}, "SyntaxError", -2146827286);
1625 exception_test(function() {eval("function {};");}, "SyntaxError", -2146827283);
1626 exception_test(function() {eval("if");}, "SyntaxError", -2146827283);
1627 exception_test(function() {eval("do i=0; while");}, "SyntaxError", -2146827283);
1628 exception_test(function() {eval("while");}, "SyntaxError", -2146827283);
1629 exception_test(function() {eval("for");}, "SyntaxError", -2146827283);
1630 exception_test(function() {eval("with");}, "SyntaxError", -2146827283);
1631 exception_test(function() {eval("switch");}, "SyntaxError", -2146827283);
1632 exception_test(function() {eval("if(false");}, "SyntaxError", -2146827282);
1633 exception_test(function() {eval("for(i=0; i<10; i++");}, "SyntaxError", -2146827282);
1634 exception_test(function() {eval("while(true");}, "SyntaxError", -2146827282);
1635 exception_test(function() {test = function() {}}, "ReferenceError", -2146823280);
1636 exception_test(function() {eval("for(i=0")}, "SyntaxError", -2146827284);
1637 exception_test(function() {eval("for(i=0;i<10")}, "SyntaxError", -2146827284);
1638 exception_test(function() {eval("while(")}, "SyntaxError", -2146827286);
1639 exception_test(function() {eval("if(")}, "SyntaxError", -2146827286);
1640 exception_test(function() {eval("'unterminated")}, "SyntaxError", -2146827273);
1641 exception_test(function() {eval("nonexistingfunc()")}, "TypeError", -2146823281);
1642 exception_test(function() {RegExp(/a/, "g");}, "RegExpError", -2146823271);
1644 function testThisExcept(func, number) {
1645 exception_test(function() {func.call(new Object())}, "TypeError", number);
1648 function testBoolThis(func) {
1649 testThisExcept(Boolean.prototype[func], -2146823278);
1652 testBoolThis("toString");
1653 testBoolThis("valueOf");
1655 function testDateThis(func) {
1656 testThisExcept(Date.prototype[func], -2146823282);
1659 testDateThis("getDate");
1660 testDateThis("getDay");
1661 testDateThis("getFullYear");
1662 testDateThis("getHours");
1663 testDateThis("getMilliseconds");
1664 testDateThis("getMinutes");
1665 testDateThis("getMonth");
1666 testDateThis("getSeconds");
1667 testDateThis("getTime");
1668 testDateThis("getTimezoneOffset");
1669 testDateThis("getUTCDate");
1670 testDateThis("getUTCDay");
1671 testDateThis("getUTCFullYear");
1672 testDateThis("getUTCHours");
1673 testDateThis("getUTCMilliseconds");
1674 testDateThis("getUTCMinutes");
1675 testDateThis("getUTCMonth");
1676 testDateThis("getUTCSeconds");
1677 testDateThis("setDate");
1678 testDateThis("setFullYear");
1679 testDateThis("setHours");
1680 testDateThis("setMilliseconds");
1681 testDateThis("setMinutes");
1682 testDateThis("setMonth");
1683 testDateThis("setSeconds");
1684 testDateThis("setTime");
1685 testDateThis("setUTCDate");
1686 testDateThis("setUTCFullYear");
1687 testDateThis("setUTCHours");
1688 testDateThis("setUTCMilliseconds");
1689 testDateThis("setUTCMinutes");
1690 testDateThis("setUTCMonth");
1691 testDateThis("setUTCSeconds");
1692 testDateThis("toDateString");
1693 testDateThis("toLocaleDateString");
1694 testDateThis("toLocaleString");
1695 testDateThis("toLocaleTimeString");
1696 testDateThis("toString");
1697 testDateThis("toTimeString");
1698 testDateThis("toUTCString");
1699 testDateThis("valueOf");
1701 function testArrayThis(func) {
1702 testThisExcept(Array.prototype[func], -2146823257);
1705 testArrayThis("toString");
1707 function testFunctionThis(func) {
1708 testThisExcept(Function.prototype[func], -2146823286);
1711 testFunctionThis("toString");
1712 testFunctionThis("call");
1713 testFunctionThis("apply");
1715 function testArrayHostThis(func) {
1716 exception_test(function() { Array.prototype[func].call(testObj); }, "TypeError", -2146823274);
1719 testArrayHostThis("push");
1720 testArrayHostThis("shift");
1721 testArrayHostThis("slice");
1722 testArrayHostThis("splice");
1723 testArrayHostThis("unshift");
1725 function testObjectInherit(obj, constr, ts, tls, vo) {
1726 ok(obj instanceof Object, "obj is not instance of Object");
1727 ok(obj instanceof constr, "obj is not instance of its constructor");
1729 ok(obj.hasOwnProperty === Object.prototype.hasOwnProperty,
1730 "obj.hasOwnProperty !== Object.prototype.hasOwnProprty");
1731 ok(obj.isPrototypeOf === Object.prototype.isPrototypeOf,
1732 "obj.isPrototypeOf !== Object.prototype.isPrototypeOf");
1733 ok(obj.propertyIsEnumerable === Object.prototype.propertyIsEnumerable,
1734 "obj.propertyIsEnumerable !== Object.prototype.propertyIsEnumerable");
1737 ok(obj.toString === Object.prototype.toString,
1738 "obj.toString !== Object.prototype.toString");
1740 ok(obj.toString != Object.prototype.toString,
1741 "obj.toString == Object.prototype.toString");
1744 ok(obj.toLocaleString === Object.prototype.toLocaleString,
1745 "obj.toLocaleString !== Object.prototype.toLocaleString");
1747 ok(obj.toLocaleString != Object.prototype.toLocaleString,
1748 "obj.toLocaleString == Object.prototype.toLocaleString");
1751 ok(obj.valueOf === Object.prototype.valueOf,
1752 "obj.valueOf !== Object.prototype.valueOf");
1754 ok(obj.valueOf != Object.prototype.valueOf,
1755 "obj.valueOf == Object.prototype.valueOf");
1757 ok(obj._test === "test", "obj.test = " + obj._test);
1760 Object.prototype._test = "test";
1761 testObjectInherit(new String("test"), String, false, true, false);
1762 testObjectInherit(/test/g, RegExp, false, true, true);
1763 testObjectInherit(new Number(1), Number, false, false, false);
1764 testObjectInherit(new Date(), Date, false, false, false);
1765 testObjectInherit(new Boolean(true), Boolean, false, true, false);
1766 testObjectInherit(new Array(), Array, false, false, true);
1767 testObjectInherit(new Error(), Error, false, true, true);
1768 testObjectInherit(testObjectInherit, Function, false, true, true);
1769 testObjectInherit(Math, Object, true, true, true);
1771 (function() { testObjectInherit(arguments, Object, true, true, true); })();
1773 function testFunctions(obj, arr) {
1776 for(var i=0; i<arr.length; i++) {
1777 l = obj[arr[i][0]].length;
1778 ok(l === arr[i][1], arr[i][0] + ".length = " + l);
1782 testFunctions(Boolean.prototype, [
1787 testFunctions(Number.prototype, [
1790 ["toExponential", 1],
1791 ["toLocaleString", 0],
1795 testFunctions(String.prototype, [
1812 ["localeCompare", 1],
1824 ["toLocaleLowerCase", 0],
1825 ["toLocaleUpperCase", 0],
1830 testFunctions(RegExp.prototype, [
1836 testFunctions(Date.prototype, [
1841 ["getMilliseconds", 0],
1846 ["getTimezoneOffset", 0],
1849 ["getUTCFullYear", 0],
1851 ["getUTCMilliseconds", 0],
1852 ["getUTCMinutes", 0],
1854 ["getUTCSeconds", 0],
1858 ["setMilliseconds", 1],
1864 ["setUTCFullYear", 3],
1866 ["setUTCMilliseconds", 1],
1867 ["setUTCMinutes", 3],
1869 ["setUTCSeconds", 2],
1870 ["toDateString", 0],
1871 ["toLocaleDateString", 0],
1872 ["toLocaleString", 0],
1873 ["toLocaleTimeString", 0],
1875 ["toTimeString", 0],
1880 testFunctions(Array.prototype, [
1890 ["toLocaleString", 0],
1895 testFunctions(Error.prototype, [
1899 testFunctions(Math, [
1920 testFunctions(Object.prototype, [
1921 ["hasOwnProperty", 1],
1922 ["isPrototypeOf", 1],
1923 ["propertyIsEnumerable", 1],
1924 ["toLocaleString", 0],
1929 testFunctions(Function.prototype, [