jscript: Inherit some Number functions from Object.
[wine] / dlls / jscript / tests / api.js
1 /*
2  * Copyright 2008 Jacek Caban for CodeWeavers
3  *
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.
8  *
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.
13  *
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
17  */
18
19 var tmp, i;
20
21 i = parseInt("0");
22 ok(i === 0, "parseInt('0') = " + i);
23 i = parseInt("123");
24 ok(i === 123, "parseInt('123') = " + i);
25 i = parseInt("-123");
26 ok(i === -123, "parseInt('-123') = " + i);
27 i = parseInt("0xff");
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);
39
40 tmp = encodeURI("abc");
41 ok(tmp === "abc", "encodeURI('abc') = " + tmp);
42 tmp = encodeURI("{abc}");
43 ok(tmp === "%7Babc%7D", "encodeURI('{abc}') = " + tmp);
44 tmp = encodeURI("");
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);
56 tmp = encodeURI();
57 ok(tmp === "undefined", "encodeURI() = " + tmp);
58 tmp = encodeURI("abc", "test");
59 ok(tmp === "abc", "encodeURI('abc') = " + tmp);
60
61 tmp = "" + new Object();
62 ok(tmp === "[object Object]", "'' + new Object() = " + tmp);
63 (tmp = new Array).f = Object.prototype.toString;
64 ok(tmp.f() === "[object Array]", "tmp.f() = " + tmp.f());
65 (tmp = new Boolean).f = Object.prototype.toString;
66 ok(tmp.f() === "[object Boolean]", "tmp.f() = " + tmp.f());
67 (tmp = new Date).f = Object.prototype.toString;
68 ok(tmp.f() === "[object Date]", "tmp.f() = " + tmp.f());
69 (tmp = function() {}).f = Object.prototype.toString;
70 ok(tmp.f() === "[object Function]", "tmp.f() = " + tmp.f());
71 Math.f = Object.prototype.toString;
72 ok(Math.f() === "[object Math]", "tmp.f() = " + tmp.f());
73 (tmp = new Number).f = Object.prototype.toString;
74 ok(tmp.f() === "[object Number]", "tmp.f() = " + tmp.f());
75 (tmp = new RegExp("")).f = Object.prototype.toString;
76 ok(tmp.f() === "[object RegExp]", "tmp.f() = " + tmp.f());
77 (tmp = new String).f = Object.prototype.toString;
78 ok(tmp.f() === "[object String]", "tmp.f() = " + tmp.f());
79
80 ok("".length === 0, "\"\".length = " + "".length);
81 ok(getVT("".length) == "VT_I4", "\"\".length = " + "".length);
82 ok("abc".length === 3, "\"abc\".length = " + "abc".length);
83 ok(String.prototype.length === 0, "String.prototype.length = " + String.prototype.length);
84
85 tmp = "".toString();
86 ok(tmp === "", "''.toString() = " + tmp);
87 tmp = "test".toString();
88 ok(tmp === "test", "''.toString() = " + tmp);
89 tmp = "test".toString(3);
90 ok(tmp === "test", "''.toString(3) = " + tmp);
91
92 tmp = "".valueOf();
93 ok(tmp === "", "''.valueOf() = " + tmp);
94 tmp = "test".valueOf();
95 ok(tmp === "test", "''.valueOf() = " + tmp);
96 tmp = "test".valueOf(3);
97 ok(tmp === "test", "''.valueOf(3) = " + tmp);
98
99 var str = new String("test");
100 ok(str.toString() === "test", "str.toString() = " + str.toString());
101 var str = new String();
102 ok(str.toString() === "", "str.toString() = " + str.toString());
103 var str = new String("test", "abc");
104 ok(str.toString() === "test", "str.toString() = " + str.toString());
105
106 tmp = "value " + str;
107 ok(tmp === "value test", "'value ' + str = " + tmp);
108
109 tmp = String();
110 ok(tmp === "", "String() = " + tmp);
111 tmp = String(false);
112 ok(tmp === "false", "String(false) = " + tmp);
113 tmp = String(null);
114 ok(tmp === "null", "String(null) = " + tmp);
115 tmp = String("test");
116 ok(tmp === "test", "String('test') = " + tmp);
117 tmp = String("test", "abc");
118 ok(tmp === "test", "String('test','abc') = " + tmp);
119
120 tmp = "abc".charAt(0);
121 ok(tmp === "a", "'abc',charAt(0) = " + tmp);
122 tmp = "abc".charAt(1);
123 ok(tmp === "b", "'abc',charAt(1) = " + tmp);
124 tmp = "abc".charAt(2);
125 ok(tmp === "c", "'abc',charAt(2) = " + tmp);
126 tmp = "abc".charAt(3);
127 ok(tmp === "", "'abc',charAt(3) = " + tmp);
128 tmp = "abc".charAt(4);
129 ok(tmp === "", "'abc',charAt(4) = " + tmp);
130 tmp = "abc".charAt();
131 ok(tmp === "a", "'abc',charAt() = " + tmp);
132 tmp = "abc".charAt(-1);
133 ok(tmp === "", "'abc',charAt(-1) = " + tmp);
134 tmp = "abc".charAt(0,2);
135 ok(tmp === "a", "'abc',charAt(0.2) = " + tmp);
136
137 tmp = "abc".charCodeAt(0);
138 ok(tmp === 0x61, "'abc'.charCodeAt(0) = " + tmp);
139 tmp = "abc".charCodeAt(1);
140 ok(tmp === 0x62, "'abc'.charCodeAt(1) = " + tmp);
141 tmp = "abc".charCodeAt(2);
142 ok(tmp === 0x63, "'abc'.charCodeAt(2) = " + tmp);
143 tmp = "abc".charCodeAt();
144 ok(tmp === 0x61, "'abc'.charCodeAt() = " + tmp);
145 tmp = "abc".charCodeAt(true);
146 ok(tmp === 0x62, "'abc'.charCodeAt(true) = " + tmp);
147 tmp = "abc".charCodeAt(0,2);
148 ok(tmp === 0x61, "'abc'.charCodeAt(0,2) = " + tmp);
149
150 tmp = "abcd".substring(1,3);
151 ok(tmp === "bc", "'abcd'.substring(1,3) = " + tmp);
152 tmp = "abcd".substring(-1,3);
153 ok(tmp === "abc", "'abcd'.substring(-1,3) = " + tmp);
154 tmp = "abcd".substring(1,6);
155 ok(tmp === "bcd", "'abcd'.substring(1,6) = " + tmp);
156 tmp = "abcd".substring(3,1);
157 ok(tmp === "bc", "'abcd'.substring(3,1) = " + tmp);
158 tmp = "abcd".substring(2,2);
159 ok(tmp === "", "'abcd'.substring(2,2) = " + tmp);
160 tmp = "abcd".substring(true,"3");
161 ok(tmp === "bc", "'abcd'.substring(true,'3') = " + tmp);
162 tmp = "abcd".substring(1,3,2);
163 ok(tmp === "bc", "'abcd'.substring(1,3,2) = " + tmp);
164 tmp = "abcd".substring();
165 ok(tmp === "abcd", "'abcd'.substring() = " + tmp);
166
167 tmp = "abcd".slice(1,3);
168 ok(tmp === "bc", "'abcd'.slice(1,3) = " + tmp);
169 tmp = "abcd".slice(1,-1);
170 ok(tmp === "bc", "'abcd'.slice(1,-1) = " + tmp);
171 tmp = "abcd".slice(-3,3);
172 ok(tmp === "bc", "'abcd'.slice(-3,3) = " + tmp);
173 tmp = "abcd".slice(-6,3);
174 ok(tmp === "abc", "'abcd'.slice(-6,3) = " + tmp);
175 tmp = "abcd".slice(3,1);
176 ok(tmp === "", "'abcd'.slice(3,1) = " + tmp);
177 tmp = "abcd".slice(true,3);
178 ok(tmp === "bc", "'abcd'.slice(true,3) = " + tmp);
179 tmp = "abcd".slice();
180 ok(tmp === "abcd", "'abcd'.slice() = " + tmp);
181 tmp = "abcd".slice(1);
182 ok(tmp === "bcd", "'abcd'.slice(1) = " + tmp);
183
184 tmp = "abc".concat(["d",1],2,false);
185 ok(tmp === "abcd,12false", "concat returned " + tmp);
186 var arr = new Array(2,"a");
187 arr.concat = String.prototype.concat;
188 tmp = arr.concat("d");
189 ok(tmp === "2,ad", "arr.concat = " + tmp);
190
191 m = "a+bcabc".match("a+");
192 ok(typeof(m) === "object", "typeof m is not object");
193 ok(m.length === 1, "m.length is not 1");
194 ok(m["0"] === "a", "m[0] is not \"ab\"");
195
196 r = "- [test] -".replace("[test]", "success");
197 ok(r === "- success -", "r = " + r + " expected '- success -'");
198
199 r = "- [test] -".replace("[test]", "success", "test");
200 ok(r === "- success -", "r = " + r + " expected '- success -'");
201
202 r = "test".replace();
203 ok(r === "test", "r = " + r + " expected 'test'");
204
205 function replaceFunc3(m, off, str) {
206     ok(arguments.length === 3, "arguments.length = " + arguments.length);
207     ok(m === "[test]", "m = " + m + " expected [test1]");
208     ok(off === 1, "off = " + off + " expected 0");
209     ok(str === "-[test]-", "str = " + arguments[3]);
210     return "ret";
211 }
212
213 r = "-[test]-".replace("[test]", replaceFunc3);
214 ok(r === "-ret-", "r = " + r + " expected '-ret-'");
215
216 r = "-[test]-".replace("[test]", replaceFunc3, "test");
217 ok(r === "-ret-", "r = " + r + " expected '-ret-'");
218
219 r = "1,2,3".split(",");
220 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
221 ok(r.length === 3, "r.length = " + r.length);
222 ok(r[0] === "1", "r[0] = " + r[0]);
223 ok(r[1] === "2", "r[1] = " + r[1]);
224 ok(r[2] === "3", "r[2] = " + r[2]);
225
226
227 r = "1,2,3".split(",*");
228 ok(r.length === 1, "r.length = " + r.length);
229 ok(r[0] === "1,2,3", "r[0] = " + r[0]);
230
231 r = "123".split("");
232 ok(r.length === 3, "r.length = " + r.length);
233 ok(r[0] === "1", "r[0] = " + r[0]);
234 ok(r[1] === "2", "r[1] = " + r[1]);
235 ok(r[2] === "3", "r[2] = " + r[2]);
236
237 r = "123".split(2);
238 ok(r.length === 2, "r.length = " + r.length);
239 ok(r[0] === "1", "r[0] = " + r[0]);
240 ok(r[1] === "3", "r[1] = " + r[1]);
241
242 r = "1,2,".split(",");
243 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
244 ok(r.length === 3, "r.length = " + r.length);
245 ok(r[0] === "1", "r[0] = " + r[0]);
246 ok(r[1] === "2", "r[1] = " + r[1]);
247 ok(r[2] === "", "r[2] = " + r[2]);
248
249 tmp = "abcd".indexOf("bc",0);
250 ok(tmp === 1, "indexOf = " + tmp);
251 tmp = "abcd".indexOf("bc",1);
252 ok(tmp === 1, "indexOf = " + tmp);
253 tmp = "abcd".indexOf("bc");
254 ok(tmp === 1, "indexOf = " + tmp);
255 tmp = "abcd".indexOf("ac");
256 ok(tmp === -1, "indexOf = " + tmp);
257 tmp = "abcd".indexOf("bc",2);
258 ok(tmp === -1, "indexOf = " + tmp);
259 tmp = "abcd".indexOf("a",0);
260 ok(tmp === 0, "indexOf = " + tmp);
261 tmp = "abcd".indexOf("bc",0,"test");
262 ok(tmp === 1, "indexOf = " + tmp);
263 tmp = "abcd".indexOf();
264 ok(tmp == -1, "indexOf = " + tmp);
265
266 tmp = "".toLowerCase();
267 ok(tmp === "", "''.toLowerCase() = " + tmp);
268 tmp = "test".toLowerCase();
269 ok(tmp === "test", "''.toLowerCase() = " + tmp);
270 tmp = "test".toLowerCase(3);
271 ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
272 tmp = "tEsT".toLowerCase();
273 ok(tmp === "test", "''.toLowerCase() = " + tmp);
274 tmp = "tEsT".toLowerCase(3);
275 ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
276
277 tmp = "".toUpperCase();
278 ok(tmp === "", "''.toUpperCase() = " + tmp);
279 tmp = "TEST".toUpperCase();
280 ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
281 tmp = "TEST".toUpperCase(3);
282 ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
283 tmp = "tEsT".toUpperCase();
284 ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
285 tmp = "tEsT".toUpperCase(3);
286 ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
287
288 tmp = "".anchor();
289 ok(tmp === "<A NAME=\"undefined\"></A>", "''.anchor() = " + tmp);
290 tmp = "".anchor(3);
291 ok(tmp === "<A NAME=\"3\"></A>", "''.anchor(3) = " + tmp);
292 tmp = "".anchor("red");
293 ok(tmp === "<A NAME=\"red\"></A>", "''.anchor('red') = " + tmp);
294 tmp = "test".anchor();
295 ok(tmp === "<A NAME=\"undefined\">test</A>", "'test'.anchor() = " + tmp);
296 tmp = "test".anchor(3);
297 ok(tmp === "<A NAME=\"3\">test</A>", "'test'.anchor(3) = " + tmp);
298 tmp = "test".anchor("green");
299 ok(tmp === "<A NAME=\"green\">test</A>", "'test'.anchor('green') = " + tmp);
300
301 tmp = "".big();
302 ok(tmp === "<BIG></BIG>", "''.big() = " + tmp);
303 tmp = "".big(3);
304 ok(tmp === "<BIG></BIG>", "''.big(3) = " + tmp);
305 tmp = "test".big();
306 ok(tmp === "<BIG>test</BIG>", "'test'.big() = " + tmp);
307 tmp = "test".big(3);
308 ok(tmp === "<BIG>test</BIG>", "'test'.big(3) = " + tmp);
309
310 tmp = "".blink();
311 ok(tmp === "<BLINK></BLINK>", "''.blink() = " + tmp);
312 tmp = "".blink(3);
313 ok(tmp === "<BLINK></BLINK>", "''.blink(3) = " + tmp);
314 tmp = "test".blink();
315 ok(tmp === "<BLINK>test</BLINK>", "'test'.blink() = " + tmp);
316 tmp = "test".blink(3);
317 ok(tmp === "<BLINK>test</BLINK>", "'test'.blink(3) = " + tmp);
318
319 tmp = "".bold();
320 ok(tmp === "<B></B>", "''.bold() = " + tmp);
321 tmp = "".bold(3);
322 ok(tmp === "<B></B>", "''.bold(3) = " + tmp);
323 tmp = "test".bold();
324 ok(tmp === "<B>test</B>", "'test'.bold() = " + tmp);
325 tmp = "test".bold(3);
326 ok(tmp === "<B>test</B>", "'test'.bold(3) = " + tmp);
327
328 tmp = "".fixed();
329 ok(tmp === "<TT></TT>", "''.fixed() = " + tmp);
330 tmp = "".fixed(3);
331 ok(tmp === "<TT></TT>", "''.fixed(3) = " + tmp);
332 tmp = "test".fixed();
333 ok(tmp === "<TT>test</TT>", "'test'.fixed() = " + tmp);
334 tmp = "test".fixed(3);
335 ok(tmp === "<TT>test</TT>", "'test'.fixed(3) = " + tmp);
336
337 tmp = "".fontcolor();
338 ok(tmp === "<FONT COLOR=\"undefined\"></FONT>", "''.fontcolor() = " + tmp);
339 tmp = "".fontcolor(3);
340 ok(tmp === "<FONT COLOR=\"3\"></FONT>", "''.fontcolor(3) = " + tmp);
341 tmp = "".fontcolor("red");
342 ok(tmp === "<FONT COLOR=\"red\"></FONT>", "''.fontcolor('red') = " + tmp);
343 tmp = "test".fontcolor();
344 ok(tmp === "<FONT COLOR=\"undefined\">test</FONT>", "'test'.fontcolor() = " + tmp);
345 tmp = "test".fontcolor(3);
346 ok(tmp === "<FONT COLOR=\"3\">test</FONT>", "'test'.fontcolor(3) = " + tmp);
347 tmp = "test".fontcolor("green");
348 ok(tmp === "<FONT COLOR=\"green\">test</FONT>", "'test'.fontcolor('green') = " + tmp);
349
350 tmp = "".fontsize();
351 ok(tmp === "<FONT SIZE=\"undefined\"></FONT>", "''.fontsize() = " + tmp);
352 tmp = "".fontsize(3);
353 ok(tmp === "<FONT SIZE=\"3\"></FONT>", "''.fontsize(3) = " + tmp);
354 tmp = "".fontsize("red");
355 ok(tmp === "<FONT SIZE=\"red\"></FONT>", "''.fontsize('red') = " + tmp);
356 tmp = "test".fontsize();
357 ok(tmp === "<FONT SIZE=\"undefined\">test</FONT>", "'test'.fontsize() = " + tmp);
358 tmp = "test".fontsize(3);
359 ok(tmp === "<FONT SIZE=\"3\">test</FONT>", "'test'.fontsize(3) = " + tmp);
360 tmp = "test".fontsize("green");
361 ok(tmp === "<FONT SIZE=\"green\">test</FONT>", "'test'.fontsize('green') = " + tmp);
362
363 tmp = ("".fontcolor()).fontsize();
364 ok(tmp === "<FONT SIZE=\"undefined\"><FONT COLOR=\"undefined\"></FONT></FONT>", "(''.fontcolor()).fontsize() = " + tmp);
365
366 tmp = "".italics();
367 ok(tmp === "<I></I>", "''.italics() = " + tmp);
368 tmp = "".italics(3);
369 ok(tmp === "<I></I>", "''.italics(3) = " + tmp);
370 tmp = "test".italics();
371 ok(tmp === "<I>test</I>", "'test'.italics() = " + tmp);
372 tmp = "test".italics(3);
373 ok(tmp === "<I>test</I>", "'test'.italics(3) = " + tmp);
374
375 tmp = "".link();
376 ok(tmp === "<A HREF=\"undefined\"></A>", "''.link() = " + tmp);
377 tmp = "".link(3);
378 ok(tmp === "<A HREF=\"3\"></A>", "''.link(3) = " + tmp);
379 tmp = "".link("red");
380 ok(tmp === "<A HREF=\"red\"></A>", "''.link('red') = " + tmp);
381 tmp = "test".link();
382 ok(tmp === "<A HREF=\"undefined\">test</A>", "'test'.link() = " + tmp);
383 tmp = "test".link(3);
384 ok(tmp === "<A HREF=\"3\">test</A>", "'test'.link(3) = " + tmp);
385 tmp = "test".link("green");
386 ok(tmp === "<A HREF=\"green\">test</A>", "'test'.link('green') = " + tmp);
387
388 tmp = "".small();
389 ok(tmp === "<SMALL></SMALL>", "''.small() = " + tmp);
390 tmp = "".small(3);
391 ok(tmp === "<SMALL></SMALL>", "''.small(3) = " + tmp);
392 tmp = "test".small();
393 ok(tmp === "<SMALL>test</SMALL>", "'test'.small() = " + tmp);
394 tmp = "test".small(3);
395 ok(tmp === "<SMALL>test</SMALL>", "'test'.small(3) = " + tmp);
396
397 tmp = "".strike();
398 ok(tmp === "<STRIKE></STRIKE>", "''.strike() = " + tmp);
399 tmp = "".strike(3);
400 ok(tmp === "<STRIKE></STRIKE>", "''.strike(3) = " + tmp);
401 tmp = "test".strike();
402 ok(tmp === "<STRIKE>test</STRIKE>", "'test'.strike() = " + tmp);
403 tmp = "test".strike(3);
404 ok(tmp === "<STRIKE>test</STRIKE>", "'test'.strike(3) = " + tmp);
405
406 tmp = "".sub();
407 ok(tmp === "<SUB></SUB>", "''.sub() = " + tmp);
408 tmp = "".sub(3);
409 ok(tmp === "<SUB></SUB>", "''.sub(3) = " + tmp);
410 tmp = "test".sub();
411 ok(tmp === "<SUB>test</SUB>", "'test'.sub() = " + tmp);
412 tmp = "test".sub(3);
413 ok(tmp === "<SUB>test</SUB>", "'test'.sub(3) = " + tmp);
414
415 tmp = "".sup();
416 ok(tmp === "<SUP></SUP>", "''.sup() = " + tmp);
417 tmp = "".sup(3);
418 ok(tmp === "<SUP></SUP>", "''.sup(3) = " + tmp);
419 tmp = "test".sup();
420 ok(tmp === "<SUP>test</SUP>", "'test'.sup() = " + tmp);
421 tmp = "test".sup(3);
422 ok(tmp === "<SUP>test</SUP>", "'test'.sup(3) = " + tmp);
423
424 ok(String.fromCharCode() === "", "String.fromCharCode() = " + String.fromCharCode());
425 ok(String.fromCharCode(65,"66",67) === "ABC", "String.fromCharCode(65,'66',67) = " + String.fromCharCode(65,"66",67));
426 ok(String.fromCharCode(1024*64+65, -1024*64+65) === "AA",
427         "String.fromCharCode(1024*64+65, -1024*64+65) = " + String.fromCharCode(1024*64+65, -1024*64+65));
428 ok(String.fromCharCode(65, NaN, undefined).length === 3,
429         "String.fromCharCode(65, NaN, undefined).length = " + String.fromCharCode(65, NaN, undefined).length);
430
431 var arr = new Array();
432 ok(typeof(arr) === "object", "arr () is not object");
433 ok((arr.length === 0), "arr.length is not 0");
434 ok(arr["0"] === undefined, "arr[0] is not undefined");
435
436 var arr = new Array(1, 2, "test");
437 ok(typeof(arr) === "object", "arr (1,2,test) is not object");
438 ok((arr.length === 3), "arr.length is not 3");
439 ok(arr["0"] === 1, "arr[0] is not 1");
440 ok(arr["1"] === 2, "arr[1] is not 2");
441 ok(arr["2"] === "test", "arr[2] is not \"test\"");
442
443 arr["7"] = true;
444 ok((arr.length === 8), "arr.length is not 8");
445
446 tmp = "" + [];
447 ok(tmp === "", "'' + [] = " + tmp);
448 tmp = "" + [1,true];
449 ok(tmp === "1,true", "'' + [1,true] = " + tmp);
450
451 var arr = new Array(6);
452 ok(typeof(arr) === "object", "arr (6) is not object");
453 ok((arr.length === 6), "arr.length is not 6");
454 ok(arr["0"] === undefined, "arr[0] is not undefined");
455
456 ok(arr.push() === 6, "arr.push() !== 6");
457 ok(arr.push(1) === 7, "arr.push(1) !== 7");
458 ok(arr[6] === 1, "arr[6] != 1");
459 ok(arr.length === 7, "arr.length != 10");
460 ok(arr.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10");
461 ok(arr[8] === "b", "arr[8] != 'b'");
462 ok(arr.length === 10, "arr.length != 10");
463
464 arr = [3,4,5];
465 tmp = arr.pop();
466 ok(arr.length === 2, "arr.length = " + arr.length);
467 ok(tmp === 5, "pop() = " + tmp);
468 tmp = arr.pop(2);
469 ok(arr.length === 1, "arr.length = " + arr.length);
470 ok(tmp === 4, "pop() = " + tmp);
471 tmp = arr.pop();
472 ok(arr.length === 0, "arr.length = " + arr.length);
473 ok(tmp === 3, "pop() = " + tmp);
474 for(tmp in arr)
475     ok(false, "not deleted " + tmp);
476 tmp = arr.pop();
477 ok(arr.length === 0, "arr.length = " + arr.length);
478 ok(tmp === undefined, "tmp = " + tmp);
479 arr = [,,,,,];
480 tmp = arr.pop();
481 ok(arr.length === 5, "arr.length = " + arr.length);
482 ok(tmp === undefined, "tmp = " + tmp);
483
484 arr = [1,2,null,false,undefined,,"a"];
485
486 tmp = arr.join();
487 ok(tmp === "1,2,,false,,,a", "arr.join() = " + tmp);
488 tmp = arr.join(";");
489 ok(tmp === "1;2;;false;;;a", "arr.join(';') = " + tmp);
490 tmp = arr.join(";","test");
491 ok(tmp === "1;2;;false;;;a", "arr.join(';') = " + tmp);
492 tmp = arr.join("");
493 ok(tmp === "12falsea", "arr.join('') = " + tmp);
494
495 tmp = arr.toString();
496 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
497 tmp = arr.toString("test");
498 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
499
500 arr = [5,true,2,-1,3,false,"2.5"];
501 tmp = arr.sort(function(x,y) { return y-x; });
502 ok(tmp === arr, "tmp !== arr");
503 tmp = [5,3,"2.5",2,true,false,-1];
504 for(var i=0; i < arr.length; i++)
505     ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
506
507 arr = [5,false,2,0,"abc",3,"a",-1];
508 tmp = arr.sort();
509 ok(tmp === arr, "tmp !== arr");
510 tmp = [-1,0,2,3,5,"a","abc",false];
511 for(var i=0; i < arr.length; i++)
512     ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
513
514 arr = ["a", "b", "ab"];
515 tmp = ["a", "ab", "b"];
516 ok(arr.sort() === arr, "arr.sort() !== arr");
517 for(var i=0; i < arr.length; i++)
518     ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
519
520 arr = ["1", "2", "3"];
521 arr.length = 1;
522 ok(arr.length === 1, "arr.length = " + arr.length);
523 arr.length = 3;
524 ok(arr.length === 3, "arr.length = " + arr.length);
525 ok(arr.toString() === "1,,", "arr.toString() = " + arr.toString());
526
527 arr = Array("a","b","c");
528 ok(arr.toString() === "a,b,c", "arr.toString() = " + arr.toString());
529
530 ok(arr.valueOf === Object.prototype.valueOf, "arr.valueOf !== Object.prototype.valueOf");
531 ok(arr === arr.valueOf(), "arr !== arr.valueOf");
532
533 var num = new Number(6);
534 arr = [0,1,2];
535 tmp = arr.concat(3, [4,5], num);
536 ok(tmp !== arr, "tmp === arr");
537 for(var i=0; i<6; i++)
538     ok(tmp[i] === i, "tmp[" + i + "] = " + tmp[i]);
539 ok(tmp[6] === num, "tmp[6] !== num");
540 ok(tmp.length === 7, "tmp.length = " + tmp.length);
541
542 arr = [].concat();
543 ok(arr.length === 0, "arr.length = " + arr.length);
544
545 arr = [1,];
546 tmp = arr.concat([2]);
547 ok(tmp.length === 3, "tmp.length = " + tmp.length);
548 ok(tmp[1] === undefined, "tmp[1] = " + tmp[1]);
549
550 arr = [1,false,'a',null,undefined,'a'];
551 ok(arr.slice(0,6).toString() === "1,false,a,,,a", "arr.slice(0,6).toString() = " + arr.slice(0,6));
552 ok(arr.slice(0,6).length === 6, "arr.slice(0,6).length = " + arr.slice(0,6).length);
553 ok(arr.slice().toString() === "1,false,a,,,a", "arr.slice().toString() = " + arr.slice());
554 ok(arr.slice("abc").toString() === "1,false,a,,,a", "arr.slice(\"abc\").toString() = " + arr.slice("abc"));
555 ok(arr.slice(3,8).toString() === ",,a", "arr.slice(3,8).toString() = " + arr.slice(3,8));
556 ok(arr.slice(3,8).length === 3, "arr.slice(3,8).length = " + arr.slice(3,8).length);
557 ok(arr.slice(1).toString() === "false,a,,,a", "arr.slice(1).toString() = " + arr.slice(1));
558 ok(arr.slice(-2).toString() === ",a", "arr.slice(-2).toString() = " + arr.slice(-2));
559 ok(arr.slice(3,1).toString() === "", "arr.slice(3,1).toString() = " + arr.slice(3,1));
560 tmp = arr.slice(0,6);
561 for(var i=0; i < arr.length; i++)
562     ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
563 arr[12] = 2;
564 ok(arr.slice(5).toString() === "a,,,,,,,2", "arr.slice(5).toString() = " + arr.slice(5).toString());
565 ok(arr.slice(5).length === 8, "arr.slice(5).length = " + arr.slice(5).length);
566
567 var num = new Number(2);
568 ok(num.toString() === "2", "num(2).toString !== 2");
569 var num = new Number();
570 ok(num.toString() === "0", "num().toString !== 0");
571
572 ok(Number() === 0, "Number() = " + Number());
573 ok(Number(false) === 0, "Number(false) = " + Number(false));
574 ok(Number("43") === 43, "Number('43') = " + Number("43"));
575
576 tmp = (new Number(1)).valueOf();
577 ok(tmp === 1, "(new Number(1)).valueOf = " + tmp);
578 tmp = (new Number(1,2)).valueOf();
579 ok(tmp === 1, "(new Number(1,2)).valueOf = " + tmp);
580 tmp = (new Number()).valueOf();
581 ok(tmp === 0, "(new Number()).valueOf = " + tmp);
582 tmp = Number.prototype.valueOf();
583 ok(tmp === 0, "Number.prototype.valueOf = " + tmp);
584
585 function equals(val, base) {
586     var i;
587     var num = 0;
588     var str = val.toString(base);
589
590     for(i=0; i<str.length; i++) {
591         if(str.substring(i, i+1) == '(') break;
592         if(str.substring(i, i+1) == '.') break;
593         num = num*base + parseInt(str.substring(i, i+1));
594     }
595
596     if(str.substring(i, i+1) == '.') {
597         var mult = base;
598         for(i++; i<str.length; i++) {
599             if(str.substring(i, i+1) == '(') break;
600             num += parseInt(str.substring(i, i+1))/mult;
601             mult *= base;
602         }
603     }
604
605     if(str.substring(i, i+1) == '(') {
606         exp = parseInt(str.substring(i+2));
607         num *= Math.pow(base, exp);
608     }
609
610     ok(num>val-val/1000 && num<val+val/1000, "equals: num = " + num);
611 }
612
613 ok((10).toString(11) === "a", "(10).toString(11) = " + (10).toString(11));
614 ok((213213433).toString(17) === "8e2ddcb", "(213213433).toString(17) = " + (213213433).toString(17));
615 ok((-3254343).toString(33) === "-2oicf", "(-3254343).toString(33) = " + (-3254343).toString(33));
616 ok((NaN).toString(12) === "NaN", "(NaN).toString(11) = " + (NaN).toString(11));
617 ok((Infinity).toString(13) === "Infinity", "(Infinity).toString(11) = " + (Infinity).toString(11));
618 for(i=2; i<10; i++) {
619     equals(1.123, i);
620     equals(2305843009200000000, i);
621     equals(5.123, i);
622     equals(21711, i);
623     equals(1024*1024*1024*1024*1024*1024*1.9999, i);
624     equals(748382, i);
625     equals(0.6, i);
626     equals(4.65661287308e-10, i);
627     ok((0).toString(i) === "0", "(0).toString("+i+") = " + (0).toString(i));
628 }
629
630 ok(parseFloat('123') === 123, "parseFloat('123') = " + parseFloat('123'));
631 ok(parseFloat('-13.7') === -13.7, "parseFloat('-13.7') = " + parseFloat('-13.7'));
632 ok(parseFloat('-0.01e-2') === -0.01e-2, "parseFloat('-0.01e-2') = " + parseFloat('-0.01e-2'));
633 ok(parseFloat('-12e+5') === -12e+5, "parseFloat('-12e+5') = " + parseFloat('-12e+5'));
634 ok(parseFloat('1E5 not parsed') === 1E5, "parseFloat('1E5 not parsed') = " + parseFloat('1E5 not parsed'));
635 ok(isNaN(parseFloat('not a number')), "parseFloat('not a number') is not NaN");
636 ok(parseFloat('+13.2e-3') === 13.2e-3, "parseFloat('+13.2e-3') = " + parseFloat('+13.2e-3'));
637 ok(parseFloat('.12') === 0.12, "parseFloat('.12') = " + parseFloat('.12'));
638 ok(parseFloat('1e') === 1, "parseFloat('1e') = " + parseFloat('1e'));
639
640 tmp = Math.min(1);
641 ok(tmp === 1, "Math.min(1) = " + tmp);
642
643 tmp = Math.min(1, false);
644 ok(tmp === 0, "Math.min(1, false) = " + tmp);
645
646 tmp = Math.min();
647 ok(tmp === Infinity, "Math.min() = " + tmp);
648
649 tmp = Math.min(1, NaN, -Infinity, false);
650 ok(isNaN(tmp), "Math.min(1, NaN, -Infinity, false) is not NaN");
651
652 tmp = Math.min(1, false, true, null, -3);
653 ok(tmp === -3, "Math.min(1, false, true, null, -3) = " + tmp);
654
655 tmp = Math.max(1);
656 ok(tmp === 1, "Math.max(1) = " + tmp);
657
658 tmp = Math.max(true, 0);
659 ok(tmp === 1, "Math.max(true, 0) = " + tmp);
660
661 tmp = Math.max(-2, false, true, null, 1);
662 ok(tmp === 1, "Math.max(-2, false, true, null, 1) = " + tmp);
663
664 tmp = Math.max();
665 ok(tmp === -Infinity, "Math.max() = " + tmp);
666
667 tmp = Math.max(true, NaN, 0);
668 ok(isNaN(tmp), "Math.max(true, NaN, 0) is not NaN");
669
670 tmp = Math.round(0.5);
671 ok(tmp === 1, "Math.round(0.5) = " + tmp);
672
673 tmp = Math.round(-0.5);
674 ok(tmp === 0, "Math.round(-0.5) = " + tmp);
675
676 tmp = Math.round(1.1);
677 ok(tmp === 1, "Math.round(1.1) = " + tmp);
678
679 tmp = Math.round(true);
680 ok(tmp === 1, "Math.round(true) = " + tmp);
681
682 tmp = Math.round(1.1, 3, 4);
683 ok(tmp === 1, "Math.round(1.1, 3, 4) = " + tmp);
684
685 tmp = Math.round();
686 ok(isNaN(tmp), "Math.round() is not NaN");
687
688 tmp = Math.ceil(0.5);
689 ok(tmp === 1, "Math.ceil(0.5) = " + tmp);
690
691 tmp = Math.ceil(-0.5);
692 ok(tmp === 0, "Math.ceil(-0.5) = " + tmp);
693
694 tmp = Math.ceil(1.1);
695 ok(tmp === 2, "Math.round(1.1) = " + tmp);
696
697 tmp = Math.ceil(true);
698 ok(tmp === 1, "Math.ceil(true) = " + tmp);
699
700 tmp = Math.ceil(1.1, 3, 4);
701 ok(tmp === 2, "Math.ceil(1.1, 3, 4) = " + tmp);
702
703 tmp = Math.ceil();
704 ok(isNaN(tmp), "ceil() is not NaN");
705
706 tmp = Math.floor(0.5);
707 ok(tmp === 0, "Math.floor(0.5) = " + tmp);
708
709 tmp = Math.floor(-0.5);
710 ok(tmp === -1, "Math.floor(-0.5) = " + tmp);
711
712 tmp = Math.floor(1.1);
713 ok(tmp === 1, "Math.floor(1.1) = " + tmp);
714
715 tmp = Math.floor(true);
716 ok(tmp === 1, "Math.floor(true) = " + tmp);
717
718 tmp = Math.floor(1.1, 3, 4);
719 ok(tmp === 1, "Math.floor(1.1, 3, 4) = " + tmp);
720
721 tmp = Math.floor();
722 ok(isNaN(tmp), "floor is not NaN");
723
724 tmp = Math.abs(3);
725 ok(tmp === 3, "Math.abs(3) = " + tmp);
726
727 tmp = Math.abs(-3);
728 ok(tmp === 3, "Math.abs(-3) = " + tmp);
729
730 tmp = Math.abs(true);
731 ok(tmp === 1, "Math.abs(true) = " + tmp);
732
733 tmp = Math.abs();
734 ok(isNaN(tmp), "Math.abs() is not NaN");
735
736 tmp = Math.abs(NaN);
737 ok(isNaN(tmp), "Math.abs() is not NaN");
738
739 tmp = Math.abs(-Infinity);
740 ok(tmp === Infinity, "Math.abs(-Infinite) = " + tmp);
741
742 tmp = Math.abs(-3, 2);
743 ok(tmp === 3, "Math.abs(-3, 2) = " + tmp);
744
745 tmp = Math.cos(0);
746 ok(tmp === 1, "Math.cos(0) = " + tmp);
747
748 tmp = Math.cos(Math.PI/2);
749 ok(Math.floor(tmp*100) === 0, "Math.cos(Math.PI/2) = " + tmp);
750
751 tmp = Math.cos(-Math.PI/2);
752 ok(Math.floor(tmp*100) === 0, "Math.cos(-Math.PI/2) = " + tmp);
753
754 tmp = Math.cos(Math.PI/3, 2);
755 ok(Math.floor(tmp*100) === 50, "Math.cos(Math.PI/3, 2) = " + tmp);
756
757 tmp = Math.cos(true);
758 ok(Math.floor(tmp*100) === 54, "Math.cos(true) = " + tmp);
759
760 tmp = Math.cos(false);
761 ok(tmp === 1, "Math.cos(false) = " + tmp);
762
763 tmp = Math.cos();
764 ok(isNaN(tmp), "Math.cos() is not NaN");
765
766 tmp = Math.cos(NaN);
767 ok(isNaN(tmp), "Math.cos(NaN) is not NaN");
768
769 tmp = Math.cos(Infinity);
770 ok(isNaN(tmp), "Math.cos(Infinity) is not NaN");
771
772 tmp = Math.cos(-Infinity);
773 ok(isNaN(tmp), "Math.cos(-Infinity) is not NaN");
774
775 tmp = Math.pow(2, 2);
776 ok(tmp === 4, "Math.pow(2, 2) = " + tmp);
777
778 tmp = Math.pow(4, 0.5);
779 ok(tmp === 2, "Math.pow(2, 2) = " + tmp);
780
781 tmp = Math.pow(2, 2, 3);
782 ok(tmp === 4, "Math.pow(2, 2, 3) = " + tmp);
783
784 tmp = Math.pow(2);
785 ok(isNaN(tmp), "Math.pow(2) is not NaN");
786
787 tmp = Math.pow();
788 ok(isNaN(tmp), "Math.pow() is not NaN");
789
790 tmp = Math.random();
791 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
792 ok(0 <= tmp && tmp <= 1, "Math.random() = " + tmp);
793
794 tmp = Math.random(100);
795 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
796 ok(0 <= tmp && tmp <= 1, "Math.random(100) = " + tmp);
797
798 tmp = Math.acos(0);
799 ok(Math.floor(tmp*100) === 157, "Math.acos(0) = " + tmp);
800
801 tmp = Math.acos(1);
802 ok(Math.floor(tmp*100) === 0, "Math.acos(1) = " + tmp);
803
804 tmp = Math.acos(-1);
805 ok(Math.floor(tmp*100) === 314, "Math.acos(-1) = " + tmp);
806
807 tmp = Math.acos(Math.PI/4, 2);
808 ok(Math.floor(tmp*100) === 66, "Math.acos(Math.PI/4, 2) = " + tmp);
809
810 tmp = Math.acos(true);
811 ok(Math.floor(tmp*100) === 0, "Math.acos(true) = " + tmp);
812
813 tmp = Math.acos(false);
814 ok(Math.floor(tmp*100) === 157, "Math.acos(false) = " + tmp);
815
816 tmp = Math.acos(1.1);
817 ok(isNaN(tmp), "Math.acos(1.1) is not NaN");
818
819 tmp = Math.acos();
820 ok(isNaN(tmp), "Math.acos() is not NaN");
821
822 tmp = Math.acos(NaN);
823 ok(isNaN(tmp), "Math.acos(NaN) is not NaN");
824
825 tmp = Math.acos(Infinity);
826 ok(isNaN(tmp), "Math.acos(Infinity) is not NaN");
827
828 tmp = Math.acos(-Infinity);
829 ok(isNaN(tmp), "Math.acos(-Infinity) is not NaN");
830
831 tmp = Math.asin(0);
832 ok(Math.floor(tmp*100) === 0, "Math.asin(0) = " + tmp);
833
834 tmp = Math.asin(1);
835 ok(Math.floor(tmp*100) === 157, "Math.asin(1) = " + tmp);
836
837 tmp = Math.asin(-1);
838 ok(Math.floor(tmp*100) === -158, "Math.asin(-1) = " + tmp);
839
840 tmp = Math.asin(Math.PI/4, 2);
841 ok(Math.floor(tmp*100) === 90, "Math.asin(Math.PI/4, 2) = " + tmp);
842
843 tmp = Math.asin(true);
844 ok(Math.floor(tmp*100) === 157, "Math.asin(true) = " + tmp);
845
846 tmp = Math.asin(false);
847 ok(Math.floor(tmp*100) === 0, "Math.asin(false) = " + tmp);
848
849 tmp = Math.asin(1.1);
850 ok(isNaN(tmp), "Math.asin(1.1) is not NaN");
851
852 tmp = Math.asin();
853 ok(isNaN(tmp), "Math.asin() is not NaN");
854
855 tmp = Math.asin(NaN);
856 ok(isNaN(tmp), "Math.asin(NaN) is not NaN");
857
858 tmp = Math.asin(Infinity);
859 ok(isNaN(tmp), "Math.asin(Infinity) is not NaN");
860
861 tmp = Math.asin(-Infinity);
862 ok(isNaN(tmp), "Math.asin(-Infinity) is not NaN");
863
864 tmp = Math.atan(0);
865 ok(Math.floor(tmp*100) === 0, "Math.atan(0) = " + tmp);
866
867 tmp = Math.atan(1);
868 ok(Math.floor(tmp*100) === 78, "Math.atan(1) = " + tmp);
869
870 tmp = Math.atan(-1);
871 ok(Math.floor(tmp*100) === -79, "Math.atan(-1) = " + tmp);
872
873 tmp = Math.atan(true);
874 ok(Math.floor(tmp*100) === 78, "Math.atan(true) = " + tmp);
875
876 tmp = Math.atan(false);
877 ok(Math.floor(tmp*100) === 0, "Math.atan(false) = " + tmp);
878
879 tmp = Math.atan();
880 ok(isNaN(tmp), "Math.atan() is not NaN");
881
882 tmp = Math.atan(NaN);
883 ok(isNaN(tmp), "Math.atan(NaN) is not NaN");
884
885 tmp = Math.atan(Infinity);
886 ok(Math.floor(tmp*100) === 157, "Math.atan(Infinity) = " + tmp);
887
888 tmp = Math.atan(-Infinity);
889 ok(Math.floor(tmp*100) === -158, "Math.atan(Infinity) = " + tmp);
890
891 tmp = Math.atan2(0, 0);
892 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 0) = " + tmp);
893
894 tmp = Math.atan2(0, 1);
895 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 1) = " + tmp);
896
897 tmp = Math.atan2(0, Infinity);
898 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, Infinity) = " + tmp);
899
900 tmp = Math.atan2(0, -1);
901 ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -1) = " + tmp);
902
903 tmp = Math.atan2(0, -Infinity);
904 ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -Infinity) = " + tmp);
905
906 tmp = Math.atan2(1, 0);
907 ok(Math.floor(tmp*100) === 157, "Math.atan2(1, 0) = " + tmp);
908
909 tmp = Math.atan2(Infinity, 0);
910 ok(Math.floor(tmp*100) === 157, "Math.atan2(Infinity, 0) = " + tmp);
911
912 tmp = Math.atan2(-1, 0);
913 ok(Math.floor(tmp*100) === -158, "Math.atan2(-1, 0) = " + tmp);
914
915 tmp = Math.atan2(-Infinity, 0);
916 ok(Math.floor(tmp*100) === -158, "Math.atan2(-Infinity, 0) = " + tmp);
917
918 tmp = Math.atan2(1, 1);
919 ok(Math.floor(tmp*100) === 78, "Math.atan2(1, 1) = " + tmp);
920
921 tmp = Math.atan2(-1, -1);
922 ok(Math.floor(tmp*100) === -236, "Math.atan2(-1, -1) = " + tmp);
923
924 tmp = Math.atan2(-1, 1);
925 ok(Math.floor(tmp*100) === -79, "Math.atan2(-1, 1) = " + tmp);
926
927 tmp = Math.atan2(Infinity, Infinity);
928 ok(Math.floor(tmp*100) === 78, "Math.atan2(Infinity, Infinity) = " + tmp);
929
930 tmp = Math.atan2(Infinity, -Infinity, 1);
931 ok(Math.floor(tmp*100) === 235, "Math.atan2(Infinity, -Infinity, 1) = " + tmp);
932
933 tmp = Math.atan2();
934 ok(isNaN(tmp), "Math.atan2() is not NaN");
935
936 tmp = Math.atan2(1);
937 ok(isNaN(tmp), "Math.atan2(1) is not NaN");
938
939 tmp = Math.exp(0);
940 ok(tmp === 1, "Math.exp(0) = " + tmp);
941
942 tmp = Math.exp(1);
943 ok(Math.floor(tmp*100) === 271, "Math.exp(1) = " + tmp);
944
945 tmp = Math.exp(-1);
946 ok(Math.floor(tmp*100) === 36, "Math.exp(-1) = " + tmp);
947
948 tmp = Math.exp(true);
949 ok(Math.floor(tmp*100) === 271, "Math.exp(true) = " + tmp);
950
951 tmp = Math.exp(1, 1);
952 ok(Math.floor(tmp*100) === 271, "Math.exp(1, 1) = " + tmp);
953
954 tmp = Math.exp();
955 ok(isNaN(tmp), "Math.exp() is not NaN");
956
957 tmp = Math.exp(NaN);
958 ok(isNaN(tmp), "Math.exp(NaN) is not NaN");
959
960 tmp = Math.exp(Infinity);
961 ok(tmp === Infinity, "Math.exp(Infinity) = " + tmp);
962
963 tmp = Math.exp(-Infinity);
964 ok(tmp === 0, "Math.exp(-Infinity) = " + tmp);
965
966 tmp = Math.log(1);
967 ok(Math.floor(tmp*100) === 0, "Math.log(1) = " + tmp);
968
969 tmp = Math.log(-1);
970 ok(isNaN(tmp), "Math.log(-1) is not NaN");
971
972 tmp = Math.log(true);
973 ok(Math.floor(tmp*100) === 0, "Math.log(true) = " + tmp);
974
975 tmp = Math.log(1, 1);
976 ok(Math.floor(tmp*100) === 0, "Math.log(1, 1) = " + tmp);
977
978 tmp = Math.log();
979 ok(isNaN(tmp), "Math.log() is not NaN");
980
981 tmp = Math.log(NaN);
982 ok(isNaN(tmp), "Math.log(NaN) is not NaN");
983
984 tmp = Math.log(Infinity);
985 ok(tmp === Infinity, "Math.log(Infinity) = " + tmp);
986
987 tmp = Math.log(-Infinity);
988 ok(isNaN(tmp), "Math.log(-Infinity) is not NaN");
989
990 tmp = Math.sin(0);
991 ok(tmp === 0, "Math.sin(0) = " + tmp);
992
993 tmp = Math.sin(Math.PI/2);
994 ok(tmp === 1, "Math.sin(Math.PI/2) = " + tmp);
995
996 tmp = Math.sin(-Math.PI/2);
997 ok(tmp === -1, "Math.sin(-Math.PI/2) = " + tmp);
998
999 tmp = Math.sin(Math.PI/3, 2);
1000 ok(Math.floor(tmp*100) === 86, "Math.sin(Math.PI/3, 2) = " + tmp);
1001
1002 tmp = Math.sin(true);
1003 ok(Math.floor(tmp*100) === 84, "Math.sin(true) = " + tmp);
1004
1005 tmp = Math.sin(false);
1006 ok(tmp === 0, "Math.sin(false) = " + tmp);
1007
1008 tmp = Math.sin();
1009 ok(isNaN(tmp), "Math.sin() is not NaN");
1010
1011 tmp = Math.sin(NaN);
1012 ok(isNaN(tmp), "Math.sin(NaN) is not NaN");
1013
1014 tmp = Math.sin(Infinity);
1015 ok(isNaN(tmp), "Math.sin(Infinity) is not NaN");
1016
1017 tmp = Math.sin(-Infinity);
1018 ok(isNaN(tmp), "Math.sin(-Infinity) is not NaN");
1019
1020 tmp = Math.sqrt(0);
1021 ok(tmp === 0, "Math.sqrt(0) = " + tmp);
1022
1023 tmp = Math.sqrt(4);
1024 ok(tmp === 2, "Math.sqrt(4) = " + tmp);
1025
1026 tmp = Math.sqrt(-1);
1027 ok(isNaN(tmp), "Math.sqrt(-1) is not NaN");
1028
1029 tmp = Math.sqrt(2, 2);
1030 ok(Math.floor(tmp*100) === 141, "Math.sqrt(2, 2) = " + tmp);
1031
1032 tmp = Math.sqrt(true);
1033 ok(tmp === 1, "Math.sqrt(true) = " + tmp);
1034
1035 tmp = Math.sqrt(false);
1036 ok(tmp === 0, "Math.sqrt(false) = " + tmp);
1037
1038 tmp = Math.sqrt();
1039 ok(isNaN(tmp), "Math.sqrt() is not NaN");
1040
1041 tmp = Math.sqrt(NaN);
1042 ok(isNaN(tmp), "Math.sqrt(NaN) is not NaN");
1043
1044 tmp = Math.sqrt(Infinity);
1045 ok(tmp === Infinity, "Math.sqrt(Infinity) = " + tmp);
1046
1047 tmp = Math.sqrt(-Infinity);
1048 ok(isNaN(tmp), "Math.sqrt(-Infinity) is not NaN");
1049
1050 tmp = Math.tan(0);
1051 ok(tmp === 0, "Math.tan(0) = " + tmp);
1052
1053 tmp = Math.tan(Math.PI);
1054 ok(Math.floor(tmp*100) === -1, "Math.tan(Math.PI) = " + tmp);
1055
1056 tmp = Math.tan(2, 2);
1057 ok(Math.floor(tmp*100) === -219, "Math.tan(2, 2) = " + tmp);
1058
1059 tmp = Math.tan(true);
1060 ok(Math.floor(tmp*100) === 155, "Math.tan(true) = " + tmp);
1061
1062 tmp = Math.tan(false);
1063 ok(tmp === 0, "Math.tan(false) = " + tmp);
1064
1065 tmp = Math.tan();
1066 ok(isNaN(tmp), "Math.tan() is not NaN");
1067
1068 tmp = Math.tan(NaN);
1069 ok(isNaN(tmp), "Math.tan(NaN) is not NaN");
1070
1071 tmp = Math.tan(Infinity);
1072 ok(isNaN(tmp), "Math.tan(Infinity) is not NaN");
1073
1074 tmp = Math.tan(-Infinity);
1075 ok(isNaN(tmp), "Math.tan(-Infinity) is not NaN");
1076
1077 var func = function  (a) {
1078         var a = 1;
1079         if(a) return;
1080     };
1081 ok(func.toString() === "function  (a) {\n        var a = 1;\n        if(a) return;\n    }",
1082    "func.toString() = " + func.toString());
1083 ok("" + func === "function  (a) {\n        var a = 1;\n        if(a) return;\n    }",
1084    "'' + func.toString() = " + func);
1085
1086 ok(func.valueOf === Object.prototype.valueOf, "func.valueOf !== Object.prototype.valueOf");
1087 ok(func === func.valueOf(), "func !== func.valueOf()");
1088
1089 function testFuncToString(x,y) {
1090     return x+y;
1091 }
1092 ok(testFuncToString.toString() === "function testFuncToString(x,y) {\n    return x+y;\n}",
1093    "testFuncToString.toString() = " + testFuncToString.toString());
1094 ok("" + testFuncToString === "function testFuncToString(x,y) {\n    return x+y;\n}",
1095    "'' + testFuncToString = " + testFuncToString);
1096
1097 var date = new Date();
1098
1099 date = new Date(100);
1100 ok(date.getTime() === 100, "date.getTime() = " + date.getTime());
1101 ok(Date.prototype.getTime() === 0, "date.prototype.getTime() = " + Date.prototype.getTime());
1102 date = new Date(8.64e15);
1103 ok(date.getTime() === 8.64e15, "date.getTime() = " + date.getTime());
1104 date = new Date(8.64e15+1);
1105 ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
1106 date = new Date(Infinity);
1107 ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
1108 date = new Date("3 July 2009 22:28:00 UTC+0100");
1109 ok(date.getTime() === 1246656480000, "date.getTime() = " + date.getTime());
1110 date = new Date(1984, 11, 29, 13, 51, 24, 120);
1111 ok(date.getFullYear() === 1984, "date.getFullYear() = " + date.getFullYear());
1112 ok(date.getMonth() === 11, "date.getMonth() = " + date.getMonth());
1113 ok(date.getDate() === 29, "date.getDate() = " + date.getDate());
1114 ok(date.getHours() === 13, "date.getHours() = " + date.getHours());
1115 ok(date.getMinutes() === 51, "date.getMinutes() = " + date.getMinutes());
1116 ok(date.getSeconds() === 24, "date.getSeconds() = " + date.getSeconds());
1117 ok(date.getMilliseconds() === 120, "date.getMilliseconds() = " + date.getMilliseconds());
1118 date = new Date(731, -32, 40, -1, 70, 65, -13);
1119 ok(date.getFullYear() === 728, "date.getFullYear() = " + date.getFullYear());
1120 ok(date.getMonth() === 5, "date.getMonth() = " + date.getMonth());
1121 ok(date.getDate() === 9, "date.getDate() = " + date.getDate());
1122 ok(date.getHours() === 0, "date.getHours() = " + date.getHours());
1123 ok(date.getMinutes() === 11, "date.getMinutes() = " + date.getMinutes());
1124 ok(date.getSeconds() === 4, "date.getSeconds() = " + date.getSeconds());
1125 ok(date.getMilliseconds() === 987, "date.getMilliseconds() = " + date.getMilliseconds());
1126
1127 ok(date.setTime(123) === 123, "date.setTime(123) !== 123");
1128 ok(date.setTime("123", NaN) === 123, "date.setTime(\"123\") !== 123");
1129 ok(isNaN(date.setTime(NaN)), "date.setTime(NaN) is not NaN");
1130
1131 ok(date.setTime(0) === date.getTime(), "date.setTime(0) !== date.getTime()");
1132 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
1133 ok(date.getUTCMonth() === 0, "date.getUTCMonth() = " + date.getUTCMonth());
1134 ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
1135 ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
1136 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
1137 ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
1138 ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
1139 ok(date.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1140 date.setTime(60*24*60*60*1000);
1141 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
1142 ok(date.getUTCMonth() === 2, "date.getUTCMonth() = " + date.getUTCMonth());
1143 ok(date.getUTCDate() === 2, "date.getUTCDate() = " + date.getUTCDate());
1144 ok(date.getUTCDay() === 1, "date.getUTCDay() = " + date.getUTCDay());
1145 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
1146 ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
1147 ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
1148 ok(date.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1149 date.setTime(59*24*60*60*1000 + 4*365*24*60*60*1000 + 60*60*1000 + 2*60*1000 + 2*1000 + 640);
1150 ok(date.getUTCFullYear() === 1974, "date.getUTCFullYear() = " + date.getUTCFullYear());
1151 ok(date.getUTCMonth() === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1152 ok(date.getUTCMonth(123) === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1153 ok(date.getUTCDate() === 28, "date.getUTCDate() = " + date.getUTCDate());
1154 ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
1155 ok(date.getUTCHours() === 1, "date.getUTCHours() = " + date.getUTCHours());
1156 ok(date.getUTCMinutes() === 2, "date.getUTCMinutes() = " + date.getUTCMinutes());
1157 ok(date.getUTCSeconds() === 2, "date.getUTCSeconds() = " + date.getUTCSeconds());
1158 ok(date.getUTCMilliseconds() === 640, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1159 date.setTime(Infinity);
1160 ok(isNaN(date.getUTCFullYear()), "date.getUTCFullYear() is not NaN");
1161 ok(isNaN(date.getUTCMonth()), "date.getUTCMonth() is not NaN");
1162 ok(isNaN(date.getUTCDate()), "date.getUTCDate() is not NaN");
1163 ok(isNaN(date.getUTCDay()), "date.getUTCDay() is not NaN");
1164 ok(isNaN(date.getUTCHours()), "date.getUTCHours() is not NaN");
1165 ok(isNaN(date.getUTCMinutes()), "date.getUTCMinutes() is not NaN");
1166 ok(isNaN(date.getUTCSeconds()), "date.getUTCSeconds() is not NaN");
1167 ok(isNaN(date.getUTCMilliseconds()), "date.getUTCMilliseconds() is not NaN");
1168 ok(isNaN(date.setMilliseconds(0)), "date.setMilliseconds() is not NaN");
1169
1170 date.setTime(0);
1171 date.setUTCMilliseconds(-10, 2);
1172 ok(date.getUTCMilliseconds() === 990, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1173 date.setUTCMilliseconds(10);
1174 ok(date.getUTCMilliseconds() === 10, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1175 date.setUTCSeconds(-10);
1176 ok(date.getUTCSeconds() === 50, "date.getUTCSeconds() = " + date.getUTCSeconds());
1177 date.setUTCMinutes(-10);
1178 ok(date.getUTCMinutes() === 50, "date.getUTCMinutes() = " + date.getUTCMinutes());
1179 date.setUTCHours(-10);
1180 ok(date.getUTCHours() === 14, "date.getUTCHours() = " + date.getUTCHours());
1181 date.setUTCHours(-123);
1182 ok(date.getTime() === -612549990, "date.getTime() = " + date.getTime());
1183 date.setUTCHours(20);
1184 ok(date.getUTCHours() === 20, "date.getUTCHours() = " + date.getUTCHours());
1185 date.setUTCDate(32);
1186 ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
1187 date.setUTCMonth(22, 37);
1188 ok(date.getTime() === 60987050010, "date.getTime() = " + date.getTime());
1189 date.setUTCFullYear(83, 21, 321);
1190 ok(date.getTime() === -59464984149990, "date.getTime() = " + date.getTime());
1191 ok(Math.abs(date) === 59464984149990, "Math.abs(date) = " + Math.abs(date));
1192 ok(getVT(date+1) === "VT_BSTR", "getVT(date+1) = " + getVT(date+1));
1193
1194 ok(isNaN(Date.parse()), "Date.parse() is not NaN");
1195 ok(isNaN(Date.parse("")), "Date.parse(\"\") is not NaN");
1196 ok(isNaN(Date.parse("Jan Jan 20 2009")), "Date.parse(\"Jan Jan 20 2009\") is not NaN");
1197 ok(Date.parse("Jan 20 2009 UTC") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC\") = " + Date.parse("Jan 20 2009 UTC"));
1198 ok(Date.parse("Jan 20 2009 GMT") === 1232409600000, "Date.parse(\"Jan 20 2009 GMT\") = " + Date.parse("Jan 20 2009 GMT"));
1199 ok(Date.parse("Jan 20 2009 UTC-0") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC-0\") = " + Date.parse("Jan 20 2009 UTC-0"));
1200 ok(Date.parse("Jan 20 2009 UTC+0000") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC+0000\") = " + Date.parse("Jan 20 2009 UTC+0000"));
1201 ok(Date.parse("Ju 13 79 UTC") === 300672000000, "Date.parse(\"Ju 13 79 UTC\") = " + Date.parse("Ju 13 79 UTC"));
1202 ok(Date.parse("12Au91 UTC") === 681955200000, "Date.parse(\"12Au91 UTC\") = " + Date.parse("12Au91 UTC"));
1203 ok(Date.parse("7/02/17 UTC") === -1656806400000, "Date.parse(\"7/02/17 UTC\") = " + Date.parse("7/02/17 UTC"));
1204 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"));
1205 ok(Date.parse("February 31   UTC, 2000 12:31:17 PM") === 952000277000,
1206         "Date.parse(\"February 31   UTC, 2000 12:31:17 PM\") = " + Date.parse("February 31   UTC, 2000 12:31:17 PM"));
1207 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 "));
1208 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"));
1209
1210 ok(typeof(Math.PI) === "number", "typeof(Math.PI) = " + typeof(Math.PI));
1211 ok(Math.floor(Math.PI*100) === 314, "Math.PI = " + Math.PI);
1212 Math.PI = "test";
1213 ok(Math.floor(Math.PI*100) === 314, "modified Math.PI = " + Math.PI);
1214
1215 ok(typeof(Math.E) === "number", "typeof(Math.E) = " + typeof(Math.E));
1216 ok(Math.floor(Math.E*100) === 271, "Math.E = " + Math.E);
1217 Math.E = "test";
1218 ok(Math.floor(Math.E*100) === 271, "modified Math.E = " + Math.E);
1219
1220 ok(typeof(Math.LOG2E) === "number", "typeof(Math.LOG2E) = " + typeof(Math.LOG2E));
1221 ok(Math.floor(Math.LOG2E*100) === 144, "Math.LOG2E = " + Math.LOG2E);
1222 Math.LOG2E = "test";
1223 ok(Math.floor(Math.LOG2E*100) === 144, "modified Math.LOG2E = " + Math.LOG2E);
1224
1225 ok(typeof(Math.LOG10E) === "number", "typeof(Math.LOG10E) = " + typeof(Math.LOG10E));
1226 ok(Math.floor(Math.LOG10E*100) === 43, "Math.LOG10E = " + Math.LOG10E);
1227 Math.LOG10E = "test";
1228 ok(Math.floor(Math.LOG10E*100) === 43, "modified Math.LOG10E = " + Math.LOG10E);
1229
1230 ok(typeof(Math.LN2) === "number", "typeof(Math.LN2) = " + typeof(Math.LN2));
1231 ok(Math.floor(Math.LN2*100) === 69, "Math.LN2 = " + Math.LN2);
1232 Math.LN2 = "test";
1233 ok(Math.floor(Math.LN2*100) === 69, "modified Math.LN2 = " + Math.LN2);
1234
1235 ok(typeof(Math.LN10) === "number", "typeof(Math.LN10) = " + typeof(Math.LN10));
1236 ok(Math.floor(Math.LN10*100) === 230, "Math.LN10 = " + Math.LN10);
1237 Math.LN10 = "test";
1238 ok(Math.floor(Math.LN10*100) === 230, "modified Math.LN10 = " + Math.LN10);
1239
1240 ok(typeof(Math.SQRT2) === "number", "typeof(Math.SQRT2) = " + typeof(Math.SQRT2));
1241 ok(Math.floor(Math.SQRT2*100) === 141, "Math.SQRT2 = " + Math.SQRT2);
1242 Math.SQRT2 = "test";
1243 ok(Math.floor(Math.SQRT2*100) === 141, "modified Math.SQRT2 = " + Math.SQRT2);
1244
1245 ok(typeof(Math.SQRT1_2) === "number", "typeof(Math.SQRT1_2) = " + typeof(Math.SQRT1_2));
1246 ok(Math.floor(Math.SQRT1_2*100) === 70, "Math.SQRT1_2 = " + Math.SQRT1_2);
1247 Math.SQRT1_2 = "test";
1248 ok(Math.floor(Math.SQRT1_2*100) === 70, "modified Math.SQRT1_2 = " + Math.SQRT1_2);
1249
1250 var bool = new Boolean();
1251 ok(bool.toString() === "false", "bool.toString() = " + bool.toString());
1252 var bool = new Boolean("false");
1253 ok(bool.toString() === "true", "bool.toString() = " + bool.toString());
1254 ok(bool.valueOf() === Boolean(1), "bool.valueOf() = " + bool.valueOf());
1255 ok(bool.toLocaleString() === bool.toString(), "bool.toLocaleString() = " + bool.toLocaleString());
1256
1257 ok(Error.prototype !== TypeError.prototype, "Error.prototype === TypeError.prototype");
1258 ok(RangeError.prototype !== TypeError.prototype, "RangeError.prototype === TypeError.prototype");
1259 ok(Error.prototype.toLocaleString === Object.prototype.toLocaleString,
1260         "Error.prototype.toLocaleString !== Object.prototype.toLocaleString");
1261 err = new Error();
1262 ok(err.valueOf === Object.prototype.valueOf, "err.valueOf !== Object.prototype.valueOf");
1263 ok(Error.prototype.name === "Error", "Error.prototype.name = " + Error.prototype.name);
1264 ok(err.name === "Error", "err.name = " + err.name);
1265 EvalError.prototype.message = "test";
1266 ok(err.toString !== Object.prototype.toString, "err.toString === Object.prototype.toString");
1267 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1268 err = new EvalError();
1269 ok(EvalError.prototype.name === "EvalError", "EvalError.prototype.name = " + EvalError.prototype.name);
1270 ok(err.name === "EvalError", "err.name = " + err.name);
1271 ok(err.toString === Error.prototype.toString, "err.toString !== Error.prototype.toString");
1272 ok(err.message === "", "err.message != ''");
1273 err.message = date;
1274 ok(err.message === date, "err.message != date");
1275 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1276 ok(err.toString !== Object.prototype.toString, "err.toString === Object.prototype.toString");
1277 err = new RangeError();
1278 ok(RangeError.prototype.name === "RangeError", "RangeError.prototype.name = " + RangeError.prototype.name);
1279 ok(err.name === "RangeError", "err.name = " + err.name);
1280 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1281 err = new ReferenceError();
1282 ok(ReferenceError.prototype.name === "ReferenceError", "ReferenceError.prototype.name = " + ReferenceError.prototype.name);
1283 ok(err.name === "ReferenceError", "err.name = " + err.name);
1284 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1285 err = new SyntaxError();
1286 ok(SyntaxError.prototype.name === "SyntaxError", "SyntaxError.prototype.name = " + SyntaxError.prototype.name);
1287 ok(err.name === "SyntaxError", "err.name = " + err.name);
1288 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1289 err = new TypeError();
1290 ok(TypeError.prototype.name === "TypeError", "TypeError.prototype.name = " + TypeError.prototype.name);
1291 ok(err.name === "TypeError", "err.name = " + err.name);
1292 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1293 err = new URIError();
1294 ok(URIError.prototype.name === "URIError", "URIError.prototype.name = " + URIError.prototype.name);
1295 ok(err.name === "URIError", "err.name = " + err.name);
1296 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1297 err = new Error("message");
1298 ok(err.message === "message", "err.message !== 'message'");
1299 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1300 err = new Error(123);
1301 ok(err.number === 123, "err.number = " + err.number);
1302 err = new Error(0, "message");
1303 ok(err.number === 0, "err.number = " + err.number);
1304 ok(err.message === "message", "err.message = " + err.message);
1305 ok(err.description === "message", "err.description = " + err.description);
1306
1307 function exception_test(func, type, number) {
1308     ret = "";
1309     num = "";
1310     try {
1311         func();
1312     } catch(e) {
1313         ret = e.name;
1314         num = e.number;
1315     }
1316     ok(ret === type, "Exception test, ret = " + ret + ", expected " + type +". Executed function: " + func.toString());
1317     ok(num === number, "Exception test, num = " + num + ", expected " + number + ". Executed function: " + func.toString());
1318 }
1319 exception_test(function() {arr.toString = Date.prototype.toString; arr.toString();}, "TypeError", -2146823282);
1320 exception_test(function() {Array(-3);}, "RangeError", -2146823259);
1321 exception_test(function() {arr.toString = Boolean.prototype.toString; arr.toString();}, "TypeError", -2146823278);
1322 exception_test(function() {date.setTime();}, "TypeError", -2146827839);
1323 exception_test(function() {arr.test();}, "TypeError", -2146827850);
1324 exception_test(function() {arr.toString = Number.prototype.toString; arr.toString();}, "TypeError", -2146823287);
1325 exception_test(function() {(new Number(3)).toString(1);}, "TypeError", -2146828283);
1326 exception_test(function() {not_existing_variable.something();}, "TypeError", -2146823279);
1327 exception_test(function() {arr.toString = Function.prototype.toString; arr.toString();}, "TypeError", -2146823286);
1328 exception_test(function() {date();}, "TypeError", -2146823286);
1329 exception_test(function() {arr();}, "TypeError", -2146823286);
1330 exception_test(function() {eval("for(i=0;) {}");}, "SyntaxError", -2146827286);
1331 exception_test(function() {eval("function {};");}, "SyntaxError", -2146827283);
1332 exception_test(function() {eval("if");}, "SyntaxError", -2146827283);
1333 exception_test(function() {eval("do i=0; while");}, "SyntaxError", -2146827283);
1334 exception_test(function() {eval("while");}, "SyntaxError", -2146827283);
1335 exception_test(function() {eval("for");}, "SyntaxError", -2146827283);
1336 exception_test(function() {eval("with");}, "SyntaxError", -2146827283);
1337 exception_test(function() {eval("switch");}, "SyntaxError", -2146827283);
1338 exception_test(function() {eval("if(false");}, "SyntaxError", -2146827282);
1339 exception_test(function() {eval("for(i=0; i<10; i++");}, "SyntaxError", -2146827282);
1340 exception_test(function() {eval("while(true");}, "SyntaxError", -2146827282);
1341 exception_test(function() {test = function() {}}, "ReferenceError", -2146823280);
1342 exception_test(function() {eval("for(i=0")}, "SyntaxError", -2146827284);
1343 exception_test(function() {eval("for(i=0;i<10")}, "SyntaxError", -2146827284);
1344 exception_test(function() {eval("while(")}, "SyntaxError", -2146827286);
1345 exception_test(function() {eval("if(")}, "SyntaxError", -2146827286);
1346 exception_test(function() {eval("'unterminated")}, "SyntaxError", -2146827273);
1347
1348 function testObjectInherit(obj, ts, tls, vo) {
1349     ok(obj.hasOwnProperty === Object.prototype.hasOwnProperty,
1350        "obj.hasOwnProperty !== Object.prototype.hasOwnProprty");
1351     ok(obj.isPrototypeOf === Object.prototype.isPrototypeOf,
1352        "obj.isPrototypeOf !== Object.prototype.isPrototypeOf");
1353     ok(obj.propertyIsEnumerable === Object.prototype.propertyIsEnumerable,
1354        "obj.propertyIsEnumerable !== Object.prototype.propertyIsEnumerable");
1355
1356     if(ts)
1357         ok(obj.toString === Object.prototype.toString,
1358            "obj.toString !== Object.prototype.toString");
1359     else
1360         ok(obj.toString != Object.prototype.toString,
1361            "obj.toString == Object.prototype.toString");
1362
1363     if(tls)
1364         ok(obj.toLocaleString === Object.prototype.toLocaleString,
1365            "obj.toLocaleString !== Object.prototype.toLocaleString");
1366     else
1367         ok(obj.toLocaleString != Object.prototype.toLocaleString,
1368            "obj.toLocaleString == Object.prototype.toLocaleString");
1369
1370     if(vo)
1371         ok(obj.valueOf === Object.prototype.valueOf,
1372            "obj.valueOf !== Object.prototype.valueOf");
1373     else
1374         ok(obj.valueOf != Object.prototype.valueOf,
1375            "obj.valueOf == Object.prototype.valueOf");
1376
1377     ok(obj._test === "test", "obj.test = " + obj._test);
1378 }
1379
1380 Object.prototype._test = "test";
1381 testObjectInherit(new String("test"), false, true, false);
1382 testObjectInherit(/test/g, false, true, true);
1383 testObjectInherit(new Number(1), false, false, false);
1384
1385 reportSuccess();