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 === "<BIG></BIG>", "''.big() = " + tmp);
275 ok(tmp === "<BIG></BIG>", "''.big(3) = " + tmp);
277 ok(tmp === "<BIG>test</BIG>", "'test'.big() = " + tmp);
279 ok(tmp === "<BIG>test</BIG>", "'test'.big(3) = " + tmp);
282 ok(tmp === "<BLINK></BLINK>", "''.blink() = " + tmp);
284 ok(tmp === "<BLINK></BLINK>", "''.blink(3) = " + tmp);
285 tmp = "test".blink();
286 ok(tmp === "<BLINK>test</BLINK>", "'test'.blink() = " + tmp);
287 tmp = "test".blink(3);
288 ok(tmp === "<BLINK>test</BLINK>", "'test'.blink(3) = " + tmp);
291 ok(tmp === "<B></B>", "''.bold() = " + tmp);
293 ok(tmp === "<B></B>", "''.bold(3) = " + tmp);
295 ok(tmp === "<B>test</B>", "'test'.bold() = " + tmp);
296 tmp = "test".bold(3);
297 ok(tmp === "<B>test</B>", "'test'.bold(3) = " + tmp);
300 ok(tmp === "<TT></TT>", "''.fixed() = " + tmp);
302 ok(tmp === "<TT></TT>", "''.fixed(3) = " + tmp);
303 tmp = "test".fixed();
304 ok(tmp === "<TT>test</TT>", "'test'.fixed() = " + tmp);
305 tmp = "test".fixed(3);
306 ok(tmp === "<TT>test</TT>", "'test'.fixed(3) = " + tmp);
309 ok(tmp === "<I></I>", "''.italics() = " + tmp);
311 ok(tmp === "<I></I>", "''.italics(3) = " + tmp);
312 tmp = "test".italics();
313 ok(tmp === "<I>test</I>", "'test'.italics() = " + tmp);
314 tmp = "test".italics(3);
315 ok(tmp === "<I>test</I>", "'test'.italics(3) = " + tmp);
318 ok(tmp === "<SMALL></SMALL>", "''.small() = " + tmp);
320 ok(tmp === "<SMALL></SMALL>", "''.small(3) = " + tmp);
321 tmp = "test".small();
322 ok(tmp === "<SMALL>test</SMALL>", "'test'.small() = " + tmp);
323 tmp = "test".small(3);
324 ok(tmp === "<SMALL>test</SMALL>", "'test'.small(3) = " + tmp);
327 ok(tmp === "<STRIKE></STRIKE>", "''.strike() = " + tmp);
329 ok(tmp === "<STRIKE></STRIKE>", "''.strike(3) = " + tmp);
330 tmp = "test".strike();
331 ok(tmp === "<STRIKE>test</STRIKE>", "'test'.strike() = " + tmp);
332 tmp = "test".strike(3);
333 ok(tmp === "<STRIKE>test</STRIKE>", "'test'.strike(3) = " + tmp);
336 ok(tmp === "<SUB></SUB>", "''.sub() = " + tmp);
338 ok(tmp === "<SUB></SUB>", "''.sub(3) = " + tmp);
340 ok(tmp === "<SUB>test</SUB>", "'test'.sub() = " + tmp);
342 ok(tmp === "<SUB>test</SUB>", "'test'.sub(3) = " + tmp);
345 ok(tmp === "<SUP></SUP>", "''.sup() = " + tmp);
347 ok(tmp === "<SUP></SUP>", "''.sup(3) = " + tmp);
349 ok(tmp === "<SUP>test</SUP>", "'test'.sup() = " + tmp);
351 ok(tmp === "<SUP>test</SUP>", "'test'.sup(3) = " + tmp);
353 var arr = new Array();
354 ok(typeof(arr) === "object", "arr () is not object");
355 ok((arr.length === 0), "arr.length is not 0");
356 ok(arr["0"] === undefined, "arr[0] is not undefined");
358 var arr = new Array(1, 2, "test");
359 ok(typeof(arr) === "object", "arr (1,2,test) is not object");
360 ok((arr.length === 3), "arr.length is not 3");
361 ok(arr["0"] === 1, "arr[0] is not 1");
362 ok(arr["1"] === 2, "arr[1] is not 2");
363 ok(arr["2"] === "test", "arr[2] is not \"test\"");
366 ok((arr.length === 8), "arr.length is not 8");
369 ok(tmp === "", "'' + [] = " + tmp);
371 ok(tmp === "1,true", "'' + [1,true] = " + tmp);
373 var arr = new Array(6);
374 ok(typeof(arr) === "object", "arr (6) is not object");
375 ok((arr.length === 6), "arr.length is not 6");
376 ok(arr["0"] === undefined, "arr[0] is not undefined");
378 ok(arr.push() === 6, "arr.push() !== 6");
379 ok(arr.push(1) === 7, "arr.push(1) !== 7");
380 ok(arr[6] === 1, "arr[6] != 1");
381 ok(arr.length === 7, "arr.length != 10");
382 ok(arr.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10");
383 ok(arr[8] === "b", "arr[8] != 'b'");
384 ok(arr.length === 10, "arr.length != 10");
388 ok(arr.length === 2, "arr.length = " + arr.length);
389 ok(tmp === 5, "pop() = " + tmp);
391 ok(arr.length === 1, "arr.length = " + arr.length);
392 ok(tmp === 4, "pop() = " + tmp);
394 ok(arr.length === 0, "arr.length = " + arr.length);
395 ok(tmp === 3, "pop() = " + tmp);
397 ok(false, "not deleted " + tmp);
399 ok(arr.length === 0, "arr.length = " + arr.length);
400 ok(tmp === undefined, "tmp = " + tmp);
403 ok(arr.length === 5, "arr.length = " + arr.length);
404 ok(tmp === undefined, "tmp = " + tmp);
406 arr = [1,2,null,false,undefined,,"a"];
409 ok(tmp === "1,2,,false,,,a", "arr.join() = " + tmp);
411 ok(tmp === "1;2;;false;;;a", "arr.join(';') = " + tmp);
412 tmp = arr.join(";","test");
413 ok(tmp === "1;2;;false;;;a", "arr.join(';') = " + tmp);
415 ok(tmp === "12falsea", "arr.join('') = " + tmp);
417 tmp = arr.toString();
418 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
419 tmp = arr.toString("test");
420 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
422 arr = [5,true,2,-1,3,false,"2.5"];
423 tmp = arr.sort(function(x,y) { return y-x; });
424 ok(tmp === arr, "tmp !== arr");
425 tmp = [5,3,"2.5",2,true,false,-1];
426 for(var i=0; i < arr.length; i++)
427 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
429 arr = [5,false,2,0,"abc",3,"a",-1];
431 ok(tmp === arr, "tmp !== arr");
432 tmp = [-1,0,2,3,5,"a","abc",false];
433 for(var i=0; i < arr.length; i++)
434 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
436 arr = ["a", "b", "ab"];
437 tmp = ["a", "ab", "b"];
438 ok(arr.sort() === arr, "arr.sort() !== arr");
439 for(var i=0; i < arr.length; i++)
440 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
442 var num = new Number(6);
444 tmp = arr.concat(3, [4,5], num);
445 ok(tmp !== arr, "tmp === arr");
446 for(var i=0; i<6; i++)
447 ok(tmp[i] === i, "tmp[" + i + "] = " + tmp[i]);
448 ok(tmp[6] === num, "tmp[6] !== num");
449 ok(tmp.length === 7, "tmp.length = " + tmp.length);
452 ok(arr.length === 0, "arr.length = " + arr.length);
455 tmp = arr.concat([2]);
456 ok(tmp.length === 3, "tmp.length = " + tmp.length);
457 ok(tmp[1] === undefined, "tmp[1] = " + tmp[1]);
459 var num = new Number(2);
460 ok(num.toString() === "2", "num(2).toString !== 2");
461 var num = new Number();
462 ok(num.toString() === "0", "num().toString !== 0");
464 ok(Number() === 0, "Number() = " + Number());
465 ok(Number(false) === 0, "Number(false) = " + Number(false));
466 ok(Number("43") === 43, "Number('43') = " + Number("43"));
468 tmp = (new Number(1)).valueOf();
469 ok(tmp === 1, "(new Number(1)).valueOf = " + tmp);
470 tmp = (new Number(1,2)).valueOf();
471 ok(tmp === 1, "(new Number(1,2)).valueOf = " + tmp);
472 tmp = (new Number()).valueOf();
473 ok(tmp === 0, "(new Number()).valueOf = " + tmp);
474 tmp = Number.prototype.valueOf();
475 ok(tmp === 0, "Number.prototype.valueOf = " + tmp);
478 ok(tmp === 1, "Math.min(1) = " + tmp);
480 tmp = Math.min(1, false);
481 ok(tmp === 0, "Math.min(1, false) = " + tmp);
484 ok(tmp === Infinity, "Math.min() = " + tmp);
486 tmp = Math.min(1, NaN, -Infinity, false);
487 ok(isNaN(tmp), "Math.min(1, NaN, -Infinity, false) is not NaN");
489 tmp = Math.min(1, false, true, null, -3);
490 ok(tmp === -3, "Math.min(1, false, true, null, -3) = " + tmp);
493 ok(tmp === 1, "Math.max(1) = " + tmp);
495 tmp = Math.max(true, 0);
496 ok(tmp === 1, "Math.max(true, 0) = " + tmp);
498 tmp = Math.max(-2, false, true, null, 1);
499 ok(tmp === 1, "Math.max(-2, false, true, null, 1) = " + tmp);
502 ok(tmp === -Infinity, "Math.max() = " + tmp);
504 tmp = Math.max(true, NaN, 0);
505 ok(isNaN(tmp), "Math.max(true, NaN, 0) is not NaN");
507 tmp = Math.round(0.5);
508 ok(tmp === 1, "Math.round(0.5) = " + tmp);
510 tmp = Math.round(-0.5);
511 ok(tmp === 0, "Math.round(-0.5) = " + tmp);
513 tmp = Math.round(1.1);
514 ok(tmp === 1, "Math.round(1.1) = " + tmp);
516 tmp = Math.round(true);
517 ok(tmp === 1, "Math.round(true) = " + tmp);
519 tmp = Math.round(1.1, 3, 4);
520 ok(tmp === 1, "Math.round(1.1, 3, 4) = " + tmp);
523 ok(isNaN(tmp), "Math.round() is not NaN");
525 tmp = Math.ceil(0.5);
526 ok(tmp === 1, "Math.ceil(0.5) = " + tmp);
528 tmp = Math.ceil(-0.5);
529 ok(tmp === 0, "Math.ceil(-0.5) = " + tmp);
531 tmp = Math.ceil(1.1);
532 ok(tmp === 2, "Math.round(1.1) = " + tmp);
534 tmp = Math.ceil(true);
535 ok(tmp === 1, "Math.ceil(true) = " + tmp);
537 tmp = Math.ceil(1.1, 3, 4);
538 ok(tmp === 2, "Math.ceil(1.1, 3, 4) = " + tmp);
541 ok(isNaN(tmp), "ceil() is not NaN");
543 tmp = Math.floor(0.5);
544 ok(tmp === 0, "Math.floor(0.5) = " + tmp);
546 tmp = Math.floor(-0.5);
547 ok(tmp === -1, "Math.floor(-0.5) = " + tmp);
549 tmp = Math.floor(1.1);
550 ok(tmp === 1, "Math.floor(1.1) = " + tmp);
552 tmp = Math.floor(true);
553 ok(tmp === 1, "Math.floor(true) = " + tmp);
555 tmp = Math.floor(1.1, 3, 4);
556 ok(tmp === 1, "Math.floor(1.1, 3, 4) = " + tmp);
559 ok(isNaN(tmp), "floor is not NaN");
562 ok(tmp === 3, "Math.abs(3) = " + tmp);
565 ok(tmp === 3, "Math.abs(-3) = " + tmp);
567 tmp = Math.abs(true);
568 ok(tmp === 1, "Math.abs(true) = " + tmp);
571 ok(isNaN(tmp), "Math.abs() is not NaN");
574 ok(isNaN(tmp), "Math.abs() is not NaN");
576 tmp = Math.abs(-Infinity);
577 ok(tmp === Infinity, "Math.abs(-Infinite) = " + tmp);
579 tmp = Math.abs(-3, 2);
580 ok(tmp === 3, "Math.abs(-3, 2) = " + tmp);
582 tmp = Math.pow(2, 2);
583 ok(tmp === 4, "Math.pow(2, 2) = " + tmp);
585 tmp = Math.pow(4, 0.5);
586 ok(tmp === 2, "Math.pow(2, 2) = " + tmp);
588 tmp = Math.pow(2, 2, 3);
589 ok(tmp === 4, "Math.pow(2, 2, 3) = " + tmp);
592 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
593 ok(0 <= tmp && tmp <= 1, "Math.random() = " + tmp);
595 tmp = Math.random(100);
596 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
597 ok(0 <= tmp && tmp <= 1, "Math.random(100) = " + tmp);
599 var func = function (a) {
603 ok(func.toString() === "function (a) {\n var a = 1;\n if(a) return;\n }",
604 "func.toString() = " + func.toString());
605 ok("" + func === "function (a) {\n var a = 1;\n if(a) return;\n }",
606 "'' + func.toString() = " + func);
608 function testFuncToString(x,y) {
612 ok(testFuncToString.toString() === "function testFuncToString(x,y) {\n return x+y;\n}",
613 "testFuncToString.toString() = " + testFuncToString.toString());
614 ok("" + testFuncToString === "function testFuncToString(x,y) {\n return x+y;\n}",
615 "'' + testFuncToString = " + testFuncToString);
617 var date = new Date();
619 date = new Date(100);
620 ok(date.getTime() === 100, "date.getTime() = " + date.getTime());
621 ok(Date.prototype.getTime() === 0, "date.prototype.getTime() = " + Date.prototype.getTime());
623 ok(typeof(Math.PI) === "number", "typeof(Math.PI) = " + typeof(Math.PI));
624 ok(Math.floor(Math.PI*100) === 314, "Math.PI = " + Math.PI);
626 ok(Math.floor(Math.PI*100) === 314, "modified Math.PI = " + Math.PI);
628 ok(typeof(Math.E) === "number", "typeof(Math.E) = " + typeof(Math.E));
629 ok(Math.floor(Math.E*100) === 271, "Math.E = " + Math.E);
631 ok(Math.floor(Math.E*100) === 271, "modified Math.E = " + Math.E);
633 ok(typeof(Math.LOG2E) === "number", "typeof(Math.LOG2E) = " + typeof(Math.LOG2E));
634 ok(Math.floor(Math.LOG2E*100) === 144, "Math.LOG2E = " + Math.LOG2E);
636 ok(Math.floor(Math.LOG2E*100) === 144, "modified Math.LOG2E = " + Math.LOG2E);
638 ok(typeof(Math.LOG10E) === "number", "typeof(Math.LOG10E) = " + typeof(Math.LOG10E));
639 ok(Math.floor(Math.LOG10E*100) === 43, "Math.LOG10E = " + Math.LOG10E);
640 Math.LOG10E = "test";
641 ok(Math.floor(Math.LOG10E*100) === 43, "modified Math.LOG10E = " + Math.LOG10E);