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 = "" + new Object();
62 ok(tmp === "[object Object]", "'' + new Object() = " + tmp);
63 (tmp = new Array).f = Object.prototype.toString;
64 ok(tmp.f() === "[object Array]", "tmp.f() = " + tmp.f());
65 (tmp = new Boolean).f = Object.prototype.toString;
66 ok(tmp.f() === "[object Boolean]", "tmp.f() = " + tmp.f());
67 (tmp = new Date).f = Object.prototype.toString;
68 ok(tmp.f() === "[object Date]", "tmp.f() = " + tmp.f());
69 (tmp = function() {}).f = Object.prototype.toString;
70 ok(tmp.f() === "[object Function]", "tmp.f() = " + tmp.f());
71 Math.f = Object.prototype.toString;
72 ok(Math.f() === "[object Math]", "tmp.f() = " + tmp.f());
73 (tmp = new Number).f = Object.prototype.toString;
74 ok(tmp.f() === "[object Number]", "tmp.f() = " + tmp.f());
75 (tmp = new RegExp("")).f = Object.prototype.toString;
76 ok(tmp.f() === "[object RegExp]", "tmp.f() = " + tmp.f());
77 (tmp = new String).f = Object.prototype.toString;
78 ok(tmp.f() === "[object String]", "tmp.f() = " + tmp.f());
80 ok("".length === 0, "\"\".length = " + "".length);
81 ok(getVT("".length) == "VT_I4", "\"\".length = " + "".length);
82 ok("abc".length === 3, "\"abc\".length = " + "abc".length);
83 ok(String.prototype.length === 0, "String.prototype.length = " + String.prototype.length);
86 ok(tmp === "", "''.toString() = " + tmp);
87 tmp = "test".toString();
88 ok(tmp === "test", "''.toString() = " + tmp);
89 tmp = "test".toString(3);
90 ok(tmp === "test", "''.toString(3) = " + tmp);
93 ok(tmp === "", "''.valueOf() = " + tmp);
94 tmp = "test".valueOf();
95 ok(tmp === "test", "''.valueOf() = " + tmp);
96 tmp = "test".valueOf(3);
97 ok(tmp === "test", "''.valueOf(3) = " + tmp);
99 var str = new String("test");
100 ok(str.toString() === "test", "str.toString() = " + str.toString());
101 var str = new String();
102 ok(str.toString() === "", "str.toString() = " + str.toString());
103 var str = new String("test", "abc");
104 ok(str.toString() === "test", "str.toString() = " + str.toString());
106 tmp = "value " + str;
107 ok(tmp === "value test", "'value ' + str = " + tmp);
110 ok(tmp === "", "String() = " + tmp);
112 ok(tmp === "false", "String(false) = " + tmp);
114 ok(tmp === "null", "String(null) = " + tmp);
115 tmp = String("test");
116 ok(tmp === "test", "String('test') = " + tmp);
117 tmp = String("test", "abc");
118 ok(tmp === "test", "String('test','abc') = " + tmp);
120 tmp = "abc".charAt(0);
121 ok(tmp === "a", "'abc',charAt(0) = " + tmp);
122 tmp = "abc".charAt(1);
123 ok(tmp === "b", "'abc',charAt(1) = " + tmp);
124 tmp = "abc".charAt(2);
125 ok(tmp === "c", "'abc',charAt(2) = " + tmp);
126 tmp = "abc".charAt(3);
127 ok(tmp === "", "'abc',charAt(3) = " + tmp);
128 tmp = "abc".charAt(4);
129 ok(tmp === "", "'abc',charAt(4) = " + tmp);
130 tmp = "abc".charAt();
131 ok(tmp === "a", "'abc',charAt() = " + tmp);
132 tmp = "abc".charAt(-1);
133 ok(tmp === "", "'abc',charAt(-1) = " + tmp);
134 tmp = "abc".charAt(0,2);
135 ok(tmp === "a", "'abc',charAt(0.2) = " + tmp);
137 tmp = "abc".charCodeAt(0);
138 ok(tmp === 0x61, "'abc'.charCodeAt(0) = " + tmp);
139 tmp = "abc".charCodeAt(1);
140 ok(tmp === 0x62, "'abc'.charCodeAt(1) = " + tmp);
141 tmp = "abc".charCodeAt(2);
142 ok(tmp === 0x63, "'abc'.charCodeAt(2) = " + tmp);
143 tmp = "abc".charCodeAt();
144 ok(tmp === 0x61, "'abc'.charCodeAt() = " + tmp);
145 tmp = "abc".charCodeAt(true);
146 ok(tmp === 0x62, "'abc'.charCodeAt(true) = " + tmp);
147 tmp = "abc".charCodeAt(0,2);
148 ok(tmp === 0x61, "'abc'.charCodeAt(0,2) = " + tmp);
150 tmp = "abcd".substring(1,3);
151 ok(tmp === "bc", "'abcd'.substring(1,3) = " + tmp);
152 tmp = "abcd".substring(-1,3);
153 ok(tmp === "abc", "'abcd'.substring(-1,3) = " + tmp);
154 tmp = "abcd".substring(1,6);
155 ok(tmp === "bcd", "'abcd'.substring(1,6) = " + tmp);
156 tmp = "abcd".substring(3,1);
157 ok(tmp === "bc", "'abcd'.substring(3,1) = " + tmp);
158 tmp = "abcd".substring(2,2);
159 ok(tmp === "", "'abcd'.substring(2,2) = " + tmp);
160 tmp = "abcd".substring(true,"3");
161 ok(tmp === "bc", "'abcd'.substring(true,'3') = " + tmp);
162 tmp = "abcd".substring(1,3,2);
163 ok(tmp === "bc", "'abcd'.substring(1,3,2) = " + tmp);
164 tmp = "abcd".substring();
165 ok(tmp === "abcd", "'abcd'.substring() = " + tmp);
167 tmp = "abcd".slice(1,3);
168 ok(tmp === "bc", "'abcd'.slice(1,3) = " + tmp);
169 tmp = "abcd".slice(1,-1);
170 ok(tmp === "bc", "'abcd'.slice(1,-1) = " + tmp);
171 tmp = "abcd".slice(-3,3);
172 ok(tmp === "bc", "'abcd'.slice(-3,3) = " + tmp);
173 tmp = "abcd".slice(-6,3);
174 ok(tmp === "abc", "'abcd'.slice(-6,3) = " + tmp);
175 tmp = "abcd".slice(3,1);
176 ok(tmp === "", "'abcd'.slice(3,1) = " + tmp);
177 tmp = "abcd".slice(true,3);
178 ok(tmp === "bc", "'abcd'.slice(true,3) = " + tmp);
179 tmp = "abcd".slice();
180 ok(tmp === "abcd", "'abcd'.slice() = " + tmp);
181 tmp = "abcd".slice(1);
182 ok(tmp === "bcd", "'abcd'.slice(1) = " + tmp);
184 tmp = "abc".concat(["d",1],2,false);
185 ok(tmp === "abcd,12false", "concat returned " + tmp);
186 var arr = new Array(2,"a");
187 arr.concat = String.prototype.concat;
188 tmp = arr.concat("d");
189 ok(tmp === "2,ad", "arr.concat = " + tmp);
191 m = "a+bcabc".match("a+");
192 ok(typeof(m) === "object", "typeof m is not object");
193 ok(m.length === 1, "m.length is not 1");
194 ok(m["0"] === "a", "m[0] is not \"ab\"");
196 r = "- [test] -".replace("[test]", "success");
197 ok(r === "- success -", "r = " + r + " expected '- success -'");
199 r = "- [test] -".replace("[test]", "success", "test");
200 ok(r === "- success -", "r = " + r + " expected '- success -'");
202 r = "test".replace();
203 ok(r === "test", "r = " + r + " expected 'test'");
205 function replaceFunc3(m, off, str) {
206 ok(arguments.length === 3, "arguments.length = " + arguments.length);
207 ok(m === "[test]", "m = " + m + " expected [test1]");
208 ok(off === 1, "off = " + off + " expected 0");
209 ok(str === "-[test]-", "str = " + arguments[3]);
213 r = "-[test]-".replace("[test]", replaceFunc3);
214 ok(r === "-ret-", "r = " + r + " expected '-ret-'");
216 r = "-[test]-".replace("[test]", replaceFunc3, "test");
217 ok(r === "-ret-", "r = " + r + " expected '-ret-'");
219 r = "1,2,3".split(",");
220 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
221 ok(r.length === 3, "r.length = " + r.length);
222 ok(r[0] === "1", "r[0] = " + r[0]);
223 ok(r[1] === "2", "r[1] = " + r[1]);
224 ok(r[2] === "3", "r[2] = " + r[2]);
227 r = "1,2,3".split(",*");
228 ok(r.length === 1, "r.length = " + r.length);
229 ok(r[0] === "1,2,3", "r[0] = " + r[0]);
232 ok(r.length === 3, "r.length = " + r.length);
233 ok(r[0] === "1", "r[0] = " + r[0]);
234 ok(r[1] === "2", "r[1] = " + r[1]);
235 ok(r[2] === "3", "r[2] = " + r[2]);
238 ok(r.length === 2, "r.length = " + r.length);
239 ok(r[0] === "1", "r[0] = " + r[0]);
240 ok(r[1] === "3", "r[1] = " + r[1]);
242 r = "1,2,".split(",");
243 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
244 ok(r.length === 3, "r.length = " + r.length);
245 ok(r[0] === "1", "r[0] = " + r[0]);
246 ok(r[1] === "2", "r[1] = " + r[1]);
247 ok(r[2] === "", "r[2] = " + r[2]);
249 tmp = "abcd".indexOf("bc",0);
250 ok(tmp === 1, "indexOf = " + tmp);
251 tmp = "abcd".indexOf("bc",1);
252 ok(tmp === 1, "indexOf = " + tmp);
253 tmp = "abcd".indexOf("bc");
254 ok(tmp === 1, "indexOf = " + tmp);
255 tmp = "abcd".indexOf("ac");
256 ok(tmp === -1, "indexOf = " + tmp);
257 tmp = "abcd".indexOf("bc",2);
258 ok(tmp === -1, "indexOf = " + tmp);
259 tmp = "abcd".indexOf("a",0);
260 ok(tmp === 0, "indexOf = " + tmp);
261 tmp = "abcd".indexOf("bc",0,"test");
262 ok(tmp === 1, "indexOf = " + tmp);
263 tmp = "abcd".indexOf();
264 ok(tmp == -1, "indexOf = " + tmp);
266 tmp = "".toLowerCase();
267 ok(tmp === "", "''.toLowerCase() = " + tmp);
268 tmp = "test".toLowerCase();
269 ok(tmp === "test", "''.toLowerCase() = " + tmp);
270 tmp = "test".toLowerCase(3);
271 ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
272 tmp = "tEsT".toLowerCase();
273 ok(tmp === "test", "''.toLowerCase() = " + tmp);
274 tmp = "tEsT".toLowerCase(3);
275 ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
277 tmp = "".toUpperCase();
278 ok(tmp === "", "''.toUpperCase() = " + tmp);
279 tmp = "TEST".toUpperCase();
280 ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
281 tmp = "TEST".toUpperCase(3);
282 ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
283 tmp = "tEsT".toUpperCase();
284 ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
285 tmp = "tEsT".toUpperCase(3);
286 ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
289 ok(tmp === "<A NAME=\"undefined\"></A>", "''.anchor() = " + tmp);
291 ok(tmp === "<A NAME=\"3\"></A>", "''.anchor(3) = " + tmp);
292 tmp = "".anchor("red");
293 ok(tmp === "<A NAME=\"red\"></A>", "''.anchor('red') = " + tmp);
294 tmp = "test".anchor();
295 ok(tmp === "<A NAME=\"undefined\">test</A>", "'test'.anchor() = " + tmp);
296 tmp = "test".anchor(3);
297 ok(tmp === "<A NAME=\"3\">test</A>", "'test'.anchor(3) = " + tmp);
298 tmp = "test".anchor("green");
299 ok(tmp === "<A NAME=\"green\">test</A>", "'test'.anchor('green') = " + tmp);
302 ok(tmp === "<BIG></BIG>", "''.big() = " + tmp);
304 ok(tmp === "<BIG></BIG>", "''.big(3) = " + tmp);
306 ok(tmp === "<BIG>test</BIG>", "'test'.big() = " + tmp);
308 ok(tmp === "<BIG>test</BIG>", "'test'.big(3) = " + tmp);
311 ok(tmp === "<BLINK></BLINK>", "''.blink() = " + tmp);
313 ok(tmp === "<BLINK></BLINK>", "''.blink(3) = " + tmp);
314 tmp = "test".blink();
315 ok(tmp === "<BLINK>test</BLINK>", "'test'.blink() = " + tmp);
316 tmp = "test".blink(3);
317 ok(tmp === "<BLINK>test</BLINK>", "'test'.blink(3) = " + tmp);
320 ok(tmp === "<B></B>", "''.bold() = " + tmp);
322 ok(tmp === "<B></B>", "''.bold(3) = " + tmp);
324 ok(tmp === "<B>test</B>", "'test'.bold() = " + tmp);
325 tmp = "test".bold(3);
326 ok(tmp === "<B>test</B>", "'test'.bold(3) = " + tmp);
329 ok(tmp === "<TT></TT>", "''.fixed() = " + tmp);
331 ok(tmp === "<TT></TT>", "''.fixed(3) = " + tmp);
332 tmp = "test".fixed();
333 ok(tmp === "<TT>test</TT>", "'test'.fixed() = " + tmp);
334 tmp = "test".fixed(3);
335 ok(tmp === "<TT>test</TT>", "'test'.fixed(3) = " + tmp);
337 tmp = "".fontcolor();
338 ok(tmp === "<FONT COLOR=\"undefined\"></FONT>", "''.fontcolor() = " + tmp);
339 tmp = "".fontcolor(3);
340 ok(tmp === "<FONT COLOR=\"3\"></FONT>", "''.fontcolor(3) = " + tmp);
341 tmp = "".fontcolor("red");
342 ok(tmp === "<FONT COLOR=\"red\"></FONT>", "''.fontcolor('red') = " + tmp);
343 tmp = "test".fontcolor();
344 ok(tmp === "<FONT COLOR=\"undefined\">test</FONT>", "'test'.fontcolor() = " + tmp);
345 tmp = "test".fontcolor(3);
346 ok(tmp === "<FONT COLOR=\"3\">test</FONT>", "'test'.fontcolor(3) = " + tmp);
347 tmp = "test".fontcolor("green");
348 ok(tmp === "<FONT COLOR=\"green\">test</FONT>", "'test'.fontcolor('green') = " + tmp);
351 ok(tmp === "<FONT SIZE=\"undefined\"></FONT>", "''.fontsize() = " + tmp);
352 tmp = "".fontsize(3);
353 ok(tmp === "<FONT SIZE=\"3\"></FONT>", "''.fontsize(3) = " + tmp);
354 tmp = "".fontsize("red");
355 ok(tmp === "<FONT SIZE=\"red\"></FONT>", "''.fontsize('red') = " + tmp);
356 tmp = "test".fontsize();
357 ok(tmp === "<FONT SIZE=\"undefined\">test</FONT>", "'test'.fontsize() = " + tmp);
358 tmp = "test".fontsize(3);
359 ok(tmp === "<FONT SIZE=\"3\">test</FONT>", "'test'.fontsize(3) = " + tmp);
360 tmp = "test".fontsize("green");
361 ok(tmp === "<FONT SIZE=\"green\">test</FONT>", "'test'.fontsize('green') = " + tmp);
363 tmp = ("".fontcolor()).fontsize();
364 ok(tmp === "<FONT SIZE=\"undefined\"><FONT COLOR=\"undefined\"></FONT></FONT>", "(''.fontcolor()).fontsize() = " + tmp);
367 ok(tmp === "<I></I>", "''.italics() = " + tmp);
369 ok(tmp === "<I></I>", "''.italics(3) = " + tmp);
370 tmp = "test".italics();
371 ok(tmp === "<I>test</I>", "'test'.italics() = " + tmp);
372 tmp = "test".italics(3);
373 ok(tmp === "<I>test</I>", "'test'.italics(3) = " + tmp);
376 ok(tmp === "<A HREF=\"undefined\"></A>", "''.link() = " + tmp);
378 ok(tmp === "<A HREF=\"3\"></A>", "''.link(3) = " + tmp);
379 tmp = "".link("red");
380 ok(tmp === "<A HREF=\"red\"></A>", "''.link('red') = " + tmp);
382 ok(tmp === "<A HREF=\"undefined\">test</A>", "'test'.link() = " + tmp);
383 tmp = "test".link(3);
384 ok(tmp === "<A HREF=\"3\">test</A>", "'test'.link(3) = " + tmp);
385 tmp = "test".link("green");
386 ok(tmp === "<A HREF=\"green\">test</A>", "'test'.link('green') = " + tmp);
389 ok(tmp === "<SMALL></SMALL>", "''.small() = " + tmp);
391 ok(tmp === "<SMALL></SMALL>", "''.small(3) = " + tmp);
392 tmp = "test".small();
393 ok(tmp === "<SMALL>test</SMALL>", "'test'.small() = " + tmp);
394 tmp = "test".small(3);
395 ok(tmp === "<SMALL>test</SMALL>", "'test'.small(3) = " + tmp);
398 ok(tmp === "<STRIKE></STRIKE>", "''.strike() = " + tmp);
400 ok(tmp === "<STRIKE></STRIKE>", "''.strike(3) = " + tmp);
401 tmp = "test".strike();
402 ok(tmp === "<STRIKE>test</STRIKE>", "'test'.strike() = " + tmp);
403 tmp = "test".strike(3);
404 ok(tmp === "<STRIKE>test</STRIKE>", "'test'.strike(3) = " + tmp);
407 ok(tmp === "<SUB></SUB>", "''.sub() = " + tmp);
409 ok(tmp === "<SUB></SUB>", "''.sub(3) = " + tmp);
411 ok(tmp === "<SUB>test</SUB>", "'test'.sub() = " + tmp);
413 ok(tmp === "<SUB>test</SUB>", "'test'.sub(3) = " + tmp);
416 ok(tmp === "<SUP></SUP>", "''.sup() = " + tmp);
418 ok(tmp === "<SUP></SUP>", "''.sup(3) = " + tmp);
420 ok(tmp === "<SUP>test</SUP>", "'test'.sup() = " + tmp);
422 ok(tmp === "<SUP>test</SUP>", "'test'.sup(3) = " + tmp);
424 ok(String.fromCharCode() === "", "String.fromCharCode() = " + String.fromCharCode());
425 ok(String.fromCharCode(65,"66",67) === "ABC", "String.fromCharCode(65,'66',67) = " + String.fromCharCode(65,"66",67));
426 ok(String.fromCharCode(1024*64+65, -1024*64+65) === "AA",
427 "String.fromCharCode(1024*64+65, -1024*64+65) = " + String.fromCharCode(1024*64+65, -1024*64+65));
428 ok(String.fromCharCode(65, NaN, undefined).length === 3,
429 "String.fromCharCode(65, NaN, undefined).length = " + String.fromCharCode(65, NaN, undefined).length);
431 var arr = new Array();
432 ok(typeof(arr) === "object", "arr () is not object");
433 ok((arr.length === 0), "arr.length is not 0");
434 ok(arr["0"] === undefined, "arr[0] is not undefined");
436 var arr = new Array(1, 2, "test");
437 ok(typeof(arr) === "object", "arr (1,2,test) is not object");
438 ok((arr.length === 3), "arr.length is not 3");
439 ok(arr["0"] === 1, "arr[0] is not 1");
440 ok(arr["1"] === 2, "arr[1] is not 2");
441 ok(arr["2"] === "test", "arr[2] is not \"test\"");
444 ok((arr.length === 8), "arr.length is not 8");
447 ok(tmp === "", "'' + [] = " + tmp);
449 ok(tmp === "1,true", "'' + [1,true] = " + tmp);
451 var arr = new Array(6);
452 ok(typeof(arr) === "object", "arr (6) is not object");
453 ok((arr.length === 6), "arr.length is not 6");
454 ok(arr["0"] === undefined, "arr[0] is not undefined");
456 ok(arr.push() === 6, "arr.push() !== 6");
457 ok(arr.push(1) === 7, "arr.push(1) !== 7");
458 ok(arr[6] === 1, "arr[6] != 1");
459 ok(arr.length === 7, "arr.length != 10");
460 ok(arr.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10");
461 ok(arr[8] === "b", "arr[8] != 'b'");
462 ok(arr.length === 10, "arr.length != 10");
466 ok(arr.length === 2, "arr.length = " + arr.length);
467 ok(tmp === 5, "pop() = " + tmp);
469 ok(arr.length === 1, "arr.length = " + arr.length);
470 ok(tmp === 4, "pop() = " + tmp);
472 ok(arr.length === 0, "arr.length = " + arr.length);
473 ok(tmp === 3, "pop() = " + tmp);
475 ok(false, "not deleted " + tmp);
477 ok(arr.length === 0, "arr.length = " + arr.length);
478 ok(tmp === undefined, "tmp = " + tmp);
481 ok(arr.length === 5, "arr.length = " + arr.length);
482 ok(tmp === undefined, "tmp = " + tmp);
484 arr = [1,2,null,false,undefined,,"a"];
487 ok(tmp === "1,2,,false,,,a", "arr.join() = " + tmp);
489 ok(tmp === "1;2;;false;;;a", "arr.join(';') = " + tmp);
490 tmp = arr.join(";","test");
491 ok(tmp === "1;2;;false;;;a", "arr.join(';') = " + tmp);
493 ok(tmp === "12falsea", "arr.join('') = " + tmp);
495 tmp = arr.toString();
496 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
497 tmp = arr.toString("test");
498 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
500 arr = [5,true,2,-1,3,false,"2.5"];
501 tmp = arr.sort(function(x,y) { return y-x; });
502 ok(tmp === arr, "tmp !== arr");
503 tmp = [5,3,"2.5",2,true,false,-1];
504 for(var i=0; i < arr.length; i++)
505 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
507 arr = [5,false,2,0,"abc",3,"a",-1];
509 ok(tmp === arr, "tmp !== arr");
510 tmp = [-1,0,2,3,5,"a","abc",false];
511 for(var i=0; i < arr.length; i++)
512 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
514 arr = ["a", "b", "ab"];
515 tmp = ["a", "ab", "b"];
516 ok(arr.sort() === arr, "arr.sort() !== arr");
517 for(var i=0; i < arr.length; i++)
518 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
520 arr = ["1", "2", "3"];
522 ok(arr.length === 1, "arr.length = " + arr.length);
524 ok(arr.length === 3, "arr.length = " + arr.length);
525 ok(arr.toString() === "1,,", "arr.toString() = " + arr.toString());
527 arr = Array("a","b","c");
528 ok(arr.toString() === "a,b,c", "arr.toString() = " + arr.toString());
530 ok(arr.valueOf === Object.prototype.valueOf, "arr.valueOf !== Object.prototype.valueOf");
531 ok(arr === arr.valueOf(), "arr !== arr.valueOf");
533 var num = new Number(6);
535 tmp = arr.concat(3, [4,5], num);
536 ok(tmp !== arr, "tmp === arr");
537 for(var i=0; i<6; i++)
538 ok(tmp[i] === i, "tmp[" + i + "] = " + tmp[i]);
539 ok(tmp[6] === num, "tmp[6] !== num");
540 ok(tmp.length === 7, "tmp.length = " + tmp.length);
543 ok(arr.length === 0, "arr.length = " + arr.length);
546 tmp = arr.concat([2]);
547 ok(tmp.length === 3, "tmp.length = " + tmp.length);
548 ok(tmp[1] === undefined, "tmp[1] = " + tmp[1]);
550 arr = [1,false,'a',null,undefined,'a'];
551 ok(arr.slice(0,6).toString() === "1,false,a,,,a", "arr.slice(0,6).toString() = " + arr.slice(0,6));
552 ok(arr.slice(0,6).length === 6, "arr.slice(0,6).length = " + arr.slice(0,6).length);
553 ok(arr.slice().toString() === "1,false,a,,,a", "arr.slice().toString() = " + arr.slice());
554 ok(arr.slice("abc").toString() === "1,false,a,,,a", "arr.slice(\"abc\").toString() = " + arr.slice("abc"));
555 ok(arr.slice(3,8).toString() === ",,a", "arr.slice(3,8).toString() = " + arr.slice(3,8));
556 ok(arr.slice(3,8).length === 3, "arr.slice(3,8).length = " + arr.slice(3,8).length);
557 ok(arr.slice(1).toString() === "false,a,,,a", "arr.slice(1).toString() = " + arr.slice(1));
558 ok(arr.slice(-2).toString() === ",a", "arr.slice(-2).toString() = " + arr.slice(-2));
559 ok(arr.slice(3,1).toString() === "", "arr.slice(3,1).toString() = " + arr.slice(3,1));
560 tmp = arr.slice(0,6);
561 for(var i=0; i < arr.length; i++)
562 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
564 ok(arr.slice(5).toString() === "a,,,,,,,2", "arr.slice(5).toString() = " + arr.slice(5).toString());
565 ok(arr.slice(5).length === 8, "arr.slice(5).length = " + arr.slice(5).length);
567 var num = new Number(2);
568 ok(num.toString() === "2", "num(2).toString !== 2");
569 var num = new Number();
570 ok(num.toString() === "0", "num().toString !== 0");
572 ok(Number() === 0, "Number() = " + Number());
573 ok(Number(false) === 0, "Number(false) = " + Number(false));
574 ok(Number("43") === 43, "Number('43') = " + Number("43"));
576 tmp = (new Number(1)).valueOf();
577 ok(tmp === 1, "(new Number(1)).valueOf = " + tmp);
578 tmp = (new Number(1,2)).valueOf();
579 ok(tmp === 1, "(new Number(1,2)).valueOf = " + tmp);
580 tmp = (new Number()).valueOf();
581 ok(tmp === 0, "(new Number()).valueOf = " + tmp);
582 tmp = Number.prototype.valueOf();
583 ok(tmp === 0, "Number.prototype.valueOf = " + tmp);
585 function equals(val, base) {
588 var str = val.toString(base);
590 for(i=0; i<str.length; i++) {
591 if(str.substring(i, i+1) == '(') break;
592 if(str.substring(i, i+1) == '.') break;
593 num = num*base + parseInt(str.substring(i, i+1));
596 if(str.substring(i, i+1) == '.') {
598 for(i++; i<str.length; i++) {
599 if(str.substring(i, i+1) == '(') break;
600 num += parseInt(str.substring(i, i+1))/mult;
605 if(str.substring(i, i+1) == '(') {
606 exp = parseInt(str.substring(i+2));
607 num *= Math.pow(base, exp);
610 ok(num>val-val/1000 && num<val+val/1000, "equals: num = " + num);
613 ok((10).toString(11) === "a", "(10).toString(11) = " + (10).toString(11));
614 ok((213213433).toString(17) === "8e2ddcb", "(213213433).toString(17) = " + (213213433).toString(17));
615 ok((-3254343).toString(33) === "-2oicf", "(-3254343).toString(33) = " + (-3254343).toString(33));
616 ok((NaN).toString(12) === "NaN", "(NaN).toString(11) = " + (NaN).toString(11));
617 ok((Infinity).toString(13) === "Infinity", "(Infinity).toString(11) = " + (Infinity).toString(11));
618 for(i=2; i<10; i++) {
620 equals(2305843009200000000, i);
623 equals(1024*1024*1024*1024*1024*1024*1.9999, i);
626 equals(4.65661287308e-10, i);
627 ok((0).toString(i) === "0", "(0).toString("+i+") = " + (0).toString(i));
631 ok(tmp === 1, "Math.min(1) = " + tmp);
633 tmp = Math.min(1, false);
634 ok(tmp === 0, "Math.min(1, false) = " + tmp);
637 ok(tmp === Infinity, "Math.min() = " + tmp);
639 tmp = Math.min(1, NaN, -Infinity, false);
640 ok(isNaN(tmp), "Math.min(1, NaN, -Infinity, false) is not NaN");
642 tmp = Math.min(1, false, true, null, -3);
643 ok(tmp === -3, "Math.min(1, false, true, null, -3) = " + tmp);
646 ok(tmp === 1, "Math.max(1) = " + tmp);
648 tmp = Math.max(true, 0);
649 ok(tmp === 1, "Math.max(true, 0) = " + tmp);
651 tmp = Math.max(-2, false, true, null, 1);
652 ok(tmp === 1, "Math.max(-2, false, true, null, 1) = " + tmp);
655 ok(tmp === -Infinity, "Math.max() = " + tmp);
657 tmp = Math.max(true, NaN, 0);
658 ok(isNaN(tmp), "Math.max(true, NaN, 0) is not NaN");
660 tmp = Math.round(0.5);
661 ok(tmp === 1, "Math.round(0.5) = " + tmp);
663 tmp = Math.round(-0.5);
664 ok(tmp === 0, "Math.round(-0.5) = " + tmp);
666 tmp = Math.round(1.1);
667 ok(tmp === 1, "Math.round(1.1) = " + tmp);
669 tmp = Math.round(true);
670 ok(tmp === 1, "Math.round(true) = " + tmp);
672 tmp = Math.round(1.1, 3, 4);
673 ok(tmp === 1, "Math.round(1.1, 3, 4) = " + tmp);
676 ok(isNaN(tmp), "Math.round() is not NaN");
678 tmp = Math.ceil(0.5);
679 ok(tmp === 1, "Math.ceil(0.5) = " + tmp);
681 tmp = Math.ceil(-0.5);
682 ok(tmp === 0, "Math.ceil(-0.5) = " + tmp);
684 tmp = Math.ceil(1.1);
685 ok(tmp === 2, "Math.round(1.1) = " + tmp);
687 tmp = Math.ceil(true);
688 ok(tmp === 1, "Math.ceil(true) = " + tmp);
690 tmp = Math.ceil(1.1, 3, 4);
691 ok(tmp === 2, "Math.ceil(1.1, 3, 4) = " + tmp);
694 ok(isNaN(tmp), "ceil() is not NaN");
696 tmp = Math.floor(0.5);
697 ok(tmp === 0, "Math.floor(0.5) = " + tmp);
699 tmp = Math.floor(-0.5);
700 ok(tmp === -1, "Math.floor(-0.5) = " + tmp);
702 tmp = Math.floor(1.1);
703 ok(tmp === 1, "Math.floor(1.1) = " + tmp);
705 tmp = Math.floor(true);
706 ok(tmp === 1, "Math.floor(true) = " + tmp);
708 tmp = Math.floor(1.1, 3, 4);
709 ok(tmp === 1, "Math.floor(1.1, 3, 4) = " + tmp);
712 ok(isNaN(tmp), "floor is not NaN");
715 ok(tmp === 3, "Math.abs(3) = " + tmp);
718 ok(tmp === 3, "Math.abs(-3) = " + tmp);
720 tmp = Math.abs(true);
721 ok(tmp === 1, "Math.abs(true) = " + tmp);
724 ok(isNaN(tmp), "Math.abs() is not NaN");
727 ok(isNaN(tmp), "Math.abs() is not NaN");
729 tmp = Math.abs(-Infinity);
730 ok(tmp === Infinity, "Math.abs(-Infinite) = " + tmp);
732 tmp = Math.abs(-3, 2);
733 ok(tmp === 3, "Math.abs(-3, 2) = " + tmp);
736 ok(tmp === 1, "Math.cos(0) = " + tmp);
738 tmp = Math.cos(Math.PI/2);
739 ok(Math.floor(tmp*100) === 0, "Math.cos(Math.PI/2) = " + tmp);
741 tmp = Math.cos(-Math.PI/2);
742 ok(Math.floor(tmp*100) === 0, "Math.cos(-Math.PI/2) = " + tmp);
744 tmp = Math.cos(Math.PI/3, 2);
745 ok(Math.floor(tmp*100) === 50, "Math.cos(Math.PI/3, 2) = " + tmp);
747 tmp = Math.cos(true);
748 ok(Math.floor(tmp*100) === 54, "Math.cos(true) = " + tmp);
750 tmp = Math.cos(false);
751 ok(tmp === 1, "Math.cos(false) = " + tmp);
754 ok(isNaN(tmp), "Math.cos() is not NaN");
757 ok(isNaN(tmp), "Math.cos(NaN) is not NaN");
759 tmp = Math.cos(Infinity);
760 ok(isNaN(tmp), "Math.cos(Infinity) is not NaN");
762 tmp = Math.cos(-Infinity);
763 ok(isNaN(tmp), "Math.cos(-Infinity) is not NaN");
765 tmp = Math.pow(2, 2);
766 ok(tmp === 4, "Math.pow(2, 2) = " + tmp);
768 tmp = Math.pow(4, 0.5);
769 ok(tmp === 2, "Math.pow(2, 2) = " + tmp);
771 tmp = Math.pow(2, 2, 3);
772 ok(tmp === 4, "Math.pow(2, 2, 3) = " + tmp);
775 ok(isNaN(tmp), "Math.pow(2) is not NaN");
778 ok(isNaN(tmp), "Math.pow() is not NaN");
781 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
782 ok(0 <= tmp && tmp <= 1, "Math.random() = " + tmp);
784 tmp = Math.random(100);
785 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
786 ok(0 <= tmp && tmp <= 1, "Math.random(100) = " + tmp);
789 ok(Math.floor(tmp*100) === 157, "Math.acos(0) = " + tmp);
792 ok(Math.floor(tmp*100) === 0, "Math.acos(1) = " + tmp);
795 ok(Math.floor(tmp*100) === 314, "Math.acos(-1) = " + tmp);
797 tmp = Math.acos(Math.PI/4, 2);
798 ok(Math.floor(tmp*100) === 66, "Math.acos(Math.PI/4, 2) = " + tmp);
800 tmp = Math.acos(true);
801 ok(Math.floor(tmp*100) === 0, "Math.acos(true) = " + tmp);
803 tmp = Math.acos(false);
804 ok(Math.floor(tmp*100) === 157, "Math.acos(false) = " + tmp);
806 tmp = Math.acos(1.1);
807 ok(isNaN(tmp), "Math.acos(1.1) is not NaN");
810 ok(isNaN(tmp), "Math.acos() is not NaN");
812 tmp = Math.acos(NaN);
813 ok(isNaN(tmp), "Math.acos(NaN) is not NaN");
815 tmp = Math.acos(Infinity);
816 ok(isNaN(tmp), "Math.acos(Infinity) is not NaN");
818 tmp = Math.acos(-Infinity);
819 ok(isNaN(tmp), "Math.acos(-Infinity) is not NaN");
822 ok(Math.floor(tmp*100) === 0, "Math.asin(0) = " + tmp);
825 ok(Math.floor(tmp*100) === 157, "Math.asin(1) = " + tmp);
828 ok(Math.floor(tmp*100) === -158, "Math.asin(-1) = " + tmp);
830 tmp = Math.asin(Math.PI/4, 2);
831 ok(Math.floor(tmp*100) === 90, "Math.asin(Math.PI/4, 2) = " + tmp);
833 tmp = Math.asin(true);
834 ok(Math.floor(tmp*100) === 157, "Math.asin(true) = " + tmp);
836 tmp = Math.asin(false);
837 ok(Math.floor(tmp*100) === 0, "Math.asin(false) = " + tmp);
839 tmp = Math.asin(1.1);
840 ok(isNaN(tmp), "Math.asin(1.1) is not NaN");
843 ok(isNaN(tmp), "Math.asin() is not NaN");
845 tmp = Math.asin(NaN);
846 ok(isNaN(tmp), "Math.asin(NaN) is not NaN");
848 tmp = Math.asin(Infinity);
849 ok(isNaN(tmp), "Math.asin(Infinity) is not NaN");
851 tmp = Math.asin(-Infinity);
852 ok(isNaN(tmp), "Math.asin(-Infinity) is not NaN");
855 ok(Math.floor(tmp*100) === 0, "Math.atan(0) = " + tmp);
858 ok(Math.floor(tmp*100) === 78, "Math.atan(1) = " + tmp);
861 ok(Math.floor(tmp*100) === -79, "Math.atan(-1) = " + tmp);
863 tmp = Math.atan(true);
864 ok(Math.floor(tmp*100) === 78, "Math.atan(true) = " + tmp);
866 tmp = Math.atan(false);
867 ok(Math.floor(tmp*100) === 0, "Math.atan(false) = " + tmp);
870 ok(isNaN(tmp), "Math.atan() is not NaN");
872 tmp = Math.atan(NaN);
873 ok(isNaN(tmp), "Math.atan(NaN) is not NaN");
875 tmp = Math.atan(Infinity);
876 ok(Math.floor(tmp*100) === 157, "Math.atan(Infinity) = " + tmp);
878 tmp = Math.atan(-Infinity);
879 ok(Math.floor(tmp*100) === -158, "Math.atan(Infinity) = " + tmp);
881 tmp = Math.atan2(0, 0);
882 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 0) = " + tmp);
884 tmp = Math.atan2(0, 1);
885 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 1) = " + tmp);
887 tmp = Math.atan2(0, Infinity);
888 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, Infinity) = " + tmp);
890 tmp = Math.atan2(0, -1);
891 ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -1) = " + tmp);
893 tmp = Math.atan2(0, -Infinity);
894 ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -Infinity) = " + tmp);
896 tmp = Math.atan2(1, 0);
897 ok(Math.floor(tmp*100) === 157, "Math.atan2(1, 0) = " + tmp);
899 tmp = Math.atan2(Infinity, 0);
900 ok(Math.floor(tmp*100) === 157, "Math.atan2(Infinity, 0) = " + tmp);
902 tmp = Math.atan2(-1, 0);
903 ok(Math.floor(tmp*100) === -158, "Math.atan2(-1, 0) = " + tmp);
905 tmp = Math.atan2(-Infinity, 0);
906 ok(Math.floor(tmp*100) === -158, "Math.atan2(-Infinity, 0) = " + tmp);
908 tmp = Math.atan2(1, 1);
909 ok(Math.floor(tmp*100) === 78, "Math.atan2(1, 1) = " + tmp);
911 tmp = Math.atan2(-1, -1);
912 ok(Math.floor(tmp*100) === -236, "Math.atan2(-1, -1) = " + tmp);
914 tmp = Math.atan2(-1, 1);
915 ok(Math.floor(tmp*100) === -79, "Math.atan2(-1, 1) = " + tmp);
917 tmp = Math.atan2(Infinity, Infinity);
918 ok(Math.floor(tmp*100) === 78, "Math.atan2(Infinity, Infinity) = " + tmp);
920 tmp = Math.atan2(Infinity, -Infinity, 1);
921 ok(Math.floor(tmp*100) === 235, "Math.atan2(Infinity, -Infinity, 1) = " + tmp);
924 ok(isNaN(tmp), "Math.atan2() is not NaN");
927 ok(isNaN(tmp), "Math.atan2(1) is not NaN");
930 ok(tmp === 1, "Math.exp(0) = " + tmp);
933 ok(Math.floor(tmp*100) === 271, "Math.exp(1) = " + tmp);
936 ok(Math.floor(tmp*100) === 36, "Math.exp(-1) = " + tmp);
938 tmp = Math.exp(true);
939 ok(Math.floor(tmp*100) === 271, "Math.exp(true) = " + tmp);
941 tmp = Math.exp(1, 1);
942 ok(Math.floor(tmp*100) === 271, "Math.exp(1, 1) = " + tmp);
945 ok(isNaN(tmp), "Math.exp() is not NaN");
948 ok(isNaN(tmp), "Math.exp(NaN) is not NaN");
950 tmp = Math.exp(Infinity);
951 ok(tmp === Infinity, "Math.exp(Infinity) = " + tmp);
953 tmp = Math.exp(-Infinity);
954 ok(tmp === 0, "Math.exp(-Infinity) = " + tmp);
957 ok(Math.floor(tmp*100) === 0, "Math.log(1) = " + tmp);
960 ok(isNaN(tmp), "Math.log(-1) is not NaN");
962 tmp = Math.log(true);
963 ok(Math.floor(tmp*100) === 0, "Math.log(true) = " + tmp);
965 tmp = Math.log(1, 1);
966 ok(Math.floor(tmp*100) === 0, "Math.log(1, 1) = " + tmp);
969 ok(isNaN(tmp), "Math.log() is not NaN");
972 ok(isNaN(tmp), "Math.log(NaN) is not NaN");
974 tmp = Math.log(Infinity);
975 ok(tmp === Infinity, "Math.log(Infinity) = " + tmp);
977 tmp = Math.log(-Infinity);
978 ok(isNaN(tmp), "Math.log(-Infinity) is not NaN");
981 ok(tmp === 0, "Math.sin(0) = " + tmp);
983 tmp = Math.sin(Math.PI/2);
984 ok(tmp === 1, "Math.sin(Math.PI/2) = " + tmp);
986 tmp = Math.sin(-Math.PI/2);
987 ok(tmp === -1, "Math.sin(-Math.PI/2) = " + tmp);
989 tmp = Math.sin(Math.PI/3, 2);
990 ok(Math.floor(tmp*100) === 86, "Math.sin(Math.PI/3, 2) = " + tmp);
992 tmp = Math.sin(true);
993 ok(Math.floor(tmp*100) === 84, "Math.sin(true) = " + tmp);
995 tmp = Math.sin(false);
996 ok(tmp === 0, "Math.sin(false) = " + tmp);
999 ok(isNaN(tmp), "Math.sin() is not NaN");
1001 tmp = Math.sin(NaN);
1002 ok(isNaN(tmp), "Math.sin(NaN) is not NaN");
1004 tmp = Math.sin(Infinity);
1005 ok(isNaN(tmp), "Math.sin(Infinity) is not NaN");
1007 tmp = Math.sin(-Infinity);
1008 ok(isNaN(tmp), "Math.sin(-Infinity) is not NaN");
1011 ok(tmp === 0, "Math.sqrt(0) = " + tmp);
1014 ok(tmp === 2, "Math.sqrt(4) = " + tmp);
1016 tmp = Math.sqrt(-1);
1017 ok(isNaN(tmp), "Math.sqrt(-1) is not NaN");
1019 tmp = Math.sqrt(2, 2);
1020 ok(Math.floor(tmp*100) === 141, "Math.sqrt(2, 2) = " + tmp);
1022 tmp = Math.sqrt(true);
1023 ok(tmp === 1, "Math.sqrt(true) = " + tmp);
1025 tmp = Math.sqrt(false);
1026 ok(tmp === 0, "Math.sqrt(false) = " + tmp);
1029 ok(isNaN(tmp), "Math.sqrt() is not NaN");
1031 tmp = Math.sqrt(NaN);
1032 ok(isNaN(tmp), "Math.sqrt(NaN) is not NaN");
1034 tmp = Math.sqrt(Infinity);
1035 ok(tmp === Infinity, "Math.sqrt(Infinity) = " + tmp);
1037 tmp = Math.sqrt(-Infinity);
1038 ok(isNaN(tmp), "Math.sqrt(-Infinity) is not NaN");
1041 ok(tmp === 0, "Math.tan(0) = " + tmp);
1043 tmp = Math.tan(Math.PI);
1044 ok(Math.floor(tmp*100) === -1, "Math.tan(Math.PI) = " + tmp);
1046 tmp = Math.tan(2, 2);
1047 ok(Math.floor(tmp*100) === -219, "Math.tan(2, 2) = " + tmp);
1049 tmp = Math.tan(true);
1050 ok(Math.floor(tmp*100) === 155, "Math.tan(true) = " + tmp);
1052 tmp = Math.tan(false);
1053 ok(tmp === 0, "Math.tan(false) = " + tmp);
1056 ok(isNaN(tmp), "Math.tan() is not NaN");
1058 tmp = Math.tan(NaN);
1059 ok(isNaN(tmp), "Math.tan(NaN) is not NaN");
1061 tmp = Math.tan(Infinity);
1062 ok(isNaN(tmp), "Math.tan(Infinity) is not NaN");
1064 tmp = Math.tan(-Infinity);
1065 ok(isNaN(tmp), "Math.tan(-Infinity) is not NaN");
1067 var func = function (a) {
1071 ok(func.toString() === "function (a) {\n var a = 1;\n if(a) return;\n }",
1072 "func.toString() = " + func.toString());
1073 ok("" + func === "function (a) {\n var a = 1;\n if(a) return;\n }",
1074 "'' + func.toString() = " + func);
1076 ok(func.valueOf === Object.prototype.valueOf, "func.valueOf !== Object.prototype.valueOf");
1077 ok(func === func.valueOf(), "func !== func.valueOf()");
1079 function testFuncToString(x,y) {
1082 ok(testFuncToString.toString() === "function testFuncToString(x,y) {\n return x+y;\n}",
1083 "testFuncToString.toString() = " + testFuncToString.toString());
1084 ok("" + testFuncToString === "function testFuncToString(x,y) {\n return x+y;\n}",
1085 "'' + testFuncToString = " + testFuncToString);
1087 var date = new Date();
1089 date = new Date(100);
1090 ok(date.getTime() === 100, "date.getTime() = " + date.getTime());
1091 ok(Date.prototype.getTime() === 0, "date.prototype.getTime() = " + Date.prototype.getTime());
1092 date = new Date(8.64e15);
1093 ok(date.getTime() === 8.64e15, "date.getTime() = " + date.getTime());
1094 date = new Date(8.64e15+1);
1095 ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
1096 date = new Date(Infinity);
1097 ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
1098 date = new Date("3 July 2009 22:28:00 UTC+0100");
1099 ok(date.getTime() === 1246656480000, "date.getTime() = " + date.getTime());
1100 date = new Date(1984, 11, 29, 13, 51, 24, 120);
1101 ok(date.getFullYear() === 1984, "date.getFullYear() = " + date.getFullYear());
1102 ok(date.getMonth() === 11, "date.getMonth() = " + date.getMonth());
1103 ok(date.getDate() === 29, "date.getDate() = " + date.getDate());
1104 ok(date.getHours() === 13, "date.getHours() = " + date.getHours());
1105 ok(date.getMinutes() === 51, "date.getMinutes() = " + date.getMinutes());
1106 ok(date.getSeconds() === 24, "date.getSeconds() = " + date.getSeconds());
1107 ok(date.getMilliseconds() === 120, "date.getMilliseconds() = " + date.getMilliseconds());
1108 date = new Date(731, -32, 40, -1, 70, 65, -13);
1109 ok(date.getFullYear() === 728, "date.getFullYear() = " + date.getFullYear());
1110 ok(date.getMonth() === 5, "date.getMonth() = " + date.getMonth());
1111 ok(date.getDate() === 9, "date.getDate() = " + date.getDate());
1112 ok(date.getHours() === 0, "date.getHours() = " + date.getHours());
1113 ok(date.getMinutes() === 11, "date.getMinutes() = " + date.getMinutes());
1114 ok(date.getSeconds() === 4, "date.getSeconds() = " + date.getSeconds());
1115 ok(date.getMilliseconds() === 987, "date.getMilliseconds() = " + date.getMilliseconds());
1117 ok(date.setTime(123) === 123, "date.setTime(123) !== 123");
1118 ok(date.setTime("123", NaN) === 123, "date.setTime(\"123\") !== 123");
1119 ok(isNaN(date.setTime(NaN)), "date.setTime(NaN) is not NaN");
1121 ok(date.setTime(0) === date.getTime(), "date.setTime(0) !== date.getTime()");
1122 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
1123 ok(date.getUTCMonth() === 0, "date.getUTCMonth() = " + date.getUTCMonth());
1124 ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
1125 ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
1126 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
1127 ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
1128 ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
1129 ok(date.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1130 date.setTime(60*24*60*60*1000);
1131 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
1132 ok(date.getUTCMonth() === 2, "date.getUTCMonth() = " + date.getUTCMonth());
1133 ok(date.getUTCDate() === 2, "date.getUTCDate() = " + date.getUTCDate());
1134 ok(date.getUTCDay() === 1, "date.getUTCDay() = " + date.getUTCDay());
1135 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
1136 ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
1137 ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
1138 ok(date.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1139 date.setTime(59*24*60*60*1000 + 4*365*24*60*60*1000 + 60*60*1000 + 2*60*1000 + 2*1000 + 640);
1140 ok(date.getUTCFullYear() === 1974, "date.getUTCFullYear() = " + date.getUTCFullYear());
1141 ok(date.getUTCMonth() === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1142 ok(date.getUTCMonth(123) === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1143 ok(date.getUTCDate() === 28, "date.getUTCDate() = " + date.getUTCDate());
1144 ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
1145 ok(date.getUTCHours() === 1, "date.getUTCHours() = " + date.getUTCHours());
1146 ok(date.getUTCMinutes() === 2, "date.getUTCMinutes() = " + date.getUTCMinutes());
1147 ok(date.getUTCSeconds() === 2, "date.getUTCSeconds() = " + date.getUTCSeconds());
1148 ok(date.getUTCMilliseconds() === 640, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1149 date.setTime(Infinity);
1150 ok(isNaN(date.getUTCFullYear()), "date.getUTCFullYear() is not NaN");
1151 ok(isNaN(date.getUTCMonth()), "date.getUTCMonth() is not NaN");
1152 ok(isNaN(date.getUTCDate()), "date.getUTCDate() is not NaN");
1153 ok(isNaN(date.getUTCDay()), "date.getUTCDay() is not NaN");
1154 ok(isNaN(date.getUTCHours()), "date.getUTCHours() is not NaN");
1155 ok(isNaN(date.getUTCMinutes()), "date.getUTCMinutes() is not NaN");
1156 ok(isNaN(date.getUTCSeconds()), "date.getUTCSeconds() is not NaN");
1157 ok(isNaN(date.getUTCMilliseconds()), "date.getUTCMilliseconds() is not NaN");
1158 ok(isNaN(date.setMilliseconds(0)), "date.setMilliseconds() is not NaN");
1161 date.setUTCMilliseconds(-10, 2);
1162 ok(date.getUTCMilliseconds() === 990, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1163 date.setUTCMilliseconds(10);
1164 ok(date.getUTCMilliseconds() === 10, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1165 date.setUTCSeconds(-10);
1166 ok(date.getUTCSeconds() === 50, "date.getUTCSeconds() = " + date.getUTCSeconds());
1167 date.setUTCMinutes(-10);
1168 ok(date.getUTCMinutes() === 50, "date.getUTCMinutes() = " + date.getUTCMinutes());
1169 date.setUTCHours(-10);
1170 ok(date.getUTCHours() === 14, "date.getUTCHours() = " + date.getUTCHours());
1171 date.setUTCHours(-123);
1172 ok(date.getTime() === -612549990, "date.getTime() = " + date.getTime());
1173 date.setUTCHours(20);
1174 ok(date.getUTCHours() === 20, "date.getUTCHours() = " + date.getUTCHours());
1175 date.setUTCDate(32);
1176 ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
1177 date.setUTCMonth(22, 37);
1178 ok(date.getTime() === 60987050010, "date.getTime() = " + date.getTime());
1179 date.setUTCFullYear(83, 21, 321);
1180 ok(date.getTime() === -59464984149990, "date.getTime() = " + date.getTime());
1181 ok(Math.abs(date) === 59464984149990, "Math.abs(date) = " + Math.abs(date));
1182 ok(getVT(date+1) === "VT_BSTR", "getVT(date+1) = " + getVT(date+1));
1184 ok(isNaN(Date.parse()), "Date.parse() is not NaN");
1185 ok(isNaN(Date.parse("")), "Date.parse(\"\") is not NaN");
1186 ok(isNaN(Date.parse("Jan Jan 20 2009")), "Date.parse(\"Jan Jan 20 2009\") is not NaN");
1187 ok(Date.parse("Jan 20 2009 UTC") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC\") = " + Date.parse("Jan 20 2009 UTC"));
1188 ok(Date.parse("Jan 20 2009 GMT") === 1232409600000, "Date.parse(\"Jan 20 2009 GMT\") = " + Date.parse("Jan 20 2009 GMT"));
1189 ok(Date.parse("Jan 20 2009 UTC-0") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC-0\") = " + Date.parse("Jan 20 2009 UTC-0"));
1190 ok(Date.parse("Jan 20 2009 UTC+0000") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC+0000\") = " + Date.parse("Jan 20 2009 UTC+0000"));
1191 ok(Date.parse("Ju 13 79 UTC") === 300672000000, "Date.parse(\"Ju 13 79 UTC\") = " + Date.parse("Ju 13 79 UTC"));
1192 ok(Date.parse("12Au91 UTC") === 681955200000, "Date.parse(\"12Au91 UTC\") = " + Date.parse("12Au91 UTC"));
1193 ok(Date.parse("7/02/17 UTC") === -1656806400000, "Date.parse(\"7/02/17 UTC\") = " + Date.parse("7/02/17 UTC"));
1194 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"));
1195 ok(Date.parse("February 31 UTC, 2000 12:31:17 PM") === 952000277000,
1196 "Date.parse(\"February 31 UTC, 2000 12:31:17 PM\") = " + Date.parse("February 31 UTC, 2000 12:31:17 PM"));
1197 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 "));
1198 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"));
1200 ok(typeof(Math.PI) === "number", "typeof(Math.PI) = " + typeof(Math.PI));
1201 ok(Math.floor(Math.PI*100) === 314, "Math.PI = " + Math.PI);
1203 ok(Math.floor(Math.PI*100) === 314, "modified Math.PI = " + Math.PI);
1205 ok(typeof(Math.E) === "number", "typeof(Math.E) = " + typeof(Math.E));
1206 ok(Math.floor(Math.E*100) === 271, "Math.E = " + Math.E);
1208 ok(Math.floor(Math.E*100) === 271, "modified Math.E = " + Math.E);
1210 ok(typeof(Math.LOG2E) === "number", "typeof(Math.LOG2E) = " + typeof(Math.LOG2E));
1211 ok(Math.floor(Math.LOG2E*100) === 144, "Math.LOG2E = " + Math.LOG2E);
1212 Math.LOG2E = "test";
1213 ok(Math.floor(Math.LOG2E*100) === 144, "modified Math.LOG2E = " + Math.LOG2E);
1215 ok(typeof(Math.LOG10E) === "number", "typeof(Math.LOG10E) = " + typeof(Math.LOG10E));
1216 ok(Math.floor(Math.LOG10E*100) === 43, "Math.LOG10E = " + Math.LOG10E);
1217 Math.LOG10E = "test";
1218 ok(Math.floor(Math.LOG10E*100) === 43, "modified Math.LOG10E = " + Math.LOG10E);
1220 ok(typeof(Math.LN2) === "number", "typeof(Math.LN2) = " + typeof(Math.LN2));
1221 ok(Math.floor(Math.LN2*100) === 69, "Math.LN2 = " + Math.LN2);
1223 ok(Math.floor(Math.LN2*100) === 69, "modified Math.LN2 = " + Math.LN2);
1225 ok(typeof(Math.LN10) === "number", "typeof(Math.LN10) = " + typeof(Math.LN10));
1226 ok(Math.floor(Math.LN10*100) === 230, "Math.LN10 = " + Math.LN10);
1228 ok(Math.floor(Math.LN10*100) === 230, "modified Math.LN10 = " + Math.LN10);
1230 ok(typeof(Math.SQRT2) === "number", "typeof(Math.SQRT2) = " + typeof(Math.SQRT2));
1231 ok(Math.floor(Math.SQRT2*100) === 141, "Math.SQRT2 = " + Math.SQRT2);
1232 Math.SQRT2 = "test";
1233 ok(Math.floor(Math.SQRT2*100) === 141, "modified Math.SQRT2 = " + Math.SQRT2);
1235 ok(typeof(Math.SQRT1_2) === "number", "typeof(Math.SQRT1_2) = " + typeof(Math.SQRT1_2));
1236 ok(Math.floor(Math.SQRT1_2*100) === 70, "Math.SQRT1_2 = " + Math.SQRT1_2);
1237 Math.SQRT1_2 = "test";
1238 ok(Math.floor(Math.SQRT1_2*100) === 70, "modified Math.SQRT1_2 = " + Math.SQRT1_2);
1240 var bool = new Boolean();
1241 ok(bool.toString() === "false", "bool.toString() = " + bool.toString());
1242 var bool = new Boolean("false");
1243 ok(bool.toString() === "true", "bool.toString() = " + bool.toString());
1244 ok(bool.valueOf() === Boolean(1), "bool.valueOf() = " + bool.valueOf());
1245 ok(bool.toLocaleString() === bool.toString(), "bool.toLocaleString() = " + bool.toLocaleString());
1247 ok(Error.prototype !== TypeError.prototype, "Error.prototype === TypeError.prototype");
1248 ok(RangeError.prototype !== TypeError.prototype, "RangeError.prototype === TypeError.prototype");
1249 ok(Error.prototype.toLocaleString === Object.prototype.toLocaleString,
1250 "Error.prototype.toLocaleString !== Object.prototype.toLocaleString");
1252 ok(err.valueOf === Object.prototype.valueOf, "err.valueOf !== Object.prototype.valueOf");
1253 ok(Error.prototype.name === "Error", "Error.prototype.name = " + Error.prototype.name);
1254 ok(err.name === "Error", "err.name = " + err.name);
1255 EvalError.prototype.message = "test";
1256 ok(err.toString !== Object.prototype.toString, "err.toString === Object.prototype.toString");
1257 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1258 err = new EvalError();
1259 ok(EvalError.prototype.name === "EvalError", "EvalError.prototype.name = " + EvalError.prototype.name);
1260 ok(err.name === "EvalError", "err.name = " + err.name);
1261 ok(err.toString === Error.prototype.toString, "err.toString !== Error.prototype.toString");
1262 ok(err.message === "", "err.message != ''");
1264 ok(err.message === date, "err.message != date");
1265 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1266 ok(err.toString !== Object.prototype.toString, "err.toString === Object.prototype.toString");
1267 err = new RangeError();
1268 ok(RangeError.prototype.name === "RangeError", "RangeError.prototype.name = " + RangeError.prototype.name);
1269 ok(err.name === "RangeError", "err.name = " + err.name);
1270 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1271 err = new ReferenceError();
1272 ok(ReferenceError.prototype.name === "ReferenceError", "ReferenceError.prototype.name = " + ReferenceError.prototype.name);
1273 ok(err.name === "ReferenceError", "err.name = " + err.name);
1274 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1275 err = new SyntaxError();
1276 ok(SyntaxError.prototype.name === "SyntaxError", "SyntaxError.prototype.name = " + SyntaxError.prototype.name);
1277 ok(err.name === "SyntaxError", "err.name = " + err.name);
1278 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1279 err = new TypeError();
1280 ok(TypeError.prototype.name === "TypeError", "TypeError.prototype.name = " + TypeError.prototype.name);
1281 ok(err.name === "TypeError", "err.name = " + err.name);
1282 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1283 err = new URIError();
1284 ok(URIError.prototype.name === "URIError", "URIError.prototype.name = " + URIError.prototype.name);
1285 ok(err.name === "URIError", "err.name = " + err.name);
1286 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1287 err = new Error("message");
1288 ok(err.message === "message", "err.message !== 'message'");
1289 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1291 function exception_test(func, type) {
1298 ok(ret === type, "Exception test, ret = " + ret + ", expected " + type +". Executed function: " + func.toString());
1300 exception_test(function() {arr.toString = Date.prototype.toString; arr.toString();}, "TypeError");
1301 exception_test(function() {Array(-3);}, "RangeError");