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
21 ok(ScriptEngine() === "JScript", "ScriptEngine() = " + ScriptEngine());
22 ok(ScriptEngine(3) === "JScript", "ScriptEngine(3) = " + ScriptEngine(3));
23 ok(ScriptEngineMajorVersion() === ScriptEngineMajorVersion(2), "ScriptEngineMajorVersion() !== ScriptEngineMajorVersion(2)");
24 ok(ScriptEngineMinorVersion() === ScriptEngineMinorVersion(2), "ScriptEngineMinorVersion() !== ScriptEngineMinorVersion(2)");
25 ok(ScriptEngineBuildVersion() === ScriptEngineBuildVersion(2), "ScriptEngineBuildVersion() !== ScriptEngineBuildVersion(2)");
28 ok(i === 0, "parseInt('0') = " + i);
30 ok(i === 123, "parseInt('123') = " + i);
32 ok(i === -123, "parseInt('-123') = " + i);
34 ok(i === 0xff, "parseInt('0xff') = " + i);
35 i = parseInt("11", 8);
36 ok(i === 9, "parseInt('11', 8) = " + i);
37 i = parseInt("1j", 22);
38 ok(i === 41, "parseInt('1j', 32) = " + i);
39 i = parseInt("123", 0);
40 ok(i === 123, "parseInt('123', 0) = " + i);
41 i = parseInt("123", 10, "test");
42 ok(i === 123, "parseInt('123', 10, 'test') = " + i);
43 i = parseInt("11", "8");
44 ok(i === 9, "parseInt('11', '8') = " + i);
46 ok(i === 8, "parseInt('010') = " + i);
48 ok(isNaN(i), "parseInt('') = " + i);
50 ok(isNaN(i), "parseInt('0x') = " + i);
52 ok(isNaN(i), "parseInt('+') = " + i);
54 ok(isNaN(i), "parseInt('-') = " + i);
55 i = parseInt("0x10", 11);
56 ok(i === 0, "parseInt('0x10', 11) = " + i);
57 i = parseInt("010", 7);
58 ok(i === 7, "parseInt('010', 7) = " + i);
59 i = parseInt("123abc");
60 ok(i === 123, "parseInt('123abc') = " + i);
61 i = parseInt(" \t123abc");
62 ok(i === 123, "parseInt(' \\t123abc') = " + i);
64 ok(isNaN(i), "parseInt('123abc') = " + i);
65 i = parseInt("-12", 11);
66 ok(i === -13, "parseInt('-12') = " + i);
67 i = parseInt("-0x10");
68 ok(i === -16, "parseInt('-0x10') = " + i);
70 ok(i === -8, "parseInt('-010') = " + i);
71 i = parseInt("123", 0);
72 ok(i === 123, "parseInt('123', 0) = " + i);
73 i = parseInt("0x10", 0);
74 ok(i === 16, "parseInt('123', 0) = " + i);
75 i = parseInt("0x10", 10);
76 ok(i === 0, "parseInt('0x10', 10) = " + i);
78 ok(isNaN(i), "parseInt('0xz') = " + i);
80 ok(isNaN(i), "parseInt('1', 1) = " + i);
81 i = parseInt("1", -1);
82 ok(isNaN(i), "parseInt('1', -1) = " + i);
83 i = parseInt("1", 37);
84 ok(isNaN(i), "parseInt('1', 37) = " + i);
85 i = parseInt("1", 36);
86 ok(i === 1, "parseInt('1', 36) = " + i);
88 tmp = encodeURI("abc");
89 ok(tmp === "abc", "encodeURI('abc') = " + tmp);
90 tmp = encodeURI("{abc}");
91 ok(tmp === "%7Babc%7D", "encodeURI('{abc}') = " + tmp);
93 ok(tmp === "", "encodeURI('') = " + tmp);
94 tmp = encodeURI("\01\02\03\04");
95 ok(tmp === "%01%02%03%04", "encodeURI('\\01\\02\\03\\04') = " + tmp);
96 tmp = encodeURI("{#@}");
97 ok(tmp === "%7B#@%7D", "encodeURI('{#@}') = " + tmp);
98 tmp = encodeURI("\xa1 ");
99 ok(tmp === "%C2%A1%20", "encodeURI(\\xa1 ) = " + tmp);
100 tmp = encodeURI("\xffff");
101 ok(tmp.length === 8, "encodeURI('\\xffff').length = " + tmp.length);
102 tmp = encodeURI("abcABC123;/?:@&=+$,-_.!~*'()");
103 ok(tmp === "abcABC123;/?:@&=+$,-_.!~*'()", "encodeURI('abcABC123;/?:@&=+$,-_.!~*'()') = " + tmp);
105 ok(tmp === "undefined", "encodeURI() = " + tmp);
106 tmp = encodeURI("abc", "test");
107 ok(tmp === "abc", "encodeURI('abc') = " + tmp);
109 tmp = encodeURIComponent("abc");
110 ok(tmp === "abc", "encodeURIComponent('abc') = " + tmp);
111 dec = decodeURIComponent(tmp);
112 ok(dec === "abc", "decodeURIComponent('" + tmp + "') = " + dec);
113 tmp = encodeURIComponent("{abc}");
114 ok(tmp === "%7Babc%7D", "encodeURIComponent('{abc}') = " + tmp);
115 dec = decodeURIComponent(tmp);
116 ok(dec === "{abc}", "decodeURIComponent('" + tmp + "') = " + dec);
117 tmp = encodeURIComponent("");
118 ok(tmp === "", "encodeURIComponent('') = " + tmp);
119 dec = decodeURIComponent(tmp);
120 ok(dec === "", "decodeURIComponent('" + tmp + "') = " + dec);
121 tmp = encodeURIComponent("\01\02\03\04");
122 ok(tmp === "%01%02%03%04", "encodeURIComponent('\\01\\02\\03\\04') = " + tmp);
123 dec = decodeURIComponent(tmp);
124 ok(dec === "\01\02\03\04", "decodeURIComponent('" + tmp + "') = " + dec);
125 tmp = encodeURIComponent("{#@}");
126 ok(tmp === "%7B%23%40%7D", "encodeURIComponent('{#@}') = " + tmp);
127 dec = decodeURIComponent(tmp);
128 ok(dec === "{#@}", "decodeURIComponent('" + tmp + "') = " + dec);
129 tmp = encodeURIComponent("\xa1 ");
130 ok(tmp === "%C2%A1%20", "encodeURIComponent(\\xa1 ) = " + tmp);
131 dec = decodeURIComponent(tmp);
132 ok(dec === "\xa1 ", "decodeURIComponent('" + tmp + "') = " + dec);
133 tmp = encodeURIComponent("\xffff");
134 ok(tmp.length === 8, "encodeURIComponent('\\xffff').length = " + tmp.length);
135 dec = decodeURIComponent(tmp);
136 ok(dec === "\xffff", "decodeURIComponent('" + tmp + "') = " + dec);
137 tmp = encodeURIComponent("abcABC123;/?:@&=+$,-_.!~*'()");
138 ok(tmp === "abcABC123%3B%2F%3F%3A%40%26%3D%2B%24%2C-_.!~*'()", "encodeURIComponent('abcABC123;/?:@&=+$,-_.!~*'()') = " + tmp);
139 dec = decodeURIComponent(tmp);
140 ok(dec === "abcABC123;/?:@&=+$,-_.!~*'()", "decodeURIComponent('" + tmp + "') = " + dec);
141 tmp = encodeURIComponent();
142 ok(tmp === "undefined", "encodeURIComponent() = " + tmp);
143 tmp = encodeURIComponent("abc", "test");
144 ok(tmp === "abc", "encodeURIComponent('abc') = " + tmp);
145 dec = decodeURIComponent();
146 ok(dec === "undefined", "decodeURIComponent() = " + dec);
147 dec = decodeURIComponent("abc", "test");
148 ok(dec === "abc", "decodeURIComponent('abc') = " + dec);
151 ok(tmp === "abc", "escape('abc') = " + tmp);
153 ok(tmp === "", "escape('') = " + tmp);
154 tmp = escape("a1b c!d+e@*-_+./,");
155 ok(tmp === "a1b%20c%21d+e@*-_+./%2C", "escape('a1b c!d+e@*-_+./,') = " + tmp);
157 ok(tmp === "undefined", "escape() = " + tmp);
158 tmp = escape('\u1234\123\xf3');
159 ok(tmp == "%u1234S%F3", "escape('\u1234\123\xf3') = " + tmp);
161 tmp = unescape("abc");
162 ok(tmp === "abc", "unescape('abc') = " + tmp);
164 ok(tmp === "", "unescape('') = " + tmp);
165 tmp = unescape("%%%");
166 ok(tmp === "%%%", "unescape('%%%') = " + tmp);
168 ok(tmp === "undefined", "unescape() = " + tmp);
169 tmp = unescape("%54%65s%u0074");
170 ok(tmp === "Test", "unescape('%54%65s%u0074') = " + tmp);
172 tmp = "aA1~`!@#$%^&*()_+=-][{}';:/.,<>?\|";
173 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));
174 ok(unescape(escape(tmp)) === tmp, "unescape(escape('" + tmp + "')) = " + unescape(escape(tmp)));
176 tmp = "" + new Object();
177 ok(tmp === "[object Object]", "'' + new Object() = " + tmp);
178 (tmp = new Array).f = Object.prototype.toString;
179 ok(tmp.f() === "[object Array]", "tmp.f() = " + tmp.f());
180 (tmp = new Boolean).f = Object.prototype.toString;
181 ok(tmp.f() === "[object Boolean]", "tmp.f() = " + tmp.f());
182 (tmp = new Date).f = Object.prototype.toString;
183 ok(tmp.f() === "[object Date]", "tmp.f() = " + tmp.f());
184 (tmp = function() {}).f = Object.prototype.toString;
185 ok(tmp.f() === "[object Function]", "tmp.f() = " + tmp.f());
186 Math.f = Object.prototype.toString;
187 ok(Math.f() === "[object Math]", "tmp.f() = " + tmp.f());
188 (tmp = new Number).f = Object.prototype.toString;
189 ok(tmp.f() === "[object Number]", "tmp.f() = " + tmp.f());
190 (tmp = new RegExp("")).f = Object.prototype.toString;
191 ok(tmp.f() === "[object RegExp]", "tmp.f() = " + tmp.f());
192 (tmp = new String).f = Object.prototype.toString;
193 ok(tmp.f() === "[object String]", "tmp.f() = " + tmp.f());
194 tmp = Object.prototype.toString.call(testObj);
195 ok(tmp === "[object Object]", "toString.call(testObj) = " + tmp);
196 tmp = Object.prototype.toString.call(this);
197 ok(tmp === "[object Object]", "toString.call(this) = " + tmp);
198 (function () { tmp = Object.prototype.toString.call(arguments); })();
199 ok(tmp === "[object Object]", "toString.call(arguments) = " + tmp);
200 tmp = Object.prototype.toString.call(new VBArray(createArray()));
201 ok(tmp === "[object Object]", "toString.call(new VBArray()) = " + tmp);
203 ok(Object(1) instanceof Number, "Object(1) is not instance of Number");
204 ok(Object("") instanceof String, "Object('') is not instance of String");
205 ok(Object(false) instanceof Boolean, "Object(false) is not instance of Boolean");
208 ok(Object(obj) === obj, "Object(obj) !== obj");
210 ok(typeof(Object()) === "object", "typeof(Object()) !== 'object'");
211 ok(typeof(Object(undefined)) === "object", "typeof(Object(undefined)) !== 'object'");
212 ok(typeof(Object(null)) === "object", "typeof(Object(null)) !== 'object'");
214 var obj = new Object();
215 obj.toString = function (x) {
216 ok(arguments.length === 0, "arguments.length = " + arguments.length);
219 ok((tmp = obj.toLocaleString()) === "test", "obj.toLocaleString() = " + tmp);
220 ok((tmp = obj.toLocaleString(1)) === "test", "obj.toLocaleString(1) = " + tmp);
221 ok(obj === obj.valueOf(), "obj !== obj.valueOf");
223 ok("".length === 0, "\"\".length = " + "".length);
224 ok(getVT("".length) == "VT_I4", "\"\".length = " + "".length);
225 ok("abc".length === 3, "\"abc\".length = " + "abc".length);
226 ok(String.prototype.length === 0, "String.prototype.length = " + String.prototype.length);
229 ok(tmp === "", "''.toString() = " + tmp);
230 tmp = "test".toString();
231 ok(tmp === "test", "''.toString() = " + tmp);
232 tmp = "test".toString(3);
233 ok(tmp === "test", "''.toString(3) = " + tmp);
236 ok(tmp === "", "''.valueOf() = " + tmp);
237 tmp = "test".valueOf();
238 ok(tmp === "test", "''.valueOf() = " + tmp);
239 tmp = "test".valueOf(3);
240 ok(tmp === "test", "''.valueOf(3) = " + tmp);
242 var str = new String("test");
243 ok(str.toString() === "test", "str.toString() = " + str.toString());
244 var str = new String();
245 ok(str.toString() === "", "str.toString() = " + str.toString());
246 var str = new String("test", "abc");
247 ok(str.toString() === "test", "str.toString() = " + str.toString());
249 var strObj = new Object();
250 strObj.toString = function() { return "abcd" };
251 strObj.substr = String.prototype.substr;
252 strObj.lastIndexOf = String.prototype.lastIndexOf;
254 tmp = "value " + str;
255 ok(tmp === "value test", "'value ' + str = " + tmp);
258 ok(tmp === "", "String() = " + tmp);
260 ok(tmp === "false", "String(false) = " + tmp);
262 ok(tmp === "null", "String(null) = " + tmp);
263 tmp = String("test");
264 ok(tmp === "test", "String('test') = " + tmp);
265 tmp = String("test", "abc");
266 ok(tmp === "test", "String('test','abc') = " + tmp);
268 tmp = "abc".charAt(0);
269 ok(tmp === "a", "'abc',charAt(0) = " + tmp);
270 tmp = "abc".charAt(1);
271 ok(tmp === "b", "'abc',charAt(1) = " + tmp);
272 tmp = "abc".charAt(2);
273 ok(tmp === "c", "'abc',charAt(2) = " + tmp);
274 tmp = "abc".charAt(3);
275 ok(tmp === "", "'abc',charAt(3) = " + tmp);
276 tmp = "abc".charAt(4);
277 ok(tmp === "", "'abc',charAt(4) = " + tmp);
278 tmp = "abc".charAt();
279 ok(tmp === "a", "'abc',charAt() = " + tmp);
280 tmp = "abc".charAt(-1);
281 ok(tmp === "", "'abc',charAt(-1) = " + tmp);
282 tmp = "abc".charAt(0,2);
283 ok(tmp === "a", "'abc',charAt(0.2) = " + tmp);
284 tmp = "abc".charAt(NaN);
285 ok(tmp === "a", "'abc',charAt(NaN) = " + tmp);
287 tmp = "abc".charCodeAt(0);
288 ok(tmp === 0x61, "'abc'.charCodeAt(0) = " + tmp);
289 tmp = "abc".charCodeAt(1);
290 ok(tmp === 0x62, "'abc'.charCodeAt(1) = " + tmp);
291 tmp = "abc".charCodeAt(2);
292 ok(tmp === 0x63, "'abc'.charCodeAt(2) = " + tmp);
293 tmp = "abc".charCodeAt();
294 ok(tmp === 0x61, "'abc'.charCodeAt() = " + tmp);
295 tmp = "abc".charCodeAt(true);
296 ok(tmp === 0x62, "'abc'.charCodeAt(true) = " + tmp);
297 tmp = "abc".charCodeAt(0,2);
298 ok(tmp === 0x61, "'abc'.charCodeAt(0,2) = " + tmp);
299 tmp = "\u49F4".charCodeAt(0);
300 ok(tmp === 0x49F4, "'\u49F4'.charCodeAt(0) = " + tmp);
301 tmp = "\052".charCodeAt(0);
302 ok(tmp === 0x2A, "'\052'.charCodeAt(0) = " + tmp);
303 tmp = "\xa2".charCodeAt(0);
304 ok(tmp === 0xA2, "'\xa2'.charCodeAt(0) = " + tmp);
306 tmp = "abcd".substring(1,3);
307 ok(tmp === "bc", "'abcd'.substring(1,3) = " + tmp);
308 tmp = "abcd".substring(-1,3);
309 ok(tmp === "abc", "'abcd'.substring(-1,3) = " + tmp);
310 tmp = "abcd".substring(1,6);
311 ok(tmp === "bcd", "'abcd'.substring(1,6) = " + tmp);
312 tmp = "abcd".substring(3,1);
313 ok(tmp === "bc", "'abcd'.substring(3,1) = " + tmp);
314 tmp = "abcd".substring(2,2);
315 ok(tmp === "", "'abcd'.substring(2,2) = " + tmp);
316 tmp = "abcd".substring(true,"3");
317 ok(tmp === "bc", "'abcd'.substring(true,'3') = " + tmp);
318 tmp = "abcd".substring(1,3,2);
319 ok(tmp === "bc", "'abcd'.substring(1,3,2) = " + tmp);
320 tmp = "abcd".substring();
321 ok(tmp === "abcd", "'abcd'.substring() = " + tmp);
323 tmp = "abcd".substr(1,3);
324 ok(tmp === "bcd", "'abcd'.substr(1,3) = " + tmp);
325 tmp = "abcd".substr(-1,3);
326 ok(tmp === "abc", "'abcd'.substr(-1,3) = " + tmp);
327 tmp = "abcd".substr(1,6);
328 ok(tmp === "bcd", "'abcd'.substr(1,6) = " + tmp);
329 tmp = "abcd".substr(2,-1);
330 ok(tmp === "", "'abcd'.substr(3,1) = " + tmp);
331 tmp = "abcd".substr(2,0);
332 ok(tmp === "", "'abcd'.substr(2,2) = " + tmp);
333 tmp = "abcd".substr(true,"3");
334 ok(tmp === "bcd", "'abcd'.substr(true,'3') = " + tmp);
335 tmp = "abcd".substr(1,3,2);
336 ok(tmp === "bcd", "'abcd'.substr(1,3,2) = " + tmp);
337 tmp = "abcd".substr();
338 ok(tmp === "abcd", "'abcd'.substr() = " + tmp);
339 tmp = strObj.substr(1,1);
340 ok(tmp === "b", "'abcd'.substr(1,3) = " + tmp);
342 tmp = "abcd".slice(1,3);
343 ok(tmp === "bc", "'abcd'.slice(1,3) = " + tmp);
344 tmp = "abcd".slice(1,-1);
345 ok(tmp === "bc", "'abcd'.slice(1,-1) = " + tmp);
346 tmp = "abcd".slice(-3,3);
347 ok(tmp === "bc", "'abcd'.slice(-3,3) = " + tmp);
348 tmp = "abcd".slice(-6,3);
349 ok(tmp === "abc", "'abcd'.slice(-6,3) = " + tmp);
350 tmp = "abcd".slice(3,1);
351 ok(tmp === "", "'abcd'.slice(3,1) = " + tmp);
352 tmp = "abcd".slice(true,3);
353 ok(tmp === "bc", "'abcd'.slice(true,3) = " + tmp);
354 tmp = "abcd".slice();
355 ok(tmp === "abcd", "'abcd'.slice() = " + tmp);
356 tmp = "abcd".slice(1);
357 ok(tmp === "bcd", "'abcd'.slice(1) = " + tmp);
359 tmp = "abc".concat(["d",1],2,false);
360 ok(tmp === "abcd,12false", "concat returned " + tmp);
361 var arr = new Array(2,"a");
362 arr.concat = String.prototype.concat;
363 tmp = arr.concat("d");
364 ok(tmp === "2,ad", "arr.concat = " + tmp);
366 m = "a+bcabc".match("a+");
367 ok(typeof(m) === "object", "typeof m is not object");
368 ok(m.length === 1, "m.length is not 1");
369 ok(m["0"] === "a", "m[0] is not \"ab\"");
371 r = "- [test] -".replace("[test]", "success");
372 ok(r === "- success -", "r = " + r + " expected '- success -'");
374 r = "- [test] -".replace("[test]", "success", "test");
375 ok(r === "- success -", "r = " + r + " expected '- success -'");
377 r = "test".replace();
378 ok(r === "test", "r = " + r + " expected 'test'");
380 function replaceFunc3(m, off, str) {
381 ok(arguments.length === 3, "arguments.length = " + arguments.length);
382 ok(m === "[test]", "m = " + m + " expected [test1]");
383 ok(off === 1, "off = " + off + " expected 0");
384 ok(str === "-[test]-", "str = " + arguments[3]);
388 r = "-[test]-".replace("[test]", replaceFunc3);
389 ok(r === "-ret-", "r = " + r + " expected '-ret-'");
391 r = "-[test]-".replace("[test]", replaceFunc3, "test");
392 ok(r === "-ret-", "r = " + r + " expected '-ret-'");
394 r = "1,2,3".split(",");
395 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
396 ok(r.length === 3, "r.length = " + r.length);
397 ok(r[0] === "1", "r[0] = " + r[0]);
398 ok(r[1] === "2", "r[1] = " + r[1]);
399 ok(r[2] === "3", "r[2] = " + r[2]);
402 r = "1,2,3".split(",*");
403 ok(r.length === 1, "r.length = " + r.length);
404 ok(r[0] === "1,2,3", "r[0] = " + r[0]);
407 ok(r.length === 3, "r.length = " + r.length);
408 ok(r[0] === "1", "r[0] = " + r[0]);
409 ok(r[1] === "2", "r[1] = " + r[1]);
410 ok(r[2] === "3", "r[2] = " + r[2]);
413 ok(r.length === 2, "r.length = " + r.length);
414 ok(r[0] === "1", "r[0] = " + r[0]);
415 ok(r[1] === "3", "r[1] = " + r[1]);
417 r = "1,2,".split(",");
418 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
419 ok(r.length === 3, "r.length = " + r.length);
420 ok(r[0] === "1", "r[0] = " + r[0]);
421 ok(r[1] === "2", "r[1] = " + r[1]);
422 ok(r[2] === "", "r[2] = " + r[2]);
424 tmp = "abcd".indexOf("bc",0);
425 ok(tmp === 1, "indexOf = " + tmp);
426 tmp = "abcd".indexOf("bc",1);
427 ok(tmp === 1, "indexOf = " + tmp);
428 tmp = "abcd".indexOf("bc");
429 ok(tmp === 1, "indexOf = " + tmp);
430 tmp = "abcd".indexOf("ac");
431 ok(tmp === -1, "indexOf = " + tmp);
432 tmp = "abcd".indexOf("bc",2);
433 ok(tmp === -1, "indexOf = " + tmp);
434 tmp = "abcd".indexOf("a",0);
435 ok(tmp === 0, "indexOf = " + tmp);
436 tmp = "abcd".indexOf("bc",0,"test");
437 ok(tmp === 1, "indexOf = " + tmp);
438 tmp = "abcd".indexOf();
439 ok(tmp == -1, "indexOf = " + tmp);
441 tmp = "abcd".lastIndexOf("bc",1);
442 ok(tmp === 1, "lastIndexOf = " + tmp);
443 tmp = "abcd".lastIndexOf("bc",2);
444 ok(tmp === 1, "lastIndexOf = " + tmp);
445 tmp = "abcd".lastIndexOf("bc");
446 ok(tmp === 1, "lastIndexOf = " + tmp);
447 tmp = "abcd".lastIndexOf("ac");
448 ok(tmp === -1, "lastIndexOf = " + tmp);
449 tmp = "abcd".lastIndexOf("d",10);
450 ok(tmp === 3, "lastIndexOf = " + tmp);
451 tmp = "abcd".lastIndexOf("bc",0,"test");
452 ok(tmp === -1, "lastIndexOf = " + tmp);
453 tmp = "abcd".lastIndexOf();
454 ok(tmp === -1, "lastIndexOf = " + tmp);
455 tmp = "aaaa".lastIndexOf("a",2);
456 ok(tmp == 2, "lastIndexOf = " + tmp);
457 tmp = strObj.lastIndexOf("b");
458 ok(tmp === 1, "lastIndexOf = " + tmp);
460 tmp = "".toLowerCase();
461 ok(tmp === "", "''.toLowerCase() = " + tmp);
462 tmp = "test".toLowerCase();
463 ok(tmp === "test", "''.toLowerCase() = " + tmp);
464 tmp = "test".toLowerCase(3);
465 ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
466 tmp = "tEsT".toLowerCase();
467 ok(tmp === "test", "''.toLowerCase() = " + tmp);
468 tmp = "tEsT".toLowerCase(3);
469 ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
471 tmp = "".toUpperCase();
472 ok(tmp === "", "''.toUpperCase() = " + tmp);
473 tmp = "TEST".toUpperCase();
474 ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
475 tmp = "TEST".toUpperCase(3);
476 ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
477 tmp = "tEsT".toUpperCase();
478 ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
479 tmp = "tEsT".toUpperCase(3);
480 ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
483 ok(tmp === "<A NAME=\"undefined\"></A>", "''.anchor() = " + tmp);
485 ok(tmp === "<A NAME=\"3\"></A>", "''.anchor(3) = " + tmp);
486 tmp = "".anchor("red");
487 ok(tmp === "<A NAME=\"red\"></A>", "''.anchor('red') = " + tmp);
488 tmp = "test".anchor();
489 ok(tmp === "<A NAME=\"undefined\">test</A>", "'test'.anchor() = " + tmp);
490 tmp = "test".anchor(3);
491 ok(tmp === "<A NAME=\"3\">test</A>", "'test'.anchor(3) = " + tmp);
492 tmp = "test".anchor("green");
493 ok(tmp === "<A NAME=\"green\">test</A>", "'test'.anchor('green') = " + tmp);
496 ok(tmp === "<BIG></BIG>", "''.big() = " + tmp);
498 ok(tmp === "<BIG></BIG>", "''.big(3) = " + tmp);
500 ok(tmp === "<BIG>test</BIG>", "'test'.big() = " + tmp);
502 ok(tmp === "<BIG>test</BIG>", "'test'.big(3) = " + tmp);
505 ok(tmp === "<BLINK></BLINK>", "''.blink() = " + tmp);
507 ok(tmp === "<BLINK></BLINK>", "''.blink(3) = " + tmp);
508 tmp = "test".blink();
509 ok(tmp === "<BLINK>test</BLINK>", "'test'.blink() = " + tmp);
510 tmp = "test".blink(3);
511 ok(tmp === "<BLINK>test</BLINK>", "'test'.blink(3) = " + tmp);
514 ok(tmp === "<B></B>", "''.bold() = " + tmp);
516 ok(tmp === "<B></B>", "''.bold(3) = " + tmp);
518 ok(tmp === "<B>test</B>", "'test'.bold() = " + tmp);
519 tmp = "test".bold(3);
520 ok(tmp === "<B>test</B>", "'test'.bold(3) = " + tmp);
523 ok(tmp === "<TT></TT>", "''.fixed() = " + tmp);
525 ok(tmp === "<TT></TT>", "''.fixed(3) = " + tmp);
526 tmp = "test".fixed();
527 ok(tmp === "<TT>test</TT>", "'test'.fixed() = " + tmp);
528 tmp = "test".fixed(3);
529 ok(tmp === "<TT>test</TT>", "'test'.fixed(3) = " + tmp);
531 tmp = "".fontcolor();
532 ok(tmp === "<FONT COLOR=\"undefined\"></FONT>", "''.fontcolor() = " + tmp);
533 tmp = "".fontcolor(3);
534 ok(tmp === "<FONT COLOR=\"3\"></FONT>", "''.fontcolor(3) = " + tmp);
535 tmp = "".fontcolor("red");
536 ok(tmp === "<FONT COLOR=\"red\"></FONT>", "''.fontcolor('red') = " + tmp);
537 tmp = "test".fontcolor();
538 ok(tmp === "<FONT COLOR=\"undefined\">test</FONT>", "'test'.fontcolor() = " + tmp);
539 tmp = "test".fontcolor(3);
540 ok(tmp === "<FONT COLOR=\"3\">test</FONT>", "'test'.fontcolor(3) = " + tmp);
541 tmp = "test".fontcolor("green");
542 ok(tmp === "<FONT COLOR=\"green\">test</FONT>", "'test'.fontcolor('green') = " + tmp);
545 ok(tmp === "<FONT SIZE=\"undefined\"></FONT>", "''.fontsize() = " + tmp);
546 tmp = "".fontsize(3);
547 ok(tmp === "<FONT SIZE=\"3\"></FONT>", "''.fontsize(3) = " + tmp);
548 tmp = "".fontsize("red");
549 ok(tmp === "<FONT SIZE=\"red\"></FONT>", "''.fontsize('red') = " + tmp);
550 tmp = "test".fontsize();
551 ok(tmp === "<FONT SIZE=\"undefined\">test</FONT>", "'test'.fontsize() = " + tmp);
552 tmp = "test".fontsize(3);
553 ok(tmp === "<FONT SIZE=\"3\">test</FONT>", "'test'.fontsize(3) = " + tmp);
554 tmp = "test".fontsize("green");
555 ok(tmp === "<FONT SIZE=\"green\">test</FONT>", "'test'.fontsize('green') = " + tmp);
557 tmp = ("".fontcolor()).fontsize();
558 ok(tmp === "<FONT SIZE=\"undefined\"><FONT COLOR=\"undefined\"></FONT></FONT>", "(''.fontcolor()).fontsize() = " + tmp);
561 ok(tmp === "<I></I>", "''.italics() = " + tmp);
563 ok(tmp === "<I></I>", "''.italics(3) = " + tmp);
564 tmp = "test".italics();
565 ok(tmp === "<I>test</I>", "'test'.italics() = " + tmp);
566 tmp = "test".italics(3);
567 ok(tmp === "<I>test</I>", "'test'.italics(3) = " + tmp);
570 ok(tmp === "<A HREF=\"undefined\"></A>", "''.link() = " + tmp);
572 ok(tmp === "<A HREF=\"3\"></A>", "''.link(3) = " + tmp);
573 tmp = "".link("red");
574 ok(tmp === "<A HREF=\"red\"></A>", "''.link('red') = " + tmp);
576 ok(tmp === "<A HREF=\"undefined\">test</A>", "'test'.link() = " + tmp);
577 tmp = "test".link(3);
578 ok(tmp === "<A HREF=\"3\">test</A>", "'test'.link(3) = " + tmp);
579 tmp = "test".link("green");
580 ok(tmp === "<A HREF=\"green\">test</A>", "'test'.link('green') = " + tmp);
583 ok(tmp === "<SMALL></SMALL>", "''.small() = " + tmp);
585 ok(tmp === "<SMALL></SMALL>", "''.small(3) = " + tmp);
586 tmp = "test".small();
587 ok(tmp === "<SMALL>test</SMALL>", "'test'.small() = " + tmp);
588 tmp = "test".small(3);
589 ok(tmp === "<SMALL>test</SMALL>", "'test'.small(3) = " + tmp);
592 ok(tmp === "<STRIKE></STRIKE>", "''.strike() = " + tmp);
594 ok(tmp === "<STRIKE></STRIKE>", "''.strike(3) = " + tmp);
595 tmp = "test".strike();
596 ok(tmp === "<STRIKE>test</STRIKE>", "'test'.strike() = " + tmp);
597 tmp = "test".strike(3);
598 ok(tmp === "<STRIKE>test</STRIKE>", "'test'.strike(3) = " + tmp);
601 ok(tmp === "<SUB></SUB>", "''.sub() = " + tmp);
603 ok(tmp === "<SUB></SUB>", "''.sub(3) = " + tmp);
605 ok(tmp === "<SUB>test</SUB>", "'test'.sub() = " + tmp);
607 ok(tmp === "<SUB>test</SUB>", "'test'.sub(3) = " + tmp);
610 ok(tmp === "<SUP></SUP>", "''.sup() = " + tmp);
612 ok(tmp === "<SUP></SUP>", "''.sup(3) = " + tmp);
614 ok(tmp === "<SUP>test</SUP>", "'test'.sup() = " + tmp);
616 ok(tmp === "<SUP>test</SUP>", "'test'.sup(3) = " + tmp);
618 ok(String.fromCharCode() === "", "String.fromCharCode() = " + String.fromCharCode());
619 ok(String.fromCharCode(65,"66",67) === "ABC", "String.fromCharCode(65,'66',67) = " + String.fromCharCode(65,"66",67));
620 ok(String.fromCharCode(1024*64+65, -1024*64+65) === "AA",
621 "String.fromCharCode(1024*64+65, -1024*64+65) = " + String.fromCharCode(1024*64+65, -1024*64+65));
622 ok(String.fromCharCode(65, NaN, undefined).length === 3,
623 "String.fromCharCode(65, NaN, undefined).length = " + String.fromCharCode(65, NaN, undefined).length);
625 var arr = new Array();
626 ok(typeof(arr) === "object", "arr () is not object");
627 ok((arr.length === 0), "arr.length is not 0");
628 ok(arr["0"] === undefined, "arr[0] is not undefined");
630 var arr = new Array(1, 2, "test");
631 ok(typeof(arr) === "object", "arr (1,2,test) is not object");
632 ok((arr.length === 3), "arr.length is not 3");
633 ok(arr["0"] === 1, "arr[0] is not 1");
634 ok(arr["1"] === 2, "arr[1] is not 2");
635 ok(arr["2"] === "test", "arr[2] is not \"test\"");
638 ok((arr.length === 8), "arr.length is not 8");
641 ok(tmp === "", "'' + [] = " + tmp);
643 ok(tmp === "1,true", "'' + [1,true] = " + tmp);
645 var arr = new Array(6);
646 ok(typeof(arr) === "object", "arr (6) is not object");
647 ok((arr.length === 6), "arr.length is not 6");
648 ok(arr["0"] === undefined, "arr[0] is not undefined");
650 ok(arr.push() === 6, "arr.push() !== 6");
651 ok(arr.push(1) === 7, "arr.push(1) !== 7");
652 ok(arr[6] === 1, "arr[6] != 1");
653 ok(arr.length === 7, "arr.length != 10");
654 ok(arr.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10");
655 ok(arr[8] === "b", "arr[8] != 'b'");
656 ok(arr.length === 10, "arr.length != 10");
658 var arr = new Object();
659 arr.push = Array.prototype.push;
663 ok(arr.push() === 6, "arr.push() !== 6");
664 ok(arr.push(1) === 7, "arr.push(1) !== 7");
665 ok(arr[6] === 1, "arr[6] != 1");
666 ok(arr.length === 7, "arr.length != 10");
667 ok(arr.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10");
668 ok(arr[8] === "b", "arr[8] != 'b'");
669 ok(arr.length === 10, "arr.length != 10");
671 arr.pop = Array.prototype.pop;
672 ok(arr.pop() === false, "arr.pop() !== false");
673 ok(arr[8] === "b", "arr[8] !== 'b'");
674 ok(arr.pop() === 'b', "arr.pop() !== 'b'");
675 ok(arr[8] === undefined, "arr[8] !== undefined");
679 ok(arr.length === 2, "arr.length = " + arr.length);
680 ok(tmp === 5, "pop() = " + tmp);
682 ok(arr.length === 1, "arr.length = " + arr.length);
683 ok(tmp === 4, "pop() = " + tmp);
685 ok(arr.length === 0, "arr.length = " + arr.length);
686 ok(tmp === 3, "pop() = " + tmp);
688 ok(false, "not deleted " + tmp);
690 ok(arr.length === 0, "arr.length = " + arr.length);
691 ok(tmp === undefined, "tmp = " + tmp);
693 arr.pop = Array.prototype.pop;
695 ok(arr.length === 0, "arr.length = " + arr.length);
696 ok(tmp === undefined, "tmp = " + tmp);
699 ok(arr.length === 5, "arr.length = " + arr.length);
700 ok(tmp === undefined, "tmp = " + tmp);
702 arr = [1,2,null,false,undefined,,"a"];
705 ok(tmp === "1,2,,false,,,a", "arr.join() = " + tmp);
707 ok(tmp === "1;2;;false;;;a", "arr.join(';') = " + tmp);
708 tmp = arr.join(";","test");
709 ok(tmp === "1;2;;false;;;a", "arr.join(';') = " + tmp);
711 ok(tmp === "12falsea", "arr.join('') = " + tmp);
713 tmp = arr.toString();
714 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
715 tmp = arr.toString("test");
716 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
723 arr.join = Array.prototype.join;
725 ok(arr.length === 3, "arr.length = " + arr.length);
726 ok(tmp === "aa,,2", "tmp = " + tmp);
728 arr = [5,true,2,-1,3,false,"2.5"];
729 tmp = arr.sort(function(x,y) { return y-x; });
730 ok(tmp === arr, "tmp !== arr");
731 tmp = [5,3,"2.5",2,true,false,-1];
732 for(var i=0; i < arr.length; i++)
733 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
735 arr = [5,false,2,0,"abc",3,"a",-1];
737 ok(tmp === arr, "tmp !== arr");
738 tmp = [-1,0,2,3,5,"a","abc",false];
739 for(var i=0; i < arr.length; i++)
740 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
742 arr = ["a", "b", "ab"];
743 tmp = ["a", "ab", "b"];
744 ok(arr.sort() === arr, "arr.sort() !== arr");
745 for(var i=0; i < arr.length; i++)
746 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
752 arr.sort = Array.prototype.sort;
754 ok(arr === tmp, "tmp !== arr");
755 ok(arr[0]===1 && arr[1]==="aa" && arr[2]===undefined, "arr is sorted incorectly");
757 tmp = [["bb","aa"],["ab","aa"]].sort().toString();
758 ok(tmp === "ab,aa,bb,aa", "sort() = " + tmp);
760 tmp = [["bb","aa"],"ab"].sort().toString();
761 ok(tmp === "ab,bb,aa", "sort() = " + tmp);
763 tmp = [["bb","aa"],"cc"].sort().toString();
764 ok(tmp === "bb,aa,cc", "sort() = " + tmp);
766 tmp = [2,"1"].sort().toString();
767 ok(tmp === "1,2", "sort() = " + tmp);
769 tmp = ["2",1].sort().toString();
770 ok(tmp === "1,2", "sort() = " + tmp);
772 tmp = [,,0,"z"].sort().toString();
773 ok(tmp === "0,z,,", "sort() = " + tmp);
775 tmp = ["a,b",["a","a"],["a","c"]].sort().toString();
776 ok(tmp === "a,a,a,b,a,c", "sort() = " + tmp);
778 arr = ["1", "2", "3"];
780 ok(arr.length === 1, "arr.length = " + arr.length);
782 ok(arr.length === 3, "arr.length = " + arr.length);
783 ok(arr.toString() === "1,,", "arr.toString() = " + arr.toString());
785 arr = Array("a","b","c");
786 ok(arr.toString() === "a,b,c", "arr.toString() = " + arr.toString());
788 ok(arr.valueOf === Object.prototype.valueOf, "arr.valueOf !== Object.prototype.valueOf");
789 ok(arr === arr.valueOf(), "arr !== arr.valueOf");
793 ok(tmp === arr, "tmp !== arr");
794 ok(arr.length === 3, "arr.length = " + arr.length);
795 ok(arr.toString() === "3,2,1", "arr.toString() = " + arr.toString());
801 ok(tmp === arr, "tmp !== arr");
802 ok(arr.length === 6, "arr.length = " + arr.length);
803 ok(arr.toString() === "1,,5,,,", "arr.toString() = " + arr.toString());
810 arr.reverse = Array.prototype.reverse;
812 ok(tmp === arr, "tmp !== arr");
813 ok(arr.length === 3, "arr.length = " + arr.length);
814 ok(arr[0] === 2 && arr[1] === undefined && arr[2] === "aa", "unexpected array");
817 tmp = arr.unshift(0);
818 ok(tmp === (invokeVersion < 2 ? undefined : 4), "[1,2,3].unshift(0) returned " +tmp);
819 ok(arr.length === 4, "arr.length = " + arr.length);
820 ok(arr.toString() === "0,1,2,3", "arr.toString() = " + arr.toString());
825 tmp = arr.unshift(-1,0);
826 ok(tmp === (invokeVersion < 2 ? undefined : 5), "unshift returned " +tmp);
827 ok(arr.length === 5, "arr.length = " + arr.length);
828 ok(arr.toString() === "-1,0,1,,3", "arr.toString() = " + arr.toString());
832 ok(tmp === (invokeVersion < 2 ? undefined : 3), "unshift returned " +tmp);
833 ok(arr.length === 3, "arr.length = " + arr.length);
834 ok(arr.toString() === "1,2,3", "arr.toString() = " + arr.toString());
840 tmp = Array.prototype.unshift.call(arr, 0);
841 ok(tmp === (invokeVersion < 2 ? undefined : 3), "unshift returned " +tmp);
842 ok(arr.length === 3, "arr.length = " + arr.length);
843 ok(arr[0] === 0 && arr[1] === 1 && arr[2] === 2, "unexpected array");
847 ok(tmp === 1, "[1,2,,4].shift() = " + tmp);
848 ok(arr.toString() === "2,,4", "arr = " + arr.toString());
852 ok(tmp === undefined, "[].shift() = " + tmp);
853 ok(arr.toString() === "", "arr = " + arr.toString());
857 ok(tmp === 1, "[1,2,,4].shift(2) = " + tmp);
858 ok(arr.toString() === "2,,4", "arr = " + arr.toString());
862 ok(tmp === 1, "[1,].shift() = " + tmp);
863 ok(arr.toString() === "", "arr = " + arr.toString());
869 tmp = Array.prototype.shift.call(obj);
870 ok(tmp === "test", "obj.shift() = " + tmp);
871 ok(obj.length == 2, "obj.length = " + obj.length);
872 ok(obj[1] === 3, "obj[1] = " + obj[1]);
874 var num = new Number(6);
876 tmp = arr.concat(3, [4,5], num);
877 ok(tmp !== arr, "tmp === arr");
878 for(var i=0; i<6; i++)
879 ok(tmp[i] === i, "tmp[" + i + "] = " + tmp[i]);
880 ok(tmp[6] === num, "tmp[6] !== num");
881 ok(tmp.length === 7, "tmp.length = " + tmp.length);
884 ok(arr.length === 0, "arr.length = " + arr.length);
887 tmp = arr.concat([2]);
888 ok(tmp.length === 3, "tmp.length = " + tmp.length);
889 ok(tmp[1] === undefined, "tmp[1] = " + tmp[1]);
891 arr = [1,false,'a',null,undefined,'a'];
892 ok(arr.slice(0,6).toString() === "1,false,a,,,a", "arr.slice(0,6).toString() = " + arr.slice(0,6));
893 ok(arr.slice(0,6).length === 6, "arr.slice(0,6).length = " + arr.slice(0,6).length);
894 ok(arr.slice().toString() === "1,false,a,,,a", "arr.slice().toString() = " + arr.slice());
895 ok(arr.slice("abc").toString() === "1,false,a,,,a", "arr.slice(\"abc\").toString() = " + arr.slice("abc"));
896 ok(arr.slice(3,8).toString() === ",,a", "arr.slice(3,8).toString() = " + arr.slice(3,8));
897 ok(arr.slice(3,8).length === 3, "arr.slice(3,8).length = " + arr.slice(3,8).length);
898 ok(arr.slice(1).toString() === "false,a,,,a", "arr.slice(1).toString() = " + arr.slice(1));
899 ok(arr.slice(-2).toString() === ",a", "arr.slice(-2).toString() = " + arr.slice(-2));
900 ok(arr.slice(3,1).toString() === "", "arr.slice(3,1).toString() = " + arr.slice(3,1));
901 tmp = arr.slice(0,6);
902 for(var i=0; i < arr.length; i++)
903 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
905 ok(arr.slice(5).toString() === "a,,,,,,,2", "arr.slice(5).toString() = " + arr.slice(5).toString());
906 ok(arr.slice(5).length === 8, "arr.slice(5).length = " + arr.slice(5).length);
909 tmp = arr.splice(2,2);
910 ok(tmp.toString() == "3,4", "arr.splice(2,2) returned " + tmp.toString());
911 ok(arr.toString() == "1,2,5", "arr.splice(2,2) is " + arr.toString());
914 tmp = arr.splice(2,2,"a");
915 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a') returned " + tmp.toString());
916 ok(arr.toString() == "1,2,a,5", "arr.splice(2,2,'a') is " + arr.toString());
919 tmp = arr.splice(2,2,'a','b','c');
920 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a','b','c') returned " + tmp.toString());
921 ok(arr.toString() == "1,2,a,b,c,5", "arr.splice(2,2,'a','b','c') is " + arr.toString());
924 tmp = arr.splice(2,2,'a','b','c');
925 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a','b','c') returned " + tmp.toString());
926 ok(arr.toString() == "1,2,a,b,c,", "arr.splice(2,2,'a','b','c') is " + arr.toString());
929 arr.splice(2,2,'a','b','c');
930 ok(arr.toString() == "1,2,a,b,c,", "arr.splice(2,2,'a','b','c') is " + arr.toString());
933 tmp = arr.splice(2,2,'a','b');
934 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a','b') returned " + tmp.toString());
935 ok(arr.toString() == "1,2,a,b,5", "arr.splice(2,2,'a','b') is " + arr.toString());
938 tmp = arr.splice(-1,2);
939 ok(tmp.toString() == "5", "arr.splice(-1,2) returned " + tmp.toString());
940 ok(arr.toString() == "1,2,3,4", "arr.splice(-1,2) is " + arr.toString());
943 tmp = arr.splice(-10,3);
944 ok(tmp.toString() == "1,2,3", "arr.splice(-10,3) returned " + tmp.toString());
945 ok(arr.toString() == "4,5", "arr.splice(-10,3) is " + arr.toString());
948 tmp = arr.splice(-10,100);
949 ok(tmp.toString() == "1,2,3,4,5", "arr.splice(-10,100) returned " + tmp.toString());
950 ok(arr.toString() == "", "arr.splice(-10,100) is " + arr.toString());
953 tmp = arr.splice(2,-1);
954 ok(tmp.toString() == "", "arr.splice(2,-1) returned " + tmp.toString());
955 ok(arr.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr.toString());
959 ok(tmp.toString() == "", "arr.splice(2,-1) returned " + tmp.toString());
960 ok(arr.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr.toString());
964 ok(tmp.toString() == "", "arr.splice(2,-1) returned " + tmp.toString());
965 ok(arr.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr.toString());
972 tmp = Array.prototype.splice.call(obj, 1, 1, 'a', 'b');
973 ok(tmp.toString() === "2", "obj.splice returned " + tmp);
974 ok(obj.length === 4, "obj.length = " + obj.length);
975 ok(obj[0] === 1, "obj[0] = " + obj[0]);
976 ok(obj[1] === 'a', "obj[1] = " + obj[1]);
977 ok(obj[2] === 'b', "obj[2] = " + obj[2]);
978 ok(obj[3] === 3, "obj[3] = " + obj[3]);
985 tmp = Array.prototype.slice.call(obj, 1, 2);
986 ok(tmp.length === 1, "tmp.length = " + tmp.length);
987 ok(tmp[0] === 2, "tmp[0] = " + tmp[0]);
989 var num = new Number(2);
990 ok(num.toString() === "2", "num(2).toString !== 2");
991 var num = new Number();
992 ok(num.toString() === "0", "num().toString !== 0");
994 ok(Number() === 0, "Number() = " + Number());
995 ok(Number(false) === 0, "Number(false) = " + Number(false));
996 ok(Number("43") === 43, "Number('43') = " + Number("43"));
998 tmp = (new Number(1)).valueOf();
999 ok(tmp === 1, "(new Number(1)).valueOf = " + tmp);
1000 tmp = (new Number(1,2)).valueOf();
1001 ok(tmp === 1, "(new Number(1,2)).valueOf = " + tmp);
1002 tmp = (new Number()).valueOf();
1003 ok(tmp === 0, "(new Number()).valueOf = " + tmp);
1004 tmp = Number.prototype.valueOf();
1005 ok(tmp === 0, "Number.prototype.valueOf = " + tmp);
1007 function equals(val, base) {
1010 var str = val.toString(base);
1012 for(i=0; i<str.length; i++) {
1013 if(str.substring(i, i+1) == '(') break;
1014 if(str.substring(i, i+1) == '.') break;
1015 num = num*base + parseInt(str.substring(i, i+1));
1018 if(str.substring(i, i+1) == '.') {
1020 for(i++; i<str.length; i++) {
1021 if(str.substring(i, i+1) == '(') break;
1022 num += parseInt(str.substring(i, i+1))/mult;
1027 if(str.substring(i, i+1) == '(') {
1028 exp = parseInt(str.substring(i+2));
1029 num *= Math.pow(base, exp);
1032 ok(num>val-val/1000 && num<val+val/1000, "equals: num = " + num);
1035 ok((10).toString(11) === "a", "(10).toString(11) = " + (10).toString(11));
1036 ok((213213433).toString(17) === "8e2ddcb", "(213213433).toString(17) = " + (213213433).toString(17));
1037 ok((-3254343).toString(33) === "-2oicf", "(-3254343).toString(33) = " + (-3254343).toString(33));
1038 ok((NaN).toString(12) === "NaN", "(NaN).toString(11) = " + (NaN).toString(11));
1039 ok((Infinity).toString(13) === "Infinity", "(Infinity).toString(11) = " + (Infinity).toString(11));
1040 for(i=2; i<10; i++) {
1042 equals(2305843009200000000, i);
1045 equals(1024*1024*1024*1024*1024*1024*1.9999, i);
1048 equals(4.65661287308e-10, i);
1049 ok((0).toString(i) === "0", "(0).toString("+i+") = " + (0).toString(i));
1052 ok(parseFloat('123') === 123, "parseFloat('123') = " + parseFloat('123'));
1053 ok(parseFloat('-13.7') === -13.7, "parseFloat('-13.7') = " + parseFloat('-13.7'));
1054 ok(parseFloat('-0.01e-2') === -0.01e-2, "parseFloat('-0.01e-2') = " + parseFloat('-0.01e-2'));
1055 ok(parseFloat('-12e+5') === -12e+5, "parseFloat('-12e+5') = " + parseFloat('-12e+5'));
1056 ok(parseFloat('1E5 not parsed') === 1E5, "parseFloat('1E5 not parsed') = " + parseFloat('1E5 not parsed'));
1057 ok(isNaN(parseFloat('not a number')), "parseFloat('not a number') is not NaN");
1058 ok(parseFloat('+13.2e-3') === 13.2e-3, "parseFloat('+13.2e-3') = " + parseFloat('+13.2e-3'));
1059 ok(parseFloat('.12') === 0.12, "parseFloat('.12') = " + parseFloat('.12'));
1060 ok(parseFloat('1e') === 1, "parseFloat('1e') = " + parseFloat('1e'));
1063 ok(tmp === 1, "Math.min(1) = " + tmp);
1065 tmp = Math.min(1, false);
1066 ok(tmp === 0, "Math.min(1, false) = " + tmp);
1069 ok(tmp === Infinity, "Math.min() = " + tmp);
1071 tmp = Math.min(1, NaN, -Infinity, false);
1072 ok(isNaN(tmp), "Math.min(1, NaN, -Infinity, false) is not NaN");
1074 tmp = Math.min(1, false, true, null, -3);
1075 ok(tmp === -3, "Math.min(1, false, true, null, -3) = " + tmp);
1078 ok(tmp === 1, "Math.max(1) = " + tmp);
1080 tmp = Math.max(true, 0);
1081 ok(tmp === 1, "Math.max(true, 0) = " + tmp);
1083 tmp = Math.max(-2, false, true, null, 1);
1084 ok(tmp === 1, "Math.max(-2, false, true, null, 1) = " + tmp);
1087 ok(tmp === -Infinity, "Math.max() = " + tmp);
1089 tmp = Math.max(true, NaN, 0);
1090 ok(isNaN(tmp), "Math.max(true, NaN, 0) is not NaN");
1092 tmp = Math.round(0.5);
1093 ok(tmp === 1, "Math.round(0.5) = " + tmp);
1095 tmp = Math.round(-0.5);
1096 ok(tmp === 0, "Math.round(-0.5) = " + tmp);
1098 tmp = Math.round(1.1);
1099 ok(tmp === 1, "Math.round(1.1) = " + tmp);
1101 tmp = Math.round(true);
1102 ok(tmp === 1, "Math.round(true) = " + tmp);
1104 tmp = Math.round(1.1, 3, 4);
1105 ok(tmp === 1, "Math.round(1.1, 3, 4) = " + tmp);
1108 ok(isNaN(tmp), "Math.round() is not NaN");
1110 tmp = Math.ceil(0.5);
1111 ok(tmp === 1, "Math.ceil(0.5) = " + tmp);
1113 tmp = Math.ceil(-0.5);
1114 ok(tmp === 0, "Math.ceil(-0.5) = " + tmp);
1116 tmp = Math.ceil(1.1);
1117 ok(tmp === 2, "Math.round(1.1) = " + tmp);
1119 tmp = Math.ceil(true);
1120 ok(tmp === 1, "Math.ceil(true) = " + tmp);
1122 tmp = Math.ceil(1.1, 3, 4);
1123 ok(tmp === 2, "Math.ceil(1.1, 3, 4) = " + tmp);
1126 ok(isNaN(tmp), "ceil() is not NaN");
1128 tmp = Math.floor(0.5);
1129 ok(tmp === 0, "Math.floor(0.5) = " + tmp);
1131 tmp = Math.floor(-0.5);
1132 ok(tmp === -1, "Math.floor(-0.5) = " + tmp);
1134 tmp = Math.floor(1.1);
1135 ok(tmp === 1, "Math.floor(1.1) = " + tmp);
1137 tmp = Math.floor(true);
1138 ok(tmp === 1, "Math.floor(true) = " + tmp);
1140 tmp = Math.floor(1.1, 3, 4);
1141 ok(tmp === 1, "Math.floor(1.1, 3, 4) = " + tmp);
1144 ok(isNaN(tmp), "floor is not NaN");
1147 ok(tmp === 3, "Math.abs(3) = " + tmp);
1150 ok(tmp === 3, "Math.abs(-3) = " + tmp);
1152 tmp = Math.abs(true);
1153 ok(tmp === 1, "Math.abs(true) = " + tmp);
1156 ok(isNaN(tmp), "Math.abs() is not NaN");
1158 tmp = Math.abs(NaN);
1159 ok(isNaN(tmp), "Math.abs() is not NaN");
1161 tmp = Math.abs(-Infinity);
1162 ok(tmp === Infinity, "Math.abs(-Infinite) = " + tmp);
1164 tmp = Math.abs(-3, 2);
1165 ok(tmp === 3, "Math.abs(-3, 2) = " + tmp);
1168 ok(tmp === 1, "Math.cos(0) = " + tmp);
1170 tmp = Math.cos(Math.PI/2);
1171 ok(Math.floor(tmp*100) === 0, "Math.cos(Math.PI/2) = " + tmp);
1173 tmp = Math.cos(-Math.PI/2);
1174 ok(Math.floor(tmp*100) === 0, "Math.cos(-Math.PI/2) = " + tmp);
1176 tmp = Math.cos(Math.PI/3, 2);
1177 ok(Math.floor(tmp*100) === 50, "Math.cos(Math.PI/3, 2) = " + tmp);
1179 tmp = Math.cos(true);
1180 ok(Math.floor(tmp*100) === 54, "Math.cos(true) = " + tmp);
1182 tmp = Math.cos(false);
1183 ok(tmp === 1, "Math.cos(false) = " + tmp);
1186 ok(isNaN(tmp), "Math.cos() is not NaN");
1188 tmp = Math.cos(NaN);
1189 ok(isNaN(tmp), "Math.cos(NaN) is not NaN");
1191 tmp = Math.cos(Infinity);
1192 ok(isNaN(tmp), "Math.cos(Infinity) is not NaN");
1194 tmp = Math.cos(-Infinity);
1195 ok(isNaN(tmp), "Math.cos(-Infinity) is not NaN");
1197 tmp = Math.pow(2, 2);
1198 ok(tmp === 4, "Math.pow(2, 2) = " + tmp);
1200 tmp = Math.pow(4, 0.5);
1201 ok(tmp === 2, "Math.pow(2, 2) = " + tmp);
1203 tmp = Math.pow(2, 2, 3);
1204 ok(tmp === 4, "Math.pow(2, 2, 3) = " + tmp);
1207 ok(isNaN(tmp), "Math.pow(2) is not NaN");
1210 ok(isNaN(tmp), "Math.pow() is not NaN");
1212 tmp = Math.random();
1213 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
1214 ok(0 <= tmp && tmp <= 1, "Math.random() = " + tmp);
1216 tmp = Math.random(100);
1217 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
1218 ok(0 <= tmp && tmp <= 1, "Math.random(100) = " + tmp);
1221 ok(Math.floor(tmp*100) === 157, "Math.acos(0) = " + tmp);
1224 ok(Math.floor(tmp*100) === 0, "Math.acos(1) = " + tmp);
1226 tmp = Math.acos(-1);
1227 ok(Math.floor(tmp*100) === 314, "Math.acos(-1) = " + tmp);
1229 tmp = Math.acos(Math.PI/4, 2);
1230 ok(Math.floor(tmp*100) === 66, "Math.acos(Math.PI/4, 2) = " + tmp);
1232 tmp = Math.acos(true);
1233 ok(Math.floor(tmp*100) === 0, "Math.acos(true) = " + tmp);
1235 tmp = Math.acos(false);
1236 ok(Math.floor(tmp*100) === 157, "Math.acos(false) = " + tmp);
1238 tmp = Math.acos(1.1);
1239 ok(isNaN(tmp), "Math.acos(1.1) is not NaN");
1242 ok(isNaN(tmp), "Math.acos() is not NaN");
1244 tmp = Math.acos(NaN);
1245 ok(isNaN(tmp), "Math.acos(NaN) is not NaN");
1247 tmp = Math.acos(Infinity);
1248 ok(isNaN(tmp), "Math.acos(Infinity) is not NaN");
1250 tmp = Math.acos(-Infinity);
1251 ok(isNaN(tmp), "Math.acos(-Infinity) is not NaN");
1254 ok(Math.floor(tmp*100) === 0, "Math.asin(0) = " + tmp);
1257 ok(Math.floor(tmp*100) === 157, "Math.asin(1) = " + tmp);
1259 tmp = Math.asin(-1);
1260 ok(Math.floor(tmp*100) === -158, "Math.asin(-1) = " + tmp);
1262 tmp = Math.asin(Math.PI/4, 2);
1263 ok(Math.floor(tmp*100) === 90, "Math.asin(Math.PI/4, 2) = " + tmp);
1265 tmp = Math.asin(true);
1266 ok(Math.floor(tmp*100) === 157, "Math.asin(true) = " + tmp);
1268 tmp = Math.asin(false);
1269 ok(Math.floor(tmp*100) === 0, "Math.asin(false) = " + tmp);
1271 tmp = Math.asin(1.1);
1272 ok(isNaN(tmp), "Math.asin(1.1) is not NaN");
1275 ok(isNaN(tmp), "Math.asin() is not NaN");
1277 tmp = Math.asin(NaN);
1278 ok(isNaN(tmp), "Math.asin(NaN) is not NaN");
1280 tmp = Math.asin(Infinity);
1281 ok(isNaN(tmp), "Math.asin(Infinity) is not NaN");
1283 tmp = Math.asin(-Infinity);
1284 ok(isNaN(tmp), "Math.asin(-Infinity) is not NaN");
1287 ok(Math.floor(tmp*100) === 0, "Math.atan(0) = " + tmp);
1290 ok(Math.floor(tmp*100) === 78, "Math.atan(1) = " + tmp);
1292 tmp = Math.atan(-1);
1293 ok(Math.floor(tmp*100) === -79, "Math.atan(-1) = " + tmp);
1295 tmp = Math.atan(true);
1296 ok(Math.floor(tmp*100) === 78, "Math.atan(true) = " + tmp);
1298 tmp = Math.atan(false);
1299 ok(Math.floor(tmp*100) === 0, "Math.atan(false) = " + tmp);
1302 ok(isNaN(tmp), "Math.atan() is not NaN");
1304 tmp = Math.atan(NaN);
1305 ok(isNaN(tmp), "Math.atan(NaN) is not NaN");
1307 tmp = Math.atan(Infinity);
1308 ok(Math.floor(tmp*100) === 157, "Math.atan(Infinity) = " + tmp);
1310 tmp = Math.atan(-Infinity);
1311 ok(Math.floor(tmp*100) === -158, "Math.atan(Infinity) = " + tmp);
1313 tmp = Math.atan2(0, 0);
1314 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 0) = " + tmp);
1316 tmp = Math.atan2(0, 1);
1317 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 1) = " + tmp);
1319 tmp = Math.atan2(0, Infinity);
1320 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, Infinity) = " + tmp);
1322 tmp = Math.atan2(0, -1);
1323 ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -1) = " + tmp);
1325 tmp = Math.atan2(0, -Infinity);
1326 ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -Infinity) = " + tmp);
1328 tmp = Math.atan2(1, 0);
1329 ok(Math.floor(tmp*100) === 157, "Math.atan2(1, 0) = " + tmp);
1331 tmp = Math.atan2(Infinity, 0);
1332 ok(Math.floor(tmp*100) === 157, "Math.atan2(Infinity, 0) = " + tmp);
1334 tmp = Math.atan2(-1, 0);
1335 ok(Math.floor(tmp*100) === -158, "Math.atan2(-1, 0) = " + tmp);
1337 tmp = Math.atan2(-Infinity, 0);
1338 ok(Math.floor(tmp*100) === -158, "Math.atan2(-Infinity, 0) = " + tmp);
1340 tmp = Math.atan2(1, 1);
1341 ok(Math.floor(tmp*100) === 78, "Math.atan2(1, 1) = " + tmp);
1343 tmp = Math.atan2(-1, -1);
1344 ok(Math.floor(tmp*100) === -236, "Math.atan2(-1, -1) = " + tmp);
1346 tmp = Math.atan2(-1, 1);
1347 ok(Math.floor(tmp*100) === -79, "Math.atan2(-1, 1) = " + tmp);
1349 tmp = Math.atan2(Infinity, Infinity);
1350 ok(Math.floor(tmp*100) === 78, "Math.atan2(Infinity, Infinity) = " + tmp);
1352 tmp = Math.atan2(Infinity, -Infinity, 1);
1353 ok(Math.floor(tmp*100) === 235, "Math.atan2(Infinity, -Infinity, 1) = " + tmp);
1356 ok(isNaN(tmp), "Math.atan2() is not NaN");
1358 tmp = Math.atan2(1);
1359 ok(isNaN(tmp), "Math.atan2(1) is not NaN");
1362 ok(tmp === 1, "Math.exp(0) = " + tmp);
1365 ok(Math.floor(tmp*100) === 271, "Math.exp(1) = " + tmp);
1368 ok(Math.floor(tmp*100) === 36, "Math.exp(-1) = " + tmp);
1370 tmp = Math.exp(true);
1371 ok(Math.floor(tmp*100) === 271, "Math.exp(true) = " + tmp);
1373 tmp = Math.exp(1, 1);
1374 ok(Math.floor(tmp*100) === 271, "Math.exp(1, 1) = " + tmp);
1377 ok(isNaN(tmp), "Math.exp() is not NaN");
1379 tmp = Math.exp(NaN);
1380 ok(isNaN(tmp), "Math.exp(NaN) is not NaN");
1382 tmp = Math.exp(Infinity);
1383 ok(tmp === Infinity, "Math.exp(Infinity) = " + tmp);
1385 tmp = Math.exp(-Infinity);
1386 ok(tmp === 0, "Math.exp(-Infinity) = " + tmp);
1389 ok(Math.floor(tmp*100) === 0, "Math.log(1) = " + tmp);
1392 ok(isNaN(tmp), "Math.log(-1) is not NaN");
1394 tmp = Math.log(true);
1395 ok(Math.floor(tmp*100) === 0, "Math.log(true) = " + tmp);
1397 tmp = Math.log(1, 1);
1398 ok(Math.floor(tmp*100) === 0, "Math.log(1, 1) = " + tmp);
1401 ok(isNaN(tmp), "Math.log() is not NaN");
1403 tmp = Math.log(NaN);
1404 ok(isNaN(tmp), "Math.log(NaN) is not NaN");
1406 tmp = Math.log(Infinity);
1407 ok(tmp === Infinity, "Math.log(Infinity) = " + tmp);
1409 tmp = Math.log(-Infinity);
1410 ok(isNaN(tmp), "Math.log(-Infinity) is not NaN");
1413 ok(tmp === 0, "Math.sin(0) = " + tmp);
1415 tmp = Math.sin(Math.PI/2);
1416 ok(tmp === 1, "Math.sin(Math.PI/2) = " + tmp);
1418 tmp = Math.sin(-Math.PI/2);
1419 ok(tmp === -1, "Math.sin(-Math.PI/2) = " + tmp);
1421 tmp = Math.sin(Math.PI/3, 2);
1422 ok(Math.floor(tmp*100) === 86, "Math.sin(Math.PI/3, 2) = " + tmp);
1424 tmp = Math.sin(true);
1425 ok(Math.floor(tmp*100) === 84, "Math.sin(true) = " + tmp);
1427 tmp = Math.sin(false);
1428 ok(tmp === 0, "Math.sin(false) = " + tmp);
1431 ok(isNaN(tmp), "Math.sin() is not NaN");
1433 tmp = Math.sin(NaN);
1434 ok(isNaN(tmp), "Math.sin(NaN) is not NaN");
1436 tmp = Math.sin(Infinity);
1437 ok(isNaN(tmp), "Math.sin(Infinity) is not NaN");
1439 tmp = Math.sin(-Infinity);
1440 ok(isNaN(tmp), "Math.sin(-Infinity) is not NaN");
1443 ok(tmp === 0, "Math.sqrt(0) = " + tmp);
1446 ok(tmp === 2, "Math.sqrt(4) = " + tmp);
1448 tmp = Math.sqrt(-1);
1449 ok(isNaN(tmp), "Math.sqrt(-1) is not NaN");
1451 tmp = Math.sqrt(2, 2);
1452 ok(Math.floor(tmp*100) === 141, "Math.sqrt(2, 2) = " + tmp);
1454 tmp = Math.sqrt(true);
1455 ok(tmp === 1, "Math.sqrt(true) = " + tmp);
1457 tmp = Math.sqrt(false);
1458 ok(tmp === 0, "Math.sqrt(false) = " + tmp);
1461 ok(isNaN(tmp), "Math.sqrt() is not NaN");
1463 tmp = Math.sqrt(NaN);
1464 ok(isNaN(tmp), "Math.sqrt(NaN) is not NaN");
1466 tmp = Math.sqrt(Infinity);
1467 ok(tmp === Infinity, "Math.sqrt(Infinity) = " + tmp);
1469 tmp = Math.sqrt(-Infinity);
1470 ok(isNaN(tmp), "Math.sqrt(-Infinity) is not NaN");
1473 ok(tmp === 0, "Math.tan(0) = " + tmp);
1475 tmp = Math.tan(Math.PI);
1476 ok(Math.floor(tmp*100) === -1, "Math.tan(Math.PI) = " + tmp);
1478 tmp = Math.tan(2, 2);
1479 ok(Math.floor(tmp*100) === -219, "Math.tan(2, 2) = " + tmp);
1481 tmp = Math.tan(true);
1482 ok(Math.floor(tmp*100) === 155, "Math.tan(true) = " + tmp);
1484 tmp = Math.tan(false);
1485 ok(tmp === 0, "Math.tan(false) = " + tmp);
1488 ok(isNaN(tmp), "Math.tan() is not NaN");
1490 tmp = Math.tan(NaN);
1491 ok(isNaN(tmp), "Math.tan(NaN) is not NaN");
1493 tmp = Math.tan(Infinity);
1494 ok(isNaN(tmp), "Math.tan(Infinity) is not NaN");
1496 tmp = Math.tan(-Infinity);
1497 ok(isNaN(tmp), "Math.tan(-Infinity) is not NaN");
1499 var func = function (a) {
1503 ok(func.toString() === "function (a) {\n var a = 1;\n if(a) return;\n }",
1504 "func.toString() = " + func.toString());
1505 ok("" + func === "function (a) {\n var a = 1;\n if(a) return;\n }",
1506 "'' + func.toString() = " + func);
1508 ok(func.valueOf === Object.prototype.valueOf, "func.valueOf !== Object.prototype.valueOf");
1509 ok(func === func.valueOf(), "func !== func.valueOf()");
1511 function testFuncToString(x,y) {
1514 ok(testFuncToString.toString() === "function testFuncToString(x,y) {\n return x+y;\n}",
1515 "testFuncToString.toString() = " + testFuncToString.toString());
1516 ok("" + testFuncToString === "function testFuncToString(x,y) {\n return x+y;\n}",
1517 "'' + testFuncToString = " + testFuncToString);
1521 function callTest(argc) {
1522 ok(this === tmp, "this !== tmp\n");
1523 ok(arguments.length === argc+1, "arguments.length = " + arguments.length + " expected " + (argc+1));
1524 for(var i=1; i <= argc; i++)
1525 ok(arguments[i] === i, "arguments[i] = " + arguments[i]);
1528 callTest.call(tmp, 1, 1);
1529 callTest.call(tmp, 2, 1, 2);
1531 callTest.apply(tmp, [1, 1]);
1532 callTest.apply(tmp, [2, 1, 2]);
1533 (function () { callTest.apply(tmp, arguments); })(2,1,2);
1535 function callTest2() {
1536 ok(this === tmp, "this !== tmp\n");
1537 ok(arguments.length === 0, "callTest2: arguments.length = " + arguments.length + " expected 0");
1540 callTest2.call(tmp);
1541 callTest2.apply(tmp, []);
1542 callTest2.apply(tmp);
1543 (function () { callTest2.apply(tmp, arguments); })();
1545 function callTest3() {
1547 ok(arguments.length === 0, "arguments.length = " + arguments.length + " expected 0");
1551 callTest3.call(undefined);
1552 callTest3.call(null);
1554 callTest3.apply(undefined);
1555 callTest3.apply(null);
1557 tmp = Number.prototype.toString.call(3);
1558 ok(tmp === "3", "Number.prototype.toString.call(3) = " + tmp);
1560 var func = new Function("return 3;");
1563 ok(tmp === 3, "func() = " + tmp);
1564 ok(func.call() === 3, "func.call() = " + tmp);
1565 ok(func.length === 0, "func.length = " + func.length);
1566 tmp = func.toString();
1567 ok(tmp === "function anonymous() {\nreturn 3;\n}", "func.toString() = " + tmp);
1569 func = new Function("x", "return x+2;");
1571 ok(tmp === 3, "func(1) = " + tmp);
1572 tmp = func.toString();
1573 ok(tmp === "function anonymous(x) {\nreturn x+2;\n}", "func.toString() = " + tmp);
1575 tmp = (new Function("x ", "return x+2;")).toString();
1576 ok(tmp === "function anonymous(x ) {\nreturn x+2;\n}", "func.toString() = " + tmp);
1578 func = new Function("x", "y", "return x+y");
1580 ok(tmp === 4, "func(1,3) = " + tmp);
1581 tmp = func.toString();
1582 ok(tmp === "function anonymous(x, y) {\nreturn x+y\n}", "func.toString() = " + tmp);
1584 func = new Function(" x, \ty", "\tz", "return x+y+z;");
1586 ok(tmp === 6, "func(1,3,2) = " + tmp);
1587 ok(func.length === 3, "func.length = " + func.length);
1588 tmp = func.toString();
1589 ok(tmp === "function anonymous( x, \ty, \tz) {\nreturn x+y+z;\n}", "func.toString() = " + tmp);
1591 func = new Function();
1593 ok(tmp === undefined, "func() = " + tmp);
1594 tmp = func.toString();
1595 ok(tmp == "function anonymous() {\n\n}", "func.toString() = " + tmp);
1597 func = (function() {
1599 return new Function("return tmp;");
1603 ok(tmp === 2, "func() = " + tmp);
1605 var date = new Date();
1607 date = new Date(100);
1608 ok(date.getTime() === 100, "date.getTime() = " + date.getTime());
1609 ok(Date.prototype.getTime() === 0, "date.prototype.getTime() = " + Date.prototype.getTime());
1610 date = new Date(8.64e15);
1611 ok(date.getTime() === 8.64e15, "date.getTime() = " + date.getTime());
1612 date = new Date(8.64e15+1);
1613 ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
1614 date = new Date(Infinity);
1615 ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
1616 date = new Date("3 July 2009 22:28:00 UTC+0100");
1617 ok(date.getTime() === 1246656480000, "date.getTime() = " + date.getTime());
1618 date = new Date(1984, 11, 29, 13, 51, 24, 120);
1619 ok(date.getFullYear() === 1984, "date.getFullYear() = " + date.getFullYear());
1620 ok(date.getMonth() === 11, "date.getMonth() = " + date.getMonth());
1621 ok(date.getDate() === 29, "date.getDate() = " + date.getDate());
1622 ok(date.getHours() === 13, "date.getHours() = " + date.getHours());
1623 ok(date.getMinutes() === 51, "date.getMinutes() = " + date.getMinutes());
1624 ok(date.getSeconds() === 24, "date.getSeconds() = " + date.getSeconds());
1625 ok(date.getMilliseconds() === 120, "date.getMilliseconds() = " + date.getMilliseconds());
1626 date = new Date(731, -32, 40, -1, 70, 65, -13);
1627 ok(date.getFullYear() === 728, "date.getFullYear() = " + date.getFullYear());
1628 ok(date.getMonth() === 5, "date.getMonth() = " + date.getMonth());
1629 ok(date.getDate() === 9, "date.getDate() = " + date.getDate());
1630 ok(date.getHours() === 0, "date.getHours() = " + date.getHours());
1631 ok(date.getMinutes() === 11, "date.getMinutes() = " + date.getMinutes());
1632 ok(date.getSeconds() === 4, "date.getSeconds() = " + date.getSeconds());
1633 ok(date.getMilliseconds() === 987, "date.getMilliseconds() = " + date.getMilliseconds());
1635 ok(date.setTime(123) === 123, "date.setTime(123) !== 123");
1636 ok(date.setTime("123", NaN) === 123, "date.setTime(\"123\") !== 123");
1637 ok(isNaN(date.setTime(NaN)), "date.setTime(NaN) is not NaN");
1639 ok(date.setTime(0) === date.getTime(), "date.setTime(0) !== date.getTime()");
1640 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
1641 ok(date.getUTCMonth() === 0, "date.getUTCMonth() = " + date.getUTCMonth());
1642 ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
1643 ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
1644 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
1645 ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
1646 ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
1647 ok(date.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1649 date.setTime(60*24*60*60*1000);
1650 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
1651 ok(date.getUTCMonth() === 2, "date.getUTCMonth() = " + date.getUTCMonth());
1652 ok(date.getUTCDate() === 2, "date.getUTCDate() = " + date.getUTCDate());
1653 ok(date.getUTCDay() === 1, "date.getUTCDay() = " + date.getUTCDay());
1654 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
1655 ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
1656 ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
1657 ok(date.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1659 date.setTime(59*24*60*60*1000 + 4*365*24*60*60*1000 + 60*60*1000 + 2*60*1000 + 2*1000 + 640);
1660 ok(date.getUTCFullYear() === 1974, "date.getUTCFullYear() = " + date.getUTCFullYear());
1661 ok(date.getUTCMonth() === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1662 ok(date.getUTCMonth(123) === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1663 ok(date.getUTCDate() === 28, "date.getUTCDate() = " + date.getUTCDate());
1664 ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
1665 ok(date.getUTCHours() === 1, "date.getUTCHours() = " + date.getUTCHours());
1666 ok(date.getUTCMinutes() === 2, "date.getUTCMinutes() = " + date.getUTCMinutes());
1667 ok(date.getUTCSeconds() === 2, "date.getUTCSeconds() = " + date.getUTCSeconds());
1668 ok(date.getUTCMilliseconds() === 640, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1670 tmp = date.setYear(96);
1671 ok(date.getYear() === 96, "date.getYear() = " + date.getYear());
1672 ok(date.getFullYear() === 1996, "date.getFullYear() = " + date.getYear());
1673 ok(date.getUTCMonth() === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1674 ok(date.getUTCMonth(123) === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1675 ok(date.getUTCMilliseconds() === 640, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1677 tmp = date.setYear(2010);
1678 ok(tmp === date.getTime(), "date.setYear(2010) = " + tmp);
1679 ok(date.getYear() === 2010, "date.getYear() = " + date.getYear());
1680 ok(date.getFullYear() === 2010, "date.getFullYear() = " + date.getYear());
1681 ok(date.getUTCMonth() === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1682 ok(date.getUTCMonth(123) === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1683 ok(date.getUTCMilliseconds() === 640, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1685 date.setTime(Infinity);
1686 ok(isNaN(date.getUTCFullYear()), "date.getUTCFullYear() is not NaN");
1687 ok(isNaN(date.getUTCMonth()), "date.getUTCMonth() is not NaN");
1688 ok(isNaN(date.getUTCDate()), "date.getUTCDate() is not NaN");
1689 ok(isNaN(date.getUTCDay()), "date.getUTCDay() is not NaN");
1690 ok(isNaN(date.getUTCHours()), "date.getUTCHours() is not NaN");
1691 ok(isNaN(date.getUTCMinutes()), "date.getUTCMinutes() is not NaN");
1692 ok(isNaN(date.getUTCSeconds()), "date.getUTCSeconds() is not NaN");
1693 ok(isNaN(date.getUTCMilliseconds()), "date.getUTCMilliseconds() is not NaN");
1694 ok(isNaN(date.setMilliseconds(0)), "date.setMilliseconds() is not NaN");
1697 tmp = date.setYear(NaN);
1698 ok(isNaN(tmp), "date.setYear(NaN) = " + tmp);
1699 ok(isNaN(date.getUTCFullYear()), "date.getUTCFullYear() is not NaN");
1700 ok(isNaN(date.getUTCMonth()), "date.getUTCMonth() is not NaN");
1703 date.setUTCMilliseconds(-10, 2);
1704 ok(date.getUTCMilliseconds() === 990, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1705 date.setUTCMilliseconds(10);
1706 ok(date.getUTCMilliseconds() === 10, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1707 date.setUTCSeconds(-10);
1708 ok(date.getUTCSeconds() === 50, "date.getUTCSeconds() = " + date.getUTCSeconds());
1709 date.setUTCMinutes(-10);
1710 ok(date.getUTCMinutes() === 50, "date.getUTCMinutes() = " + date.getUTCMinutes());
1711 date.setUTCHours(-10);
1712 ok(date.getUTCHours() === 14, "date.getUTCHours() = " + date.getUTCHours());
1713 date.setUTCHours(-123);
1714 ok(date.getTime() === -612549990, "date.getTime() = " + date.getTime());
1715 date.setUTCHours(20);
1716 ok(date.getUTCHours() === 20, "date.getUTCHours() = " + date.getUTCHours());
1717 date.setUTCDate(32);
1718 ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
1719 date.setUTCMonth(22, 37);
1720 ok(date.getTime() === 60987050010, "date.getTime() = " + date.getTime());
1721 date.setUTCFullYear(83, 21, 321);
1722 ok(date.getTime() === -59464984149990, "date.getTime() = " + date.getTime());
1723 ok(Math.abs(date) === 59464984149990, "Math.abs(date) = " + Math.abs(date));
1724 ok(getVT(date+1) === "VT_BSTR", "getVT(date+1) = " + getVT(date+1));
1726 ok(isNaN(Date.parse()), "Date.parse() is not NaN");
1727 ok(isNaN(Date.parse("")), "Date.parse(\"\") is not NaN");
1728 ok(isNaN(Date.parse("Jan Jan 20 2009")), "Date.parse(\"Jan Jan 20 2009\") is not NaN");
1729 ok(Date.parse("Jan 20 2009 UTC") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC\") = " + Date.parse("Jan 20 2009 UTC"));
1730 ok(Date.parse("Jan 20 2009 GMT") === 1232409600000, "Date.parse(\"Jan 20 2009 GMT\") = " + Date.parse("Jan 20 2009 GMT"));
1731 ok(Date.parse("Jan 20 2009 UTC-0") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC-0\") = " + Date.parse("Jan 20 2009 UTC-0"));
1732 ok(Date.parse("Jan 20 2009 UTC+0000") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC+0000\") = " + Date.parse("Jan 20 2009 UTC+0000"));
1733 ok(Date.parse("Ju 13 79 UTC") === 300672000000, "Date.parse(\"Ju 13 79 UTC\") = " + Date.parse("Ju 13 79 UTC"));
1734 ok(Date.parse("12Au91 UTC") === 681955200000, "Date.parse(\"12Au91 UTC\") = " + Date.parse("12Au91 UTC"));
1735 ok(Date.parse("7/02/17 UTC") === -1656806400000, "Date.parse(\"7/02/17 UTC\") = " + Date.parse("7/02/17 UTC"));
1736 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"));
1737 ok(Date.parse("February 31 UTC, 2000 12:31:17 PM") === 952000277000,
1738 "Date.parse(\"February 31 UTC, 2000 12:31:17 PM\") = " + Date.parse("February 31 UTC, 2000 12:31:17 PM"));
1739 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 "));
1740 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"));
1742 ok(typeof(Math.PI) === "number", "typeof(Math.PI) = " + typeof(Math.PI));
1743 ok(Math.floor(Math.PI*100) === 314, "Math.PI = " + Math.PI);
1745 ok(Math.floor(Math.PI*100) === 314, "modified Math.PI = " + Math.PI);
1747 ok(typeof(Math.E) === "number", "typeof(Math.E) = " + typeof(Math.E));
1748 ok(Math.floor(Math.E*100) === 271, "Math.E = " + Math.E);
1750 ok(Math.floor(Math.E*100) === 271, "modified Math.E = " + Math.E);
1752 ok(typeof(Math.LOG2E) === "number", "typeof(Math.LOG2E) = " + typeof(Math.LOG2E));
1753 ok(Math.floor(Math.LOG2E*100) === 144, "Math.LOG2E = " + Math.LOG2E);
1754 Math.LOG2E = "test";
1755 ok(Math.floor(Math.LOG2E*100) === 144, "modified Math.LOG2E = " + Math.LOG2E);
1757 ok(typeof(Math.LOG10E) === "number", "typeof(Math.LOG10E) = " + typeof(Math.LOG10E));
1758 ok(Math.floor(Math.LOG10E*100) === 43, "Math.LOG10E = " + Math.LOG10E);
1759 Math.LOG10E = "test";
1760 ok(Math.floor(Math.LOG10E*100) === 43, "modified Math.LOG10E = " + Math.LOG10E);
1762 ok(typeof(Math.LN2) === "number", "typeof(Math.LN2) = " + typeof(Math.LN2));
1763 ok(Math.floor(Math.LN2*100) === 69, "Math.LN2 = " + Math.LN2);
1765 ok(Math.floor(Math.LN2*100) === 69, "modified Math.LN2 = " + Math.LN2);
1767 ok(typeof(Math.LN10) === "number", "typeof(Math.LN10) = " + typeof(Math.LN10));
1768 ok(Math.floor(Math.LN10*100) === 230, "Math.LN10 = " + Math.LN10);
1770 ok(Math.floor(Math.LN10*100) === 230, "modified Math.LN10 = " + Math.LN10);
1772 ok(typeof(Math.SQRT2) === "number", "typeof(Math.SQRT2) = " + typeof(Math.SQRT2));
1773 ok(Math.floor(Math.SQRT2*100) === 141, "Math.SQRT2 = " + Math.SQRT2);
1774 Math.SQRT2 = "test";
1775 ok(Math.floor(Math.SQRT2*100) === 141, "modified Math.SQRT2 = " + Math.SQRT2);
1777 ok(typeof(Math.SQRT1_2) === "number", "typeof(Math.SQRT1_2) = " + typeof(Math.SQRT1_2));
1778 ok(Math.floor(Math.SQRT1_2*100) === 70, "Math.SQRT1_2 = " + Math.SQRT1_2);
1779 Math.SQRT1_2 = "test";
1780 ok(Math.floor(Math.SQRT1_2*100) === 70, "modified Math.SQRT1_2 = " + Math.SQRT1_2);
1782 ok(isNaN.toString() === "\nfunction isNaN() {\n [native code]\n}\n",
1783 "isNaN.toString = '" + isNaN.toString() + "'");
1784 ok(Array.toString() === "\nfunction Array() {\n [native code]\n}\n",
1785 "isNaN.toString = '" + Array.toString() + "'");
1786 ok(Function.toString() === "\nfunction Function() {\n [native code]\n}\n",
1787 "isNaN.toString = '" + Function.toString() + "'");
1788 ok(Function.prototype.toString() === "\nfunction prototype() {\n [native code]\n}\n",
1789 "isNaN.toString = '" + Function.prototype.toString() + "'");
1790 ok("".substr.toString() === "\nfunction substr() {\n [native code]\n}\n",
1791 "''.substr.toString = '" + "".substr.toString() + "'");
1793 var bool = new Boolean();
1794 ok(bool.toString() === "false", "bool.toString() = " + bool.toString());
1795 var bool = new Boolean("false");
1796 ok(bool.toString() === "true", "bool.toString() = " + bool.toString());
1797 ok(bool.valueOf() === Boolean(1), "bool.valueOf() = " + bool.valueOf());
1798 ok(bool.toLocaleString() === bool.toString(), "bool.toLocaleString() = " + bool.toLocaleString());
1800 ok(ActiveXObject instanceof Function, "ActiveXObject is not instance of Function");
1801 ok(ActiveXObject.prototype instanceof Object, "ActiveXObject.prototype is not instance of Object");
1803 ok(Error.prototype !== TypeError.prototype, "Error.prototype === TypeError.prototype");
1804 ok(RangeError.prototype !== TypeError.prototype, "RangeError.prototype === TypeError.prototype");
1805 ok(Error.prototype.toLocaleString === Object.prototype.toLocaleString,
1806 "Error.prototype.toLocaleString !== Object.prototype.toLocaleString");
1808 ok(err.valueOf === Object.prototype.valueOf, "err.valueOf !== Object.prototype.valueOf");
1809 ok(Error.prototype.name === "Error", "Error.prototype.name = " + Error.prototype.name);
1810 ok(err.name === "Error", "err.name = " + err.name);
1811 EvalError.prototype.message = "test";
1812 ok(err.toString !== Object.prototype.toString, "err.toString === Object.prototype.toString");
1813 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "Error"), "err.toString() = " + err.toString());
1814 err = new EvalError();
1815 ok(EvalError.prototype.name === "EvalError", "EvalError.prototype.name = " + EvalError.prototype.name);
1816 ok(err.name === "EvalError", "err.name = " + err.name);
1817 ok(err.toString === Error.prototype.toString, "err.toString !== Error.prototype.toString");
1818 ok(err.message === "", "err.message != ''");
1820 ok(err.message === date, "err.message != date");
1821 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "EvalError: "+err.message),
1822 "err.toString() = " + err.toString());
1823 ok(err.toString !== Object.prototype.toString, "err.toString === Object.prototype.toString");
1824 err = new RangeError();
1825 ok(RangeError.prototype.name === "RangeError", "RangeError.prototype.name = " + RangeError.prototype.name);
1826 ok(err.name === "RangeError", "err.name = " + err.name);
1827 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "RangeError"), "err.toString() = " + err.toString());
1828 err = new ReferenceError();
1829 ok(ReferenceError.prototype.name === "ReferenceError", "ReferenceError.prototype.name = " + ReferenceError.prototype.name);
1830 ok(err.name === "ReferenceError", "err.name = " + err.name);
1831 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "ReferenceError"), "err.toString() = " + err.toString());
1832 err = new SyntaxError();
1833 ok(SyntaxError.prototype.name === "SyntaxError", "SyntaxError.prototype.name = " + SyntaxError.prototype.name);
1834 ok(err.name === "SyntaxError", "err.name = " + err.name);
1835 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "SyntaxError"), "err.toString() = " + err.toString());
1836 err = new TypeError();
1837 ok(TypeError.prototype.name === "TypeError", "TypeError.prototype.name = " + TypeError.prototype.name);
1838 ok(err.name === "TypeError", "err.name = " + err.name);
1839 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "TypeError"), "err.toString() = " + err.toString());
1840 err = new URIError();
1841 ok(URIError.prototype.name === "URIError", "URIError.prototype.name = " + URIError.prototype.name);
1842 ok(err.name === "URIError", "err.name = " + err.name);
1843 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "URIError"), "err.toString() = " + err.toString());
1844 err = new Error("message");
1845 ok(err.message === "message", "err.message !== 'message'");
1846 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "Error: message"), "err.toString() = " + err.toString());
1847 err = new Error(123);
1848 ok(err.number === 123, "err.number = " + err.number);
1850 ok(err.number === 254, "err.number = " + err.number);
1851 err = new Error(0, "message");
1852 ok(err.number === 0, "err.number = " + err.number);
1853 ok(err.message === "message", "err.message = " + err.message);
1854 ok(err.description === "message", "err.description = " + err.description);
1856 ok(err.number === 0, "err.number = " + err.number);
1857 ok(err.description === "", "err.description = " + err.description);
1858 err.description = 5;
1859 ok(err.description === 5, "err.description = " + err.description);
1860 ok(err.message === "", "err.message = " + err.message);
1862 ok(err.message === 4, "err.message = " + err.message);
1864 ok(!("number" in Error), "number is in Error");
1867 tmp.toString = function() { return "test"; };
1869 tmp = Error.prototype.toString.call(tmp);
1870 ok(tmp === "[object Error]", "Error.prototype.toString.call(tmp) = " + tmp);
1872 if(invokeVersion >= 2) {
1875 tmp = Error.prototype.toString.call(obj);
1876 ok(tmp === "test", "Error.prototype.toString.call(obj) = " + tmp);
1880 obj.message = false;
1881 tmp = Error.prototype.toString.call(obj);
1882 ok(tmp === "6: false", "Error.prototype.toString.call(obj) = " + tmp);
1885 obj.message = "test";
1886 tmp = Error.prototype.toString.call(obj);
1887 ok(tmp === "test", "Error.prototype.toString.call(obj) = " + tmp);
1891 obj.message = "test";
1892 tmp = Error.prototype.toString.call(obj);
1893 ok(tmp === "test", "Error.prototype.toString.call(obj) = " + tmp);
1896 tmp = Error.prototype.toString.call(testObj);
1897 ok(tmp === "[object Error]", "Error.prototype.toString.call(testObj) = " + tmp);
1901 ok(err.name === null, "err.name = " + err.name + " expected null");
1902 if(invokeVersion >= 2)
1903 ok(err.toString() === "null", "err.toString() = " + err.toString());
1906 err.message = false;
1907 ok(err.message === false, "err.message = " + err.message + " expected false");
1908 if(invokeVersion >= 2)
1909 ok(err.toString() === "Error: false", "err.toString() = " + err.toString());
1912 err.message = new Object();
1913 err.message.toString = function() { return ""; };
1914 if(invokeVersion >= 2)
1915 ok(err.toString() === "Error", "err.toString() = " + err.toString());
1918 err.message = undefined;
1919 if(invokeVersion >= 2)
1920 ok(err.toString() === "Error", "err.toString() = " + err.toString());
1922 var exception_array = {
1923 E_INVALID_LENGTH: { type: "RangeError", number: -2146823259 },
1925 E_NOT_DATE: { type: "TypeError", number: -2146823282 },
1926 E_NOT_BOOL: { type: "TypeError", number: -2146823278 },
1927 E_ARG_NOT_OPT: { type: "TypeError", number: -2146827839 },
1928 E_NO_PROPERTY: { type: "TypeError", number: -2146827850 },
1929 E_NOT_NUM: { type: "TypeError", number: -2146823287 },
1930 E_INVALID_CALL_ARG: { type: "TypeError", number: -2146828283 },
1931 E_NOT_FUNC: { type: "TypeError", number: -2146823286 },
1932 E_OBJECT_EXPECTED: { type: "TypeError", number: -2146823281 },
1933 E_UNSUPPORTED_ACTION: { type: "TypeError", number: -2146827843 },
1934 E_NOT_VBARRAY: { type: "TypeError", number: -2146823275 },
1935 E_UNDEFINED: { type: "TypeError", number: -2146823279 },
1936 E_JSCRIPT_EXPECTED: { type: "TypeError", number: -2146823274 },
1937 E_NOT_ARRAY: { type: "TypeError", number: -2146823257 },
1939 E_SYNTAX_ERROR: { type: "SyntaxError", number: -2146827286 },
1940 E_LBRACKET: { type: "SyntaxError", number: -2146827283 },
1941 E_RBRACKET: { type: "SyntaxError", number: -2146827282 },
1942 E_SEMICOLON: { type: "SyntaxError", number: -2146827284 },
1943 E_UNTERMINATED_STR: { type: "SyntaxError", number: -2146827273 },
1944 E_DISABLED_CC: { type: "SyntaxError", number: -2146827258 },
1946 E_ILLEGAL_ASSIGN: { type: "ReferenceError", number: -2146823280 },
1948 E_SUBSCRIPT_OUT_OF_RANGE: {type: "RangeError", number: -2146828279 },
1950 E_REGEXP_SYNTAX_ERROR: { type: "RegExpError", number: -2146823271 },
1952 E_URI_INVALID_CHAR: { type: "URIError", number: -2146823264 }
1955 function testException(func, id) {
1956 var ex = exception_array[id];
1957 var ret = "", num = "";
1966 ok(ret === ex.type, "Exception test, ret = " + ret + ", expected " + ex.type +". Executed function: " + func.toString());
1967 ok(num === ex.number, "Exception test, num = " + num + ", expected " + ex.number + ". Executed function: " + func.toString());
1971 testException(function() {Array(-3);}, "E_INVALID_LENGTH");
1972 testException(function() {createArray().lbound("aaa");}, "E_SUBSCRIPT_OUT_OF_RANGE");
1973 testException(function() {createArray().lbound(3);}, "E_SUBSCRIPT_OUT_OF_RANGE");
1974 testException(function() {createArray().getItem(3);}, "E_SUBSCRIPT_OUT_OF_RANGE");
1977 testException(function() {date.setTime();}, "E_ARG_NOT_OPT");
1978 testException(function() {date.setYear();}, "E_ARG_NOT_OPT");
1979 testException(function() {arr.test();}, "E_NO_PROPERTY");
1980 testException(function() {arr.toString = Number.prototype.toString; arr.toString();}, "E_NOT_NUM");
1981 testException(function() {(new Number(3)).toString(1);}, "E_INVALID_CALL_ARG");
1982 testException(function() {not_existing_variable.something();}, "E_UNDEFINED");
1983 testException(function() {date();}, "E_NOT_FUNC");
1984 testException(function() {arr();}, "E_NOT_FUNC");
1985 testException(function() {eval("nonexistingfunc()")}, "E_OBJECT_EXPECTED");
1986 testException(function() {(new Object()) instanceof 3;}, "E_NOT_FUNC");
1987 testException(function() {(new Object()) instanceof null;}, "E_NOT_FUNC");
1988 testException(function() {(new Object()) instanceof nullDisp;}, "E_NOT_FUNC");
1989 testException(function() {"test" in 3;}, "E_OBJECT_EXPECTED");
1990 testException(function() {"test" in null;}, "E_OBJECT_EXPECTED");
1991 testException(function() {"test" in nullDisp;}, "E_OBJECT_EXPECTED");
1992 testException(function() {new 3;}, "E_UNSUPPORTED_ACTION");
1993 testException(function() {new null;}, "E_OBJECT_EXPECTED");
1994 testException(function() {new nullDisp;}, "E_NO_PROPERTY");
1995 testException(function() {new VBArray();}, "E_NOT_VBARRAY");
1996 testException(function() {new VBArray(new VBArray(createArray()));}, "E_NOT_VBARRAY");
1997 testException(function() {VBArray.prototype.lbound.call(new Object());}, "E_NOT_VBARRAY");
1999 // SyntaxError tests
2000 function testSyntaxError(code, id) {
2001 var ex = exception_array[id];
2002 var ret = "", num = "";
2011 ok(ret === ex.type, "Syntax exception test, ret = " + ret + ", expected " + ex.type +". Executed code: " + code);
2012 ok(num === ex.number, "Syntax exception test, num = " + num + ", expected " + ex.number + ". Executed code: " + code);
2015 testSyntaxError("for(i=0;) {}", "E_SYNTAX_ERROR");
2016 testSyntaxError("function {};", "E_LBRACKET");
2017 testSyntaxError("if", "E_LBRACKET");
2018 testSyntaxError("do i=0; while", "E_LBRACKET");
2019 testSyntaxError("while", "E_LBRACKET");
2020 testSyntaxError("for", "E_LBRACKET");
2021 testSyntaxError("with", "E_LBRACKET");
2022 testSyntaxError("switch", "E_LBRACKET");
2023 testSyntaxError("if(false", "E_RBRACKET");
2024 testSyntaxError("for(i=0; i<10; i++", "E_RBRACKET");
2025 testSyntaxError("while(true", "E_RBRACKET");
2026 testSyntaxError("for(i=0", "E_SEMICOLON");
2027 testSyntaxError("for(i=0;i<10", "E_SEMICOLON");
2028 testSyntaxError("while(", "E_SYNTAX_ERROR");
2029 testSyntaxError("if(", "E_SYNTAX_ERROR");
2030 testSyntaxError("'unterminated", "E_UNTERMINATED_STR");
2031 testSyntaxError("*", "E_SYNTAX_ERROR");
2032 testSyntaxError("@_jscript_version", "E_DISABLED_CC");
2033 testSyntaxError("@a", "E_DISABLED_CC");
2034 testSyntaxError("/* @cc_on @*/ @_jscript_version", "E_DISABLED_CC");
2036 // ReferenceError tests
2037 testException(function() {test = function() {}}, "E_ILLEGAL_ASSIGN");
2039 // RegExpError tests
2040 testException(function() {RegExp(/a/, "g");}, "E_REGEXP_SYNTAX_ERROR");
2043 testException(function() {encodeURI('\udcaa');}, "E_URI_INVALID_CHAR");
2045 function testThisExcept(func, e) {
2046 testException(function() {func.call(new Object())}, e);
2049 function testBoolThis(func) {
2050 testThisExcept(Boolean.prototype[func], "E_NOT_BOOL");
2053 testBoolThis("toString");
2054 testBoolThis("valueOf");
2056 function testDateThis(func) {
2057 testThisExcept(Date.prototype[func], "E_NOT_DATE");
2060 testDateThis("getDate");
2061 testDateThis("getDay");
2062 testDateThis("getFullYear");
2063 testDateThis("getHours");
2064 testDateThis("getMilliseconds");
2065 testDateThis("getMinutes");
2066 testDateThis("getMonth");
2067 testDateThis("getSeconds");
2068 testDateThis("getTime");
2069 testDateThis("getTimezoneOffset");
2070 testDateThis("getUTCDate");
2071 testDateThis("getUTCDay");
2072 testDateThis("getUTCFullYear");
2073 testDateThis("getUTCHours");
2074 testDateThis("getUTCMilliseconds");
2075 testDateThis("getUTCMinutes");
2076 testDateThis("getUTCMonth");
2077 testDateThis("getUTCSeconds");
2078 testDateThis("getYear");
2079 testDateThis("setDate");
2080 testDateThis("setFullYear");
2081 testDateThis("setHours");
2082 testDateThis("setMilliseconds");
2083 testDateThis("setMinutes");
2084 testDateThis("setMonth");
2085 testDateThis("setSeconds");
2086 testDateThis("setTime");
2087 testDateThis("setUTCDate");
2088 testDateThis("setUTCFullYear");
2089 testDateThis("setUTCHours");
2090 testDateThis("setUTCMilliseconds");
2091 testDateThis("setUTCMinutes");
2092 testDateThis("setUTCMonth");
2093 testDateThis("setUTCSeconds");
2094 testDateThis("setYear");
2095 testDateThis("toDateString");
2096 testDateThis("toLocaleDateString");
2097 testDateThis("toLocaleString");
2098 testDateThis("toLocaleTimeString");
2099 testDateThis("toString");
2100 testDateThis("toTimeString");
2101 testDateThis("toUTCString");
2102 testDateThis("valueOf");
2104 function testArrayThis(func) {
2105 testThisExcept(Array.prototype[func], "E_NOT_ARRAY");
2108 testArrayThis("toString");
2110 function testFunctionThis(func) {
2111 testThisExcept(Function.prototype[func], "E_NOT_FUNC");
2114 testFunctionThis("toString");
2115 testFunctionThis("call");
2116 testFunctionThis("apply");
2118 function testArrayHostThis(func) {
2119 testException(function() { Array.prototype[func].call(testObj); }, "E_JSCRIPT_EXPECTED");
2122 testArrayHostThis("push");
2123 testArrayHostThis("shift");
2124 testArrayHostThis("slice");
2125 testArrayHostThis("splice");
2126 testArrayHostThis("unshift");
2127 testArrayHostThis("reverse");
2128 testArrayHostThis("join");
2129 testArrayHostThis("pop");
2130 testArrayHostThis("sort");
2132 function testObjectInherit(obj, constr, ts, tls, vo) {
2133 ok(obj instanceof Object, "obj is not instance of Object");
2134 ok(obj instanceof constr, "obj is not instance of its constructor");
2136 ok(obj.hasOwnProperty === Object.prototype.hasOwnProperty,
2137 "obj.hasOwnProperty !== Object.prototype.hasOwnProprty");
2138 ok(obj.isPrototypeOf === Object.prototype.isPrototypeOf,
2139 "obj.isPrototypeOf !== Object.prototype.isPrototypeOf");
2140 ok(obj.propertyIsEnumerable === Object.prototype.propertyIsEnumerable,
2141 "obj.propertyIsEnumerable !== Object.prototype.propertyIsEnumerable");
2144 ok(obj.toString === Object.prototype.toString,
2145 "obj.toString !== Object.prototype.toString");
2147 ok(obj.toString != Object.prototype.toString,
2148 "obj.toString == Object.prototype.toString");
2151 ok(obj.toLocaleString === Object.prototype.toLocaleString,
2152 "obj.toLocaleString !== Object.prototype.toLocaleString");
2154 ok(obj.toLocaleString != Object.prototype.toLocaleString,
2155 "obj.toLocaleString == Object.prototype.toLocaleString");
2158 ok(obj.valueOf === Object.prototype.valueOf,
2159 "obj.valueOf !== Object.prototype.valueOf");
2161 ok(obj.valueOf != Object.prototype.valueOf,
2162 "obj.valueOf == Object.prototype.valueOf");
2164 ok(obj._test === "test", "obj.test = " + obj._test);
2167 Object.prototype._test = "test";
2168 testObjectInherit(new String("test"), String, false, true, false);
2169 testObjectInherit(/test/g, RegExp, false, true, true);
2170 testObjectInherit(new Number(1), Number, false, false, false);
2171 testObjectInherit(new Date(), Date, false, false, false);
2172 testObjectInherit(new Boolean(true), Boolean, false, true, false);
2173 testObjectInherit(new Array(), Array, false, false, true);
2174 testObjectInherit(new Error(), Error, false, true, true);
2175 testObjectInherit(testObjectInherit, Function, false, true, true);
2176 testObjectInherit(Math, Object, true, true, true);
2178 (function() { testObjectInherit(arguments, Object, true, true, true); })();
2180 function testFunctions(obj, arr) {
2183 for(var i=0; i<arr.length; i++) {
2184 l = obj[arr[i][0]].length;
2185 ok(l === arr[i][1], arr[i][0] + ".length = " + l);
2189 testFunctions(Boolean.prototype, [
2194 testFunctions(Number.prototype, [
2197 ["toExponential", 1],
2198 ["toLocaleString", 0],
2202 testFunctions(String.prototype, [
2219 ["localeCompare", 1],
2231 ["toLocaleLowerCase", 0],
2232 ["toLocaleUpperCase", 0],
2237 testFunctions(RegExp.prototype, [
2243 testFunctions(Date.prototype, [
2248 ["getMilliseconds", 0],
2253 ["getTimezoneOffset", 0],
2256 ["getUTCFullYear", 0],
2258 ["getUTCMilliseconds", 0],
2259 ["getUTCMinutes", 0],
2261 ["getUTCSeconds", 0],
2266 ["setMilliseconds", 1],
2272 ["setUTCFullYear", 3],
2274 ["setUTCMilliseconds", 1],
2275 ["setUTCMinutes", 3],
2277 ["setUTCSeconds", 2],
2279 ["toDateString", 0],
2280 ["toLocaleDateString", 0],
2281 ["toLocaleString", 0],
2282 ["toLocaleTimeString", 0],
2284 ["toTimeString", 0],
2290 testFunctions(Array.prototype, [
2300 ["toLocaleString", 0],
2305 testFunctions(Error.prototype, [
2309 testFunctions(Math, [
2330 testFunctions(Object.prototype, [
2331 ["hasOwnProperty", 1],
2332 ["isPrototypeOf", 1],
2333 ["propertyIsEnumerable", 1],
2334 ["toLocaleString", 0],
2339 testFunctions(Function.prototype, [
2345 testFunctions(VBArray.prototype, [
2353 ok(ActiveXObject.length == 1, "ActiveXObject.length = " + ActiveXObject.length);
2354 ok(Array.length == 1, "Array.length = " + Array.length);
2355 ok(Boolean.length == 1, "Boolean.length = " + Boolean.length);
2356 ok(CollectGarbage.length == 0, "CollectGarbage.length = " + CollectGarbage.length);
2357 ok(Date.length == 7, "Date.length = " + Date.length);
2358 ok(Enumerator.length == 7, "Enumerator.length = " + Enumerator.length);
2359 ok(Error.length == 1, "Error.length = " + Error.length);
2360 ok(EvalError.length == 1, "EvalError.length = " + EvalError.length);
2361 ok(Function.length == 1, "Function.length = " + Function.length);
2362 ok(GetObject.length == 2, "GetObject.length = " + GetObject.length);
2363 ok(Number.length == 1, "Number.length = " + Number.length);
2364 ok(Object.length == 0, "Object.length = " + Object.length);
2365 ok(RangeError.length == 1, "RangeError.length = " + RangeError.length);
2366 ok(ReferenceError.length == 1, "ReferenceError.length = " + ReferenceError.length);
2367 ok(RegExp.length == 2, "RegExp.length = " + RegExp.length);
2368 ok(ScriptEngine.length == 0, "ScriptEngine.length = " + ScriptEngine.length);
2369 ok(ScriptEngineBuildVersion.length == 0,
2370 "ScriptEngineBuildVersion.length = " + ScriptEngineBuildVersion.length);
2371 ok(ScriptEngineMajorVersion.length == 0,
2372 "ScriptEngineMajorVersion.length = " + ScriptEngineMajorVersion.length);
2373 ok(ScriptEngineMinorVersion.length == 0,
2374 "ScriptEngineMinorVersion.length = " + ScriptEngineMinorVersion.length);
2375 ok(String.length == 1, "String.length = " + String.length);
2376 ok(SyntaxError.length == 1, "SyntaxError.length = " + SyntaxError.length);
2377 ok(TypeError.length == 1, "TypeError.length = " + TypeError.length);
2378 ok(URIError.length == 1, "URIError.length = " + URIError.length);
2379 ok(VBArray.length == 1, "VBArray.length = " + VBArray.length);
2380 ok(decodeURI.length == 1, "decodeURI.length = " + decodeURI.length);
2381 ok(decodeURIComponent.length == 1, "decodeURIComponent.length = " + decodeURIComponent.length);
2382 ok(encodeURI.length == 1, "encodeURI.length = " + encodeURI.length);
2383 ok(encodeURIComponent.length == 1, "encodeURIComponent.length = " + encodeURIComponent.length);
2384 ok(escape.length == 1, "escape.length = " + escape.length);
2385 ok(eval.length == 1, "eval.length = " + eval.length);
2386 ok(isFinite.length == 1, "isFinite.length = " + isFinite.length);
2387 ok(isNaN.length == 1, "isNaN.length = " + isNaN.length);
2388 ok(parseFloat.length == 1, "parseFloat.length = " + parseFloat.length);
2389 ok(parseInt.length == 2, "parseInt.length = " + parseInt.length);
2390 ok(unescape.length == 1, "unescape.length = " + unescape.length);
2393 ok(String.length == 1, "String.length = " + String.length);
2395 var tmp = createArray();
2396 ok(getVT(tmp) == "VT_ARRAY|VT_VARIANT", "getVT(createArray()) = " + getVT(tmp));
2397 ok(getVT(VBArray(tmp)) == "VT_ARRAY|VT_VARIANT", "getVT(VBArray(tmp)) = " + getVT(VBArray(tmp)));
2398 tmp = new VBArray(tmp);
2399 tmp = new VBArray(VBArray(createArray()));
2400 ok(tmp.dimensions() == 2, "tmp.dimensions() = " + tmp.dimensions());
2401 ok(tmp.lbound() == 0, "tmp.lbound() = " + tmp.lbound());
2402 ok(tmp.lbound(1) == 0, "tmp.lbound(1) = " + tmp.lbound(1));
2403 ok(tmp.lbound(2, 1) == 2, "tmp.lbound(2, 1) = " + tmp.lbound(2, 1));
2404 ok(tmp.ubound() == 4, "tmp.ubound() = " + tmp.ubound());
2405 ok(tmp.ubound("2") == 3, "tmp.ubound(\"2\") = " + tmp.ubound("2"));
2406 ok(tmp.getItem(1, 2) == 3, "tmp.getItem(1, 2) = " + tmp.getItem(1, 2));
2407 ok(tmp.getItem(2, 3) == 33, "tmp.getItem(2, 3) = " + tmp.getItem(2, 3));
2408 ok(tmp.getItem(3, 2) == 13, "tmp.getItem(3, 2) = " + tmp.getItem(3, 2));
2409 ok(tmp.toArray() == "2,3,12,13,22,23,32,33,42,43", "tmp.toArray() = " + tmp.toArray());
2410 ok(createArray().toArray() == "2,3,12,13,22,23,32,33,42,43",
2411 "createArray.toArray()=" + createArray().toArray());