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);
64 ok("".length === 0, "\"\".length = " + "".length);
65 ok(getVT("".length) == "VT_I4", "\"\".length = " + "".length);
66 ok("abc".length === 3, "\"abc\".length = " + "abc".length);
67 ok(String.prototype.length === 0, "String.prototype.length = " + String.prototype.length);
70 ok(tmp === "", "''.toString() = " + tmp);
71 tmp = "test".toString();
72 ok(tmp === "test", "''.toString() = " + tmp);
73 tmp = "test".toString(3);
74 ok(tmp === "test", "''.toString(3) = " + tmp);
77 ok(tmp === "", "''.valueOf() = " + tmp);
78 tmp = "test".valueOf();
79 ok(tmp === "test", "''.valueOf() = " + tmp);
80 tmp = "test".valueOf(3);
81 ok(tmp === "test", "''.valueOf(3) = " + tmp);
83 var str = new String("test");
84 ok(str.toString() === "test", "str.toString() = " + str.toString());
85 var str = new String();
86 ok(str.toString() === "", "str.toString() = " + str.toString());
87 var str = new String("test", "abc");
88 ok(str.toString() === "test", "str.toString() = " + str.toString());
91 ok(tmp === "value test", "'value ' + str = " + tmp);
94 ok(tmp === "", "String() = " + tmp);
96 ok(tmp === "false", "String(false) = " + tmp);
98 ok(tmp === "null", "String(null) = " + tmp);
100 ok(tmp === "test", "String('test') = " + tmp);
101 tmp = String("test", "abc");
102 ok(tmp === "test", "String('test','abc') = " + tmp);
104 tmp = "abc".charAt(0);
105 ok(tmp === "a", "'abc',charAt(0) = " + tmp);
106 tmp = "abc".charAt(1);
107 ok(tmp === "b", "'abc',charAt(1) = " + tmp);
108 tmp = "abc".charAt(2);
109 ok(tmp === "c", "'abc',charAt(2) = " + tmp);
110 tmp = "abc".charAt(3);
111 ok(tmp === "", "'abc',charAt(3) = " + tmp);
112 tmp = "abc".charAt(4);
113 ok(tmp === "", "'abc',charAt(4) = " + tmp);
114 tmp = "abc".charAt();
115 ok(tmp === "a", "'abc',charAt() = " + tmp);
116 tmp = "abc".charAt(-1);
117 ok(tmp === "", "'abc',charAt(-1) = " + tmp);
118 tmp = "abc".charAt(0,2);
119 ok(tmp === "a", "'abc',charAt(0.2) = " + tmp);
121 tmp = "abc".charCodeAt(0);
122 ok(tmp === 0x61, "'abc'.charCodeAt(0) = " + tmp);
123 tmp = "abc".charCodeAt(1);
124 ok(tmp === 0x62, "'abc'.charCodeAt(1) = " + tmp);
125 tmp = "abc".charCodeAt(2);
126 ok(tmp === 0x63, "'abc'.charCodeAt(2) = " + tmp);
127 tmp = "abc".charCodeAt();
128 ok(tmp === 0x61, "'abc'.charCodeAt() = " + tmp);
129 tmp = "abc".charCodeAt(true);
130 ok(tmp === 0x62, "'abc'.charCodeAt(true) = " + tmp);
131 tmp = "abc".charCodeAt(0,2);
132 ok(tmp === 0x61, "'abc'.charCodeAt(0,2) = " + tmp);
134 tmp = "abcd".substring(1,3);
135 ok(tmp === "bc", "'abcd'.substring(1,3) = " + tmp);
136 tmp = "abcd".substring(-1,3);
137 ok(tmp === "abc", "'abcd'.substring(-1,3) = " + tmp);
138 tmp = "abcd".substring(1,6);
139 ok(tmp === "bcd", "'abcd'.substring(1,6) = " + tmp);
140 tmp = "abcd".substring(3,1);
141 ok(tmp === "bc", "'abcd'.substring(3,1) = " + tmp);
142 tmp = "abcd".substring(2,2);
143 ok(tmp === "", "'abcd'.substring(2,2) = " + tmp);
144 tmp = "abcd".substring(true,"3");
145 ok(tmp === "bc", "'abcd'.substring(true,'3') = " + tmp);
146 tmp = "abcd".substring(1,3,2);
147 ok(tmp === "bc", "'abcd'.substring(1,3,2) = " + tmp);
148 tmp = "abcd".substring();
149 ok(tmp === "abcd", "'abcd'.substring() = " + tmp);
151 tmp = "abcd".slice(1,3);
152 ok(tmp === "bc", "'abcd'.slice(1,3) = " + tmp);
153 tmp = "abcd".slice(1,-1);
154 ok(tmp === "bc", "'abcd'.slice(1,-1) = " + tmp);
155 tmp = "abcd".slice(-3,3);
156 ok(tmp === "bc", "'abcd'.slice(-3,3) = " + tmp);
157 tmp = "abcd".slice(-6,3);
158 ok(tmp === "abc", "'abcd'.slice(-6,3) = " + tmp);
159 tmp = "abcd".slice(3,1);
160 ok(tmp === "", "'abcd'.slice(3,1) = " + tmp);
161 tmp = "abcd".slice(true,3);
162 ok(tmp === "bc", "'abcd'.slice(true,3) = " + tmp);
163 tmp = "abcd".slice();
164 ok(tmp === "abcd", "'abcd'.slice() = " + tmp);
165 tmp = "abcd".slice(1);
166 ok(tmp === "bcd", "'abcd'.slice(1) = " + tmp);
168 tmp = "abc".concat(["d",1],2,false);
169 ok(tmp === "abcd,12false", "concat returned " + tmp);
170 var arr = new Array(2,"a");
171 arr.concat = String.prototype.concat;
172 tmp = arr.concat("d");
173 ok(tmp === "2,ad", "arr.concat = " + tmp);
175 m = "a+bcabc".match("a+");
176 ok(typeof(m) === "object", "typeof m is not object");
177 ok(m.length === 1, "m.length is not 1");
178 ok(m["0"] === "a", "m[0] is not \"ab\"");
180 r = "- [test] -".replace("[test]", "success");
181 ok(r === "- success -", "r = " + r + " expected '- success -'");
183 r = "- [test] -".replace("[test]", "success", "test");
184 ok(r === "- success -", "r = " + r + " expected '- success -'");
186 r = "test".replace();
187 ok(r === "test", "r = " + r + " expected 'test'");
189 function replaceFunc3(m, off, str) {
190 ok(arguments.length === 3, "arguments.length = " + arguments.length);
191 ok(m === "[test]", "m = " + m + " expected [test1]");
192 ok(off === 1, "off = " + off + " expected 0");
193 ok(str === "-[test]-", "str = " + arguments[3]);
197 r = "-[test]-".replace("[test]", replaceFunc3);
198 ok(r === "-ret-", "r = " + r + " expected '-ret-'");
200 r = "-[test]-".replace("[test]", replaceFunc3, "test");
201 ok(r === "-ret-", "r = " + r + " expected '-ret-'");
203 r = "1,2,3".split(",");
204 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
205 ok(r.length === 3, "r.length = " + r.length);
206 ok(r[0] === "1", "r[0] = " + r[0]);
207 ok(r[1] === "2", "r[1] = " + r[1]);
208 ok(r[2] === "3", "r[2] = " + r[2]);
211 r = "1,2,3".split(",*");
212 ok(r.length === 1, "r.length = " + r.length);
213 ok(r[0] === "1,2,3", "r[0] = " + r[0]);
216 ok(r.length === 3, "r.length = " + r.length);
217 ok(r[0] === "1", "r[0] = " + r[0]);
218 ok(r[1] === "2", "r[1] = " + r[1]);
219 ok(r[2] === "3", "r[2] = " + r[2]);
222 ok(r.length === 2, "r.length = " + r.length);
223 ok(r[0] === "1", "r[0] = " + r[0]);
224 ok(r[1] === "3", "r[1] = " + r[1]);
226 r = "1,2,".split(",");
227 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
228 ok(r.length === 3, "r.length = " + r.length);
229 ok(r[0] === "1", "r[0] = " + r[0]);
230 ok(r[1] === "2", "r[1] = " + r[1]);
231 ok(r[2] === "", "r[2] = " + r[2]);
233 tmp = "abcd".indexOf("bc",0);
234 ok(tmp === 1, "indexOf = " + tmp);
235 tmp = "abcd".indexOf("bc",1);
236 ok(tmp === 1, "indexOf = " + tmp);
237 tmp = "abcd".indexOf("bc");
238 ok(tmp === 1, "indexOf = " + tmp);
239 tmp = "abcd".indexOf("ac");
240 ok(tmp === -1, "indexOf = " + tmp);
241 tmp = "abcd".indexOf("bc",2);
242 ok(tmp === -1, "indexOf = " + tmp);
243 tmp = "abcd".indexOf("a",0);
244 ok(tmp === 0, "indexOf = " + tmp);
245 tmp = "abcd".indexOf("bc",0,"test");
246 ok(tmp === 1, "indexOf = " + tmp);
247 tmp = "abcd".indexOf();
248 ok(tmp == -1, "indexOf = " + tmp);
250 tmp = "".toLowerCase();
251 ok(tmp === "", "''.toLowerCase() = " + tmp);
252 tmp = "test".toLowerCase();
253 ok(tmp === "test", "''.toLowerCase() = " + tmp);
254 tmp = "test".toLowerCase(3);
255 ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
256 tmp = "tEsT".toLowerCase();
257 ok(tmp === "test", "''.toLowerCase() = " + tmp);
258 tmp = "tEsT".toLowerCase(3);
259 ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
261 tmp = "".toUpperCase();
262 ok(tmp === "", "''.toUpperCase() = " + tmp);
263 tmp = "TEST".toUpperCase();
264 ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
265 tmp = "TEST".toUpperCase(3);
266 ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
267 tmp = "tEsT".toUpperCase();
268 ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
269 tmp = "tEsT".toUpperCase(3);
270 ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
273 ok(tmp === "<A NAME=\"undefined\"></A>", "''.anchor() = " + tmp);
275 ok(tmp === "<A NAME=\"3\"></A>", "''.anchor(3) = " + tmp);
276 tmp = "".anchor("red");
277 ok(tmp === "<A NAME=\"red\"></A>", "''.anchor('red') = " + tmp);
278 tmp = "test".anchor();
279 ok(tmp === "<A NAME=\"undefined\">test</A>", "'test'.anchor() = " + tmp);
280 tmp = "test".anchor(3);
281 ok(tmp === "<A NAME=\"3\">test</A>", "'test'.anchor(3) = " + tmp);
282 tmp = "test".anchor("green");
283 ok(tmp === "<A NAME=\"green\">test</A>", "'test'.anchor('green') = " + tmp);
286 ok(tmp === "<BIG></BIG>", "''.big() = " + tmp);
288 ok(tmp === "<BIG></BIG>", "''.big(3) = " + tmp);
290 ok(tmp === "<BIG>test</BIG>", "'test'.big() = " + tmp);
292 ok(tmp === "<BIG>test</BIG>", "'test'.big(3) = " + tmp);
295 ok(tmp === "<BLINK></BLINK>", "''.blink() = " + tmp);
297 ok(tmp === "<BLINK></BLINK>", "''.blink(3) = " + tmp);
298 tmp = "test".blink();
299 ok(tmp === "<BLINK>test</BLINK>", "'test'.blink() = " + tmp);
300 tmp = "test".blink(3);
301 ok(tmp === "<BLINK>test</BLINK>", "'test'.blink(3) = " + tmp);
304 ok(tmp === "<B></B>", "''.bold() = " + tmp);
306 ok(tmp === "<B></B>", "''.bold(3) = " + tmp);
308 ok(tmp === "<B>test</B>", "'test'.bold() = " + tmp);
309 tmp = "test".bold(3);
310 ok(tmp === "<B>test</B>", "'test'.bold(3) = " + tmp);
313 ok(tmp === "<TT></TT>", "''.fixed() = " + tmp);
315 ok(tmp === "<TT></TT>", "''.fixed(3) = " + tmp);
316 tmp = "test".fixed();
317 ok(tmp === "<TT>test</TT>", "'test'.fixed() = " + tmp);
318 tmp = "test".fixed(3);
319 ok(tmp === "<TT>test</TT>", "'test'.fixed(3) = " + tmp);
321 tmp = "".fontcolor();
322 ok(tmp === "<FONT COLOR=\"undefined\"></FONT>", "''.fontcolor() = " + tmp);
323 tmp = "".fontcolor(3);
324 ok(tmp === "<FONT COLOR=\"3\"></FONT>", "''.fontcolor(3) = " + tmp);
325 tmp = "".fontcolor("red");
326 ok(tmp === "<FONT COLOR=\"red\"></FONT>", "''.fontcolor('red') = " + tmp);
327 tmp = "test".fontcolor();
328 ok(tmp === "<FONT COLOR=\"undefined\">test</FONT>", "'test'.fontcolor() = " + tmp);
329 tmp = "test".fontcolor(3);
330 ok(tmp === "<FONT COLOR=\"3\">test</FONT>", "'test'.fontcolor(3) = " + tmp);
331 tmp = "test".fontcolor("green");
332 ok(tmp === "<FONT COLOR=\"green\">test</FONT>", "'test'.fontcolor('green') = " + tmp);
335 ok(tmp === "<FONT SIZE=\"undefined\"></FONT>", "''.fontsize() = " + tmp);
336 tmp = "".fontsize(3);
337 ok(tmp === "<FONT SIZE=\"3\"></FONT>", "''.fontsize(3) = " + tmp);
338 tmp = "".fontsize("red");
339 ok(tmp === "<FONT SIZE=\"red\"></FONT>", "''.fontsize('red') = " + tmp);
340 tmp = "test".fontsize();
341 ok(tmp === "<FONT SIZE=\"undefined\">test</FONT>", "'test'.fontsize() = " + tmp);
342 tmp = "test".fontsize(3);
343 ok(tmp === "<FONT SIZE=\"3\">test</FONT>", "'test'.fontsize(3) = " + tmp);
344 tmp = "test".fontsize("green");
345 ok(tmp === "<FONT SIZE=\"green\">test</FONT>", "'test'.fontsize('green') = " + tmp);
347 tmp = ("".fontcolor()).fontsize();
348 ok(tmp === "<FONT SIZE=\"undefined\"><FONT COLOR=\"undefined\"></FONT></FONT>", "(''.fontcolor()).fontsize() = " + tmp);
351 ok(tmp === "<I></I>", "''.italics() = " + tmp);
353 ok(tmp === "<I></I>", "''.italics(3) = " + tmp);
354 tmp = "test".italics();
355 ok(tmp === "<I>test</I>", "'test'.italics() = " + tmp);
356 tmp = "test".italics(3);
357 ok(tmp === "<I>test</I>", "'test'.italics(3) = " + tmp);
360 ok(tmp === "<A HREF=\"undefined\"></A>", "''.link() = " + tmp);
362 ok(tmp === "<A HREF=\"3\"></A>", "''.link(3) = " + tmp);
363 tmp = "".link("red");
364 ok(tmp === "<A HREF=\"red\"></A>", "''.link('red') = " + tmp);
366 ok(tmp === "<A HREF=\"undefined\">test</A>", "'test'.link() = " + tmp);
367 tmp = "test".link(3);
368 ok(tmp === "<A HREF=\"3\">test</A>", "'test'.link(3) = " + tmp);
369 tmp = "test".link("green");
370 ok(tmp === "<A HREF=\"green\">test</A>", "'test'.link('green') = " + tmp);
373 ok(tmp === "<SMALL></SMALL>", "''.small() = " + tmp);
375 ok(tmp === "<SMALL></SMALL>", "''.small(3) = " + tmp);
376 tmp = "test".small();
377 ok(tmp === "<SMALL>test</SMALL>", "'test'.small() = " + tmp);
378 tmp = "test".small(3);
379 ok(tmp === "<SMALL>test</SMALL>", "'test'.small(3) = " + tmp);
382 ok(tmp === "<STRIKE></STRIKE>", "''.strike() = " + tmp);
384 ok(tmp === "<STRIKE></STRIKE>", "''.strike(3) = " + tmp);
385 tmp = "test".strike();
386 ok(tmp === "<STRIKE>test</STRIKE>", "'test'.strike() = " + tmp);
387 tmp = "test".strike(3);
388 ok(tmp === "<STRIKE>test</STRIKE>", "'test'.strike(3) = " + tmp);
391 ok(tmp === "<SUB></SUB>", "''.sub() = " + tmp);
393 ok(tmp === "<SUB></SUB>", "''.sub(3) = " + tmp);
395 ok(tmp === "<SUB>test</SUB>", "'test'.sub() = " + tmp);
397 ok(tmp === "<SUB>test</SUB>", "'test'.sub(3) = " + tmp);
400 ok(tmp === "<SUP></SUP>", "''.sup() = " + tmp);
402 ok(tmp === "<SUP></SUP>", "''.sup(3) = " + tmp);
404 ok(tmp === "<SUP>test</SUP>", "'test'.sup() = " + tmp);
406 ok(tmp === "<SUP>test</SUP>", "'test'.sup(3) = " + tmp);
408 ok(String.fromCharCode() === "", "String.fromCharCode() = " + String.fromCharCode());
409 ok(String.fromCharCode(65,"66",67) === "ABC", "String.fromCharCode(65,'66',67) = " + String.fromCharCode(65,"66",67));
410 ok(String.fromCharCode(1024*64+65, -1024*64+65) === "AA",
411 "String.fromCharCode(1024*64+65, -1024*64+65) = " + String.fromCharCode(1024*64+65, -1024*64+65));
412 ok(String.fromCharCode(65, NaN, undefined).length === 3,
413 "String.fromCharCode(65, NaN, undefined).length = " + String.fromCharCode(65, NaN, undefined).length);
415 var arr = new Array();
416 ok(typeof(arr) === "object", "arr () is not object");
417 ok((arr.length === 0), "arr.length is not 0");
418 ok(arr["0"] === undefined, "arr[0] is not undefined");
420 var arr = new Array(1, 2, "test");
421 ok(typeof(arr) === "object", "arr (1,2,test) is not object");
422 ok((arr.length === 3), "arr.length is not 3");
423 ok(arr["0"] === 1, "arr[0] is not 1");
424 ok(arr["1"] === 2, "arr[1] is not 2");
425 ok(arr["2"] === "test", "arr[2] is not \"test\"");
428 ok((arr.length === 8), "arr.length is not 8");
431 ok(tmp === "", "'' + [] = " + tmp);
433 ok(tmp === "1,true", "'' + [1,true] = " + tmp);
435 var arr = new Array(6);
436 ok(typeof(arr) === "object", "arr (6) is not object");
437 ok((arr.length === 6), "arr.length is not 6");
438 ok(arr["0"] === undefined, "arr[0] is not undefined");
440 ok(arr.push() === 6, "arr.push() !== 6");
441 ok(arr.push(1) === 7, "arr.push(1) !== 7");
442 ok(arr[6] === 1, "arr[6] != 1");
443 ok(arr.length === 7, "arr.length != 10");
444 ok(arr.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10");
445 ok(arr[8] === "b", "arr[8] != 'b'");
446 ok(arr.length === 10, "arr.length != 10");
450 ok(arr.length === 2, "arr.length = " + arr.length);
451 ok(tmp === 5, "pop() = " + tmp);
453 ok(arr.length === 1, "arr.length = " + arr.length);
454 ok(tmp === 4, "pop() = " + tmp);
456 ok(arr.length === 0, "arr.length = " + arr.length);
457 ok(tmp === 3, "pop() = " + tmp);
459 ok(false, "not deleted " + tmp);
461 ok(arr.length === 0, "arr.length = " + arr.length);
462 ok(tmp === undefined, "tmp = " + tmp);
465 ok(arr.length === 5, "arr.length = " + arr.length);
466 ok(tmp === undefined, "tmp = " + tmp);
468 arr = [1,2,null,false,undefined,,"a"];
471 ok(tmp === "1,2,,false,,,a", "arr.join() = " + tmp);
473 ok(tmp === "1;2;;false;;;a", "arr.join(';') = " + tmp);
474 tmp = arr.join(";","test");
475 ok(tmp === "1;2;;false;;;a", "arr.join(';') = " + tmp);
477 ok(tmp === "12falsea", "arr.join('') = " + tmp);
479 tmp = arr.toString();
480 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
481 tmp = arr.toString("test");
482 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
484 arr = [5,true,2,-1,3,false,"2.5"];
485 tmp = arr.sort(function(x,y) { return y-x; });
486 ok(tmp === arr, "tmp !== arr");
487 tmp = [5,3,"2.5",2,true,false,-1];
488 for(var i=0; i < arr.length; i++)
489 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
491 arr = [5,false,2,0,"abc",3,"a",-1];
493 ok(tmp === arr, "tmp !== arr");
494 tmp = [-1,0,2,3,5,"a","abc",false];
495 for(var i=0; i < arr.length; i++)
496 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
498 arr = ["a", "b", "ab"];
499 tmp = ["a", "ab", "b"];
500 ok(arr.sort() === arr, "arr.sort() !== arr");
501 for(var i=0; i < arr.length; i++)
502 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
504 arr = ["1", "2", "3"];
506 ok(arr.length === 1, "arr.length = " + arr.length);
508 ok(arr.length === 3, "arr.length = " + arr.length);
509 ok(arr.toString() === "1,,", "arr.toString() = " + arr.toString());
511 arr = Array("a","b","c");
512 ok(arr.toString() === "a,b,c", "arr.toString() = " + arr.toString());
514 ok(arr.valueOf === Object.prototype.valueOf, "arr.valueOf !== Object.prototype.valueOf");
515 ok(arr === arr.valueOf(), "arr !== arr.valueOf");
517 var num = new Number(6);
519 tmp = arr.concat(3, [4,5], num);
520 ok(tmp !== arr, "tmp === arr");
521 for(var i=0; i<6; i++)
522 ok(tmp[i] === i, "tmp[" + i + "] = " + tmp[i]);
523 ok(tmp[6] === num, "tmp[6] !== num");
524 ok(tmp.length === 7, "tmp.length = " + tmp.length);
527 ok(arr.length === 0, "arr.length = " + arr.length);
530 tmp = arr.concat([2]);
531 ok(tmp.length === 3, "tmp.length = " + tmp.length);
532 ok(tmp[1] === undefined, "tmp[1] = " + tmp[1]);
534 arr = [1,false,'a',null,undefined,'a'];
535 ok(arr.slice(0,6).toString() === "1,false,a,,,a", "arr.slice(0,6).toString() = " + arr.slice(0,6));
536 ok(arr.slice(0,6).length === 6, "arr.slice(0,6).length = " + arr.slice(0,6).length);
537 ok(arr.slice().toString() === "1,false,a,,,a", "arr.slice().toString() = " + arr.slice());
538 ok(arr.slice("abc").toString() === "1,false,a,,,a", "arr.slice(\"abc\").toString() = " + arr.slice("abc"));
539 ok(arr.slice(3,8).toString() === ",,a", "arr.slice(3,8).toString() = " + arr.slice(3,8));
540 ok(arr.slice(3,8).length === 3, "arr.slice(3,8).length = " + arr.slice(3,8).length);
541 ok(arr.slice(1).toString() === "false,a,,,a", "arr.slice(1).toString() = " + arr.slice(1));
542 ok(arr.slice(-2).toString() === ",a", "arr.slice(-2).toString() = " + arr.slice(-2));
543 ok(arr.slice(3,1).toString() === "", "arr.slice(3,1).toString() = " + arr.slice(3,1));
544 tmp = arr.slice(0,6);
545 for(var i=0; i < arr.length; i++)
546 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
548 ok(arr.slice(5).toString() === "a,,,,,,,2", "arr.slice(5).toString() = " + arr.slice(5).toString());
549 ok(arr.slice(5).length === 8, "arr.slice(5).length = " + arr.slice(5).length);
551 var num = new Number(2);
552 ok(num.toString() === "2", "num(2).toString !== 2");
553 var num = new Number();
554 ok(num.toString() === "0", "num().toString !== 0");
556 ok(Number() === 0, "Number() = " + Number());
557 ok(Number(false) === 0, "Number(false) = " + Number(false));
558 ok(Number("43") === 43, "Number('43') = " + Number("43"));
560 tmp = (new Number(1)).valueOf();
561 ok(tmp === 1, "(new Number(1)).valueOf = " + tmp);
562 tmp = (new Number(1,2)).valueOf();
563 ok(tmp === 1, "(new Number(1,2)).valueOf = " + tmp);
564 tmp = (new Number()).valueOf();
565 ok(tmp === 0, "(new Number()).valueOf = " + tmp);
566 tmp = Number.prototype.valueOf();
567 ok(tmp === 0, "Number.prototype.valueOf = " + tmp);
569 function equals(val, base) {
572 var str = val.toString(base);
574 for(i=0; i<str.length; i++) {
575 if(str.substring(i, i+1) == '(') break;
576 if(str.substring(i, i+1) == '.') break;
577 num = num*base + parseInt(str.substring(i, i+1));
580 if(str.substring(i, i+1) == '.') {
582 for(i++; i<str.length; i++) {
583 if(str.substring(i, i+1) == '(') break;
584 num += parseInt(str.substring(i, i+1))/mult;
589 if(str.substring(i, i+1) == '(') {
590 exp = parseInt(str.substring(i+2));
591 num *= Math.pow(base, exp);
594 ok(num>val-val/1000 && num<val+val/1000, "equals: num = " + num);
597 ok((10).toString(11) === "a", "(10).toString(11) = " + (10).toString(11));
598 ok((213213433).toString(17) === "8e2ddcb", "(213213433).toString(17) = " + (213213433).toString(17));
599 ok((-3254343).toString(33) === "-2oicf", "(-3254343).toString(33) = " + (-3254343).toString(33));
600 ok((NaN).toString(12) === "NaN", "(NaN).toString(11) = " + (NaN).toString(11));
601 ok((Infinity).toString(13) === "Infinity", "(Infinity).toString(11) = " + (Infinity).toString(11));
602 for(i=2; i<10; i++) {
604 equals(2305843009200000000, i);
606 equals(1/(1024*1024*1024*1024*1024*1024*1.9), i);
607 equals(1024*1024*1024*1024*1024*1024*1.9999, i);
608 equals(0.0000000000000000001, i);
610 equals(4.65661287308e-10, i);
611 ok((0).toString(i) === "0", "(0).toString("+i+") = " + (0).toString(i));
615 ok(tmp === 1, "Math.min(1) = " + tmp);
617 tmp = Math.min(1, false);
618 ok(tmp === 0, "Math.min(1, false) = " + tmp);
621 ok(tmp === Infinity, "Math.min() = " + tmp);
623 tmp = Math.min(1, NaN, -Infinity, false);
624 ok(isNaN(tmp), "Math.min(1, NaN, -Infinity, false) is not NaN");
626 tmp = Math.min(1, false, true, null, -3);
627 ok(tmp === -3, "Math.min(1, false, true, null, -3) = " + tmp);
630 ok(tmp === 1, "Math.max(1) = " + tmp);
632 tmp = Math.max(true, 0);
633 ok(tmp === 1, "Math.max(true, 0) = " + tmp);
635 tmp = Math.max(-2, false, true, null, 1);
636 ok(tmp === 1, "Math.max(-2, false, true, null, 1) = " + tmp);
639 ok(tmp === -Infinity, "Math.max() = " + tmp);
641 tmp = Math.max(true, NaN, 0);
642 ok(isNaN(tmp), "Math.max(true, NaN, 0) is not NaN");
644 tmp = Math.round(0.5);
645 ok(tmp === 1, "Math.round(0.5) = " + tmp);
647 tmp = Math.round(-0.5);
648 ok(tmp === 0, "Math.round(-0.5) = " + tmp);
650 tmp = Math.round(1.1);
651 ok(tmp === 1, "Math.round(1.1) = " + tmp);
653 tmp = Math.round(true);
654 ok(tmp === 1, "Math.round(true) = " + tmp);
656 tmp = Math.round(1.1, 3, 4);
657 ok(tmp === 1, "Math.round(1.1, 3, 4) = " + tmp);
660 ok(isNaN(tmp), "Math.round() is not NaN");
662 tmp = Math.ceil(0.5);
663 ok(tmp === 1, "Math.ceil(0.5) = " + tmp);
665 tmp = Math.ceil(-0.5);
666 ok(tmp === 0, "Math.ceil(-0.5) = " + tmp);
668 tmp = Math.ceil(1.1);
669 ok(tmp === 2, "Math.round(1.1) = " + tmp);
671 tmp = Math.ceil(true);
672 ok(tmp === 1, "Math.ceil(true) = " + tmp);
674 tmp = Math.ceil(1.1, 3, 4);
675 ok(tmp === 2, "Math.ceil(1.1, 3, 4) = " + tmp);
678 ok(isNaN(tmp), "ceil() is not NaN");
680 tmp = Math.floor(0.5);
681 ok(tmp === 0, "Math.floor(0.5) = " + tmp);
683 tmp = Math.floor(-0.5);
684 ok(tmp === -1, "Math.floor(-0.5) = " + tmp);
686 tmp = Math.floor(1.1);
687 ok(tmp === 1, "Math.floor(1.1) = " + tmp);
689 tmp = Math.floor(true);
690 ok(tmp === 1, "Math.floor(true) = " + tmp);
692 tmp = Math.floor(1.1, 3, 4);
693 ok(tmp === 1, "Math.floor(1.1, 3, 4) = " + tmp);
696 ok(isNaN(tmp), "floor is not NaN");
699 ok(tmp === 3, "Math.abs(3) = " + tmp);
702 ok(tmp === 3, "Math.abs(-3) = " + tmp);
704 tmp = Math.abs(true);
705 ok(tmp === 1, "Math.abs(true) = " + tmp);
708 ok(isNaN(tmp), "Math.abs() is not NaN");
711 ok(isNaN(tmp), "Math.abs() is not NaN");
713 tmp = Math.abs(-Infinity);
714 ok(tmp === Infinity, "Math.abs(-Infinite) = " + tmp);
716 tmp = Math.abs(-3, 2);
717 ok(tmp === 3, "Math.abs(-3, 2) = " + tmp);
720 ok(tmp === 1, "Math.cos(0) = " + tmp);
722 tmp = Math.cos(Math.PI/2);
723 ok(Math.floor(tmp*100) === 0, "Math.cos(Math.PI/2) = " + tmp);
725 tmp = Math.cos(-Math.PI/2);
726 ok(Math.floor(tmp*100) === 0, "Math.cos(-Math.PI/2) = " + tmp);
728 tmp = Math.cos(Math.PI/3, 2);
729 ok(Math.floor(tmp*100) === 50, "Math.cos(Math.PI/3, 2) = " + tmp);
731 tmp = Math.cos(true);
732 ok(Math.floor(tmp*100) === 54, "Math.cos(true) = " + tmp);
734 tmp = Math.cos(false);
735 ok(tmp === 1, "Math.cos(false) = " + tmp);
738 ok(isNaN(tmp), "Math.cos() is not NaN");
741 ok(isNaN(tmp), "Math.cos(NaN) is not NaN");
743 tmp = Math.cos(Infinity);
744 ok(isNaN(tmp), "Math.cos(Infinity) is not NaN");
746 tmp = Math.cos(-Infinity);
747 ok(isNaN(tmp), "Math.cos(-Infinity) is not NaN");
749 tmp = Math.pow(2, 2);
750 ok(tmp === 4, "Math.pow(2, 2) = " + tmp);
752 tmp = Math.pow(4, 0.5);
753 ok(tmp === 2, "Math.pow(2, 2) = " + tmp);
755 tmp = Math.pow(2, 2, 3);
756 ok(tmp === 4, "Math.pow(2, 2, 3) = " + tmp);
759 ok(isNaN(tmp), "Math.pow(2) is not NaN");
762 ok(isNaN(tmp), "Math.pow() is not NaN");
765 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
766 ok(0 <= tmp && tmp <= 1, "Math.random() = " + tmp);
768 tmp = Math.random(100);
769 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
770 ok(0 <= tmp && tmp <= 1, "Math.random(100) = " + tmp);
773 ok(Math.floor(tmp*100) === 157, "Math.acos(0) = " + tmp);
776 ok(Math.floor(tmp*100) === 0, "Math.acos(1) = " + tmp);
779 ok(Math.floor(tmp*100) === 314, "Math.acos(-1) = " + tmp);
781 tmp = Math.acos(Math.PI/4, 2);
782 ok(Math.floor(tmp*100) === 66, "Math.acos(Math.PI/4, 2) = " + tmp);
784 tmp = Math.acos(true);
785 ok(Math.floor(tmp*100) === 0, "Math.acos(true) = " + tmp);
787 tmp = Math.acos(false);
788 ok(Math.floor(tmp*100) === 157, "Math.acos(false) = " + tmp);
790 tmp = Math.acos(1.1);
791 ok(isNaN(tmp), "Math.acos(1.1) is not NaN");
794 ok(isNaN(tmp), "Math.acos() is not NaN");
796 tmp = Math.acos(NaN);
797 ok(isNaN(tmp), "Math.acos(NaN) is not NaN");
799 tmp = Math.acos(Infinity);
800 ok(isNaN(tmp), "Math.acos(Infinity) is not NaN");
802 tmp = Math.acos(-Infinity);
803 ok(isNaN(tmp), "Math.acos(-Infinity) is not NaN");
806 ok(Math.floor(tmp*100) === 0, "Math.asin(0) = " + tmp);
809 ok(Math.floor(tmp*100) === 157, "Math.asin(1) = " + tmp);
812 ok(Math.floor(tmp*100) === -158, "Math.asin(-1) = " + tmp);
814 tmp = Math.asin(Math.PI/4, 2);
815 ok(Math.floor(tmp*100) === 90, "Math.asin(Math.PI/4, 2) = " + tmp);
817 tmp = Math.asin(true);
818 ok(Math.floor(tmp*100) === 157, "Math.asin(true) = " + tmp);
820 tmp = Math.asin(false);
821 ok(Math.floor(tmp*100) === 0, "Math.asin(false) = " + tmp);
823 tmp = Math.asin(1.1);
824 ok(isNaN(tmp), "Math.asin(1.1) is not NaN");
827 ok(isNaN(tmp), "Math.asin() is not NaN");
829 tmp = Math.asin(NaN);
830 ok(isNaN(tmp), "Math.asin(NaN) is not NaN");
832 tmp = Math.asin(Infinity);
833 ok(isNaN(tmp), "Math.asin(Infinity) is not NaN");
835 tmp = Math.asin(-Infinity);
836 ok(isNaN(tmp), "Math.asin(-Infinity) is not NaN");
839 ok(Math.floor(tmp*100) === 0, "Math.atan(0) = " + tmp);
842 ok(Math.floor(tmp*100) === 78, "Math.atan(1) = " + tmp);
845 ok(Math.floor(tmp*100) === -79, "Math.atan(-1) = " + tmp);
847 tmp = Math.atan(true);
848 ok(Math.floor(tmp*100) === 78, "Math.atan(true) = " + tmp);
850 tmp = Math.atan(false);
851 ok(Math.floor(tmp*100) === 0, "Math.atan(false) = " + tmp);
854 ok(isNaN(tmp), "Math.atan() is not NaN");
856 tmp = Math.atan(NaN);
857 ok(isNaN(tmp), "Math.atan(NaN) is not NaN");
859 tmp = Math.atan(Infinity);
860 ok(Math.floor(tmp*100) === 157, "Math.atan(Infinity) = " + tmp);
862 tmp = Math.atan(-Infinity);
863 ok(Math.floor(tmp*100) === -158, "Math.atan(Infinity) = " + tmp);
865 tmp = Math.atan2(0, 0);
866 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 0) = " + tmp);
868 tmp = Math.atan2(0, 1);
869 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 1) = " + tmp);
871 tmp = Math.atan2(0, Infinity);
872 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, Infinity) = " + tmp);
874 tmp = Math.atan2(0, -1);
875 ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -1) = " + tmp);
877 tmp = Math.atan2(0, -Infinity);
878 ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -Infinity) = " + tmp);
880 tmp = Math.atan2(1, 0);
881 ok(Math.floor(tmp*100) === 157, "Math.atan2(1, 0) = " + tmp);
883 tmp = Math.atan2(Infinity, 0);
884 ok(Math.floor(tmp*100) === 157, "Math.atan2(Infinity, 0) = " + tmp);
886 tmp = Math.atan2(-1, 0);
887 ok(Math.floor(tmp*100) === -158, "Math.atan2(-1, 0) = " + tmp);
889 tmp = Math.atan2(-Infinity, 0);
890 ok(Math.floor(tmp*100) === -158, "Math.atan2(-Infinity, 0) = " + tmp);
892 tmp = Math.atan2(1, 1);
893 ok(Math.floor(tmp*100) === 78, "Math.atan2(1, 1) = " + tmp);
895 tmp = Math.atan2(-1, -1);
896 ok(Math.floor(tmp*100) === -236, "Math.atan2(-1, -1) = " + tmp);
898 tmp = Math.atan2(-1, 1);
899 ok(Math.floor(tmp*100) === -79, "Math.atan2(-1, 1) = " + tmp);
901 tmp = Math.atan2(Infinity, Infinity);
902 ok(Math.floor(tmp*100) === 78, "Math.atan2(Infinity, Infinity) = " + tmp);
904 tmp = Math.atan2(Infinity, -Infinity, 1);
905 ok(Math.floor(tmp*100) === 235, "Math.atan2(Infinity, -Infinity, 1) = " + tmp);
908 ok(isNaN(tmp), "Math.atan2() is not NaN");
911 ok(isNaN(tmp), "Math.atan2(1) is not NaN");
914 ok(tmp === 1, "Math.exp(0) = " + tmp);
917 ok(Math.floor(tmp*100) === 271, "Math.exp(1) = " + tmp);
920 ok(Math.floor(tmp*100) === 36, "Math.exp(-1) = " + tmp);
922 tmp = Math.exp(true);
923 ok(Math.floor(tmp*100) === 271, "Math.exp(true) = " + tmp);
925 tmp = Math.exp(1, 1);
926 ok(Math.floor(tmp*100) === 271, "Math.exp(1, 1) = " + tmp);
929 ok(isNaN(tmp), "Math.exp() is not NaN");
932 ok(isNaN(tmp), "Math.exp(NaN) is not NaN");
934 tmp = Math.exp(Infinity);
935 ok(tmp === Infinity, "Math.exp(Infinity) = " + tmp);
937 tmp = Math.exp(-Infinity);
938 ok(tmp === 0, "Math.exp(-Infinity) = " + tmp);
941 ok(Math.floor(tmp*100) === 0, "Math.log(1) = " + tmp);
944 ok(isNaN(tmp), "Math.log(-1) is not NaN");
946 tmp = Math.log(true);
947 ok(Math.floor(tmp*100) === 0, "Math.log(true) = " + tmp);
949 tmp = Math.log(1, 1);
950 ok(Math.floor(tmp*100) === 0, "Math.log(1, 1) = " + tmp);
953 ok(isNaN(tmp), "Math.log() is not NaN");
956 ok(isNaN(tmp), "Math.log(NaN) is not NaN");
958 tmp = Math.log(Infinity);
959 ok(tmp === Infinity, "Math.log(Infinity) = " + tmp);
961 tmp = Math.log(-Infinity);
962 ok(isNaN(tmp), "Math.log(-Infinity) is not NaN");
965 ok(tmp === 0, "Math.sin(0) = " + tmp);
967 tmp = Math.sin(Math.PI/2);
968 ok(tmp === 1, "Math.sin(Math.PI/2) = " + tmp);
970 tmp = Math.sin(-Math.PI/2);
971 ok(tmp === -1, "Math.sin(-Math.PI/2) = " + tmp);
973 tmp = Math.sin(Math.PI/3, 2);
974 ok(Math.floor(tmp*100) === 86, "Math.sin(Math.PI/3, 2) = " + tmp);
976 tmp = Math.sin(true);
977 ok(Math.floor(tmp*100) === 84, "Math.sin(true) = " + tmp);
979 tmp = Math.sin(false);
980 ok(tmp === 0, "Math.sin(false) = " + tmp);
983 ok(isNaN(tmp), "Math.sin() is not NaN");
986 ok(isNaN(tmp), "Math.sin(NaN) is not NaN");
988 tmp = Math.sin(Infinity);
989 ok(isNaN(tmp), "Math.sin(Infinity) is not NaN");
991 tmp = Math.sin(-Infinity);
992 ok(isNaN(tmp), "Math.sin(-Infinity) is not NaN");
995 ok(tmp === 0, "Math.sqrt(0) = " + tmp);
998 ok(tmp === 2, "Math.sqrt(4) = " + tmp);
1000 tmp = Math.sqrt(-1);
1001 ok(isNaN(tmp), "Math.sqrt(-1) is not NaN");
1003 tmp = Math.sqrt(2, 2);
1004 ok(Math.floor(tmp*100) === 141, "Math.sqrt(2, 2) = " + tmp);
1006 tmp = Math.sqrt(true);
1007 ok(tmp === 1, "Math.sqrt(true) = " + tmp);
1009 tmp = Math.sqrt(false);
1010 ok(tmp === 0, "Math.sqrt(false) = " + tmp);
1013 ok(isNaN(tmp), "Math.sqrt() is not NaN");
1015 tmp = Math.sqrt(NaN);
1016 ok(isNaN(tmp), "Math.sqrt(NaN) is not NaN");
1018 tmp = Math.sqrt(Infinity);
1019 ok(tmp === Infinity, "Math.sqrt(Infinity) = " + tmp);
1021 tmp = Math.sqrt(-Infinity);
1022 ok(isNaN(tmp), "Math.sqrt(-Infinity) is not NaN");
1025 ok(tmp === 0, "Math.tan(0) = " + tmp);
1027 tmp = Math.tan(Math.PI);
1028 ok(Math.floor(tmp*100) === -1, "Math.tan(Math.PI) = " + tmp);
1030 tmp = Math.tan(2, 2);
1031 ok(Math.floor(tmp*100) === -219, "Math.tan(2, 2) = " + tmp);
1033 tmp = Math.tan(true);
1034 ok(Math.floor(tmp*100) === 155, "Math.tan(true) = " + tmp);
1036 tmp = Math.tan(false);
1037 ok(tmp === 0, "Math.tan(false) = " + tmp);
1040 ok(isNaN(tmp), "Math.tan() is not NaN");
1042 tmp = Math.tan(NaN);
1043 ok(isNaN(tmp), "Math.tan(NaN) is not NaN");
1045 tmp = Math.tan(Infinity);
1046 ok(isNaN(tmp), "Math.tan(Infinity) is not NaN");
1048 tmp = Math.tan(-Infinity);
1049 ok(isNaN(tmp), "Math.tan(-Infinity) is not NaN");
1051 var func = function (a) {
1055 ok(func.toString() === "function (a) {\n var a = 1;\n if(a) return;\n }",
1056 "func.toString() = " + func.toString());
1057 ok("" + func === "function (a) {\n var a = 1;\n if(a) return;\n }",
1058 "'' + func.toString() = " + func);
1060 ok(func.valueOf === Object.prototype.valueOf, "func.valueOf !== Object.prototype.valueOf");
1061 ok(func === func.valueOf(), "func !== func.valueOf()");
1063 function testFuncToString(x,y) {
1066 ok(testFuncToString.toString() === "function testFuncToString(x,y) {\n return x+y;\n}",
1067 "testFuncToString.toString() = " + testFuncToString.toString());
1068 ok("" + testFuncToString === "function testFuncToString(x,y) {\n return x+y;\n}",
1069 "'' + testFuncToString = " + testFuncToString);
1071 var date = new Date();
1073 date = new Date(100);
1074 ok(date.getTime() === 100, "date.getTime() = " + date.getTime());
1075 ok(Date.prototype.getTime() === 0, "date.prototype.getTime() = " + Date.prototype.getTime());
1076 date = new Date(8.64e15);
1077 ok(date.getTime() === 8.64e15, "date.getTime() = " + date.getTime());
1078 date = new Date(8.64e15+1);
1079 ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
1080 date = new Date(Infinity);
1081 ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
1082 date = new Date("3 July 2009 22:28:00 UTC+0100");
1083 ok(date.getTime() === 1246656480000, "date.getTime() = " + date.getTime());
1084 date = new Date(1984, 11, 29, 13, 51, 24, 120);
1085 ok(date.getFullYear() === 1984, "date.getFullYear() = " + date.getFullYear());
1086 ok(date.getMonth() === 11, "date.getMonth() = " + date.getMonth());
1087 ok(date.getDate() === 29, "date.getDate() = " + date.getDate());
1088 ok(date.getHours() === 13, "date.getHours() = " + date.getHours());
1089 ok(date.getMinutes() === 51, "date.getMinutes() = " + date.getMinutes());
1090 ok(date.getSeconds() === 24, "date.getSeconds() = " + date.getSeconds());
1091 ok(date.getMilliseconds() === 120, "date.getMilliseconds() = " + date.getMilliseconds());
1092 date = new Date(731, -32, 40, -1, 70, 65, -13);
1093 ok(date.getFullYear() === 728, "date.getFullYear() = " + date.getFullYear());
1094 ok(date.getMonth() === 5, "date.getMonth() = " + date.getMonth());
1095 ok(date.getDate() === 9, "date.getDate() = " + date.getDate());
1096 ok(date.getHours() === 0, "date.getHours() = " + date.getHours());
1097 ok(date.getMinutes() === 11, "date.getMinutes() = " + date.getMinutes());
1098 ok(date.getSeconds() === 4, "date.getSeconds() = " + date.getSeconds());
1099 ok(date.getMilliseconds() === 987, "date.getMilliseconds() = " + date.getMilliseconds());
1101 ok(date.setTime(123) === 123, "date.setTime(123) !== 123");
1102 ok(date.setTime("123", NaN) === 123, "date.setTime(\"123\") !== 123");
1103 ok(isNaN(date.setTime(NaN)), "date.setTime(NaN) is not NaN");
1105 ok(date.setTime(0) === date.getTime(), "date.setTime(0) !== date.getTime()");
1106 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
1107 ok(date.getUTCMonth() === 0, "date.getUTCMonth() = " + date.getUTCMonth());
1108 ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
1109 ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
1110 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
1111 ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
1112 ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
1113 ok(date.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1114 date.setTime(60*24*60*60*1000);
1115 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
1116 ok(date.getUTCMonth() === 2, "date.getUTCMonth() = " + date.getUTCMonth());
1117 ok(date.getUTCDate() === 2, "date.getUTCDate() = " + date.getUTCDate());
1118 ok(date.getUTCDay() === 1, "date.getUTCDay() = " + date.getUTCDay());
1119 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
1120 ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
1121 ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
1122 ok(date.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1123 date.setTime(59*24*60*60*1000 + 4*365*24*60*60*1000 + 60*60*1000 + 2*60*1000 + 2*1000 + 640);
1124 ok(date.getUTCFullYear() === 1974, "date.getUTCFullYear() = " + date.getUTCFullYear());
1125 ok(date.getUTCMonth() === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1126 ok(date.getUTCMonth(123) === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1127 ok(date.getUTCDate() === 28, "date.getUTCDate() = " + date.getUTCDate());
1128 ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
1129 ok(date.getUTCHours() === 1, "date.getUTCHours() = " + date.getUTCHours());
1130 ok(date.getUTCMinutes() === 2, "date.getUTCMinutes() = " + date.getUTCMinutes());
1131 ok(date.getUTCSeconds() === 2, "date.getUTCSeconds() = " + date.getUTCSeconds());
1132 ok(date.getUTCMilliseconds() === 640, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1133 date.setTime(Infinity);
1134 ok(isNaN(date.getUTCFullYear()), "date.getUTCFullYear() is not NaN");
1135 ok(isNaN(date.getUTCMonth()), "date.getUTCMonth() is not NaN");
1136 ok(isNaN(date.getUTCDate()), "date.getUTCDate() is not NaN");
1137 ok(isNaN(date.getUTCDay()), "date.getUTCDay() is not NaN");
1138 ok(isNaN(date.getUTCHours()), "date.getUTCHours() is not NaN");
1139 ok(isNaN(date.getUTCMinutes()), "date.getUTCMinutes() is not NaN");
1140 ok(isNaN(date.getUTCSeconds()), "date.getUTCSeconds() is not NaN");
1141 ok(isNaN(date.getUTCMilliseconds()), "date.getUTCMilliseconds() is not NaN");
1142 ok(isNaN(date.setMilliseconds(0)), "date.setMilliseconds() is not NaN");
1145 date.setUTCMilliseconds(-10, 2);
1146 ok(date.getUTCMilliseconds() === 990, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1147 date.setUTCMilliseconds(10);
1148 ok(date.getUTCMilliseconds() === 10, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1149 date.setUTCSeconds(-10);
1150 ok(date.getUTCSeconds() === 50, "date.getUTCSeconds() = " + date.getUTCSeconds());
1151 date.setUTCMinutes(-10);
1152 ok(date.getUTCMinutes() === 50, "date.getUTCMinutes() = " + date.getUTCMinutes());
1153 date.setUTCHours(-10);
1154 ok(date.getUTCHours() === 14, "date.getUTCHours() = " + date.getUTCHours());
1155 date.setUTCHours(-123);
1156 ok(date.getTime() === -612549990, "date.getTime() = " + date.getTime());
1157 date.setUTCHours(20);
1158 ok(date.getUTCHours() === 20, "date.getUTCHours() = " + date.getUTCHours());
1159 date.setUTCDate(32);
1160 ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
1161 date.setUTCMonth(22, 37);
1162 ok(date.getTime() === 60987050010, "date.getTime() = " + date.getTime());
1163 date.setUTCFullYear(83, 21, 321);
1164 ok(date.getTime() === -59464984149990, "date.getTime() = " + date.getTime());
1165 ok(Math.abs(date) === 59464984149990, "Math.abs(date) = " + Math.abs(date));
1166 ok(getVT(date+1) === "VT_BSTR", "getVT(date+1) = " + getVT(date+1));
1168 ok(isNaN(Date.parse()), "Date.parse() is not NaN");
1169 ok(isNaN(Date.parse("")), "Date.parse(\"\") is not NaN");
1170 ok(isNaN(Date.parse("Jan Jan 20 2009")), "Date.parse(\"Jan Jan 20 2009\") is not NaN");
1171 ok(Date.parse("Jan 20 2009 UTC") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC\") = " + Date.parse("Jan 20 2009 UTC"));
1172 ok(Date.parse("Jan 20 2009 GMT") === 1232409600000, "Date.parse(\"Jan 20 2009 GMT\") = " + Date.parse("Jan 20 2009 GMT"));
1173 ok(Date.parse("Jan 20 2009 UTC-0") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC-0\") = " + Date.parse("Jan 20 2009 UTC-0"));
1174 ok(Date.parse("Jan 20 2009 UTC+0000") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC+0000\") = " + Date.parse("Jan 20 2009 UTC+0000"));
1175 ok(Date.parse("Ju 13 79 UTC") === 300672000000, "Date.parse(\"Ju 13 79 UTC\") = " + Date.parse("Ju 13 79 UTC"));
1176 ok(Date.parse("12Au91 UTC") === 681955200000, "Date.parse(\"12Au91 UTC\") = " + Date.parse("12Au91 UTC"));
1177 ok(Date.parse("7/02/17 UTC") === -1656806400000, "Date.parse(\"7/02/17 UTC\") = " + Date.parse("7/02/17 UTC"));
1178 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"));
1179 ok(Date.parse("February 31 UTC, 2000 12:31:17 PM") === 952000277000,
1180 "Date.parse(\"February 31 UTC, 2000 12:31:17 PM\") = " + Date.parse("February 31 UTC, 2000 12:31:17 PM"));
1181 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 "));
1182 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"));
1184 ok(typeof(Math.PI) === "number", "typeof(Math.PI) = " + typeof(Math.PI));
1185 ok(Math.floor(Math.PI*100) === 314, "Math.PI = " + Math.PI);
1187 ok(Math.floor(Math.PI*100) === 314, "modified Math.PI = " + Math.PI);
1189 ok(typeof(Math.E) === "number", "typeof(Math.E) = " + typeof(Math.E));
1190 ok(Math.floor(Math.E*100) === 271, "Math.E = " + Math.E);
1192 ok(Math.floor(Math.E*100) === 271, "modified Math.E = " + Math.E);
1194 ok(typeof(Math.LOG2E) === "number", "typeof(Math.LOG2E) = " + typeof(Math.LOG2E));
1195 ok(Math.floor(Math.LOG2E*100) === 144, "Math.LOG2E = " + Math.LOG2E);
1196 Math.LOG2E = "test";
1197 ok(Math.floor(Math.LOG2E*100) === 144, "modified Math.LOG2E = " + Math.LOG2E);
1199 ok(typeof(Math.LOG10E) === "number", "typeof(Math.LOG10E) = " + typeof(Math.LOG10E));
1200 ok(Math.floor(Math.LOG10E*100) === 43, "Math.LOG10E = " + Math.LOG10E);
1201 Math.LOG10E = "test";
1202 ok(Math.floor(Math.LOG10E*100) === 43, "modified Math.LOG10E = " + Math.LOG10E);
1204 ok(typeof(Math.LN2) === "number", "typeof(Math.LN2) = " + typeof(Math.LN2));
1205 ok(Math.floor(Math.LN2*100) === 69, "Math.LN2 = " + Math.LN2);
1207 ok(Math.floor(Math.LN2*100) === 69, "modified Math.LN2 = " + Math.LN2);
1209 ok(typeof(Math.LN10) === "number", "typeof(Math.LN10) = " + typeof(Math.LN10));
1210 ok(Math.floor(Math.LN10*100) === 230, "Math.LN10 = " + Math.LN10);
1212 ok(Math.floor(Math.LN10*100) === 230, "modified Math.LN10 = " + Math.LN10);
1214 ok(typeof(Math.SQRT2) === "number", "typeof(Math.SQRT2) = " + typeof(Math.SQRT2));
1215 ok(Math.floor(Math.SQRT2*100) === 141, "Math.SQRT2 = " + Math.SQRT2);
1216 Math.SQRT2 = "test";
1217 ok(Math.floor(Math.SQRT2*100) === 141, "modified Math.SQRT2 = " + Math.SQRT2);
1219 ok(typeof(Math.SQRT1_2) === "number", "typeof(Math.SQRT1_2) = " + typeof(Math.SQRT1_2));
1220 ok(Math.floor(Math.SQRT1_2*100) === 70, "Math.SQRT1_2 = " + Math.SQRT1_2);
1221 Math.SQRT1_2 = "test";
1222 ok(Math.floor(Math.SQRT1_2*100) === 70, "modified Math.SQRT1_2 = " + Math.SQRT1_2);
1224 var bool = new Boolean();
1225 ok(bool.toString() === "false", "bool.toString() = " + bool.toString());
1226 var bool = new Boolean("false");
1227 ok(bool.toString() === "true", "bool.toString() = " + bool.toString());
1228 ok(bool.valueOf() === Boolean(1), "bool.valueOf() = " + bool.valueOf());
1229 ok(bool.toLocaleString() === bool.toString(), "bool.toLocaleString() = " + bool.toLocaleString());