dxgi: Implement IDXGIFactory::GetParent().
[wine/testsucceed.git] / dlls / jscript / tests / api.js
blob42a79e8f71efd5ae43d21c585ba6fe42a575f12b
1 /*
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
19 var tmp, i;
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);
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);
61 tmp = encodeURIComponent("abc");
62 ok(tmp === "abc", "encodeURIComponent('abc') = " + tmp);
63 dec = decodeURIComponent(tmp);
64 ok(dec === "abc", "decodeURIComponent('" + tmp + "') = " + dec);
65 tmp = encodeURIComponent("{abc}");
66 ok(tmp === "%7Babc%7D", "encodeURIComponent('{abc}') = " + tmp);
67 dec = decodeURIComponent(tmp);
68 ok(dec === "{abc}", "decodeURIComponent('" + tmp + "') = " + dec);
69 tmp = encodeURIComponent("");
70 ok(tmp === "", "encodeURIComponent('') = " + tmp);
71 dec = decodeURIComponent(tmp);
72 ok(dec === "", "decodeURIComponent('" + tmp + "') = " + dec);
73 tmp = encodeURIComponent("\01\02\03\04");
74 ok(tmp === "%01%02%03%04", "encodeURIComponent('\\01\\02\\03\\04') = " + tmp);
75 dec = decodeURIComponent(tmp);
76 ok(dec === "\01\02\03\04", "decodeURIComponent('" + tmp + "') = " + dec);
77 tmp = encodeURIComponent("{#@}");
78 ok(tmp === "%7B%23%40%7D", "encodeURIComponent('{#@}') = " + tmp);
79 dec = decodeURIComponent(tmp);
80 ok(dec === "{#@}", "decodeURIComponent('" + tmp + "') = " + dec);
81 tmp = encodeURIComponent("\xa1 ");
82 ok(tmp === "%C2%A1%20", "encodeURIComponent(\\xa1 ) = " + tmp);
83 dec = decodeURIComponent(tmp);
84 ok(dec === "\xa1 ", "decodeURIComponent('" + tmp + "') = " + dec);
85 tmp = encodeURIComponent("\xffff");
86 ok(tmp.length === 8, "encodeURIComponent('\\xffff').length = " + tmp.length);
87 dec = decodeURIComponent(tmp);
88 ok(dec === "\xffff", "decodeURIComponent('" + tmp + "') = " + dec);
89 tmp = encodeURIComponent("abcABC123;/?:@&=+$,-_.!~*'()");
90 ok(tmp === "abcABC123%3B%2F%3F%3A%40%26%3D%2B%24%2C-_.!~*'()", "encodeURIComponent('abcABC123;/?:@&=+$,-_.!~*'()') = " + tmp);
91 dec = decodeURIComponent(tmp);
92 ok(dec === "abcABC123;/?:@&=+$,-_.!~*'()", "decodeURIComponent('" + tmp + "') = " + dec);
93 tmp = encodeURIComponent();
94 ok(tmp === "undefined", "encodeURIComponent() = " + tmp);
95 tmp = encodeURIComponent("abc", "test");
96 ok(tmp === "abc", "encodeURIComponent('abc') = " + tmp);
97 dec = decodeURIComponent();
98 ok(dec === "undefined", "decodeURIComponent() = " + dec);
99 dec = decodeURIComponent("abc", "test");
100 ok(dec === "abc", "decodeURIComponent('abc') = " + dec);
102 tmp = escape("abc");
103 ok(tmp === "abc", "escape('abc') = " + tmp);
104 tmp = escape("");
105 ok(tmp === "", "escape('') = " + tmp);
106 tmp = escape("a1b c!d+e@*-_+./,");
107 ok(tmp === "a1b%20c%21d+e@*-_+./%2C", "escape('a1b c!d+e@*-_+./,') = " + tmp);
108 tmp = escape();
109 ok(tmp === "undefined", "escape() = " + tmp);
110 tmp = escape('\u1234\123\xf3');
111 ok(tmp == "%u1234S%F3", "escape('\u1234\123\xf3') = " + tmp);
113 tmp = unescape("abc");
114 ok(tmp === "abc", "unescape('abc') = " + tmp);
115 tmp = unescape("");
116 ok(tmp === "", "unescape('') = " + tmp);
117 tmp = unescape("%%%");
118 ok(tmp === "%%%", "unescape('%%%') = " + tmp);
119 tmp = unescape();
120 ok(tmp === "undefined", "unescape() = " + tmp);
121 tmp = unescape("%54%65s%u0074");
122 ok(tmp === "Test", "unescape('%54%65s%u0074') = " + tmp);
124 tmp = "aA1~`!@#$%^&*()_+=-][{}';:/.,<>?\|";
125 ok(escape(tmp) === "aA1%7E%60%21@%23%24%25%5E%26*%28%29_+%3D-%5D%5B%7B%7D%27%3B%3A/.%2C%3C%3E%3F%7C", "escape('" + tmp + "') = " + escape(tmp));
126 ok(unescape(escape(tmp)) === tmp, "unescape(escape('" + tmp + "')) = " + unescape(escape(tmp)));
128 tmp = "" + new Object();
129 ok(tmp === "[object Object]", "'' + new Object() = " + tmp);
130 (tmp = new Array).f = Object.prototype.toString;
131 ok(tmp.f() === "[object Array]", "tmp.f() = " + tmp.f());
132 (tmp = new Boolean).f = Object.prototype.toString;
133 ok(tmp.f() === "[object Boolean]", "tmp.f() = " + tmp.f());
134 (tmp = new Date).f = Object.prototype.toString;
135 ok(tmp.f() === "[object Date]", "tmp.f() = " + tmp.f());
136 (tmp = function() {}).f = Object.prototype.toString;
137 ok(tmp.f() === "[object Function]", "tmp.f() = " + tmp.f());
138 Math.f = Object.prototype.toString;
139 ok(Math.f() === "[object Math]", "tmp.f() = " + tmp.f());
140 (tmp = new Number).f = Object.prototype.toString;
141 ok(tmp.f() === "[object Number]", "tmp.f() = " + tmp.f());
142 (tmp = new RegExp("")).f = Object.prototype.toString;
143 ok(tmp.f() === "[object RegExp]", "tmp.f() = " + tmp.f());
144 (tmp = new String).f = Object.prototype.toString;
145 ok(tmp.f() === "[object String]", "tmp.f() = " + tmp.f());
146 tmp = Object.prototype.toString.call(testObj);
147 ok(tmp === "[object Object]", "toString.call(testObj) = " + tmp);
148 tmp = Object.prototype.toString.call(this);
149 ok(tmp === "[object Object]", "toString.call(this) = " + tmp);
150 (function () { tmp = Object.prototype.toString.call(arguments); })();
151 ok(tmp === "[object Object]", "toString.call(arguments) = " + tmp);
153 ok(Object(1) instanceof Number, "Object(1) is not instance of Number");
154 ok(Object("") instanceof String, "Object('') is not instance of String");
155 ok(Object(false) instanceof Boolean, "Object(false) is not instance of Boolean");
157 obj = new Object();
158 ok(Object(obj) === obj, "Object(obj) !== obj");
160 ok(typeof(Object()) === "object", "typeof(Object()) !== 'object'");
161 ok(typeof(Object(undefined)) === "object", "typeof(Object(undefined)) !== 'object'");
162 ok(typeof(Object(null)) === "object", "typeof(Object(null)) !== 'object'");
164 var obj = new Object();
165 obj.toString = function (x) {
166 ok(arguments.length === 0, "arguments.length = " + arguments.length);
167 return "test";
169 ok((tmp = obj.toLocaleString()) === "test", "obj.toLocaleString() = " + tmp);
170 ok((tmp = obj.toLocaleString(1)) === "test", "obj.toLocaleString(1) = " + tmp);
171 ok(obj === obj.valueOf(), "obj !== obj.valueOf");
173 ok("".length === 0, "\"\".length = " + "".length);
174 ok(getVT("".length) == "VT_I4", "\"\".length = " + "".length);
175 ok("abc".length === 3, "\"abc\".length = " + "abc".length);
176 ok(String.prototype.length === 0, "String.prototype.length = " + String.prototype.length);
178 tmp = "".toString();
179 ok(tmp === "", "''.toString() = " + tmp);
180 tmp = "test".toString();
181 ok(tmp === "test", "''.toString() = " + tmp);
182 tmp = "test".toString(3);
183 ok(tmp === "test", "''.toString(3) = " + tmp);
185 tmp = "".valueOf();
186 ok(tmp === "", "''.valueOf() = " + tmp);
187 tmp = "test".valueOf();
188 ok(tmp === "test", "''.valueOf() = " + tmp);
189 tmp = "test".valueOf(3);
190 ok(tmp === "test", "''.valueOf(3) = " + tmp);
192 var str = new String("test");
193 ok(str.toString() === "test", "str.toString() = " + str.toString());
194 var str = new String();
195 ok(str.toString() === "", "str.toString() = " + str.toString());
196 var str = new String("test", "abc");
197 ok(str.toString() === "test", "str.toString() = " + str.toString());
199 var strObj = new Object();
200 strObj.toString = function() { return "abcd" };
201 strObj.substr = String.prototype.substr;
202 strObj.lastIndexOf = String.prototype.lastIndexOf;
204 tmp = "value " + str;
205 ok(tmp === "value test", "'value ' + str = " + tmp);
207 tmp = String();
208 ok(tmp === "", "String() = " + tmp);
209 tmp = String(false);
210 ok(tmp === "false", "String(false) = " + tmp);
211 tmp = String(null);
212 ok(tmp === "null", "String(null) = " + tmp);
213 tmp = String("test");
214 ok(tmp === "test", "String('test') = " + tmp);
215 tmp = String("test", "abc");
216 ok(tmp === "test", "String('test','abc') = " + tmp);
218 tmp = "abc".charAt(0);
219 ok(tmp === "a", "'abc',charAt(0) = " + tmp);
220 tmp = "abc".charAt(1);
221 ok(tmp === "b", "'abc',charAt(1) = " + tmp);
222 tmp = "abc".charAt(2);
223 ok(tmp === "c", "'abc',charAt(2) = " + tmp);
224 tmp = "abc".charAt(3);
225 ok(tmp === "", "'abc',charAt(3) = " + tmp);
226 tmp = "abc".charAt(4);
227 ok(tmp === "", "'abc',charAt(4) = " + tmp);
228 tmp = "abc".charAt();
229 ok(tmp === "a", "'abc',charAt() = " + tmp);
230 tmp = "abc".charAt(-1);
231 ok(tmp === "", "'abc',charAt(-1) = " + tmp);
232 tmp = "abc".charAt(0,2);
233 ok(tmp === "a", "'abc',charAt(0.2) = " + tmp);
235 tmp = "abc".charCodeAt(0);
236 ok(tmp === 0x61, "'abc'.charCodeAt(0) = " + tmp);
237 tmp = "abc".charCodeAt(1);
238 ok(tmp === 0x62, "'abc'.charCodeAt(1) = " + tmp);
239 tmp = "abc".charCodeAt(2);
240 ok(tmp === 0x63, "'abc'.charCodeAt(2) = " + tmp);
241 tmp = "abc".charCodeAt();
242 ok(tmp === 0x61, "'abc'.charCodeAt() = " + tmp);
243 tmp = "abc".charCodeAt(true);
244 ok(tmp === 0x62, "'abc'.charCodeAt(true) = " + tmp);
245 tmp = "abc".charCodeAt(0,2);
246 ok(tmp === 0x61, "'abc'.charCodeAt(0,2) = " + tmp);
247 tmp = "\u49F4".charCodeAt(0);
248 ok(tmp === 0x49F4, "'\u49F4'.charCodeAt(0) = " + tmp);
249 tmp = "\052".charCodeAt(0);
250 ok(tmp === 0x2A, "'\052'.charCodeAt(0) = " + tmp);
251 tmp = "\xa2".charCodeAt(0);
252 ok(tmp === 0xA2, "'\xa2'.charCodeAt(0) = " + tmp);
254 tmp = "abcd".substring(1,3);
255 ok(tmp === "bc", "'abcd'.substring(1,3) = " + tmp);
256 tmp = "abcd".substring(-1,3);
257 ok(tmp === "abc", "'abcd'.substring(-1,3) = " + tmp);
258 tmp = "abcd".substring(1,6);
259 ok(tmp === "bcd", "'abcd'.substring(1,6) = " + tmp);
260 tmp = "abcd".substring(3,1);
261 ok(tmp === "bc", "'abcd'.substring(3,1) = " + tmp);
262 tmp = "abcd".substring(2,2);
263 ok(tmp === "", "'abcd'.substring(2,2) = " + tmp);
264 tmp = "abcd".substring(true,"3");
265 ok(tmp === "bc", "'abcd'.substring(true,'3') = " + tmp);
266 tmp = "abcd".substring(1,3,2);
267 ok(tmp === "bc", "'abcd'.substring(1,3,2) = " + tmp);
268 tmp = "abcd".substring();
269 ok(tmp === "abcd", "'abcd'.substring() = " + tmp);
271 tmp = "abcd".substr(1,3);
272 ok(tmp === "bcd", "'abcd'.substr(1,3) = " + tmp);
273 tmp = "abcd".substr(-1,3);
274 ok(tmp === "abc", "'abcd'.substr(-1,3) = " + tmp);
275 tmp = "abcd".substr(1,6);
276 ok(tmp === "bcd", "'abcd'.substr(1,6) = " + tmp);
277 tmp = "abcd".substr(2,-1);
278 ok(tmp === "", "'abcd'.substr(3,1) = " + tmp);
279 tmp = "abcd".substr(2,0);
280 ok(tmp === "", "'abcd'.substr(2,2) = " + tmp);
281 tmp = "abcd".substr(true,"3");
282 ok(tmp === "bcd", "'abcd'.substr(true,'3') = " + tmp);
283 tmp = "abcd".substr(1,3,2);
284 ok(tmp === "bcd", "'abcd'.substr(1,3,2) = " + tmp);
285 tmp = "abcd".substr();
286 ok(tmp === "abcd", "'abcd'.substr() = " + tmp);
287 tmp = strObj.substr(1,1);
288 ok(tmp === "b", "'abcd'.substr(1,3) = " + tmp);
290 tmp = "abcd".slice(1,3);
291 ok(tmp === "bc", "'abcd'.slice(1,3) = " + tmp);
292 tmp = "abcd".slice(1,-1);
293 ok(tmp === "bc", "'abcd'.slice(1,-1) = " + tmp);
294 tmp = "abcd".slice(-3,3);
295 ok(tmp === "bc", "'abcd'.slice(-3,3) = " + tmp);
296 tmp = "abcd".slice(-6,3);
297 ok(tmp === "abc", "'abcd'.slice(-6,3) = " + tmp);
298 tmp = "abcd".slice(3,1);
299 ok(tmp === "", "'abcd'.slice(3,1) = " + tmp);
300 tmp = "abcd".slice(true,3);
301 ok(tmp === "bc", "'abcd'.slice(true,3) = " + tmp);
302 tmp = "abcd".slice();
303 ok(tmp === "abcd", "'abcd'.slice() = " + tmp);
304 tmp = "abcd".slice(1);
305 ok(tmp === "bcd", "'abcd'.slice(1) = " + tmp);
307 tmp = "abc".concat(["d",1],2,false);
308 ok(tmp === "abcd,12false", "concat returned " + tmp);
309 var arr = new Array(2,"a");
310 arr.concat = String.prototype.concat;
311 tmp = arr.concat("d");
312 ok(tmp === "2,ad", "arr.concat = " + tmp);
314 m = "a+bcabc".match("a+");
315 ok(typeof(m) === "object", "typeof m is not object");
316 ok(m.length === 1, "m.length is not 1");
317 ok(m["0"] === "a", "m[0] is not \"ab\"");
319 r = "- [test] -".replace("[test]", "success");
320 ok(r === "- success -", "r = " + r + " expected '- success -'");
322 r = "- [test] -".replace("[test]", "success", "test");
323 ok(r === "- success -", "r = " + r + " expected '- success -'");
325 r = "test".replace();
326 ok(r === "test", "r = " + r + " expected 'test'");
328 function replaceFunc3(m, off, str) {
329 ok(arguments.length === 3, "arguments.length = " + arguments.length);
330 ok(m === "[test]", "m = " + m + " expected [test1]");
331 ok(off === 1, "off = " + off + " expected 0");
332 ok(str === "-[test]-", "str = " + arguments[3]);
333 return "ret";
336 r = "-[test]-".replace("[test]", replaceFunc3);
337 ok(r === "-ret-", "r = " + r + " expected '-ret-'");
339 r = "-[test]-".replace("[test]", replaceFunc3, "test");
340 ok(r === "-ret-", "r = " + r + " expected '-ret-'");
342 r = "1,2,3".split(",");
343 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
344 ok(r.length === 3, "r.length = " + r.length);
345 ok(r[0] === "1", "r[0] = " + r[0]);
346 ok(r[1] === "2", "r[1] = " + r[1]);
347 ok(r[2] === "3", "r[2] = " + r[2]);
350 r = "1,2,3".split(",*");
351 ok(r.length === 1, "r.length = " + r.length);
352 ok(r[0] === "1,2,3", "r[0] = " + r[0]);
354 r = "123".split("");
355 ok(r.length === 3, "r.length = " + r.length);
356 ok(r[0] === "1", "r[0] = " + r[0]);
357 ok(r[1] === "2", "r[1] = " + r[1]);
358 ok(r[2] === "3", "r[2] = " + r[2]);
360 r = "123".split(2);
361 ok(r.length === 2, "r.length = " + r.length);
362 ok(r[0] === "1", "r[0] = " + r[0]);
363 ok(r[1] === "3", "r[1] = " + r[1]);
365 r = "1,2,".split(",");
366 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
367 ok(r.length === 3, "r.length = " + r.length);
368 ok(r[0] === "1", "r[0] = " + r[0]);
369 ok(r[1] === "2", "r[1] = " + r[1]);
370 ok(r[2] === "", "r[2] = " + r[2]);
372 tmp = "abcd".indexOf("bc",0);
373 ok(tmp === 1, "indexOf = " + tmp);
374 tmp = "abcd".indexOf("bc",1);
375 ok(tmp === 1, "indexOf = " + tmp);
376 tmp = "abcd".indexOf("bc");
377 ok(tmp === 1, "indexOf = " + tmp);
378 tmp = "abcd".indexOf("ac");
379 ok(tmp === -1, "indexOf = " + tmp);
380 tmp = "abcd".indexOf("bc",2);
381 ok(tmp === -1, "indexOf = " + tmp);
382 tmp = "abcd".indexOf("a",0);
383 ok(tmp === 0, "indexOf = " + tmp);
384 tmp = "abcd".indexOf("bc",0,"test");
385 ok(tmp === 1, "indexOf = " + tmp);
386 tmp = "abcd".indexOf();
387 ok(tmp == -1, "indexOf = " + tmp);
389 tmp = "abcd".lastIndexOf("bc",1);
390 ok(tmp === 1, "lastIndexOf = " + tmp);
391 tmp = "abcd".lastIndexOf("bc",2);
392 ok(tmp === 1, "lastIndexOf = " + tmp);
393 tmp = "abcd".lastIndexOf("bc");
394 ok(tmp === 1, "lastIndexOf = " + tmp);
395 tmp = "abcd".lastIndexOf("ac");
396 ok(tmp === -1, "lastIndexOf = " + tmp);
397 tmp = "abcd".lastIndexOf("d",10);
398 ok(tmp === 3, "lastIndexOf = " + tmp);
399 tmp = "abcd".lastIndexOf("bc",0,"test");
400 ok(tmp === -1, "lastIndexOf = " + tmp);
401 tmp = "abcd".lastIndexOf();
402 ok(tmp === -1, "lastIndexOf = " + tmp);
403 tmp = "aaaa".lastIndexOf("a",2);
404 ok(tmp == 2, "lastIndexOf = " + tmp);
405 tmp = strObj.lastIndexOf("b");
406 ok(tmp === 1, "lastIndexOf = " + tmp);
408 tmp = "".toLowerCase();
409 ok(tmp === "", "''.toLowerCase() = " + tmp);
410 tmp = "test".toLowerCase();
411 ok(tmp === "test", "''.toLowerCase() = " + tmp);
412 tmp = "test".toLowerCase(3);
413 ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
414 tmp = "tEsT".toLowerCase();
415 ok(tmp === "test", "''.toLowerCase() = " + tmp);
416 tmp = "tEsT".toLowerCase(3);
417 ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
419 tmp = "".toUpperCase();
420 ok(tmp === "", "''.toUpperCase() = " + tmp);
421 tmp = "TEST".toUpperCase();
422 ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
423 tmp = "TEST".toUpperCase(3);
424 ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
425 tmp = "tEsT".toUpperCase();
426 ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
427 tmp = "tEsT".toUpperCase(3);
428 ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
430 tmp = "".anchor();
431 ok(tmp === "<A NAME=\"undefined\"></A>", "''.anchor() = " + tmp);
432 tmp = "".anchor(3);
433 ok(tmp === "<A NAME=\"3\"></A>", "''.anchor(3) = " + tmp);
434 tmp = "".anchor("red");
435 ok(tmp === "<A NAME=\"red\"></A>", "''.anchor('red') = " + tmp);
436 tmp = "test".anchor();
437 ok(tmp === "<A NAME=\"undefined\">test</A>", "'test'.anchor() = " + tmp);
438 tmp = "test".anchor(3);
439 ok(tmp === "<A NAME=\"3\">test</A>", "'test'.anchor(3) = " + tmp);
440 tmp = "test".anchor("green");
441 ok(tmp === "<A NAME=\"green\">test</A>", "'test'.anchor('green') = " + tmp);
443 tmp = "".big();
444 ok(tmp === "<BIG></BIG>", "''.big() = " + tmp);
445 tmp = "".big(3);
446 ok(tmp === "<BIG></BIG>", "''.big(3) = " + tmp);
447 tmp = "test".big();
448 ok(tmp === "<BIG>test</BIG>", "'test'.big() = " + tmp);
449 tmp = "test".big(3);
450 ok(tmp === "<BIG>test</BIG>", "'test'.big(3) = " + tmp);
452 tmp = "".blink();
453 ok(tmp === "<BLINK></BLINK>", "''.blink() = " + tmp);
454 tmp = "".blink(3);
455 ok(tmp === "<BLINK></BLINK>", "''.blink(3) = " + tmp);
456 tmp = "test".blink();
457 ok(tmp === "<BLINK>test</BLINK>", "'test'.blink() = " + tmp);
458 tmp = "test".blink(3);
459 ok(tmp === "<BLINK>test</BLINK>", "'test'.blink(3) = " + tmp);
461 tmp = "".bold();
462 ok(tmp === "<B></B>", "''.bold() = " + tmp);
463 tmp = "".bold(3);
464 ok(tmp === "<B></B>", "''.bold(3) = " + tmp);
465 tmp = "test".bold();
466 ok(tmp === "<B>test</B>", "'test'.bold() = " + tmp);
467 tmp = "test".bold(3);
468 ok(tmp === "<B>test</B>", "'test'.bold(3) = " + tmp);
470 tmp = "".fixed();
471 ok(tmp === "<TT></TT>", "''.fixed() = " + tmp);
472 tmp = "".fixed(3);
473 ok(tmp === "<TT></TT>", "''.fixed(3) = " + tmp);
474 tmp = "test".fixed();
475 ok(tmp === "<TT>test</TT>", "'test'.fixed() = " + tmp);
476 tmp = "test".fixed(3);
477 ok(tmp === "<TT>test</TT>", "'test'.fixed(3) = " + tmp);
479 tmp = "".fontcolor();
480 ok(tmp === "<FONT COLOR=\"undefined\"></FONT>", "''.fontcolor() = " + tmp);
481 tmp = "".fontcolor(3);
482 ok(tmp === "<FONT COLOR=\"3\"></FONT>", "''.fontcolor(3) = " + tmp);
483 tmp = "".fontcolor("red");
484 ok(tmp === "<FONT COLOR=\"red\"></FONT>", "''.fontcolor('red') = " + tmp);
485 tmp = "test".fontcolor();
486 ok(tmp === "<FONT COLOR=\"undefined\">test</FONT>", "'test'.fontcolor() = " + tmp);
487 tmp = "test".fontcolor(3);
488 ok(tmp === "<FONT COLOR=\"3\">test</FONT>", "'test'.fontcolor(3) = " + tmp);
489 tmp = "test".fontcolor("green");
490 ok(tmp === "<FONT COLOR=\"green\">test</FONT>", "'test'.fontcolor('green') = " + tmp);
492 tmp = "".fontsize();
493 ok(tmp === "<FONT SIZE=\"undefined\"></FONT>", "''.fontsize() = " + tmp);
494 tmp = "".fontsize(3);
495 ok(tmp === "<FONT SIZE=\"3\"></FONT>", "''.fontsize(3) = " + tmp);
496 tmp = "".fontsize("red");
497 ok(tmp === "<FONT SIZE=\"red\"></FONT>", "''.fontsize('red') = " + tmp);
498 tmp = "test".fontsize();
499 ok(tmp === "<FONT SIZE=\"undefined\">test</FONT>", "'test'.fontsize() = " + tmp);
500 tmp = "test".fontsize(3);
501 ok(tmp === "<FONT SIZE=\"3\">test</FONT>", "'test'.fontsize(3) = " + tmp);
502 tmp = "test".fontsize("green");
503 ok(tmp === "<FONT SIZE=\"green\">test</FONT>", "'test'.fontsize('green') = " + tmp);
505 tmp = ("".fontcolor()).fontsize();
506 ok(tmp === "<FONT SIZE=\"undefined\"><FONT COLOR=\"undefined\"></FONT></FONT>", "(''.fontcolor()).fontsize() = " + tmp);
508 tmp = "".italics();
509 ok(tmp === "<I></I>", "''.italics() = " + tmp);
510 tmp = "".italics(3);
511 ok(tmp === "<I></I>", "''.italics(3) = " + tmp);
512 tmp = "test".italics();
513 ok(tmp === "<I>test</I>", "'test'.italics() = " + tmp);
514 tmp = "test".italics(3);
515 ok(tmp === "<I>test</I>", "'test'.italics(3) = " + tmp);
517 tmp = "".link();
518 ok(tmp === "<A HREF=\"undefined\"></A>", "''.link() = " + tmp);
519 tmp = "".link(3);
520 ok(tmp === "<A HREF=\"3\"></A>", "''.link(3) = " + tmp);
521 tmp = "".link("red");
522 ok(tmp === "<A HREF=\"red\"></A>", "''.link('red') = " + tmp);
523 tmp = "test".link();
524 ok(tmp === "<A HREF=\"undefined\">test</A>", "'test'.link() = " + tmp);
525 tmp = "test".link(3);
526 ok(tmp === "<A HREF=\"3\">test</A>", "'test'.link(3) = " + tmp);
527 tmp = "test".link("green");
528 ok(tmp === "<A HREF=\"green\">test</A>", "'test'.link('green') = " + tmp);
530 tmp = "".small();
531 ok(tmp === "<SMALL></SMALL>", "''.small() = " + tmp);
532 tmp = "".small(3);
533 ok(tmp === "<SMALL></SMALL>", "''.small(3) = " + tmp);
534 tmp = "test".small();
535 ok(tmp === "<SMALL>test</SMALL>", "'test'.small() = " + tmp);
536 tmp = "test".small(3);
537 ok(tmp === "<SMALL>test</SMALL>", "'test'.small(3) = " + tmp);
539 tmp = "".strike();
540 ok(tmp === "<STRIKE></STRIKE>", "''.strike() = " + tmp);
541 tmp = "".strike(3);
542 ok(tmp === "<STRIKE></STRIKE>", "''.strike(3) = " + tmp);
543 tmp = "test".strike();
544 ok(tmp === "<STRIKE>test</STRIKE>", "'test'.strike() = " + tmp);
545 tmp = "test".strike(3);
546 ok(tmp === "<STRIKE>test</STRIKE>", "'test'.strike(3) = " + tmp);
548 tmp = "".sub();
549 ok(tmp === "<SUB></SUB>", "''.sub() = " + tmp);
550 tmp = "".sub(3);
551 ok(tmp === "<SUB></SUB>", "''.sub(3) = " + tmp);
552 tmp = "test".sub();
553 ok(tmp === "<SUB>test</SUB>", "'test'.sub() = " + tmp);
554 tmp = "test".sub(3);
555 ok(tmp === "<SUB>test</SUB>", "'test'.sub(3) = " + tmp);
557 tmp = "".sup();
558 ok(tmp === "<SUP></SUP>", "''.sup() = " + tmp);
559 tmp = "".sup(3);
560 ok(tmp === "<SUP></SUP>", "''.sup(3) = " + tmp);
561 tmp = "test".sup();
562 ok(tmp === "<SUP>test</SUP>", "'test'.sup() = " + tmp);
563 tmp = "test".sup(3);
564 ok(tmp === "<SUP>test</SUP>", "'test'.sup(3) = " + tmp);
566 ok(String.fromCharCode() === "", "String.fromCharCode() = " + String.fromCharCode());
567 ok(String.fromCharCode(65,"66",67) === "ABC", "String.fromCharCode(65,'66',67) = " + String.fromCharCode(65,"66",67));
568 ok(String.fromCharCode(1024*64+65, -1024*64+65) === "AA",
569 "String.fromCharCode(1024*64+65, -1024*64+65) = " + String.fromCharCode(1024*64+65, -1024*64+65));
570 ok(String.fromCharCode(65, NaN, undefined).length === 3,
571 "String.fromCharCode(65, NaN, undefined).length = " + String.fromCharCode(65, NaN, undefined).length);
573 var arr = new Array();
574 ok(typeof(arr) === "object", "arr () is not object");
575 ok((arr.length === 0), "arr.length is not 0");
576 ok(arr["0"] === undefined, "arr[0] is not undefined");
578 var arr = new Array(1, 2, "test");
579 ok(typeof(arr) === "object", "arr (1,2,test) is not object");
580 ok((arr.length === 3), "arr.length is not 3");
581 ok(arr["0"] === 1, "arr[0] is not 1");
582 ok(arr["1"] === 2, "arr[1] is not 2");
583 ok(arr["2"] === "test", "arr[2] is not \"test\"");
585 arr["7"] = true;
586 ok((arr.length === 8), "arr.length is not 8");
588 tmp = "" + [];
589 ok(tmp === "", "'' + [] = " + tmp);
590 tmp = "" + [1,true];
591 ok(tmp === "1,true", "'' + [1,true] = " + tmp);
593 var arr = new Array(6);
594 ok(typeof(arr) === "object", "arr (6) is not object");
595 ok((arr.length === 6), "arr.length is not 6");
596 ok(arr["0"] === undefined, "arr[0] is not undefined");
598 ok(arr.push() === 6, "arr.push() !== 6");
599 ok(arr.push(1) === 7, "arr.push(1) !== 7");
600 ok(arr[6] === 1, "arr[6] != 1");
601 ok(arr.length === 7, "arr.length != 10");
602 ok(arr.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10");
603 ok(arr[8] === "b", "arr[8] != 'b'");
604 ok(arr.length === 10, "arr.length != 10");
606 var arr = new Object();
607 arr.push = Array.prototype.push;
609 arr.length = 6;
611 ok(arr.push() === 6, "arr.push() !== 6");
612 ok(arr.push(1) === 7, "arr.push(1) !== 7");
613 ok(arr[6] === 1, "arr[6] != 1");
614 ok(arr.length === 7, "arr.length != 10");
615 ok(arr.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10");
616 ok(arr[8] === "b", "arr[8] != 'b'");
617 ok(arr.length === 10, "arr.length != 10");
619 arr = [3,4,5];
620 tmp = arr.pop();
621 ok(arr.length === 2, "arr.length = " + arr.length);
622 ok(tmp === 5, "pop() = " + tmp);
623 tmp = arr.pop(2);
624 ok(arr.length === 1, "arr.length = " + arr.length);
625 ok(tmp === 4, "pop() = " + tmp);
626 tmp = arr.pop();
627 ok(arr.length === 0, "arr.length = " + arr.length);
628 ok(tmp === 3, "pop() = " + tmp);
629 for(tmp in arr)
630 ok(false, "not deleted " + tmp);
631 tmp = arr.pop();
632 ok(arr.length === 0, "arr.length = " + arr.length);
633 ok(tmp === undefined, "tmp = " + tmp);
634 arr = [,,,,,];
635 tmp = arr.pop();
636 ok(arr.length === 5, "arr.length = " + arr.length);
637 ok(tmp === undefined, "tmp = " + tmp);
639 arr = [1,2,null,false,undefined,,"a"];
641 tmp = arr.join();
642 ok(tmp === "1,2,,false,,,a", "arr.join() = " + tmp);
643 tmp = arr.join(";");
644 ok(tmp === "1;2;;false;;;a", "arr.join(';') = " + tmp);
645 tmp = arr.join(";","test");
646 ok(tmp === "1;2;;false;;;a", "arr.join(';') = " + tmp);
647 tmp = arr.join("");
648 ok(tmp === "12falsea", "arr.join('') = " + tmp);
650 tmp = arr.toString();
651 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
652 tmp = arr.toString("test");
653 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
655 arr = [5,true,2,-1,3,false,"2.5"];
656 tmp = arr.sort(function(x,y) { return y-x; });
657 ok(tmp === arr, "tmp !== arr");
658 tmp = [5,3,"2.5",2,true,false,-1];
659 for(var i=0; i < arr.length; i++)
660 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
662 arr = [5,false,2,0,"abc",3,"a",-1];
663 tmp = arr.sort();
664 ok(tmp === arr, "tmp !== arr");
665 tmp = [-1,0,2,3,5,"a","abc",false];
666 for(var i=0; i < arr.length; i++)
667 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
669 arr = ["a", "b", "ab"];
670 tmp = ["a", "ab", "b"];
671 ok(arr.sort() === arr, "arr.sort() !== arr");
672 for(var i=0; i < arr.length; i++)
673 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
675 arr = ["1", "2", "3"];
676 arr.length = 1;
677 ok(arr.length === 1, "arr.length = " + arr.length);
678 arr.length = 3;
679 ok(arr.length === 3, "arr.length = " + arr.length);
680 ok(arr.toString() === "1,,", "arr.toString() = " + arr.toString());
682 arr = Array("a","b","c");
683 ok(arr.toString() === "a,b,c", "arr.toString() = " + arr.toString());
685 ok(arr.valueOf === Object.prototype.valueOf, "arr.valueOf !== Object.prototype.valueOf");
686 ok(arr === arr.valueOf(), "arr !== arr.valueOf");
688 arr = [1,2,3];
689 tmp = arr.unshift(0);
690 ok(tmp === (invokeVersion < 2 ? undefined : 4), "[1,2,3].unshift(0) returned " +tmp);
691 ok(arr.length === 4, "arr.length = " + arr.length);
692 ok(arr.toString() === "0,1,2,3", "arr.toString() = " + arr.toString());
694 arr = new Array(3);
695 arr[0] = 1;
696 arr[2] = 3;
697 tmp = arr.unshift(-1,0);
698 ok(tmp === (invokeVersion < 2 ? undefined : 5), "unshift returned " +tmp);
699 ok(arr.length === 5, "arr.length = " + arr.length);
700 ok(arr.toString() === "-1,0,1,,3", "arr.toString() = " + arr.toString());
702 arr = [1,2,3];
703 tmp = arr.unshift();
704 ok(tmp === (invokeVersion < 2 ? undefined : 3), "unshift returned " +tmp);
705 ok(arr.length === 3, "arr.length = " + arr.length);
706 ok(arr.toString() === "1,2,3", "arr.toString() = " + arr.toString());
708 arr = new Object();
709 arr.length = 2;
710 arr[0] = 1;
711 arr[1] = 2;
712 tmp = Array.prototype.unshift.call(arr, 0);
713 ok(tmp === (invokeVersion < 2 ? undefined : 3), "unshift returned " +tmp);
714 ok(arr.length === 3, "arr.length = " + arr.length);
715 ok(arr[0] === 0 && arr[1] === 1 && arr[2] === 2, "unexpected array");
717 arr = [1,2,,4];
718 tmp = arr.shift();
719 ok(tmp === 1, "[1,2,,4].shift() = " + tmp);
720 ok(arr.toString() === "2,,4", "arr = " + arr.toString());
722 arr = [];
723 tmp = arr.shift();
724 ok(tmp === undefined, "[].shift() = " + tmp);
725 ok(arr.toString() === "", "arr = " + arr.toString());
727 arr = [1,2,,4];
728 tmp = arr.shift(2);
729 ok(tmp === 1, "[1,2,,4].shift(2) = " + tmp);
730 ok(arr.toString() === "2,,4", "arr = " + arr.toString());
732 arr = [1,];
733 tmp = arr.shift();
734 ok(tmp === 1, "[1,].shift() = " + tmp);
735 ok(arr.toString() === "", "arr = " + arr.toString());
737 obj = new Object();
738 obj[0] = "test";
739 obj[2] = 3;
740 obj.length = 3;
741 tmp = Array.prototype.shift.call(obj);
742 ok(tmp === "test", "obj.shift() = " + tmp);
743 ok(obj.length == 2, "obj.length = " + obj.length);
744 ok(obj[1] === 3, "obj[1] = " + obj[1]);
746 var num = new Number(6);
747 arr = [0,1,2];
748 tmp = arr.concat(3, [4,5], num);
749 ok(tmp !== arr, "tmp === arr");
750 for(var i=0; i<6; i++)
751 ok(tmp[i] === i, "tmp[" + i + "] = " + tmp[i]);
752 ok(tmp[6] === num, "tmp[6] !== num");
753 ok(tmp.length === 7, "tmp.length = " + tmp.length);
755 arr = [].concat();
756 ok(arr.length === 0, "arr.length = " + arr.length);
758 arr = [1,];
759 tmp = arr.concat([2]);
760 ok(tmp.length === 3, "tmp.length = " + tmp.length);
761 ok(tmp[1] === undefined, "tmp[1] = " + tmp[1]);
763 arr = [1,false,'a',null,undefined,'a'];
764 ok(arr.slice(0,6).toString() === "1,false,a,,,a", "arr.slice(0,6).toString() = " + arr.slice(0,6));
765 ok(arr.slice(0,6).length === 6, "arr.slice(0,6).length = " + arr.slice(0,6).length);
766 ok(arr.slice().toString() === "1,false,a,,,a", "arr.slice().toString() = " + arr.slice());
767 ok(arr.slice("abc").toString() === "1,false,a,,,a", "arr.slice(\"abc\").toString() = " + arr.slice("abc"));
768 ok(arr.slice(3,8).toString() === ",,a", "arr.slice(3,8).toString() = " + arr.slice(3,8));
769 ok(arr.slice(3,8).length === 3, "arr.slice(3,8).length = " + arr.slice(3,8).length);
770 ok(arr.slice(1).toString() === "false,a,,,a", "arr.slice(1).toString() = " + arr.slice(1));
771 ok(arr.slice(-2).toString() === ",a", "arr.slice(-2).toString() = " + arr.slice(-2));
772 ok(arr.slice(3,1).toString() === "", "arr.slice(3,1).toString() = " + arr.slice(3,1));
773 tmp = arr.slice(0,6);
774 for(var i=0; i < arr.length; i++)
775 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
776 arr[12] = 2;
777 ok(arr.slice(5).toString() === "a,,,,,,,2", "arr.slice(5).toString() = " + arr.slice(5).toString());
778 ok(arr.slice(5).length === 8, "arr.slice(5).length = " + arr.slice(5).length);
780 arr = [1,2,3,4,5];
781 tmp = arr.splice(2,2);
782 ok(tmp.toString() == "3,4", "arr.splice(2,2) returned " + tmp.toString());
783 ok(arr.toString() == "1,2,5", "arr.splice(2,2) is " + arr.toString());
785 arr = [1,2,3,4,5];
786 tmp = arr.splice(2,2,"a");
787 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a') returned " + tmp.toString());
788 ok(arr.toString() == "1,2,a,5", "arr.splice(2,2,'a') is " + arr.toString());
790 arr = [1,2,3,4,5];
791 tmp = arr.splice(2,2,'a','b','c');
792 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a','b','c') returned " + tmp.toString());
793 ok(arr.toString() == "1,2,a,b,c,5", "arr.splice(2,2,'a','b','c') is " + arr.toString());
795 arr = [1,2,3,4,];
796 tmp = arr.splice(2,2,'a','b','c');
797 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a','b','c') returned " + tmp.toString());
798 ok(arr.toString() == "1,2,a,b,c,", "arr.splice(2,2,'a','b','c') is " + arr.toString());
800 arr = [1,2,3,4,];
801 arr.splice(2,2,'a','b','c');
802 ok(arr.toString() == "1,2,a,b,c,", "arr.splice(2,2,'a','b','c') is " + arr.toString());
804 arr = [1,2,3,4,5];
805 tmp = arr.splice(2,2,'a','b');
806 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a','b') returned " + tmp.toString());
807 ok(arr.toString() == "1,2,a,b,5", "arr.splice(2,2,'a','b') is " + arr.toString());
809 arr = [1,2,3,4,5];
810 tmp = arr.splice(-1,2);
811 ok(tmp.toString() == "5", "arr.splice(-1,2) returned " + tmp.toString());
812 ok(arr.toString() == "1,2,3,4", "arr.splice(-1,2) is " + arr.toString());
814 arr = [1,2,3,4,5];
815 tmp = arr.splice(-10,3);
816 ok(tmp.toString() == "1,2,3", "arr.splice(-10,3) returned " + tmp.toString());
817 ok(arr.toString() == "4,5", "arr.splice(-10,3) is " + arr.toString());
819 arr = [1,2,3,4,5];
820 tmp = arr.splice(-10,100);
821 ok(tmp.toString() == "1,2,3,4,5", "arr.splice(-10,100) returned " + tmp.toString());
822 ok(arr.toString() == "", "arr.splice(-10,100) is " + arr.toString());
824 arr = [1,2,3,4,5];
825 tmp = arr.splice(2,-1);
826 ok(tmp.toString() == "", "arr.splice(2,-1) returned " + tmp.toString());
827 ok(arr.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr.toString());
829 arr = [1,2,3,4,5];
830 tmp = arr.splice(2);
831 ok(tmp.toString() == "", "arr.splice(2,-1) returned " + tmp.toString());
832 ok(arr.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr.toString());
834 arr = [1,2,3,4,5];
835 tmp = arr.splice();
836 ok(tmp.toString() == "", "arr.splice(2,-1) returned " + tmp.toString());
837 ok(arr.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr.toString());
839 obj = new Object();
840 obj.length = 3;
841 obj[0] = 1;
842 obj[1] = 2;
843 obj[2] = 3;
844 tmp = Array.prototype.splice.call(obj, 1, 1, 'a', 'b');
845 ok(tmp.toString() === "2", "obj.splice returned " + tmp);
846 ok(obj.length === 4, "obj.length = " + obj.length);
847 ok(obj[0] === 1, "obj[0] = " + obj[0]);
848 ok(obj[1] === 'a', "obj[1] = " + obj[1]);
849 ok(obj[2] === 'b', "obj[2] = " + obj[2]);
850 ok(obj[3] === 3, "obj[3] = " + obj[3]);
852 obj = new Object();
853 obj.length = 3;
854 obj[0] = 1;
855 obj[1] = 2;
856 obj[2] = 3;
857 tmp = Array.prototype.slice.call(obj, 1, 2);
858 ok(tmp.length === 1, "tmp.length = " + tmp.length);
859 ok(tmp[0] === 2, "tmp[0] = " + tmp[0]);
861 var num = new Number(2);
862 ok(num.toString() === "2", "num(2).toString !== 2");
863 var num = new Number();
864 ok(num.toString() === "0", "num().toString !== 0");
866 ok(Number() === 0, "Number() = " + Number());
867 ok(Number(false) === 0, "Number(false) = " + Number(false));
868 ok(Number("43") === 43, "Number('43') = " + Number("43"));
870 tmp = (new Number(1)).valueOf();
871 ok(tmp === 1, "(new Number(1)).valueOf = " + tmp);
872 tmp = (new Number(1,2)).valueOf();
873 ok(tmp === 1, "(new Number(1,2)).valueOf = " + tmp);
874 tmp = (new Number()).valueOf();
875 ok(tmp === 0, "(new Number()).valueOf = " + tmp);
876 tmp = Number.prototype.valueOf();
877 ok(tmp === 0, "Number.prototype.valueOf = " + tmp);
879 function equals(val, base) {
880 var i;
881 var num = 0;
882 var str = val.toString(base);
884 for(i=0; i<str.length; i++) {
885 if(str.substring(i, i+1) == '(') break;
886 if(str.substring(i, i+1) == '.') break;
887 num = num*base + parseInt(str.substring(i, i+1));
890 if(str.substring(i, i+1) == '.') {
891 var mult = base;
892 for(i++; i<str.length; i++) {
893 if(str.substring(i, i+1) == '(') break;
894 num += parseInt(str.substring(i, i+1))/mult;
895 mult *= base;
899 if(str.substring(i, i+1) == '(') {
900 exp = parseInt(str.substring(i+2));
901 num *= Math.pow(base, exp);
904 ok(num>val-val/1000 && num<val+val/1000, "equals: num = " + num);
907 ok((10).toString(11) === "a", "(10).toString(11) = " + (10).toString(11));
908 ok((213213433).toString(17) === "8e2ddcb", "(213213433).toString(17) = " + (213213433).toString(17));
909 ok((-3254343).toString(33) === "-2oicf", "(-3254343).toString(33) = " + (-3254343).toString(33));
910 ok((NaN).toString(12) === "NaN", "(NaN).toString(11) = " + (NaN).toString(11));
911 ok((Infinity).toString(13) === "Infinity", "(Infinity).toString(11) = " + (Infinity).toString(11));
912 for(i=2; i<10; i++) {
913 equals(1.123, i);
914 equals(2305843009200000000, i);
915 equals(5.123, i);
916 equals(21711, i);
917 equals(1024*1024*1024*1024*1024*1024*1.9999, i);
918 equals(748382, i);
919 equals(0.6, i);
920 equals(4.65661287308e-10, i);
921 ok((0).toString(i) === "0", "(0).toString("+i+") = " + (0).toString(i));
924 ok(parseFloat('123') === 123, "parseFloat('123') = " + parseFloat('123'));
925 ok(parseFloat('-13.7') === -13.7, "parseFloat('-13.7') = " + parseFloat('-13.7'));
926 ok(parseFloat('-0.01e-2') === -0.01e-2, "parseFloat('-0.01e-2') = " + parseFloat('-0.01e-2'));
927 ok(parseFloat('-12e+5') === -12e+5, "parseFloat('-12e+5') = " + parseFloat('-12e+5'));
928 ok(parseFloat('1E5 not parsed') === 1E5, "parseFloat('1E5 not parsed') = " + parseFloat('1E5 not parsed'));
929 ok(isNaN(parseFloat('not a number')), "parseFloat('not a number') is not NaN");
930 ok(parseFloat('+13.2e-3') === 13.2e-3, "parseFloat('+13.2e-3') = " + parseFloat('+13.2e-3'));
931 ok(parseFloat('.12') === 0.12, "parseFloat('.12') = " + parseFloat('.12'));
932 ok(parseFloat('1e') === 1, "parseFloat('1e') = " + parseFloat('1e'));
934 tmp = Math.min(1);
935 ok(tmp === 1, "Math.min(1) = " + tmp);
937 tmp = Math.min(1, false);
938 ok(tmp === 0, "Math.min(1, false) = " + tmp);
940 tmp = Math.min();
941 ok(tmp === Infinity, "Math.min() = " + tmp);
943 tmp = Math.min(1, NaN, -Infinity, false);
944 ok(isNaN(tmp), "Math.min(1, NaN, -Infinity, false) is not NaN");
946 tmp = Math.min(1, false, true, null, -3);
947 ok(tmp === -3, "Math.min(1, false, true, null, -3) = " + tmp);
949 tmp = Math.max(1);
950 ok(tmp === 1, "Math.max(1) = " + tmp);
952 tmp = Math.max(true, 0);
953 ok(tmp === 1, "Math.max(true, 0) = " + tmp);
955 tmp = Math.max(-2, false, true, null, 1);
956 ok(tmp === 1, "Math.max(-2, false, true, null, 1) = " + tmp);
958 tmp = Math.max();
959 ok(tmp === -Infinity, "Math.max() = " + tmp);
961 tmp = Math.max(true, NaN, 0);
962 ok(isNaN(tmp), "Math.max(true, NaN, 0) is not NaN");
964 tmp = Math.round(0.5);
965 ok(tmp === 1, "Math.round(0.5) = " + tmp);
967 tmp = Math.round(-0.5);
968 ok(tmp === 0, "Math.round(-0.5) = " + tmp);
970 tmp = Math.round(1.1);
971 ok(tmp === 1, "Math.round(1.1) = " + tmp);
973 tmp = Math.round(true);
974 ok(tmp === 1, "Math.round(true) = " + tmp);
976 tmp = Math.round(1.1, 3, 4);
977 ok(tmp === 1, "Math.round(1.1, 3, 4) = " + tmp);
979 tmp = Math.round();
980 ok(isNaN(tmp), "Math.round() is not NaN");
982 tmp = Math.ceil(0.5);
983 ok(tmp === 1, "Math.ceil(0.5) = " + tmp);
985 tmp = Math.ceil(-0.5);
986 ok(tmp === 0, "Math.ceil(-0.5) = " + tmp);
988 tmp = Math.ceil(1.1);
989 ok(tmp === 2, "Math.round(1.1) = " + tmp);
991 tmp = Math.ceil(true);
992 ok(tmp === 1, "Math.ceil(true) = " + tmp);
994 tmp = Math.ceil(1.1, 3, 4);
995 ok(tmp === 2, "Math.ceil(1.1, 3, 4) = " + tmp);
997 tmp = Math.ceil();
998 ok(isNaN(tmp), "ceil() is not NaN");
1000 tmp = Math.floor(0.5);
1001 ok(tmp === 0, "Math.floor(0.5) = " + tmp);
1003 tmp = Math.floor(-0.5);
1004 ok(tmp === -1, "Math.floor(-0.5) = " + tmp);
1006 tmp = Math.floor(1.1);
1007 ok(tmp === 1, "Math.floor(1.1) = " + tmp);
1009 tmp = Math.floor(true);
1010 ok(tmp === 1, "Math.floor(true) = " + tmp);
1012 tmp = Math.floor(1.1, 3, 4);
1013 ok(tmp === 1, "Math.floor(1.1, 3, 4) = " + tmp);
1015 tmp = Math.floor();
1016 ok(isNaN(tmp), "floor is not NaN");
1018 tmp = Math.abs(3);
1019 ok(tmp === 3, "Math.abs(3) = " + tmp);
1021 tmp = Math.abs(-3);
1022 ok(tmp === 3, "Math.abs(-3) = " + tmp);
1024 tmp = Math.abs(true);
1025 ok(tmp === 1, "Math.abs(true) = " + tmp);
1027 tmp = Math.abs();
1028 ok(isNaN(tmp), "Math.abs() is not NaN");
1030 tmp = Math.abs(NaN);
1031 ok(isNaN(tmp), "Math.abs() is not NaN");
1033 tmp = Math.abs(-Infinity);
1034 ok(tmp === Infinity, "Math.abs(-Infinite) = " + tmp);
1036 tmp = Math.abs(-3, 2);
1037 ok(tmp === 3, "Math.abs(-3, 2) = " + tmp);
1039 tmp = Math.cos(0);
1040 ok(tmp === 1, "Math.cos(0) = " + tmp);
1042 tmp = Math.cos(Math.PI/2);
1043 ok(Math.floor(tmp*100) === 0, "Math.cos(Math.PI/2) = " + tmp);
1045 tmp = Math.cos(-Math.PI/2);
1046 ok(Math.floor(tmp*100) === 0, "Math.cos(-Math.PI/2) = " + tmp);
1048 tmp = Math.cos(Math.PI/3, 2);
1049 ok(Math.floor(tmp*100) === 50, "Math.cos(Math.PI/3, 2) = " + tmp);
1051 tmp = Math.cos(true);
1052 ok(Math.floor(tmp*100) === 54, "Math.cos(true) = " + tmp);
1054 tmp = Math.cos(false);
1055 ok(tmp === 1, "Math.cos(false) = " + tmp);
1057 tmp = Math.cos();
1058 ok(isNaN(tmp), "Math.cos() is not NaN");
1060 tmp = Math.cos(NaN);
1061 ok(isNaN(tmp), "Math.cos(NaN) is not NaN");
1063 tmp = Math.cos(Infinity);
1064 ok(isNaN(tmp), "Math.cos(Infinity) is not NaN");
1066 tmp = Math.cos(-Infinity);
1067 ok(isNaN(tmp), "Math.cos(-Infinity) is not NaN");
1069 tmp = Math.pow(2, 2);
1070 ok(tmp === 4, "Math.pow(2, 2) = " + tmp);
1072 tmp = Math.pow(4, 0.5);
1073 ok(tmp === 2, "Math.pow(2, 2) = " + tmp);
1075 tmp = Math.pow(2, 2, 3);
1076 ok(tmp === 4, "Math.pow(2, 2, 3) = " + tmp);
1078 tmp = Math.pow(2);
1079 ok(isNaN(tmp), "Math.pow(2) is not NaN");
1081 tmp = Math.pow();
1082 ok(isNaN(tmp), "Math.pow() is not NaN");
1084 tmp = Math.random();
1085 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
1086 ok(0 <= tmp && tmp <= 1, "Math.random() = " + tmp);
1088 tmp = Math.random(100);
1089 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
1090 ok(0 <= tmp && tmp <= 1, "Math.random(100) = " + tmp);
1092 tmp = Math.acos(0);
1093 ok(Math.floor(tmp*100) === 157, "Math.acos(0) = " + tmp);
1095 tmp = Math.acos(1);
1096 ok(Math.floor(tmp*100) === 0, "Math.acos(1) = " + tmp);
1098 tmp = Math.acos(-1);
1099 ok(Math.floor(tmp*100) === 314, "Math.acos(-1) = " + tmp);
1101 tmp = Math.acos(Math.PI/4, 2);
1102 ok(Math.floor(tmp*100) === 66, "Math.acos(Math.PI/4, 2) = " + tmp);
1104 tmp = Math.acos(true);
1105 ok(Math.floor(tmp*100) === 0, "Math.acos(true) = " + tmp);
1107 tmp = Math.acos(false);
1108 ok(Math.floor(tmp*100) === 157, "Math.acos(false) = " + tmp);
1110 tmp = Math.acos(1.1);
1111 ok(isNaN(tmp), "Math.acos(1.1) is not NaN");
1113 tmp = Math.acos();
1114 ok(isNaN(tmp), "Math.acos() is not NaN");
1116 tmp = Math.acos(NaN);
1117 ok(isNaN(tmp), "Math.acos(NaN) is not NaN");
1119 tmp = Math.acos(Infinity);
1120 ok(isNaN(tmp), "Math.acos(Infinity) is not NaN");
1122 tmp = Math.acos(-Infinity);
1123 ok(isNaN(tmp), "Math.acos(-Infinity) is not NaN");
1125 tmp = Math.asin(0);
1126 ok(Math.floor(tmp*100) === 0, "Math.asin(0) = " + tmp);
1128 tmp = Math.asin(1);
1129 ok(Math.floor(tmp*100) === 157, "Math.asin(1) = " + tmp);
1131 tmp = Math.asin(-1);
1132 ok(Math.floor(tmp*100) === -158, "Math.asin(-1) = " + tmp);
1134 tmp = Math.asin(Math.PI/4, 2);
1135 ok(Math.floor(tmp*100) === 90, "Math.asin(Math.PI/4, 2) = " + tmp);
1137 tmp = Math.asin(true);
1138 ok(Math.floor(tmp*100) === 157, "Math.asin(true) = " + tmp);
1140 tmp = Math.asin(false);
1141 ok(Math.floor(tmp*100) === 0, "Math.asin(false) = " + tmp);
1143 tmp = Math.asin(1.1);
1144 ok(isNaN(tmp), "Math.asin(1.1) is not NaN");
1146 tmp = Math.asin();
1147 ok(isNaN(tmp), "Math.asin() is not NaN");
1149 tmp = Math.asin(NaN);
1150 ok(isNaN(tmp), "Math.asin(NaN) is not NaN");
1152 tmp = Math.asin(Infinity);
1153 ok(isNaN(tmp), "Math.asin(Infinity) is not NaN");
1155 tmp = Math.asin(-Infinity);
1156 ok(isNaN(tmp), "Math.asin(-Infinity) is not NaN");
1158 tmp = Math.atan(0);
1159 ok(Math.floor(tmp*100) === 0, "Math.atan(0) = " + tmp);
1161 tmp = Math.atan(1);
1162 ok(Math.floor(tmp*100) === 78, "Math.atan(1) = " + tmp);
1164 tmp = Math.atan(-1);
1165 ok(Math.floor(tmp*100) === -79, "Math.atan(-1) = " + tmp);
1167 tmp = Math.atan(true);
1168 ok(Math.floor(tmp*100) === 78, "Math.atan(true) = " + tmp);
1170 tmp = Math.atan(false);
1171 ok(Math.floor(tmp*100) === 0, "Math.atan(false) = " + tmp);
1173 tmp = Math.atan();
1174 ok(isNaN(tmp), "Math.atan() is not NaN");
1176 tmp = Math.atan(NaN);
1177 ok(isNaN(tmp), "Math.atan(NaN) is not NaN");
1179 tmp = Math.atan(Infinity);
1180 ok(Math.floor(tmp*100) === 157, "Math.atan(Infinity) = " + tmp);
1182 tmp = Math.atan(-Infinity);
1183 ok(Math.floor(tmp*100) === -158, "Math.atan(Infinity) = " + tmp);
1185 tmp = Math.atan2(0, 0);
1186 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 0) = " + tmp);
1188 tmp = Math.atan2(0, 1);
1189 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 1) = " + tmp);
1191 tmp = Math.atan2(0, Infinity);
1192 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, Infinity) = " + tmp);
1194 tmp = Math.atan2(0, -1);
1195 ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -1) = " + tmp);
1197 tmp = Math.atan2(0, -Infinity);
1198 ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -Infinity) = " + tmp);
1200 tmp = Math.atan2(1, 0);
1201 ok(Math.floor(tmp*100) === 157, "Math.atan2(1, 0) = " + tmp);
1203 tmp = Math.atan2(Infinity, 0);
1204 ok(Math.floor(tmp*100) === 157, "Math.atan2(Infinity, 0) = " + tmp);
1206 tmp = Math.atan2(-1, 0);
1207 ok(Math.floor(tmp*100) === -158, "Math.atan2(-1, 0) = " + tmp);
1209 tmp = Math.atan2(-Infinity, 0);
1210 ok(Math.floor(tmp*100) === -158, "Math.atan2(-Infinity, 0) = " + tmp);
1212 tmp = Math.atan2(1, 1);
1213 ok(Math.floor(tmp*100) === 78, "Math.atan2(1, 1) = " + tmp);
1215 tmp = Math.atan2(-1, -1);
1216 ok(Math.floor(tmp*100) === -236, "Math.atan2(-1, -1) = " + tmp);
1218 tmp = Math.atan2(-1, 1);
1219 ok(Math.floor(tmp*100) === -79, "Math.atan2(-1, 1) = " + tmp);
1221 tmp = Math.atan2(Infinity, Infinity);
1222 ok(Math.floor(tmp*100) === 78, "Math.atan2(Infinity, Infinity) = " + tmp);
1224 tmp = Math.atan2(Infinity, -Infinity, 1);
1225 ok(Math.floor(tmp*100) === 235, "Math.atan2(Infinity, -Infinity, 1) = " + tmp);
1227 tmp = Math.atan2();
1228 ok(isNaN(tmp), "Math.atan2() is not NaN");
1230 tmp = Math.atan2(1);
1231 ok(isNaN(tmp), "Math.atan2(1) is not NaN");
1233 tmp = Math.exp(0);
1234 ok(tmp === 1, "Math.exp(0) = " + tmp);
1236 tmp = Math.exp(1);
1237 ok(Math.floor(tmp*100) === 271, "Math.exp(1) = " + tmp);
1239 tmp = Math.exp(-1);
1240 ok(Math.floor(tmp*100) === 36, "Math.exp(-1) = " + tmp);
1242 tmp = Math.exp(true);
1243 ok(Math.floor(tmp*100) === 271, "Math.exp(true) = " + tmp);
1245 tmp = Math.exp(1, 1);
1246 ok(Math.floor(tmp*100) === 271, "Math.exp(1, 1) = " + tmp);
1248 tmp = Math.exp();
1249 ok(isNaN(tmp), "Math.exp() is not NaN");
1251 tmp = Math.exp(NaN);
1252 ok(isNaN(tmp), "Math.exp(NaN) is not NaN");
1254 tmp = Math.exp(Infinity);
1255 ok(tmp === Infinity, "Math.exp(Infinity) = " + tmp);
1257 tmp = Math.exp(-Infinity);
1258 ok(tmp === 0, "Math.exp(-Infinity) = " + tmp);
1260 tmp = Math.log(1);
1261 ok(Math.floor(tmp*100) === 0, "Math.log(1) = " + tmp);
1263 tmp = Math.log(-1);
1264 ok(isNaN(tmp), "Math.log(-1) is not NaN");
1266 tmp = Math.log(true);
1267 ok(Math.floor(tmp*100) === 0, "Math.log(true) = " + tmp);
1269 tmp = Math.log(1, 1);
1270 ok(Math.floor(tmp*100) === 0, "Math.log(1, 1) = " + tmp);
1272 tmp = Math.log();
1273 ok(isNaN(tmp), "Math.log() is not NaN");
1275 tmp = Math.log(NaN);
1276 ok(isNaN(tmp), "Math.log(NaN) is not NaN");
1278 tmp = Math.log(Infinity);
1279 ok(tmp === Infinity, "Math.log(Infinity) = " + tmp);
1281 tmp = Math.log(-Infinity);
1282 ok(isNaN(tmp), "Math.log(-Infinity) is not NaN");
1284 tmp = Math.sin(0);
1285 ok(tmp === 0, "Math.sin(0) = " + tmp);
1287 tmp = Math.sin(Math.PI/2);
1288 ok(tmp === 1, "Math.sin(Math.PI/2) = " + tmp);
1290 tmp = Math.sin(-Math.PI/2);
1291 ok(tmp === -1, "Math.sin(-Math.PI/2) = " + tmp);
1293 tmp = Math.sin(Math.PI/3, 2);
1294 ok(Math.floor(tmp*100) === 86, "Math.sin(Math.PI/3, 2) = " + tmp);
1296 tmp = Math.sin(true);
1297 ok(Math.floor(tmp*100) === 84, "Math.sin(true) = " + tmp);
1299 tmp = Math.sin(false);
1300 ok(tmp === 0, "Math.sin(false) = " + tmp);
1302 tmp = Math.sin();
1303 ok(isNaN(tmp), "Math.sin() is not NaN");
1305 tmp = Math.sin(NaN);
1306 ok(isNaN(tmp), "Math.sin(NaN) is not NaN");
1308 tmp = Math.sin(Infinity);
1309 ok(isNaN(tmp), "Math.sin(Infinity) is not NaN");
1311 tmp = Math.sin(-Infinity);
1312 ok(isNaN(tmp), "Math.sin(-Infinity) is not NaN");
1314 tmp = Math.sqrt(0);
1315 ok(tmp === 0, "Math.sqrt(0) = " + tmp);
1317 tmp = Math.sqrt(4);
1318 ok(tmp === 2, "Math.sqrt(4) = " + tmp);
1320 tmp = Math.sqrt(-1);
1321 ok(isNaN(tmp), "Math.sqrt(-1) is not NaN");
1323 tmp = Math.sqrt(2, 2);
1324 ok(Math.floor(tmp*100) === 141, "Math.sqrt(2, 2) = " + tmp);
1326 tmp = Math.sqrt(true);
1327 ok(tmp === 1, "Math.sqrt(true) = " + tmp);
1329 tmp = Math.sqrt(false);
1330 ok(tmp === 0, "Math.sqrt(false) = " + tmp);
1332 tmp = Math.sqrt();
1333 ok(isNaN(tmp), "Math.sqrt() is not NaN");
1335 tmp = Math.sqrt(NaN);
1336 ok(isNaN(tmp), "Math.sqrt(NaN) is not NaN");
1338 tmp = Math.sqrt(Infinity);
1339 ok(tmp === Infinity, "Math.sqrt(Infinity) = " + tmp);
1341 tmp = Math.sqrt(-Infinity);
1342 ok(isNaN(tmp), "Math.sqrt(-Infinity) is not NaN");
1344 tmp = Math.tan(0);
1345 ok(tmp === 0, "Math.tan(0) = " + tmp);
1347 tmp = Math.tan(Math.PI);
1348 ok(Math.floor(tmp*100) === -1, "Math.tan(Math.PI) = " + tmp);
1350 tmp = Math.tan(2, 2);
1351 ok(Math.floor(tmp*100) === -219, "Math.tan(2, 2) = " + tmp);
1353 tmp = Math.tan(true);
1354 ok(Math.floor(tmp*100) === 155, "Math.tan(true) = " + tmp);
1356 tmp = Math.tan(false);
1357 ok(tmp === 0, "Math.tan(false) = " + tmp);
1359 tmp = Math.tan();
1360 ok(isNaN(tmp), "Math.tan() is not NaN");
1362 tmp = Math.tan(NaN);
1363 ok(isNaN(tmp), "Math.tan(NaN) is not NaN");
1365 tmp = Math.tan(Infinity);
1366 ok(isNaN(tmp), "Math.tan(Infinity) is not NaN");
1368 tmp = Math.tan(-Infinity);
1369 ok(isNaN(tmp), "Math.tan(-Infinity) is not NaN");
1371 var func = function (a) {
1372 var a = 1;
1373 if(a) return;
1375 ok(func.toString() === "function (a) {\n var a = 1;\n if(a) return;\n }",
1376 "func.toString() = " + func.toString());
1377 ok("" + func === "function (a) {\n var a = 1;\n if(a) return;\n }",
1378 "'' + func.toString() = " + func);
1380 ok(func.valueOf === Object.prototype.valueOf, "func.valueOf !== Object.prototype.valueOf");
1381 ok(func === func.valueOf(), "func !== func.valueOf()");
1383 function testFuncToString(x,y) {
1384 return x+y;
1386 ok(testFuncToString.toString() === "function testFuncToString(x,y) {\n return x+y;\n}",
1387 "testFuncToString.toString() = " + testFuncToString.toString());
1388 ok("" + testFuncToString === "function testFuncToString(x,y) {\n return x+y;\n}",
1389 "'' + testFuncToString = " + testFuncToString);
1391 tmp = new Object();
1393 function callTest(argc) {
1394 ok(this === tmp, "this !== tmp\n");
1395 ok(arguments.length === argc+1, "arguments.length = " + arguments.length + " expected " + (argc+1));
1396 for(var i=1; i <= argc; i++)
1397 ok(arguments[i] === i, "arguments[i] = " + arguments[i]);
1400 callTest.call(tmp, 1, 1);
1401 callTest.call(tmp, 2, 1, 2);
1403 callTest.apply(tmp, [1, 1]);
1404 callTest.apply(tmp, [2, 1, 2]);
1405 (function () { callTest.apply(tmp, arguments); })(2,1,2);
1407 function callTest2() {
1408 ok(this === tmp, "this !== tmp\n");
1409 ok(arguments.length === 0, "callTest2: arguments.length = " + arguments.length + " expected 0");
1412 callTest2.call(tmp);
1413 callTest2.apply(tmp, []);
1414 callTest2.apply(tmp);
1415 (function () { callTest2.apply(tmp, arguments); })();
1417 function callTest3() {
1418 testThis(this);
1419 ok(arguments.length === 0, "arguments.length = " + arguments.length + " expected 0");
1422 callTest3.call();
1423 callTest3.call(undefined);
1424 callTest3.call(null);
1425 callTest3.apply();
1426 callTest3.apply(undefined);
1427 callTest3.apply(null);
1429 tmp = Number.prototype.toString.call(3);
1430 ok(tmp === "3", "Number.prototype.toString.call(3) = " + tmp);
1432 var date = new Date();
1434 date = new Date(100);
1435 ok(date.getTime() === 100, "date.getTime() = " + date.getTime());
1436 ok(Date.prototype.getTime() === 0, "date.prototype.getTime() = " + Date.prototype.getTime());
1437 date = new Date(8.64e15);
1438 ok(date.getTime() === 8.64e15, "date.getTime() = " + date.getTime());
1439 date = new Date(8.64e15+1);
1440 ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
1441 date = new Date(Infinity);
1442 ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
1443 date = new Date("3 July 2009 22:28:00 UTC+0100");
1444 ok(date.getTime() === 1246656480000, "date.getTime() = " + date.getTime());
1445 date = new Date(1984, 11, 29, 13, 51, 24, 120);
1446 ok(date.getFullYear() === 1984, "date.getFullYear() = " + date.getFullYear());
1447 ok(date.getMonth() === 11, "date.getMonth() = " + date.getMonth());
1448 ok(date.getDate() === 29, "date.getDate() = " + date.getDate());
1449 ok(date.getHours() === 13, "date.getHours() = " + date.getHours());
1450 ok(date.getMinutes() === 51, "date.getMinutes() = " + date.getMinutes());
1451 ok(date.getSeconds() === 24, "date.getSeconds() = " + date.getSeconds());
1452 ok(date.getMilliseconds() === 120, "date.getMilliseconds() = " + date.getMilliseconds());
1453 date = new Date(731, -32, 40, -1, 70, 65, -13);
1454 ok(date.getFullYear() === 728, "date.getFullYear() = " + date.getFullYear());
1455 ok(date.getMonth() === 5, "date.getMonth() = " + date.getMonth());
1456 ok(date.getDate() === 9, "date.getDate() = " + date.getDate());
1457 ok(date.getHours() === 0, "date.getHours() = " + date.getHours());
1458 ok(date.getMinutes() === 11, "date.getMinutes() = " + date.getMinutes());
1459 ok(date.getSeconds() === 4, "date.getSeconds() = " + date.getSeconds());
1460 ok(date.getMilliseconds() === 987, "date.getMilliseconds() = " + date.getMilliseconds());
1462 ok(date.setTime(123) === 123, "date.setTime(123) !== 123");
1463 ok(date.setTime("123", NaN) === 123, "date.setTime(\"123\") !== 123");
1464 ok(isNaN(date.setTime(NaN)), "date.setTime(NaN) is not NaN");
1466 ok(date.setTime(0) === date.getTime(), "date.setTime(0) !== date.getTime()");
1467 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
1468 ok(date.getUTCMonth() === 0, "date.getUTCMonth() = " + date.getUTCMonth());
1469 ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
1470 ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
1471 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
1472 ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
1473 ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
1474 ok(date.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1475 date.setTime(60*24*60*60*1000);
1476 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
1477 ok(date.getUTCMonth() === 2, "date.getUTCMonth() = " + date.getUTCMonth());
1478 ok(date.getUTCDate() === 2, "date.getUTCDate() = " + date.getUTCDate());
1479 ok(date.getUTCDay() === 1, "date.getUTCDay() = " + date.getUTCDay());
1480 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
1481 ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
1482 ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
1483 ok(date.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1484 date.setTime(59*24*60*60*1000 + 4*365*24*60*60*1000 + 60*60*1000 + 2*60*1000 + 2*1000 + 640);
1485 ok(date.getUTCFullYear() === 1974, "date.getUTCFullYear() = " + date.getUTCFullYear());
1486 ok(date.getUTCMonth() === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1487 ok(date.getUTCMonth(123) === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1488 ok(date.getUTCDate() === 28, "date.getUTCDate() = " + date.getUTCDate());
1489 ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
1490 ok(date.getUTCHours() === 1, "date.getUTCHours() = " + date.getUTCHours());
1491 ok(date.getUTCMinutes() === 2, "date.getUTCMinutes() = " + date.getUTCMinutes());
1492 ok(date.getUTCSeconds() === 2, "date.getUTCSeconds() = " + date.getUTCSeconds());
1493 ok(date.getUTCMilliseconds() === 640, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1494 date.setTime(Infinity);
1495 ok(isNaN(date.getUTCFullYear()), "date.getUTCFullYear() is not NaN");
1496 ok(isNaN(date.getUTCMonth()), "date.getUTCMonth() is not NaN");
1497 ok(isNaN(date.getUTCDate()), "date.getUTCDate() is not NaN");
1498 ok(isNaN(date.getUTCDay()), "date.getUTCDay() is not NaN");
1499 ok(isNaN(date.getUTCHours()), "date.getUTCHours() is not NaN");
1500 ok(isNaN(date.getUTCMinutes()), "date.getUTCMinutes() is not NaN");
1501 ok(isNaN(date.getUTCSeconds()), "date.getUTCSeconds() is not NaN");
1502 ok(isNaN(date.getUTCMilliseconds()), "date.getUTCMilliseconds() is not NaN");
1503 ok(isNaN(date.setMilliseconds(0)), "date.setMilliseconds() is not NaN");
1505 date.setTime(0);
1506 date.setUTCMilliseconds(-10, 2);
1507 ok(date.getUTCMilliseconds() === 990, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1508 date.setUTCMilliseconds(10);
1509 ok(date.getUTCMilliseconds() === 10, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1510 date.setUTCSeconds(-10);
1511 ok(date.getUTCSeconds() === 50, "date.getUTCSeconds() = " + date.getUTCSeconds());
1512 date.setUTCMinutes(-10);
1513 ok(date.getUTCMinutes() === 50, "date.getUTCMinutes() = " + date.getUTCMinutes());
1514 date.setUTCHours(-10);
1515 ok(date.getUTCHours() === 14, "date.getUTCHours() = " + date.getUTCHours());
1516 date.setUTCHours(-123);
1517 ok(date.getTime() === -612549990, "date.getTime() = " + date.getTime());
1518 date.setUTCHours(20);
1519 ok(date.getUTCHours() === 20, "date.getUTCHours() = " + date.getUTCHours());
1520 date.setUTCDate(32);
1521 ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
1522 date.setUTCMonth(22, 37);
1523 ok(date.getTime() === 60987050010, "date.getTime() = " + date.getTime());
1524 date.setUTCFullYear(83, 21, 321);
1525 ok(date.getTime() === -59464984149990, "date.getTime() = " + date.getTime());
1526 ok(Math.abs(date) === 59464984149990, "Math.abs(date) = " + Math.abs(date));
1527 ok(getVT(date+1) === "VT_BSTR", "getVT(date+1) = " + getVT(date+1));
1529 ok(isNaN(Date.parse()), "Date.parse() is not NaN");
1530 ok(isNaN(Date.parse("")), "Date.parse(\"\") is not NaN");
1531 ok(isNaN(Date.parse("Jan Jan 20 2009")), "Date.parse(\"Jan Jan 20 2009\") is not NaN");
1532 ok(Date.parse("Jan 20 2009 UTC") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC\") = " + Date.parse("Jan 20 2009 UTC"));
1533 ok(Date.parse("Jan 20 2009 GMT") === 1232409600000, "Date.parse(\"Jan 20 2009 GMT\") = " + Date.parse("Jan 20 2009 GMT"));
1534 ok(Date.parse("Jan 20 2009 UTC-0") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC-0\") = " + Date.parse("Jan 20 2009 UTC-0"));
1535 ok(Date.parse("Jan 20 2009 UTC+0000") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC+0000\") = " + Date.parse("Jan 20 2009 UTC+0000"));
1536 ok(Date.parse("Ju 13 79 UTC") === 300672000000, "Date.parse(\"Ju 13 79 UTC\") = " + Date.parse("Ju 13 79 UTC"));
1537 ok(Date.parse("12Au91 UTC") === 681955200000, "Date.parse(\"12Au91 UTC\") = " + Date.parse("12Au91 UTC"));
1538 ok(Date.parse("7/02/17 UTC") === -1656806400000, "Date.parse(\"7/02/17 UTC\") = " + Date.parse("7/02/17 UTC"));
1539 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"));
1540 ok(Date.parse("February 31 UTC, 2000 12:31:17 PM") === 952000277000,
1541 "Date.parse(\"February 31 UTC, 2000 12:31:17 PM\") = " + Date.parse("February 31 UTC, 2000 12:31:17 PM"));
1542 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 "));
1543 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"));
1545 ok(typeof(Math.PI) === "number", "typeof(Math.PI) = " + typeof(Math.PI));
1546 ok(Math.floor(Math.PI*100) === 314, "Math.PI = " + Math.PI);
1547 Math.PI = "test";
1548 ok(Math.floor(Math.PI*100) === 314, "modified Math.PI = " + Math.PI);
1550 ok(typeof(Math.E) === "number", "typeof(Math.E) = " + typeof(Math.E));
1551 ok(Math.floor(Math.E*100) === 271, "Math.E = " + Math.E);
1552 Math.E = "test";
1553 ok(Math.floor(Math.E*100) === 271, "modified Math.E = " + Math.E);
1555 ok(typeof(Math.LOG2E) === "number", "typeof(Math.LOG2E) = " + typeof(Math.LOG2E));
1556 ok(Math.floor(Math.LOG2E*100) === 144, "Math.LOG2E = " + Math.LOG2E);
1557 Math.LOG2E = "test";
1558 ok(Math.floor(Math.LOG2E*100) === 144, "modified Math.LOG2E = " + Math.LOG2E);
1560 ok(typeof(Math.LOG10E) === "number", "typeof(Math.LOG10E) = " + typeof(Math.LOG10E));
1561 ok(Math.floor(Math.LOG10E*100) === 43, "Math.LOG10E = " + Math.LOG10E);
1562 Math.LOG10E = "test";
1563 ok(Math.floor(Math.LOG10E*100) === 43, "modified Math.LOG10E = " + Math.LOG10E);
1565 ok(typeof(Math.LN2) === "number", "typeof(Math.LN2) = " + typeof(Math.LN2));
1566 ok(Math.floor(Math.LN2*100) === 69, "Math.LN2 = " + Math.LN2);
1567 Math.LN2 = "test";
1568 ok(Math.floor(Math.LN2*100) === 69, "modified Math.LN2 = " + Math.LN2);
1570 ok(typeof(Math.LN10) === "number", "typeof(Math.LN10) = " + typeof(Math.LN10));
1571 ok(Math.floor(Math.LN10*100) === 230, "Math.LN10 = " + Math.LN10);
1572 Math.LN10 = "test";
1573 ok(Math.floor(Math.LN10*100) === 230, "modified Math.LN10 = " + Math.LN10);
1575 ok(typeof(Math.SQRT2) === "number", "typeof(Math.SQRT2) = " + typeof(Math.SQRT2));
1576 ok(Math.floor(Math.SQRT2*100) === 141, "Math.SQRT2 = " + Math.SQRT2);
1577 Math.SQRT2 = "test";
1578 ok(Math.floor(Math.SQRT2*100) === 141, "modified Math.SQRT2 = " + Math.SQRT2);
1580 ok(typeof(Math.SQRT1_2) === "number", "typeof(Math.SQRT1_2) = " + typeof(Math.SQRT1_2));
1581 ok(Math.floor(Math.SQRT1_2*100) === 70, "Math.SQRT1_2 = " + Math.SQRT1_2);
1582 Math.SQRT1_2 = "test";
1583 ok(Math.floor(Math.SQRT1_2*100) === 70, "modified Math.SQRT1_2 = " + Math.SQRT1_2);
1585 ok(isNaN.toString() === "\nfunction isNaN() {\n [native code]\n}\n",
1586 "isNaN.toString = '" + isNaN.toString() + "'");
1587 ok(Array.toString() === "\nfunction Array() {\n [native code]\n}\n",
1588 "isNaN.toString = '" + Array.toString() + "'");
1589 ok(Function.toString() === "\nfunction Function() {\n [native code]\n}\n",
1590 "isNaN.toString = '" + Function.toString() + "'");
1591 ok(Function.prototype.toString() === "\nfunction prototype() {\n [native code]\n}\n",
1592 "isNaN.toString = '" + Function.prototype.toString() + "'");
1593 ok("".substr.toString() === "\nfunction substr() {\n [native code]\n}\n",
1594 "''.substr.toString = '" + "".substr.toString() + "'");
1596 var bool = new Boolean();
1597 ok(bool.toString() === "false", "bool.toString() = " + bool.toString());
1598 var bool = new Boolean("false");
1599 ok(bool.toString() === "true", "bool.toString() = " + bool.toString());
1600 ok(bool.valueOf() === Boolean(1), "bool.valueOf() = " + bool.valueOf());
1601 ok(bool.toLocaleString() === bool.toString(), "bool.toLocaleString() = " + bool.toLocaleString());
1603 ok(ActiveXObject instanceof Function, "ActiveXObject is not instance of Function");
1604 ok(ActiveXObject.prototype instanceof Object, "ActiveXObject.prototype is not instance of Object");
1606 ok(Error.prototype !== TypeError.prototype, "Error.prototype === TypeError.prototype");
1607 ok(RangeError.prototype !== TypeError.prototype, "RangeError.prototype === TypeError.prototype");
1608 ok(Error.prototype.toLocaleString === Object.prototype.toLocaleString,
1609 "Error.prototype.toLocaleString !== Object.prototype.toLocaleString");
1610 err = new Error();
1611 ok(err.valueOf === Object.prototype.valueOf, "err.valueOf !== Object.prototype.valueOf");
1612 ok(Error.prototype.name === "Error", "Error.prototype.name = " + Error.prototype.name);
1613 ok(err.name === "Error", "err.name = " + err.name);
1614 EvalError.prototype.message = "test";
1615 ok(err.toString !== Object.prototype.toString, "err.toString === Object.prototype.toString");
1616 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "Error"), "err.toString() = " + err.toString());
1617 err = new EvalError();
1618 ok(EvalError.prototype.name === "EvalError", "EvalError.prototype.name = " + EvalError.prototype.name);
1619 ok(err.name === "EvalError", "err.name = " + err.name);
1620 ok(err.toString === Error.prototype.toString, "err.toString !== Error.prototype.toString");
1621 ok(err.message === "", "err.message != ''");
1622 err.message = date;
1623 ok(err.message === date, "err.message != date");
1624 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "EvalError: "+err.message),
1625 "err.toString() = " + err.toString());
1626 ok(err.toString !== Object.prototype.toString, "err.toString === Object.prototype.toString");
1627 err = new RangeError();
1628 ok(RangeError.prototype.name === "RangeError", "RangeError.prototype.name = " + RangeError.prototype.name);
1629 ok(err.name === "RangeError", "err.name = " + err.name);
1630 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "RangeError"), "err.toString() = " + err.toString());
1631 err = new ReferenceError();
1632 ok(ReferenceError.prototype.name === "ReferenceError", "ReferenceError.prototype.name = " + ReferenceError.prototype.name);
1633 ok(err.name === "ReferenceError", "err.name = " + err.name);
1634 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "ReferenceError"), "err.toString() = " + err.toString());
1635 err = new SyntaxError();
1636 ok(SyntaxError.prototype.name === "SyntaxError", "SyntaxError.prototype.name = " + SyntaxError.prototype.name);
1637 ok(err.name === "SyntaxError", "err.name = " + err.name);
1638 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "SyntaxError"), "err.toString() = " + err.toString());
1639 err = new TypeError();
1640 ok(TypeError.prototype.name === "TypeError", "TypeError.prototype.name = " + TypeError.prototype.name);
1641 ok(err.name === "TypeError", "err.name = " + err.name);
1642 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "TypeError"), "err.toString() = " + err.toString());
1643 err = new URIError();
1644 ok(URIError.prototype.name === "URIError", "URIError.prototype.name = " + URIError.prototype.name);
1645 ok(err.name === "URIError", "err.name = " + err.name);
1646 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "URIError"), "err.toString() = " + err.toString());
1647 err = new Error("message");
1648 ok(err.message === "message", "err.message !== 'message'");
1649 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "Error: message"), "err.toString() = " + err.toString());
1650 err = new Error(123);
1651 ok(err.number === 123, "err.number = " + err.number);
1652 err = new Error(0, "message");
1653 ok(err.number === 0, "err.number = " + err.number);
1654 ok(err.message === "message", "err.message = " + err.message);
1655 ok(err.description === "message", "err.description = " + err.description);
1657 tmp = new Object();
1658 tmp.toString = function() { return "test"; };
1660 tmp = Error.prototype.toString.call(tmp);
1661 ok(tmp === "[object Error]", "Error.prototype.toString.call(tmp) = " + tmp);
1663 err = new Error();
1664 err.name = null;
1665 ok(err.name === null, "err.name = " + err.name + " expected null");
1666 if(invokeVersion >= 2)
1667 ok(err.toString() === "null", "err.toString() = " + err.toString());
1669 err = new Error();
1670 err.message = false;
1671 ok(err.message === false, "err.message = " + err.message + " expected false");
1672 if(invokeVersion >= 2)
1673 ok(err.toString() === "Error: false", "err.toString() = " + err.toString());
1675 err = new Error();
1676 err.message = new Object();
1677 err.message.toString = function() { return ""; };
1678 if(invokeVersion >= 2)
1679 ok(err.toString() === "Error", "err.toString() = " + err.toString());
1681 err = new Error();
1682 err.message = undefined;
1683 if(invokeVersion >= 2)
1684 ok(err.toString() === "Error", "err.toString() = " + err.toString());
1686 function exception_test(func, type, number) {
1687 ret = "";
1688 num = "";
1689 try {
1690 func();
1691 } catch(e) {
1692 ret = e.name;
1693 num = e.number;
1695 ok(ret === type, "Exception test, ret = " + ret + ", expected " + type +". Executed function: " + func.toString());
1696 ok(num === number, "Exception test, num = " + num + ", expected " + number + ". Executed function: " + func.toString());
1698 exception_test(function() {arr.toString = Date.prototype.toString; arr.toString();}, "TypeError", -2146823282);
1699 exception_test(function() {Array(-3);}, "RangeError", -2146823259);
1700 exception_test(function() {arr.toString = Boolean.prototype.toString; arr.toString();}, "TypeError", -2146823278);
1701 exception_test(function() {date.setTime();}, "TypeError", -2146827839);
1702 exception_test(function() {arr.test();}, "TypeError", -2146827850);
1703 exception_test(function() {arr.toString = Number.prototype.toString; arr.toString();}, "TypeError", -2146823287);
1704 exception_test(function() {(new Number(3)).toString(1);}, "TypeError", -2146828283);
1705 exception_test(function() {not_existing_variable.something();}, "TypeError", -2146823279);
1706 exception_test(function() {arr.toString = Function.prototype.toString; arr.toString();}, "TypeError", -2146823286);
1707 exception_test(function() {date();}, "TypeError", -2146823286);
1708 exception_test(function() {arr();}, "TypeError", -2146823286);
1709 exception_test(function() {eval("for(i=0;) {}");}, "SyntaxError", -2146827286);
1710 exception_test(function() {eval("function {};");}, "SyntaxError", -2146827283);
1711 exception_test(function() {eval("if");}, "SyntaxError", -2146827283);
1712 exception_test(function() {eval("do i=0; while");}, "SyntaxError", -2146827283);
1713 exception_test(function() {eval("while");}, "SyntaxError", -2146827283);
1714 exception_test(function() {eval("for");}, "SyntaxError", -2146827283);
1715 exception_test(function() {eval("with");}, "SyntaxError", -2146827283);
1716 exception_test(function() {eval("switch");}, "SyntaxError", -2146827283);
1717 exception_test(function() {eval("if(false");}, "SyntaxError", -2146827282);
1718 exception_test(function() {eval("for(i=0; i<10; i++");}, "SyntaxError", -2146827282);
1719 exception_test(function() {eval("while(true");}, "SyntaxError", -2146827282);
1720 exception_test(function() {test = function() {}}, "ReferenceError", -2146823280);
1721 exception_test(function() {eval("for(i=0")}, "SyntaxError", -2146827284);
1722 exception_test(function() {eval("for(i=0;i<10")}, "SyntaxError", -2146827284);
1723 exception_test(function() {eval("while(")}, "SyntaxError", -2146827286);
1724 exception_test(function() {eval("if(")}, "SyntaxError", -2146827286);
1725 exception_test(function() {eval("'unterminated")}, "SyntaxError", -2146827273);
1726 exception_test(function() {eval("nonexistingfunc()")}, "TypeError", -2146823281);
1727 exception_test(function() {RegExp(/a/, "g");}, "RegExpError", -2146823271);
1728 exception_test(function() {encodeURI('\udcaa');}, "URIError", -2146823264);
1730 function testThisExcept(func, number) {
1731 exception_test(function() {func.call(new Object())}, "TypeError", number);
1734 function testBoolThis(func) {
1735 testThisExcept(Boolean.prototype[func], -2146823278);
1738 testBoolThis("toString");
1739 testBoolThis("valueOf");
1741 function testDateThis(func) {
1742 testThisExcept(Date.prototype[func], -2146823282);
1745 testDateThis("getDate");
1746 testDateThis("getDay");
1747 testDateThis("getFullYear");
1748 testDateThis("getHours");
1749 testDateThis("getMilliseconds");
1750 testDateThis("getMinutes");
1751 testDateThis("getMonth");
1752 testDateThis("getSeconds");
1753 testDateThis("getTime");
1754 testDateThis("getTimezoneOffset");
1755 testDateThis("getUTCDate");
1756 testDateThis("getUTCDay");
1757 testDateThis("getUTCFullYear");
1758 testDateThis("getUTCHours");
1759 testDateThis("getUTCMilliseconds");
1760 testDateThis("getUTCMinutes");
1761 testDateThis("getUTCMonth");
1762 testDateThis("getUTCSeconds");
1763 testDateThis("setDate");
1764 testDateThis("setFullYear");
1765 testDateThis("setHours");
1766 testDateThis("setMilliseconds");
1767 testDateThis("setMinutes");
1768 testDateThis("setMonth");
1769 testDateThis("setSeconds");
1770 testDateThis("setTime");
1771 testDateThis("setUTCDate");
1772 testDateThis("setUTCFullYear");
1773 testDateThis("setUTCHours");
1774 testDateThis("setUTCMilliseconds");
1775 testDateThis("setUTCMinutes");
1776 testDateThis("setUTCMonth");
1777 testDateThis("setUTCSeconds");
1778 testDateThis("toDateString");
1779 testDateThis("toLocaleDateString");
1780 testDateThis("toLocaleString");
1781 testDateThis("toLocaleTimeString");
1782 testDateThis("toString");
1783 testDateThis("toTimeString");
1784 testDateThis("toUTCString");
1785 testDateThis("valueOf");
1787 function testArrayThis(func) {
1788 testThisExcept(Array.prototype[func], -2146823257);
1791 testArrayThis("toString");
1793 function testFunctionThis(func) {
1794 testThisExcept(Function.prototype[func], -2146823286);
1797 testFunctionThis("toString");
1798 testFunctionThis("call");
1799 testFunctionThis("apply");
1801 function testArrayHostThis(func) {
1802 exception_test(function() { Array.prototype[func].call(testObj); }, "TypeError", -2146823274);
1805 testArrayHostThis("push");
1806 testArrayHostThis("shift");
1807 testArrayHostThis("slice");
1808 testArrayHostThis("splice");
1809 testArrayHostThis("unshift");
1811 function testObjectInherit(obj, constr, ts, tls, vo) {
1812 ok(obj instanceof Object, "obj is not instance of Object");
1813 ok(obj instanceof constr, "obj is not instance of its constructor");
1815 ok(obj.hasOwnProperty === Object.prototype.hasOwnProperty,
1816 "obj.hasOwnProperty !== Object.prototype.hasOwnProprty");
1817 ok(obj.isPrototypeOf === Object.prototype.isPrototypeOf,
1818 "obj.isPrototypeOf !== Object.prototype.isPrototypeOf");
1819 ok(obj.propertyIsEnumerable === Object.prototype.propertyIsEnumerable,
1820 "obj.propertyIsEnumerable !== Object.prototype.propertyIsEnumerable");
1822 if(ts)
1823 ok(obj.toString === Object.prototype.toString,
1824 "obj.toString !== Object.prototype.toString");
1825 else
1826 ok(obj.toString != Object.prototype.toString,
1827 "obj.toString == Object.prototype.toString");
1829 if(tls)
1830 ok(obj.toLocaleString === Object.prototype.toLocaleString,
1831 "obj.toLocaleString !== Object.prototype.toLocaleString");
1832 else
1833 ok(obj.toLocaleString != Object.prototype.toLocaleString,
1834 "obj.toLocaleString == Object.prototype.toLocaleString");
1836 if(vo)
1837 ok(obj.valueOf === Object.prototype.valueOf,
1838 "obj.valueOf !== Object.prototype.valueOf");
1839 else
1840 ok(obj.valueOf != Object.prototype.valueOf,
1841 "obj.valueOf == Object.prototype.valueOf");
1843 ok(obj._test === "test", "obj.test = " + obj._test);
1846 Object.prototype._test = "test";
1847 testObjectInherit(new String("test"), String, false, true, false);
1848 testObjectInherit(/test/g, RegExp, false, true, true);
1849 testObjectInherit(new Number(1), Number, false, false, false);
1850 testObjectInherit(new Date(), Date, false, false, false);
1851 testObjectInherit(new Boolean(true), Boolean, false, true, false);
1852 testObjectInherit(new Array(), Array, false, false, true);
1853 testObjectInherit(new Error(), Error, false, true, true);
1854 testObjectInherit(testObjectInherit, Function, false, true, true);
1855 testObjectInherit(Math, Object, true, true, true);
1857 (function() { testObjectInherit(arguments, Object, true, true, true); })();
1859 function testFunctions(obj, arr) {
1860 var l;
1862 for(var i=0; i<arr.length; i++) {
1863 l = obj[arr[i][0]].length;
1864 ok(l === arr[i][1], arr[i][0] + ".length = " + l);
1868 testFunctions(Boolean.prototype, [
1869 ["valueOf", 0],
1870 ["toString", 0]
1873 testFunctions(Number.prototype, [
1874 ["valueOf", 0],
1875 ["toString", 1],
1876 ["toExponential", 1],
1877 ["toLocaleString", 0],
1878 ["toPrecision", 1]
1881 testFunctions(String.prototype, [
1882 ["valueOf", 0],
1883 ["toString", 0],
1884 ["anchor", 1],
1885 ["big", 0],
1886 ["blink", 0],
1887 ["bold", 0],
1888 ["charAt", 1],
1889 ["charCodeAt", 1],
1890 ["concat", 1],
1891 ["fixed", 0],
1892 ["fontcolor", 1],
1893 ["fontsize", 1],
1894 ["indexOf", 2],
1895 ["italics", 0],
1896 ["lastIndexOf", 2],
1897 ["link", 1],
1898 ["localeCompare", 1],
1899 ["match", 1],
1900 ["replace", 1],
1901 ["search", 0],
1902 ["slice", 0],
1903 ["small", 0],
1904 ["split", 2],
1905 ["strike", 0],
1906 ["sub", 0],
1907 ["substr", 2],
1908 ["substring", 2],
1909 ["sup", 0],
1910 ["toLocaleLowerCase", 0],
1911 ["toLocaleUpperCase", 0],
1912 ["toLowerCase", 0],
1913 ["toUpperCase", 0]
1916 testFunctions(RegExp.prototype, [
1917 ["toString", 0],
1918 ["exec", 1],
1919 ["test", 1]
1922 testFunctions(Date.prototype, [
1923 ["getDate", 0],
1924 ["getDay", 0],
1925 ["getFullYear", 0],
1926 ["getHours", 0],
1927 ["getMilliseconds", 0],
1928 ["getMinutes", 0],
1929 ["getMonth", 0],
1930 ["getSeconds", 0],
1931 ["getTime", 0],
1932 ["getTimezoneOffset", 0],
1933 ["getUTCDate", 0],
1934 ["getUTCDay", 0],
1935 ["getUTCFullYear", 0],
1936 ["getUTCHours", 0],
1937 ["getUTCMilliseconds", 0],
1938 ["getUTCMinutes", 0],
1939 ["getUTCMonth", 0],
1940 ["getUTCSeconds", 0],
1941 ["setDate", 1],
1942 ["setFullYear", 3],
1943 ["setHours", 4],
1944 ["setMilliseconds", 1],
1945 ["setMinutes", 3],
1946 ["setMonth", 2],
1947 ["setSeconds", 2],
1948 ["setTime", 1],
1949 ["setUTCDate", 1],
1950 ["setUTCFullYear", 3],
1951 ["setUTCHours", 4],
1952 ["setUTCMilliseconds", 1],
1953 ["setUTCMinutes", 3],
1954 ["setUTCMonth", 2],
1955 ["setUTCSeconds", 2],
1956 ["toDateString", 0],
1957 ["toLocaleDateString", 0],
1958 ["toLocaleString", 0],
1959 ["toLocaleTimeString", 0],
1960 ["toString", 0],
1961 ["toTimeString", 0],
1962 ["toUTCString", 0],
1963 ["toGMTString", 0],
1964 ["valueOf", 0]
1967 testFunctions(Array.prototype, [
1968 ["concat", 1],
1969 ["join", 1],
1970 ["push", 1],
1971 ["pop", 0],
1972 ["reverse", 0],
1973 ["shift", 0],
1974 ["slice", 2],
1975 ["sort", 1],
1976 ["splice", 2],
1977 ["toLocaleString", 0],
1978 ["toString", 0],
1979 ["unshift", 1]
1982 testFunctions(Error.prototype, [
1983 ["toString", 0]
1986 testFunctions(Math, [
1987 ["abs", 1],
1988 ["acos", 1],
1989 ["asin", 1],
1990 ["atan", 1],
1991 ["atan2", 2],
1992 ["ceil", 1],
1993 ["cos", 1],
1994 ["exp", 1],
1995 ["floor", 1],
1996 ["log", 1],
1997 ["max", 2],
1998 ["min", 2],
1999 ["pow", 2],
2000 ["random", 0],
2001 ["round", 1],
2002 ["sin", 1],
2003 ["sqrt", 1],
2004 ["tan", 1]
2007 testFunctions(Object.prototype, [
2008 ["hasOwnProperty", 1],
2009 ["isPrototypeOf", 1],
2010 ["propertyIsEnumerable", 1],
2011 ["toLocaleString", 0],
2012 ["toString", 0],
2013 ["valueOf", 0]
2016 testFunctions(Function.prototype, [
2017 ["apply", 2],
2018 ["call", 1],
2019 ["toString", 0]
2022 ok(ActiveXObject.length == 1, "ActiveXObject.length = " + ActiveXObject.length);
2023 ok(Array.length == 1, "Array.length = " + Array.length);
2024 ok(Boolean.length == 1, "Boolean.length = " + Boolean.length);
2025 ok(CollectGarbage.length == 0, "CollectGarbage.length = " + CollectGarbage.length);
2026 //ok(Date.length == 7, "Date.length = " + Date.length);
2027 ok(Enumerator.length == 7, "Enumerator.length = " + Enumerator.length);
2028 ok(Error.length == 1, "Error.length = " + Error.length);
2029 ok(EvalError.length == 1, "EvalError.length = " + EvalError.length);
2030 ok(Function.length == 1, "Function.length = " + Function.length);
2031 ok(GetObject.length == 2, "GetObject.length = " + GetObject.length);
2032 ok(Number.length == 1, "Number.length = " + Number.length);
2033 ok(Object.length == 0, "Object.length = " + Object.length);
2034 ok(RangeError.length == 1, "RangeError.length = " + RangeError.length);
2035 ok(ReferenceError.length == 1, "ReferenceError.length = " + ReferenceError.length);
2036 ok(RegExp.length == 2, "RegExp.length = " + RegExp.length);
2037 ok(ScriptEngine.length == 0, "ScriptEngine.length = " + ScriptEngine.length);
2038 ok(ScriptEngineBuildVersion.length == 0,
2039 "ScriptEngineBuildVersion.length = " + ScriptEngineBuildVersion.length);
2040 ok(ScriptEngineMajorVersion.length == 0,
2041 "ScriptEngineMajorVersion.length = " + ScriptEngineMajorVersion.length);
2042 ok(ScriptEngineMinorVersion.length == 0,
2043 "ScriptEngineMinorVersion.length = " + ScriptEngineMinorVersion.length);
2044 //ok(String.length == 1, "String.length = " + String.length);
2045 ok(SyntaxError.length == 1, "SyntaxError.length = " + SyntaxError.length);
2046 ok(TypeError.length == 1, "TypeError.length = " + TypeError.length);
2047 ok(URIError.length == 1, "URIError.length = " + URIError.length);
2048 ok(VBArray.length == 1, "VBArray.length = " + VBArray.length);
2049 ok(decodeURI.length == 1, "decodeURI.length = " + decodeURI.length);
2050 ok(decodeURIComponent.length == 1, "decodeURIComponent.length = " + decodeURIComponent.length);
2051 ok(encodeURI.length == 1, "encodeURI.length = " + encodeURI.length);
2052 ok(encodeURIComponent.length == 1, "encodeURIComponent.length = " + encodeURIComponent.length);
2053 ok(escape.length == 1, "escape.length = " + escape.length);
2054 ok(eval.length == 1, "eval.length = " + eval.length);
2055 ok(isFinite.length == 1, "isFinite.length = " + isFinite.length);
2056 ok(isNaN.length == 1, "isNaN.length = " + isNaN.length);
2057 ok(parseFloat.length == 1, "parseFloat.length = " + parseFloat.length);
2058 ok(parseInt.length == 2, "parseInt.length = " + parseInt.length);
2059 ok(unescape.length == 1, "unescape.length = " + unescape.length);
2061 reportSuccess();