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 num = new Number(NaN);
570 ok(num.toString() === "NaN", "num.toString() = " + num.toString());
571 num = new Number(-Infinity);
572 ok(num.toString() === "-Infinity", "num.toString() = " + num.toString());
573 num = new Number(Infinity);
574 ok(num.toString() === "Infinity", "num.toString() = " + num.toString());
577 ok(tmp === 1, "Math.min(1) = " + tmp);
579 tmp = Math.min(1, false);
580 ok(tmp === 0, "Math.min(1, false) = " + tmp);
583 ok(tmp === Infinity, "Math.min() = " + tmp);
585 tmp = Math.min(1, NaN, -Infinity, false);
586 ok(isNaN(tmp), "Math.min(1, NaN, -Infinity, false) is not NaN");
588 tmp = Math.min(1, false, true, null, -3);
589 ok(tmp === -3, "Math.min(1, false, true, null, -3) = " + tmp);
592 ok(tmp === 1, "Math.max(1) = " + tmp);
594 tmp = Math.max(true, 0);
595 ok(tmp === 1, "Math.max(true, 0) = " + tmp);
597 tmp = Math.max(-2, false, true, null, 1);
598 ok(tmp === 1, "Math.max(-2, false, true, null, 1) = " + tmp);
601 ok(tmp === -Infinity, "Math.max() = " + tmp);
603 tmp = Math.max(true, NaN, 0);
604 ok(isNaN(tmp), "Math.max(true, NaN, 0) is not NaN");
606 tmp = Math.round(0.5);
607 ok(tmp === 1, "Math.round(0.5) = " + tmp);
609 tmp = Math.round(-0.5);
610 ok(tmp === 0, "Math.round(-0.5) = " + tmp);
612 tmp = Math.round(1.1);
613 ok(tmp === 1, "Math.round(1.1) = " + tmp);
615 tmp = Math.round(true);
616 ok(tmp === 1, "Math.round(true) = " + tmp);
618 tmp = Math.round(1.1, 3, 4);
619 ok(tmp === 1, "Math.round(1.1, 3, 4) = " + tmp);
622 ok(isNaN(tmp), "Math.round() is not NaN");
624 tmp = Math.ceil(0.5);
625 ok(tmp === 1, "Math.ceil(0.5) = " + tmp);
627 tmp = Math.ceil(-0.5);
628 ok(tmp === 0, "Math.ceil(-0.5) = " + tmp);
630 tmp = Math.ceil(1.1);
631 ok(tmp === 2, "Math.round(1.1) = " + tmp);
633 tmp = Math.ceil(true);
634 ok(tmp === 1, "Math.ceil(true) = " + tmp);
636 tmp = Math.ceil(1.1, 3, 4);
637 ok(tmp === 2, "Math.ceil(1.1, 3, 4) = " + tmp);
640 ok(isNaN(tmp), "ceil() is not NaN");
642 tmp = Math.floor(0.5);
643 ok(tmp === 0, "Math.floor(0.5) = " + tmp);
645 tmp = Math.floor(-0.5);
646 ok(tmp === -1, "Math.floor(-0.5) = " + tmp);
648 tmp = Math.floor(1.1);
649 ok(tmp === 1, "Math.floor(1.1) = " + tmp);
651 tmp = Math.floor(true);
652 ok(tmp === 1, "Math.floor(true) = " + tmp);
654 tmp = Math.floor(1.1, 3, 4);
655 ok(tmp === 1, "Math.floor(1.1, 3, 4) = " + tmp);
658 ok(isNaN(tmp), "floor is not NaN");
661 ok(tmp === 3, "Math.abs(3) = " + tmp);
664 ok(tmp === 3, "Math.abs(-3) = " + tmp);
666 tmp = Math.abs(true);
667 ok(tmp === 1, "Math.abs(true) = " + tmp);
670 ok(isNaN(tmp), "Math.abs() is not NaN");
673 ok(isNaN(tmp), "Math.abs() is not NaN");
675 tmp = Math.abs(-Infinity);
676 ok(tmp === Infinity, "Math.abs(-Infinite) = " + tmp);
678 tmp = Math.abs(-3, 2);
679 ok(tmp === 3, "Math.abs(-3, 2) = " + tmp);
682 ok(tmp === 1, "Math.cos(0) = " + tmp);
684 tmp = Math.cos(Math.PI/2);
685 ok(Math.floor(tmp*100) === 0, "Math.cos(Math.PI/2) = " + tmp);
687 tmp = Math.cos(-Math.PI/2);
688 ok(Math.floor(tmp*100) === 0, "Math.cos(-Math.PI/2) = " + tmp);
690 tmp = Math.cos(Math.PI/3, 2);
691 ok(Math.floor(tmp*100) === 50, "Math.cos(Math.PI/3, 2) = " + tmp);
693 tmp = Math.cos(true);
694 ok(Math.floor(tmp*100) === 54, "Math.cos(true) = " + tmp);
696 tmp = Math.cos(false);
697 ok(tmp === 1, "Math.cos(false) = " + tmp);
700 ok(isNaN(tmp), "Math.cos() is not NaN");
703 ok(isNaN(tmp), "Math.cos(NaN) is not NaN");
705 tmp = Math.cos(Infinity);
706 ok(isNaN(tmp), "Math.cos(Infinity) is not NaN");
708 tmp = Math.cos(-Infinity);
709 ok(isNaN(tmp), "Math.cos(-Infinity) is not NaN");
711 tmp = Math.pow(2, 2);
712 ok(tmp === 4, "Math.pow(2, 2) = " + tmp);
714 tmp = Math.pow(4, 0.5);
715 ok(tmp === 2, "Math.pow(2, 2) = " + tmp);
717 tmp = Math.pow(2, 2, 3);
718 ok(tmp === 4, "Math.pow(2, 2, 3) = " + tmp);
721 ok(isNaN(tmp), "Math.pow(2) is not NaN");
724 ok(isNaN(tmp), "Math.pow() is not NaN");
727 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
728 ok(0 <= tmp && tmp <= 1, "Math.random() = " + tmp);
730 tmp = Math.random(100);
731 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
732 ok(0 <= tmp && tmp <= 1, "Math.random(100) = " + tmp);
735 ok(Math.floor(tmp*100) === 157, "Math.acos(0) = " + tmp);
738 ok(Math.floor(tmp*100) === 0, "Math.acos(1) = " + tmp);
741 ok(Math.floor(tmp*100) === 314, "Math.acos(-1) = " + tmp);
743 tmp = Math.acos(Math.PI/4, 2);
744 ok(Math.floor(tmp*100) === 66, "Math.acos(Math.PI/4, 2) = " + tmp);
746 tmp = Math.acos(true);
747 ok(Math.floor(tmp*100) === 0, "Math.acos(true) = " + tmp);
749 tmp = Math.acos(false);
750 ok(Math.floor(tmp*100) === 157, "Math.acos(false) = " + tmp);
752 tmp = Math.acos(1.1);
753 ok(isNaN(tmp), "Math.acos(1.1) is not NaN");
756 ok(isNaN(tmp), "Math.acos() is not NaN");
758 tmp = Math.acos(NaN);
759 ok(isNaN(tmp), "Math.acos(NaN) is not NaN");
761 tmp = Math.acos(Infinity);
762 ok(isNaN(tmp), "Math.acos(Infinity) is not NaN");
764 tmp = Math.acos(-Infinity);
765 ok(isNaN(tmp), "Math.acos(-Infinity) is not NaN");
768 ok(Math.floor(tmp*100) === 0, "Math.asin(0) = " + tmp);
771 ok(Math.floor(tmp*100) === 157, "Math.asin(1) = " + tmp);
774 ok(Math.floor(tmp*100) === -158, "Math.asin(-1) = " + tmp);
776 tmp = Math.asin(Math.PI/4, 2);
777 ok(Math.floor(tmp*100) === 90, "Math.asin(Math.PI/4, 2) = " + tmp);
779 tmp = Math.asin(true);
780 ok(Math.floor(tmp*100) === 157, "Math.asin(true) = " + tmp);
782 tmp = Math.asin(false);
783 ok(Math.floor(tmp*100) === 0, "Math.asin(false) = " + tmp);
785 tmp = Math.asin(1.1);
786 ok(isNaN(tmp), "Math.asin(1.1) is not NaN");
789 ok(isNaN(tmp), "Math.asin() is not NaN");
791 tmp = Math.asin(NaN);
792 ok(isNaN(tmp), "Math.asin(NaN) is not NaN");
794 tmp = Math.asin(Infinity);
795 ok(isNaN(tmp), "Math.asin(Infinity) is not NaN");
797 tmp = Math.asin(-Infinity);
798 ok(isNaN(tmp), "Math.asin(-Infinity) is not NaN");
801 ok(Math.floor(tmp*100) === 0, "Math.atan(0) = " + tmp);
804 ok(Math.floor(tmp*100) === 78, "Math.atan(1) = " + tmp);
807 ok(Math.floor(tmp*100) === -79, "Math.atan(-1) = " + tmp);
809 tmp = Math.atan(true);
810 ok(Math.floor(tmp*100) === 78, "Math.atan(true) = " + tmp);
812 tmp = Math.atan(false);
813 ok(Math.floor(tmp*100) === 0, "Math.atan(false) = " + tmp);
816 ok(isNaN(tmp), "Math.atan() is not NaN");
818 tmp = Math.atan(NaN);
819 ok(isNaN(tmp), "Math.atan(NaN) is not NaN");
821 tmp = Math.atan(Infinity);
822 ok(Math.floor(tmp*100) === 157, "Math.atan(Infinity) = " + tmp);
824 tmp = Math.atan(-Infinity);
825 ok(Math.floor(tmp*100) === -158, "Math.atan(Infinity) = " + tmp);
827 tmp = Math.atan2(0, 0);
828 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 0) = " + tmp);
830 tmp = Math.atan2(0, 1);
831 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 1) = " + tmp);
833 tmp = Math.atan2(0, Infinity);
834 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, Infinity) = " + tmp);
836 tmp = Math.atan2(0, -1);
837 ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -1) = " + tmp);
839 tmp = Math.atan2(0, -Infinity);
840 ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -Infinity) = " + tmp);
842 tmp = Math.atan2(1, 0);
843 ok(Math.floor(tmp*100) === 157, "Math.atan2(1, 0) = " + tmp);
845 tmp = Math.atan2(Infinity, 0);
846 ok(Math.floor(tmp*100) === 157, "Math.atan2(Infinity, 0) = " + tmp);
848 tmp = Math.atan2(-1, 0);
849 ok(Math.floor(tmp*100) === -158, "Math.atan2(-1, 0) = " + tmp);
851 tmp = Math.atan2(-Infinity, 0);
852 ok(Math.floor(tmp*100) === -158, "Math.atan2(-Infinity, 0) = " + tmp);
854 tmp = Math.atan2(1, 1);
855 ok(Math.floor(tmp*100) === 78, "Math.atan2(1, 1) = " + tmp);
857 tmp = Math.atan2(-1, -1);
858 ok(Math.floor(tmp*100) === -236, "Math.atan2(-1, -1) = " + tmp);
860 tmp = Math.atan2(-1, 1);
861 ok(Math.floor(tmp*100) === -79, "Math.atan2(-1, 1) = " + tmp);
863 tmp = Math.atan2(Infinity, Infinity);
864 ok(Math.floor(tmp*100) === 78, "Math.atan2(Infinity, Infinity) = " + tmp);
866 tmp = Math.atan2(Infinity, -Infinity, 1);
867 ok(Math.floor(tmp*100) === 235, "Math.atan2(Infinity, -Infinity, 1) = " + tmp);
870 ok(isNaN(tmp), "Math.atan2() is not NaN");
873 ok(isNaN(tmp), "Math.atan2(1) is not NaN");
876 ok(tmp === 1, "Math.exp(0) = " + tmp);
879 ok(Math.floor(tmp*100) === 271, "Math.exp(1) = " + tmp);
882 ok(Math.floor(tmp*100) === 36, "Math.exp(-1) = " + tmp);
884 tmp = Math.exp(true);
885 ok(Math.floor(tmp*100) === 271, "Math.exp(true) = " + tmp);
887 tmp = Math.exp(1, 1);
888 ok(Math.floor(tmp*100) === 271, "Math.exp(1, 1) = " + tmp);
891 ok(isNaN(tmp), "Math.exp() is not NaN");
894 ok(isNaN(tmp), "Math.exp(NaN) is not NaN");
896 tmp = Math.exp(Infinity);
897 ok(tmp === Infinity, "Math.exp(Infinity) = " + tmp);
899 tmp = Math.exp(-Infinity);
900 ok(tmp === 0, "Math.exp(-Infinity) = " + tmp);
903 ok(Math.floor(tmp*100) === 0, "Math.log(1) = " + tmp);
906 ok(isNaN(tmp), "Math.log(-1) is not NaN");
908 tmp = Math.log(true);
909 ok(Math.floor(tmp*100) === 0, "Math.log(true) = " + tmp);
911 tmp = Math.log(1, 1);
912 ok(Math.floor(tmp*100) === 0, "Math.log(1, 1) = " + tmp);
915 ok(isNaN(tmp), "Math.log() is not NaN");
918 ok(isNaN(tmp), "Math.log(NaN) is not NaN");
920 tmp = Math.log(Infinity);
921 ok(tmp === Infinity, "Math.log(Infinity) = " + tmp);
923 tmp = Math.log(-Infinity);
924 ok(isNaN(tmp), "Math.log(-Infinity) is not NaN");
927 ok(tmp === 0, "Math.sin(0) = " + tmp);
929 tmp = Math.sin(Math.PI/2);
930 ok(tmp === 1, "Math.sin(Math.PI/2) = " + tmp);
932 tmp = Math.sin(-Math.PI/2);
933 ok(tmp === -1, "Math.sin(-Math.PI/2) = " + tmp);
935 tmp = Math.sin(Math.PI/3, 2);
936 ok(Math.floor(tmp*100) === 86, "Math.sin(Math.PI/3, 2) = " + tmp);
938 tmp = Math.sin(true);
939 ok(Math.floor(tmp*100) === 84, "Math.sin(true) = " + tmp);
941 tmp = Math.sin(false);
942 ok(tmp === 0, "Math.sin(false) = " + tmp);
945 ok(isNaN(tmp), "Math.sin() is not NaN");
948 ok(isNaN(tmp), "Math.sin(NaN) is not NaN");
950 tmp = Math.sin(Infinity);
951 ok(isNaN(tmp), "Math.sin(Infinity) is not NaN");
953 tmp = Math.sin(-Infinity);
954 ok(isNaN(tmp), "Math.sin(-Infinity) is not NaN");
957 ok(tmp === 0, "Math.sqrt(0) = " + tmp);
960 ok(tmp === 2, "Math.sqrt(4) = " + tmp);
963 ok(isNaN(tmp), "Math.sqrt(-1) is not NaN");
965 tmp = Math.sqrt(2, 2);
966 ok(Math.floor(tmp*100) === 141, "Math.sqrt(2, 2) = " + tmp);
968 tmp = Math.sqrt(true);
969 ok(tmp === 1, "Math.sqrt(true) = " + tmp);
971 tmp = Math.sqrt(false);
972 ok(tmp === 0, "Math.sqrt(false) = " + tmp);
975 ok(isNaN(tmp), "Math.sqrt() is not NaN");
977 tmp = Math.sqrt(NaN);
978 ok(isNaN(tmp), "Math.sqrt(NaN) is not NaN");
980 tmp = Math.sqrt(Infinity);
981 ok(tmp === Infinity, "Math.sqrt(Infinity) = " + tmp);
983 tmp = Math.sqrt(-Infinity);
984 ok(isNaN(tmp), "Math.sqrt(-Infinity) is not NaN");
987 ok(tmp === 0, "Math.tan(0) = " + tmp);
989 tmp = Math.tan(Math.PI);
990 ok(Math.floor(tmp*100) === -1, "Math.tan(Math.PI) = " + tmp);
992 tmp = Math.tan(2, 2);
993 ok(Math.floor(tmp*100) === -219, "Math.tan(2, 2) = " + tmp);
995 tmp = Math.tan(true);
996 ok(Math.floor(tmp*100) === 155, "Math.tan(true) = " + tmp);
998 tmp = Math.tan(false);
999 ok(tmp === 0, "Math.tan(false) = " + tmp);
1002 ok(isNaN(tmp), "Math.tan() is not NaN");
1004 tmp = Math.tan(NaN);
1005 ok(isNaN(tmp), "Math.tan(NaN) is not NaN");
1007 tmp = Math.tan(Infinity);
1008 ok(isNaN(tmp), "Math.tan(Infinity) is not NaN");
1010 tmp = Math.tan(-Infinity);
1011 ok(isNaN(tmp), "Math.tan(-Infinity) is not NaN");
1013 var func = function (a) {
1017 ok(func.toString() === "function (a) {\n var a = 1;\n if(a) return;\n }",
1018 "func.toString() = " + func.toString());
1019 ok("" + func === "function (a) {\n var a = 1;\n if(a) return;\n }",
1020 "'' + func.toString() = " + func);
1022 ok(func.valueOf === Object.prototype.valueOf, "func.valueOf !== Object.prototype.valueOf");
1023 ok(func === func.valueOf(), "func !== func.valueOf()");
1025 function testFuncToString(x,y) {
1028 ok(testFuncToString.toString() === "function testFuncToString(x,y) {\n return x+y;\n}",
1029 "testFuncToString.toString() = " + testFuncToString.toString());
1030 ok("" + testFuncToString === "function testFuncToString(x,y) {\n return x+y;\n}",
1031 "'' + testFuncToString = " + testFuncToString);
1033 var date = new Date();
1035 date = new Date(100);
1036 ok(date.getTime() === 100, "date.getTime() = " + date.getTime());
1037 ok(Date.prototype.getTime() === 0, "date.prototype.getTime() = " + Date.prototype.getTime());
1038 date = new Date(8.64e15);
1039 ok(date.getTime() === 8.64e15, "date.getTime() = " + date.getTime());
1040 date = new Date(8.64e15+1);
1041 ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
1042 date = new Date(Infinity);
1043 ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
1044 date = new Date("3 July 2009 22:28:00 UTC+0100");
1045 ok(date.getTime() === 1246656480000, "date.getTime() = " + date.getTime());
1046 date = new Date(1984, 11, 29, 13, 51, 24, 120);
1047 ok(date.getFullYear() === 1984, "date.getFullYear() = " + date.getFullYear());
1048 ok(date.getMonth() === 11, "date.getMonth() = " + date.getMonth());
1049 ok(date.getDate() === 29, "date.getDate() = " + date.getDate());
1050 ok(date.getHours() === 13, "date.getHours() = " + date.getHours());
1051 ok(date.getMinutes() === 51, "date.getMinutes() = " + date.getMinutes());
1052 ok(date.getSeconds() === 24, "date.getSeconds() = " + date.getSeconds());
1053 ok(date.getMilliseconds() === 120, "date.getMilliseconds() = " + date.getMilliseconds());
1054 date = new Date(731, -32, 40, -1, 70, 65, -13);
1055 ok(date.getFullYear() === 728, "date.getFullYear() = " + date.getFullYear());
1056 ok(date.getMonth() === 5, "date.getMonth() = " + date.getMonth());
1057 ok(date.getDate() === 9, "date.getDate() = " + date.getDate());
1058 ok(date.getHours() === 0, "date.getHours() = " + date.getHours());
1059 ok(date.getMinutes() === 11, "date.getMinutes() = " + date.getMinutes());
1060 ok(date.getSeconds() === 4, "date.getSeconds() = " + date.getSeconds());
1061 ok(date.getMilliseconds() === 987, "date.getMilliseconds() = " + date.getMilliseconds());
1063 ok(date.setTime(123) === 123, "date.setTime(123) !== 123");
1064 ok(date.setTime("123", NaN) === 123, "date.setTime(\"123\") !== 123");
1065 ok(isNaN(date.setTime(NaN)), "date.setTime(NaN) is not NaN");
1067 ok(date.setTime(0) === date.getTime(), "date.setTime(0) !== date.getTime()");
1068 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
1069 ok(date.getUTCMonth() === 0, "date.getUTCMonth() = " + date.getUTCMonth());
1070 ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
1071 ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
1072 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
1073 ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
1074 ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
1075 ok(date.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1076 date.setTime(60*24*60*60*1000);
1077 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
1078 ok(date.getUTCMonth() === 2, "date.getUTCMonth() = " + date.getUTCMonth());
1079 ok(date.getUTCDate() === 2, "date.getUTCDate() = " + date.getUTCDate());
1080 ok(date.getUTCDay() === 1, "date.getUTCDay() = " + date.getUTCDay());
1081 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
1082 ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
1083 ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
1084 ok(date.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1085 date.setTime(59*24*60*60*1000 + 4*365*24*60*60*1000 + 60*60*1000 + 2*60*1000 + 2*1000 + 640);
1086 ok(date.getUTCFullYear() === 1974, "date.getUTCFullYear() = " + date.getUTCFullYear());
1087 ok(date.getUTCMonth() === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1088 ok(date.getUTCMonth(123) === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1089 ok(date.getUTCDate() === 28, "date.getUTCDate() = " + date.getUTCDate());
1090 ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
1091 ok(date.getUTCHours() === 1, "date.getUTCHours() = " + date.getUTCHours());
1092 ok(date.getUTCMinutes() === 2, "date.getUTCMinutes() = " + date.getUTCMinutes());
1093 ok(date.getUTCSeconds() === 2, "date.getUTCSeconds() = " + date.getUTCSeconds());
1094 ok(date.getUTCMilliseconds() === 640, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1095 date.setTime(Infinity);
1096 ok(isNaN(date.getUTCFullYear()), "date.getUTCFullYear() is not NaN");
1097 ok(isNaN(date.getUTCMonth()), "date.getUTCMonth() is not NaN");
1098 ok(isNaN(date.getUTCDate()), "date.getUTCDate() is not NaN");
1099 ok(isNaN(date.getUTCDay()), "date.getUTCDay() is not NaN");
1100 ok(isNaN(date.getUTCHours()), "date.getUTCHours() is not NaN");
1101 ok(isNaN(date.getUTCMinutes()), "date.getUTCMinutes() is not NaN");
1102 ok(isNaN(date.getUTCSeconds()), "date.getUTCSeconds() is not NaN");
1103 ok(isNaN(date.getUTCMilliseconds()), "date.getUTCMilliseconds() is not NaN");
1104 ok(isNaN(date.setMilliseconds(0)), "date.setMilliseconds() is not NaN");
1107 date.setUTCMilliseconds(-10, 2);
1108 ok(date.getUTCMilliseconds() === 990, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1109 date.setUTCMilliseconds(10);
1110 ok(date.getUTCMilliseconds() === 10, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1111 date.setUTCSeconds(-10);
1112 ok(date.getUTCSeconds() === 50, "date.getUTCSeconds() = " + date.getUTCSeconds());
1113 date.setUTCMinutes(-10);
1114 ok(date.getUTCMinutes() === 50, "date.getUTCMinutes() = " + date.getUTCMinutes());
1115 date.setUTCHours(-10);
1116 ok(date.getUTCHours() === 14, "date.getUTCHours() = " + date.getUTCHours());
1117 date.setUTCHours(-123);
1118 ok(date.getTime() === -612549990, "date.getTime() = " + date.getTime());
1119 date.setUTCHours(20);
1120 ok(date.getUTCHours() === 20, "date.getUTCHours() = " + date.getUTCHours());
1121 date.setUTCDate(32);
1122 ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
1123 date.setUTCMonth(22, 37);
1124 ok(date.getTime() === 60987050010, "date.getTime() = " + date.getTime());
1125 date.setUTCFullYear(83, 21, 321);
1126 ok(date.getTime() === -59464984149990, "date.getTime() = " + date.getTime());
1127 ok(Math.abs(date) === 59464984149990, "Math.abs(date) = " + Math.abs(date));
1128 ok(getVT(date+1) === "VT_BSTR", "getVT(date+1) = " + getVT(date+1));
1130 ok(isNaN(Date.parse()), "Date.parse() is not NaN");
1131 ok(isNaN(Date.parse("")), "Date.parse(\"\") is not NaN");
1132 ok(isNaN(Date.parse("Jan Jan 20 2009")), "Date.parse(\"Jan Jan 20 2009\") is not NaN");
1133 ok(Date.parse("Jan 20 2009 UTC") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC\") = " + Date.parse("Jan 20 2009 UTC"));
1134 ok(Date.parse("Jan 20 2009 GMT") === 1232409600000, "Date.parse(\"Jan 20 2009 GMT\") = " + Date.parse("Jan 20 2009 GMT"));
1135 ok(Date.parse("Jan 20 2009 UTC-0") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC-0\") = " + Date.parse("Jan 20 2009 UTC-0"));
1136 ok(Date.parse("Jan 20 2009 UTC+0000") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC+0000\") = " + Date.parse("Jan 20 2009 UTC+0000"));
1137 ok(Date.parse("Ju 13 79 UTC") === 300672000000, "Date.parse(\"Ju 13 79 UTC\") = " + Date.parse("Ju 13 79 UTC"));
1138 ok(Date.parse("12Au91 UTC") === 681955200000, "Date.parse(\"12Au91 UTC\") = " + Date.parse("12Au91 UTC"));
1139 ok(Date.parse("7/02/17 UTC") === -1656806400000, "Date.parse(\"7/02/17 UTC\") = " + Date.parse("7/02/17 UTC"));
1140 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"));
1141 ok(Date.parse("February 31 UTC, 2000 12:31:17 PM") === 952000277000,
1142 "Date.parse(\"February 31 UTC, 2000 12:31:17 PM\") = " + Date.parse("February 31 UTC, 2000 12:31:17 PM"));
1143 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 "));
1144 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"));
1146 ok(typeof(Math.PI) === "number", "typeof(Math.PI) = " + typeof(Math.PI));
1147 ok(Math.floor(Math.PI*100) === 314, "Math.PI = " + Math.PI);
1149 ok(Math.floor(Math.PI*100) === 314, "modified Math.PI = " + Math.PI);
1151 ok(typeof(Math.E) === "number", "typeof(Math.E) = " + typeof(Math.E));
1152 ok(Math.floor(Math.E*100) === 271, "Math.E = " + Math.E);
1154 ok(Math.floor(Math.E*100) === 271, "modified Math.E = " + Math.E);
1156 ok(typeof(Math.LOG2E) === "number", "typeof(Math.LOG2E) = " + typeof(Math.LOG2E));
1157 ok(Math.floor(Math.LOG2E*100) === 144, "Math.LOG2E = " + Math.LOG2E);
1158 Math.LOG2E = "test";
1159 ok(Math.floor(Math.LOG2E*100) === 144, "modified Math.LOG2E = " + Math.LOG2E);
1161 ok(typeof(Math.LOG10E) === "number", "typeof(Math.LOG10E) = " + typeof(Math.LOG10E));
1162 ok(Math.floor(Math.LOG10E*100) === 43, "Math.LOG10E = " + Math.LOG10E);
1163 Math.LOG10E = "test";
1164 ok(Math.floor(Math.LOG10E*100) === 43, "modified Math.LOG10E = " + Math.LOG10E);
1166 ok(typeof(Math.LN2) === "number", "typeof(Math.LN2) = " + typeof(Math.LN2));
1167 ok(Math.floor(Math.LN2*100) === 69, "Math.LN2 = " + Math.LN2);
1169 ok(Math.floor(Math.LN2*100) === 69, "modified Math.LN2 = " + Math.LN2);
1171 ok(typeof(Math.LN10) === "number", "typeof(Math.LN10) = " + typeof(Math.LN10));
1172 ok(Math.floor(Math.LN10*100) === 230, "Math.LN10 = " + Math.LN10);
1174 ok(Math.floor(Math.LN10*100) === 230, "modified Math.LN10 = " + Math.LN10);
1176 ok(typeof(Math.SQRT2) === "number", "typeof(Math.SQRT2) = " + typeof(Math.SQRT2));
1177 ok(Math.floor(Math.SQRT2*100) === 141, "Math.SQRT2 = " + Math.SQRT2);
1178 Math.SQRT2 = "test";
1179 ok(Math.floor(Math.SQRT2*100) === 141, "modified Math.SQRT2 = " + Math.SQRT2);
1181 ok(typeof(Math.SQRT1_2) === "number", "typeof(Math.SQRT1_2) = " + typeof(Math.SQRT1_2));
1182 ok(Math.floor(Math.SQRT1_2*100) === 70, "Math.SQRT1_2 = " + Math.SQRT1_2);
1183 Math.SQRT1_2 = "test";
1184 ok(Math.floor(Math.SQRT1_2*100) === 70, "modified Math.SQRT1_2 = " + Math.SQRT1_2);
1186 var bool = new Boolean();
1187 ok(bool.toString() === "false", "bool.toString() = " + bool.toString());
1188 var bool = new Boolean("false");
1189 ok(bool.toString() === "true", "bool.toString() = " + bool.toString());
1190 ok(bool.valueOf() === Boolean(1), "bool.valueOf() = " + bool.valueOf());
1191 ok(bool.toLocaleString() === bool.toString(), "bool.toLocaleString() = " + bool.toLocaleString());