jscript: Throw type error on invalid delete.
[wine.git] / dlls / jscript / tests / api.js
blob2b2245e6c18dead824ea16a31ed790971a555a5c
1 /*
2  * Copyright 2008 Jacek Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
19 var tmp, i;
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)");
27 i = parseInt("0");
28 ok(i === 0, "parseInt('0') = " + i);
29 i = parseInt("123");
30 ok(i === 123, "parseInt('123') = " + i);
31 i = parseInt("-123");
32 ok(i === -123, "parseInt('-123') = " + i);
33 i = parseInt("0xff");
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);
45 i = parseInt("010");
46 ok(i === 8, "parseInt('010') = " + i);
47 i = parseInt("");
48 ok(isNaN(i), "parseInt('') = " + i);
49 i = parseInt("0x");
50 ok(isNaN(i), "parseInt('0x') = " + i);
51 i = parseInt("+");
52 ok(isNaN(i), "parseInt('+') = " + i);
53 i = parseInt("-");
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);
63 i = parseInt("abc");
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);
69 i = parseInt("-010");
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);
77 i = parseInt("0xz");
78 ok(isNaN(i), "parseInt('0xz') = " + i);
79 i = parseInt("1", 1);
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);
92 tmp = encodeURI("");
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);
104 tmp = encodeURI("%");
105 ok(tmp === "%25", "encodeURI('%') = " + tmp);
106 tmp = encodeURI();
107 ok(tmp === "undefined", "encodeURI() = " + tmp);
108 tmp = encodeURI("abc", "test");
109 ok(tmp === "abc", "encodeURI('abc') = " + tmp);
111 tmp = decodeURI("abc");
112 ok(tmp === "abc", "decodeURI('abc') = " + tmp);
113 tmp = decodeURI("{abc}");
114 ok(tmp === "{abc}", "decodeURI('{abc}') = " + tmp);
115 tmp = decodeURI("");
116 ok(tmp === "", "decodeURI('') = " + tmp);
117 tmp = decodeURI("\01\02\03\04");
118 ok(tmp === "\01\02\03\04", "decodeURI('\\01\\02\\03\\04') = " + tmp);
119 tmp = decodeURI();
120 ok(tmp === "undefined", "decodeURI() = " + tmp);
121 tmp = decodeURI("abc", "test");
122 ok(tmp === "abc", "decodeURI('abc') = " + tmp);
123 tmp = decodeURI("%7babc%7d");
124 ok(tmp === "{abc}", "decodeURI('%7Babc%7D') = " + tmp);
125 tmp = decodeURI("%01%02%03%04");
126 ok(tmp === "\01\02\03\04", "decodeURI('%01%02%03%04') = " + tmp);
127 tmp = decodeURI("%C2%A1%20");
128 ok(tmp === "\xa1 ", "decodeURI('%C2%A1%20') = " + tmp);
129 tmp = decodeURI("%C3%BFff");
130 ok(tmp.length === 3, "decodeURI('%C3%BFff').length = " + tmp.length);
132 tmp = encodeURIComponent("abc");
133 ok(tmp === "abc", "encodeURIComponent('abc') = " + tmp);
134 dec = decodeURIComponent(tmp);
135 ok(dec === "abc", "decodeURIComponent('" + tmp + "') = " + dec);
136 tmp = encodeURIComponent("{abc}");
137 ok(tmp === "%7Babc%7D", "encodeURIComponent('{abc}') = " + tmp);
138 dec = decodeURIComponent(tmp);
139 ok(dec === "{abc}", "decodeURIComponent('" + tmp + "') = " + dec);
140 tmp = encodeURIComponent("");
141 ok(tmp === "", "encodeURIComponent('') = " + tmp);
142 dec = decodeURIComponent(tmp);
143 ok(dec === "", "decodeURIComponent('" + tmp + "') = " + dec);
144 tmp = encodeURIComponent("\01\02\03\04");
145 ok(tmp === "%01%02%03%04", "encodeURIComponent('\\01\\02\\03\\04') = " + tmp);
146 dec = decodeURIComponent(tmp);
147 ok(dec === "\01\02\03\04", "decodeURIComponent('" + tmp + "') = " + dec);
148 tmp = encodeURIComponent("{#@}");
149 ok(tmp === "%7B%23%40%7D", "encodeURIComponent('{#@}') = " + tmp);
150 dec = decodeURIComponent(tmp);
151 ok(dec === "{#@}", "decodeURIComponent('" + tmp + "') = " + dec);
152 tmp = encodeURIComponent("\xa1 ");
153 ok(tmp === "%C2%A1%20", "encodeURIComponent(\\xa1 ) = " + tmp);
154 dec = decodeURIComponent(tmp);
155 ok(dec === "\xa1 ", "decodeURIComponent('" + tmp + "') = " + dec);
156 tmp = encodeURIComponent("\xffff");
157 ok(tmp.length === 8, "encodeURIComponent('\\xffff').length = " + tmp.length);
158 dec = decodeURIComponent(tmp);
159 ok(dec === "\xffff", "decodeURIComponent('" + tmp + "') = " + dec);
160 tmp = encodeURIComponent("abcABC123;/?:@&=+$,-_.!~*'()");
161 ok(tmp === "abcABC123%3B%2F%3F%3A%40%26%3D%2B%24%2C-_.!~*'()", "encodeURIComponent('abcABC123;/?:@&=+$,-_.!~*'()') = " + tmp);
162 dec = decodeURIComponent(tmp);
163 ok(dec === "abcABC123;/?:@&=+$,-_.!~*'()", "decodeURIComponent('" + tmp + "') = " + dec);
164 tmp = encodeURIComponent();
165 ok(tmp === "undefined", "encodeURIComponent() = " + tmp);
166 tmp = encodeURIComponent("abc", "test");
167 ok(tmp === "abc", "encodeURIComponent('abc') = " + tmp);
168 dec = decodeURIComponent();
169 ok(dec === "undefined", "decodeURIComponent() = " + dec);
170 dec = decodeURIComponent("abc", "test");
171 ok(dec === "abc", "decodeURIComponent('abc') = " + dec);
173 tmp = escape("abc");
174 ok(tmp === "abc", "escape('abc') = " + tmp);
175 tmp = escape("");
176 ok(tmp === "", "escape('') = " + tmp);
177 tmp = escape("a1b c!d+e@*-_+./,");
178 ok(tmp === "a1b%20c%21d+e@*-_+./%2C", "escape('a1b c!d+e@*-_+./,') = " + tmp);
179 tmp = escape();
180 ok(tmp === "undefined", "escape() = " + tmp);
181 tmp = escape('\u1234\123\xf3');
182 ok(tmp == "%u1234S%F3", "escape('\u1234\123\xf3') = " + tmp);
184 tmp = unescape("abc");
185 ok(tmp === "abc", "unescape('abc') = " + tmp);
186 tmp = unescape("");
187 ok(tmp === "", "unescape('') = " + tmp);
188 tmp = unescape("%%%");
189 ok(tmp === "%%%", "unescape('%%%') = " + tmp);
190 tmp = unescape();
191 ok(tmp === "undefined", "unescape() = " + tmp);
192 tmp = unescape("%54%65s%u0074");
193 ok(tmp === "Test", "unescape('%54%65s%u0074') = " + tmp);
195 tmp = "aA1~`!@#$%^&*()_+=-][{}';:/.,<>?\|";
196 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));
197 ok(unescape(escape(tmp)) === tmp, "unescape(escape('" + tmp + "')) = " + unescape(escape(tmp)));
199 tmp = "" + new Object();
200 ok(tmp === "[object Object]", "'' + new Object() = " + tmp);
201 (tmp = new Array).f = Object.prototype.toString;
202 ok(tmp.f() === "[object Array]", "tmp.f() = " + tmp.f());
203 (tmp = new Boolean).f = Object.prototype.toString;
204 ok(tmp.f() === "[object Boolean]", "tmp.f() = " + tmp.f());
205 (tmp = new Date).f = Object.prototype.toString;
206 ok(tmp.f() === "[object Date]", "tmp.f() = " + tmp.f());
207 (tmp = function() {}).f = Object.prototype.toString;
208 ok(tmp.f() === "[object Function]", "tmp.f() = " + tmp.f());
209 Math.f = Object.prototype.toString;
210 ok(Math.f() === "[object Math]", "tmp.f() = " + tmp.f());
211 (tmp = new Number).f = Object.prototype.toString;
212 ok(tmp.f() === "[object Number]", "tmp.f() = " + tmp.f());
213 (tmp = new RegExp("")).f = Object.prototype.toString;
214 ok(tmp.f() === "[object RegExp]", "tmp.f() = " + tmp.f());
215 (tmp = new String).f = Object.prototype.toString;
216 ok(tmp.f() === "[object String]", "tmp.f() = " + tmp.f());
217 tmp = Object.prototype.toString.call(testObj);
218 ok(tmp === "[object Object]", "toString.call(testObj) = " + tmp);
219 tmp = Object.prototype.toString.call(this);
220 ok(tmp === "[object Object]", "toString.call(this) = " + tmp);
221 (function () { tmp = Object.prototype.toString.call(arguments); })();
222 ok(tmp === "[object Object]", "toString.call(arguments) = " + tmp);
223 tmp = Object.prototype.toString.call(new VBArray(createArray()));
224 ok(tmp === "[object Object]", "toString.call(new VBArray()) = " + tmp);
226 ok(Object(1) instanceof Number, "Object(1) is not instance of Number");
227 ok(Object("") instanceof String, "Object('') is not instance of String");
228 ok(Object(false) instanceof Boolean, "Object(false) is not instance of Boolean");
230 obj = new Object();
231 ok(Object(obj) === obj, "Object(obj) !== obj");
233 ok(typeof(Object()) === "object", "typeof(Object()) !== 'object'");
234 ok(typeof(Object(undefined)) === "object", "typeof(Object(undefined)) !== 'object'");
235 ok(typeof(Object(null)) === "object", "typeof(Object(null)) !== 'object'");
237 var obj = new Object();
238 obj.toString = function (x) {
239     ok(arguments.length === 0, "arguments.length = " + arguments.length);
240     return "test";
242 ok((tmp = obj.toLocaleString()) === "test", "obj.toLocaleString() = " + tmp);
243 ok((tmp = obj.toLocaleString(1)) === "test", "obj.toLocaleString(1) = " + tmp);
244 ok(obj === obj.valueOf(), "obj !== obj.valueOf");
246 ok("".length === 0, "\"\".length = " + "".length);
247 ok(getVT("".length) == "VT_I4", "\"\".length = " + "".length);
248 ok("abc".length === 3, "\"abc\".length = " + "abc".length);
249 ok(String.prototype.length === 0, "String.prototype.length = " + String.prototype.length);
251 tmp = "".toString();
252 ok(tmp === "", "''.toString() = " + tmp);
253 tmp = "test".toString();
254 ok(tmp === "test", "''.toString() = " + tmp);
255 tmp = "test".toString(3);
256 ok(tmp === "test", "''.toString(3) = " + tmp);
258 tmp = "".valueOf();
259 ok(tmp === "", "''.valueOf() = " + tmp);
260 tmp = "test".valueOf();
261 ok(tmp === "test", "''.valueOf() = " + tmp);
262 tmp = "test".valueOf(3);
263 ok(tmp === "test", "''.valueOf(3) = " + tmp);
265 var str = new String("test");
266 ok(str.toString() === "test", "str.toString() = " + str.toString());
267 var str = new String();
268 ok(str.toString() === "", "str.toString() = " + str.toString());
269 var str = new String("test", "abc");
270 ok(str.toString() === "test", "str.toString() = " + str.toString());
272 var strObj = new Object();
273 strObj.toString = function() { return "abcd" };
274 strObj.substr = String.prototype.substr;
275 strObj.lastIndexOf = String.prototype.lastIndexOf;
277 tmp = "value " + str;
278 ok(tmp === "value test", "'value ' + str = " + tmp);
280 tmp = String();
281 ok(tmp === "", "String() = " + tmp);
282 tmp = String(false);
283 ok(tmp === "false", "String(false) = " + tmp);
284 tmp = String(null);
285 ok(tmp === "null", "String(null) = " + tmp);
286 tmp = String("test");
287 ok(tmp === "test", "String('test') = " + tmp);
288 tmp = String("test", "abc");
289 ok(tmp === "test", "String('test','abc') = " + tmp);
291 tmp = "abc".charAt(0);
292 ok(tmp === "a", "'abc',charAt(0) = " + tmp);
293 tmp = "abc".charAt(1);
294 ok(tmp === "b", "'abc',charAt(1) = " + tmp);
295 tmp = "abc".charAt(2);
296 ok(tmp === "c", "'abc',charAt(2) = " + tmp);
297 tmp = "abc".charAt(3);
298 ok(tmp === "", "'abc',charAt(3) = " + tmp);
299 tmp = "abc".charAt(4);
300 ok(tmp === "", "'abc',charAt(4) = " + tmp);
301 tmp = "abc".charAt();
302 ok(tmp === "a", "'abc',charAt() = " + tmp);
303 tmp = "abc".charAt(-1);
304 ok(tmp === "", "'abc',charAt(-1) = " + tmp);
305 tmp = "abc".charAt(0,2);
306 ok(tmp === "a", "'abc',charAt(0.2) = " + tmp);
307 tmp = "abc".charAt(NaN);
308 ok(tmp === "a", "'abc',charAt(NaN) = " + tmp);
310 tmp = "abc".charCodeAt(0);
311 ok(tmp === 0x61, "'abc'.charCodeAt(0) = " + tmp);
312 tmp = "abc".charCodeAt(1);
313 ok(tmp === 0x62, "'abc'.charCodeAt(1) = " + tmp);
314 tmp = "abc".charCodeAt(2);
315 ok(tmp === 0x63, "'abc'.charCodeAt(2) = " + tmp);
316 tmp = "abc".charCodeAt();
317 ok(tmp === 0x61, "'abc'.charCodeAt() = " + tmp);
318 tmp = "abc".charCodeAt(true);
319 ok(tmp === 0x62, "'abc'.charCodeAt(true) = " + tmp);
320 tmp = "abc".charCodeAt(0,2);
321 ok(tmp === 0x61, "'abc'.charCodeAt(0,2) = " + tmp);
322 tmp = "\u49F4".charCodeAt(0);
323 ok(tmp === 0x49F4, "'\u49F4'.charCodeAt(0) = " + tmp);
324 tmp = "\052".charCodeAt(0);
325 ok(tmp === 0x2A, "'\052'.charCodeAt(0) = " + tmp);
326 tmp = "\xa2".charCodeAt(0);
327 ok(tmp === 0xA2, "'\xa2'.charCodeAt(0) = " + tmp);
329 tmp = "abcd".substring(1,3);
330 ok(tmp === "bc", "'abcd'.substring(1,3) = " + tmp);
331 tmp = "abcd".substring(-1,3);
332 ok(tmp === "abc", "'abcd'.substring(-1,3) = " + tmp);
333 tmp = "abcd".substring(1,6);
334 ok(tmp === "bcd", "'abcd'.substring(1,6) = " + tmp);
335 tmp = "abcd".substring(3,1);
336 ok(tmp === "bc", "'abcd'.substring(3,1) = " + tmp);
337 tmp = "abcd".substring(2,2);
338 ok(tmp === "", "'abcd'.substring(2,2) = " + tmp);
339 tmp = "abcd".substring(true,"3");
340 ok(tmp === "bc", "'abcd'.substring(true,'3') = " + tmp);
341 tmp = "abcd".substring(1,3,2);
342 ok(tmp === "bc", "'abcd'.substring(1,3,2) = " + tmp);
343 tmp = "abcd".substring();
344 ok(tmp === "abcd", "'abcd'.substring() = " + tmp);
346 tmp = "abcd".substr(1,3);
347 ok(tmp === "bcd", "'abcd'.substr(1,3) = " + tmp);
348 tmp = "abcd".substr(-1,3);
349 ok(tmp === "abc", "'abcd'.substr(-1,3) = " + tmp);
350 tmp = "abcd".substr(1,6);
351 ok(tmp === "bcd", "'abcd'.substr(1,6) = " + tmp);
352 tmp = "abcd".substr(2,-1);
353 ok(tmp === "", "'abcd'.substr(3,1) = " + tmp);
354 tmp = "abcd".substr(2,0);
355 ok(tmp === "", "'abcd'.substr(2,2) = " + tmp);
356 tmp = "abcd".substr(true,"3");
357 ok(tmp === "bcd", "'abcd'.substr(true,'3') = " + tmp);
358 tmp = "abcd".substr(1,3,2);
359 ok(tmp === "bcd", "'abcd'.substr(1,3,2) = " + tmp);
360 tmp = "abcd".substr();
361 ok(tmp === "abcd", "'abcd'.substr() = " + tmp);
362 tmp = strObj.substr(1,1);
363 ok(tmp === "b", "'abcd'.substr(1,3) = " + tmp);
365 tmp = "abcd".slice(1,3);
366 ok(tmp === "bc", "'abcd'.slice(1,3) = " + tmp);
367 tmp = "abcd".slice(1,-1);
368 ok(tmp === "bc", "'abcd'.slice(1,-1) = " + tmp);
369 tmp = "abcd".slice(-3,3);
370 ok(tmp === "bc", "'abcd'.slice(-3,3) = " + tmp);
371 tmp = "abcd".slice(-6,3);
372 ok(tmp === "abc", "'abcd'.slice(-6,3) = " + tmp);
373 tmp = "abcd".slice(3,1);
374 ok(tmp === "", "'abcd'.slice(3,1) = " + tmp);
375 tmp = "abcd".slice(true,3);
376 ok(tmp === "bc", "'abcd'.slice(true,3) = " + tmp);
377 tmp = "abcd".slice();
378 ok(tmp === "abcd", "'abcd'.slice() = " + tmp);
379 tmp = "abcd".slice(1);
380 ok(tmp === "bcd", "'abcd'.slice(1) = " + tmp);
382 tmp = "abc".concat(["d",1],2,false);
383 ok(tmp === "abcd,12false", "concat returned " + tmp);
384 var arr = new Array(2,"a");
385 arr.concat = String.prototype.concat;
386 tmp = arr.concat("d");
387 ok(tmp === "2,ad", "arr.concat = " + tmp);
389 m = "a+bcabc".match("a+");
390 ok(typeof(m) === "object", "typeof m is not object");
391 ok(m.length === 1, "m.length is not 1");
392 ok(m["0"] === "a", "m[0] is not \"ab\"");
394 r = "- [test] -".replace("[test]", "success");
395 ok(r === "- success -", "r = " + r + " expected '- success -'");
397 r = "- [test] -".replace("[test]", "success", "test");
398 ok(r === "- success -", "r = " + r + " expected '- success -'");
400 r = "test".replace();
401 ok(r === "test", "r = " + r + " expected 'test'");
403 function replaceFunc3(m, off, str) {
404     ok(arguments.length === 3, "arguments.length = " + arguments.length);
405     ok(m === "[test]", "m = " + m + " expected [test1]");
406     ok(off === 1, "off = " + off + " expected 0");
407     ok(str === "-[test]-", "str = " + arguments[3]);
408     return "ret";
411 r = "-[test]-".replace("[test]", replaceFunc3);
412 ok(r === "-ret-", "r = " + r + " expected '-ret-'");
414 r = "-[test]-".replace("[test]", replaceFunc3, "test");
415 ok(r === "-ret-", "r = " + r + " expected '-ret-'");
417 r = "1,2,3".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] === "3", "r[2] = " + r[2]);
425 r = "1,2,3".split(",*");
426 ok(r.length === 1, "r.length = " + r.length);
427 ok(r[0] === "1,2,3", "r[0] = " + r[0]);
429 r = "123".split("");
430 ok(r.length === 3, "r.length = " + r.length);
431 ok(r[0] === "1", "r[0] = " + r[0]);
432 ok(r[1] === "2", "r[1] = " + r[1]);
433 ok(r[2] === "3", "r[2] = " + r[2]);
435 r = "123".split(2);
436 ok(r.length === 2, "r.length = " + r.length);
437 ok(r[0] === "1", "r[0] = " + r[0]);
438 ok(r[1] === "3", "r[1] = " + r[1]);
440 r = "1,2,".split(",");
441 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
442 ok(r.length === 3, "r.length = " + r.length);
443 ok(r[0] === "1", "r[0] = " + r[0]);
444 ok(r[1] === "2", "r[1] = " + r[1]);
445 ok(r[2] === "", "r[2] = " + r[2]);
447 tmp = "abcd".indexOf("bc",0);
448 ok(tmp === 1, "indexOf = " + tmp);
449 tmp = "abcd".indexOf("bc",1);
450 ok(tmp === 1, "indexOf = " + tmp);
451 tmp = "abcd".indexOf("bc");
452 ok(tmp === 1, "indexOf = " + tmp);
453 tmp = "abcd".indexOf("ac");
454 ok(tmp === -1, "indexOf = " + tmp);
455 tmp = "abcd".indexOf("bc",2);
456 ok(tmp === -1, "indexOf = " + tmp);
457 tmp = "abcd".indexOf("a",0);
458 ok(tmp === 0, "indexOf = " + tmp);
459 tmp = "abcd".indexOf("bc",0,"test");
460 ok(tmp === 1, "indexOf = " + tmp);
461 tmp = "abcd".indexOf();
462 ok(tmp == -1, "indexOf = " + tmp);
464 tmp = "abcd".lastIndexOf("bc",1);
465 ok(tmp === 1, "lastIndexOf = " + tmp);
466 tmp = "abcd".lastIndexOf("bc",2);
467 ok(tmp === 1, "lastIndexOf = " + tmp);
468 tmp = "abcd".lastIndexOf("bc");
469 ok(tmp === 1, "lastIndexOf = " + tmp);
470 tmp = "abcd".lastIndexOf("ac");
471 ok(tmp === -1, "lastIndexOf = " + tmp);
472 tmp = "abcd".lastIndexOf("d",10);
473 ok(tmp === 3, "lastIndexOf = " + tmp);
474 tmp = "abcd".lastIndexOf("bc",0,"test");
475 ok(tmp === -1, "lastIndexOf = " + tmp);
476 tmp = "abcd".lastIndexOf();
477 ok(tmp === -1, "lastIndexOf = " + tmp);
478 tmp = "aaaa".lastIndexOf("a",2);
479 ok(tmp == 2, "lastIndexOf = " + tmp);
480 tmp = strObj.lastIndexOf("b");
481 ok(tmp === 1, "lastIndexOf = " + tmp);
483 tmp = "".toLowerCase();
484 ok(tmp === "", "''.toLowerCase() = " + tmp);
485 tmp = "test".toLowerCase();
486 ok(tmp === "test", "''.toLowerCase() = " + tmp);
487 tmp = "test".toLowerCase(3);
488 ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
489 tmp = "tEsT".toLowerCase();
490 ok(tmp === "test", "''.toLowerCase() = " + tmp);
491 tmp = "tEsT".toLowerCase(3);
492 ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
494 tmp = "".toUpperCase();
495 ok(tmp === "", "''.toUpperCase() = " + tmp);
496 tmp = "TEST".toUpperCase();
497 ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
498 tmp = "TEST".toUpperCase(3);
499 ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
500 tmp = "tEsT".toUpperCase();
501 ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
502 tmp = "tEsT".toUpperCase(3);
503 ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
505 tmp = "".anchor();
506 ok(tmp === "<A NAME=\"undefined\"></A>", "''.anchor() = " + tmp);
507 tmp = "".anchor(3);
508 ok(tmp === "<A NAME=\"3\"></A>", "''.anchor(3) = " + tmp);
509 tmp = "".anchor("red");
510 ok(tmp === "<A NAME=\"red\"></A>", "''.anchor('red') = " + tmp);
511 tmp = "test".anchor();
512 ok(tmp === "<A NAME=\"undefined\">test</A>", "'test'.anchor() = " + tmp);
513 tmp = "test".anchor(3);
514 ok(tmp === "<A NAME=\"3\">test</A>", "'test'.anchor(3) = " + tmp);
515 tmp = "test".anchor("green");
516 ok(tmp === "<A NAME=\"green\">test</A>", "'test'.anchor('green') = " + tmp);
518 tmp = "".big();
519 ok(tmp === "<BIG></BIG>", "''.big() = " + tmp);
520 tmp = "".big(3);
521 ok(tmp === "<BIG></BIG>", "''.big(3) = " + tmp);
522 tmp = "test".big();
523 ok(tmp === "<BIG>test</BIG>", "'test'.big() = " + tmp);
524 tmp = "test".big(3);
525 ok(tmp === "<BIG>test</BIG>", "'test'.big(3) = " + tmp);
527 tmp = "".blink();
528 ok(tmp === "<BLINK></BLINK>", "''.blink() = " + tmp);
529 tmp = "".blink(3);
530 ok(tmp === "<BLINK></BLINK>", "''.blink(3) = " + tmp);
531 tmp = "test".blink();
532 ok(tmp === "<BLINK>test</BLINK>", "'test'.blink() = " + tmp);
533 tmp = "test".blink(3);
534 ok(tmp === "<BLINK>test</BLINK>", "'test'.blink(3) = " + tmp);
536 tmp = "".bold();
537 ok(tmp === "<B></B>", "''.bold() = " + tmp);
538 tmp = "".bold(3);
539 ok(tmp === "<B></B>", "''.bold(3) = " + tmp);
540 tmp = "test".bold();
541 ok(tmp === "<B>test</B>", "'test'.bold() = " + tmp);
542 tmp = "test".bold(3);
543 ok(tmp === "<B>test</B>", "'test'.bold(3) = " + tmp);
545 tmp = "".fixed();
546 ok(tmp === "<TT></TT>", "''.fixed() = " + tmp);
547 tmp = "".fixed(3);
548 ok(tmp === "<TT></TT>", "''.fixed(3) = " + tmp);
549 tmp = "test".fixed();
550 ok(tmp === "<TT>test</TT>", "'test'.fixed() = " + tmp);
551 tmp = "test".fixed(3);
552 ok(tmp === "<TT>test</TT>", "'test'.fixed(3) = " + tmp);
554 tmp = "".fontcolor();
555 ok(tmp === "<FONT COLOR=\"undefined\"></FONT>", "''.fontcolor() = " + tmp);
556 tmp = "".fontcolor(3);
557 ok(tmp === "<FONT COLOR=\"3\"></FONT>", "''.fontcolor(3) = " + tmp);
558 tmp = "".fontcolor("red");
559 ok(tmp === "<FONT COLOR=\"red\"></FONT>", "''.fontcolor('red') = " + tmp);
560 tmp = "test".fontcolor();
561 ok(tmp === "<FONT COLOR=\"undefined\">test</FONT>", "'test'.fontcolor() = " + tmp);
562 tmp = "test".fontcolor(3);
563 ok(tmp === "<FONT COLOR=\"3\">test</FONT>", "'test'.fontcolor(3) = " + tmp);
564 tmp = "test".fontcolor("green");
565 ok(tmp === "<FONT COLOR=\"green\">test</FONT>", "'test'.fontcolor('green') = " + tmp);
567 tmp = "".fontsize();
568 ok(tmp === "<FONT SIZE=\"undefined\"></FONT>", "''.fontsize() = " + tmp);
569 tmp = "".fontsize(3);
570 ok(tmp === "<FONT SIZE=\"3\"></FONT>", "''.fontsize(3) = " + tmp);
571 tmp = "".fontsize("red");
572 ok(tmp === "<FONT SIZE=\"red\"></FONT>", "''.fontsize('red') = " + tmp);
573 tmp = "test".fontsize();
574 ok(tmp === "<FONT SIZE=\"undefined\">test</FONT>", "'test'.fontsize() = " + tmp);
575 tmp = "test".fontsize(3);
576 ok(tmp === "<FONT SIZE=\"3\">test</FONT>", "'test'.fontsize(3) = " + tmp);
577 tmp = "test".fontsize("green");
578 ok(tmp === "<FONT SIZE=\"green\">test</FONT>", "'test'.fontsize('green') = " + tmp);
580 tmp = ("".fontcolor()).fontsize();
581 ok(tmp === "<FONT SIZE=\"undefined\"><FONT COLOR=\"undefined\"></FONT></FONT>", "(''.fontcolor()).fontsize() = " + tmp);
583 tmp = "".italics();
584 ok(tmp === "<I></I>", "''.italics() = " + tmp);
585 tmp = "".italics(3);
586 ok(tmp === "<I></I>", "''.italics(3) = " + tmp);
587 tmp = "test".italics();
588 ok(tmp === "<I>test</I>", "'test'.italics() = " + tmp);
589 tmp = "test".italics(3);
590 ok(tmp === "<I>test</I>", "'test'.italics(3) = " + tmp);
592 tmp = "".link();
593 ok(tmp === "<A HREF=\"undefined\"></A>", "''.link() = " + tmp);
594 tmp = "".link(3);
595 ok(tmp === "<A HREF=\"3\"></A>", "''.link(3) = " + tmp);
596 tmp = "".link("red");
597 ok(tmp === "<A HREF=\"red\"></A>", "''.link('red') = " + tmp);
598 tmp = "test".link();
599 ok(tmp === "<A HREF=\"undefined\">test</A>", "'test'.link() = " + tmp);
600 tmp = "test".link(3);
601 ok(tmp === "<A HREF=\"3\">test</A>", "'test'.link(3) = " + tmp);
602 tmp = "test".link("green");
603 ok(tmp === "<A HREF=\"green\">test</A>", "'test'.link('green') = " + tmp);
605 tmp = "".small();
606 ok(tmp === "<SMALL></SMALL>", "''.small() = " + tmp);
607 tmp = "".small(3);
608 ok(tmp === "<SMALL></SMALL>", "''.small(3) = " + tmp);
609 tmp = "test".small();
610 ok(tmp === "<SMALL>test</SMALL>", "'test'.small() = " + tmp);
611 tmp = "test".small(3);
612 ok(tmp === "<SMALL>test</SMALL>", "'test'.small(3) = " + tmp);
614 tmp = "".strike();
615 ok(tmp === "<STRIKE></STRIKE>", "''.strike() = " + tmp);
616 tmp = "".strike(3);
617 ok(tmp === "<STRIKE></STRIKE>", "''.strike(3) = " + tmp);
618 tmp = "test".strike();
619 ok(tmp === "<STRIKE>test</STRIKE>", "'test'.strike() = " + tmp);
620 tmp = "test".strike(3);
621 ok(tmp === "<STRIKE>test</STRIKE>", "'test'.strike(3) = " + tmp);
623 tmp = "".sub();
624 ok(tmp === "<SUB></SUB>", "''.sub() = " + tmp);
625 tmp = "".sub(3);
626 ok(tmp === "<SUB></SUB>", "''.sub(3) = " + tmp);
627 tmp = "test".sub();
628 ok(tmp === "<SUB>test</SUB>", "'test'.sub() = " + tmp);
629 tmp = "test".sub(3);
630 ok(tmp === "<SUB>test</SUB>", "'test'.sub(3) = " + tmp);
632 tmp = "".sup();
633 ok(tmp === "<SUP></SUP>", "''.sup() = " + tmp);
634 tmp = "".sup(3);
635 ok(tmp === "<SUP></SUP>", "''.sup(3) = " + tmp);
636 tmp = "test".sup();
637 ok(tmp === "<SUP>test</SUP>", "'test'.sup() = " + tmp);
638 tmp = "test".sup(3);
639 ok(tmp === "<SUP>test</SUP>", "'test'.sup(3) = " + tmp);
641 ok(String.fromCharCode() === "", "String.fromCharCode() = " + String.fromCharCode());
642 ok(String.fromCharCode(65,"66",67) === "ABC", "String.fromCharCode(65,'66',67) = " + String.fromCharCode(65,"66",67));
643 ok(String.fromCharCode(1024*64+65, -1024*64+65) === "AA",
644         "String.fromCharCode(1024*64+65, -1024*64+65) = " + String.fromCharCode(1024*64+65, -1024*64+65));
645 ok(String.fromCharCode(65, NaN, undefined).length === 3,
646         "String.fromCharCode(65, NaN, undefined).length = " + String.fromCharCode(65, NaN, undefined).length);
648 var arr = new Array();
649 ok(typeof(arr) === "object", "arr () is not object");
650 ok((arr.length === 0), "arr.length is not 0");
651 ok(arr["0"] === undefined, "arr[0] is not undefined");
653 var arr = new Array(1, 2, "test");
654 ok(typeof(arr) === "object", "arr (1,2,test) is not object");
655 ok((arr.length === 3), "arr.length is not 3");
656 ok(arr["0"] === 1, "arr[0] is not 1");
657 ok(arr["1"] === 2, "arr[1] is not 2");
658 ok(arr["2"] === "test", "arr[2] is not \"test\"");
660 arr["7"] = true;
661 ok((arr.length === 8), "arr.length is not 8");
663 tmp = "" + [];
664 ok(tmp === "", "'' + [] = " + tmp);
665 tmp = "" + [1,true];
666 ok(tmp === "1,true", "'' + [1,true] = " + tmp);
668 var arr = new Array(6);
669 ok(typeof(arr) === "object", "arr (6) is not object");
670 ok((arr.length === 6), "arr.length is not 6");
671 ok(arr["0"] === undefined, "arr[0] is not undefined");
673 ok(arr.push() === 6, "arr.push() !== 6");
674 ok(arr.push(1) === 7, "arr.push(1) !== 7");
675 ok(arr[6] === 1, "arr[6] != 1");
676 ok(arr.length === 7, "arr.length != 10");
677 ok(arr.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10");
678 ok(arr[8] === "b", "arr[8] != 'b'");
679 ok(arr.length === 10, "arr.length != 10");
681 var arr = new Object();
682 arr.push = Array.prototype.push;
684 arr.length = 6;
686 ok(arr.push() === 6, "arr.push() !== 6");
687 ok(arr.push(1) === 7, "arr.push(1) !== 7");
688 ok(arr[6] === 1, "arr[6] != 1");
689 ok(arr.length === 7, "arr.length != 10");
690 ok(arr.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10");
691 ok(arr[8] === "b", "arr[8] != 'b'");
692 ok(arr.length === 10, "arr.length != 10");
694 arr.pop = Array.prototype.pop;
695 ok(arr.pop() === false, "arr.pop() !== false");
696 ok(arr[8] === "b", "arr[8] !== 'b'");
697 ok(arr.pop() === 'b', "arr.pop() !== 'b'");
698 ok(arr[8] === undefined, "arr[8] !== undefined");
700 arr = [3,4,5];
701 tmp = arr.pop();
702 ok(arr.length === 2, "arr.length = " + arr.length);
703 ok(tmp === 5, "pop() = " + tmp);
704 tmp = arr.pop(2);
705 ok(arr.length === 1, "arr.length = " + arr.length);
706 ok(tmp === 4, "pop() = " + tmp);
707 tmp = arr.pop();
708 ok(arr.length === 0, "arr.length = " + arr.length);
709 ok(tmp === 3, "pop() = " + tmp);
710 for(tmp in arr)
711     ok(false, "not deleted " + tmp);
712 tmp = arr.pop();
713 ok(arr.length === 0, "arr.length = " + arr.length);
714 ok(tmp === undefined, "tmp = " + tmp);
715 arr = new Object();
716 arr.pop = Array.prototype.pop;
717 tmp = arr.pop();
718 ok(arr.length === 0, "arr.length = " + arr.length);
719 ok(tmp === undefined, "tmp = " + tmp);
720 arr = [,,,,,];
721 tmp = arr.pop();
722 ok(arr.length === 5, "arr.length = " + arr.length);
723 ok(tmp === undefined, "tmp = " + tmp);
725 arr = [1,2,null,false,undefined,,"a"];
727 tmp = arr.join();
728 ok(tmp === "1,2,,false,,,a", "arr.join() = " + tmp);
729 tmp = arr.join(";");
730 ok(tmp === "1;2;;false;;;a", "arr.join(';') = " + tmp);
731 tmp = arr.join(";","test");
732 ok(tmp === "1;2;;false;;;a", "arr.join(';') = " + tmp);
733 tmp = arr.join("");
734 ok(tmp === "12falsea", "arr.join('') = " + tmp);
736 tmp = arr.toString();
737 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
738 tmp = arr.toString("test");
739 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
741 arr = new Object();
742 arr.length = 3;
743 arr[0] = "aa";
744 arr[2] = 2;
745 arr[7] = 3;
746 arr.join = Array.prototype.join;
747 tmp = arr.join(",");
748 ok(arr.length === 3, "arr.length = " + arr.length);
749 ok(tmp === "aa,,2", "tmp = " + tmp);
751 arr = [5,true,2,-1,3,false,"2.5"];
752 tmp = arr.sort(function(x,y) { return y-x; });
753 ok(tmp === arr, "tmp !== arr");
754 tmp = [5,3,"2.5",2,true,false,-1];
755 for(var i=0; i < arr.length; i++)
756     ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
758 arr = [5,false,2,0,"abc",3,"a",-1];
759 tmp = arr.sort();
760 ok(tmp === arr, "tmp !== arr");
761 tmp = [-1,0,2,3,5,"a","abc",false];
762 for(var i=0; i < arr.length; i++)
763     ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
765 arr = ["a", "b", "ab"];
766 tmp = ["a", "ab", "b"];
767 ok(arr.sort() === arr, "arr.sort() !== arr");
768 for(var i=0; i < arr.length; i++)
769     ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
771 arr = new Object();
772 arr.length = 3;
773 arr[0] = 1;
774 arr[2] = "aa";
775 arr.sort = Array.prototype.sort;
776 tmp = arr.sort();
777 ok(arr === tmp, "tmp !== arr");
778 ok(arr[0]===1 && arr[1]==="aa" && arr[2]===undefined, "arr is sorted incorrectly");
780 tmp = [["bb","aa"],["ab","aa"]].sort().toString();
781 ok(tmp === "ab,aa,bb,aa", "sort() = " + tmp);
783 tmp = [["bb","aa"],"ab"].sort().toString();
784 ok(tmp === "ab,bb,aa", "sort() = " + tmp);
786 tmp = [["bb","aa"],"cc"].sort().toString();
787 ok(tmp === "bb,aa,cc", "sort() = " + tmp);
789 tmp = [2,"1"].sort().toString();
790 ok(tmp === "1,2", "sort() = " + tmp);
792 tmp = ["2",1].sort().toString();
793 ok(tmp === "1,2", "sort() = " + tmp);
795 tmp = [,,0,"z"].sort().toString();
796 ok(tmp === "0,z,,", "sort() = " + tmp);
798 tmp = ["a,b",["a","a"],["a","c"]].sort().toString();
799 ok(tmp === "a,a,a,b,a,c", "sort() = " + tmp);
801 arr = ["1", "2", "3"];
802 arr.length = 1;
803 ok(arr.length === 1, "arr.length = " + arr.length);
804 arr.length = 3;
805 ok(arr.length === 3, "arr.length = " + arr.length);
806 ok(arr.toString() === "1,,", "arr.toString() = " + arr.toString());
808 arr = Array("a","b","c");
809 ok(arr.toString() === "a,b,c", "arr.toString() = " + arr.toString());
811 ok(arr.valueOf === Object.prototype.valueOf, "arr.valueOf !== Object.prototype.valueOf");
812 ok(arr === arr.valueOf(), "arr !== arr.valueOf");
814 arr = [1,2,3];
815 tmp = arr.reverse();
816 ok(tmp === arr, "tmp !== arr");
817 ok(arr.length === 3, "arr.length = " + arr.length);
818 ok(arr.toString() === "3,2,1", "arr.toString() = " + arr.toString());
820 arr = [];
821 arr[3] = 5;
822 arr[5] = 1;
823 tmp = arr.reverse();
824 ok(tmp === arr, "tmp !== arr");
825 ok(arr.length === 6, "arr.length = " + arr.length);
826 ok(arr.toString() === "1,,5,,,", "arr.toString() = " + arr.toString());
828 arr = new Object();
829 arr.length = 3;
830 arr[0] = "aa";
831 arr[2] = 2;
832 arr[7] = 3;
833 arr.reverse = Array.prototype.reverse;
834 tmp = arr.reverse();
835 ok(tmp === arr, "tmp !== arr");
836 ok(arr.length === 3, "arr.length = " + arr.length);
837 ok(arr[0] === 2 && arr[1] === undefined && arr[2] === "aa", "unexpected array");
839 arr = [1,2,3];
840 tmp = arr.unshift(0);
841 ok(tmp === (invokeVersion < 2 ? undefined : 4), "[1,2,3].unshift(0) returned " +tmp);
842 ok(arr.length === 4, "arr.length = " + arr.length);
843 ok(arr.toString() === "0,1,2,3", "arr.toString() = " + arr.toString());
845 arr = new Array(3);
846 arr[0] = 1;
847 arr[2] = 3;
848 tmp = arr.unshift(-1,0);
849 ok(tmp === (invokeVersion < 2 ? undefined : 5), "unshift returned " +tmp);
850 ok(arr.length === 5, "arr.length = " + arr.length);
851 ok(arr.toString() === "-1,0,1,,3", "arr.toString() = " + arr.toString());
853 arr = [1,2,3];
854 tmp = arr.unshift();
855 ok(tmp === (invokeVersion < 2 ? undefined : 3), "unshift returned " +tmp);
856 ok(arr.length === 3, "arr.length = " + arr.length);
857 ok(arr.toString() === "1,2,3", "arr.toString() = " + arr.toString());
859 arr = new Object();
860 arr.length = 2;
861 arr[0] = 1;
862 arr[1] = 2;
863 tmp = Array.prototype.unshift.call(arr, 0);
864 ok(tmp === (invokeVersion < 2 ? undefined : 3), "unshift returned " +tmp);
865 ok(arr.length === 3, "arr.length = " + arr.length);
866 ok(arr[0] === 0 && arr[1] === 1 && arr[2] === 2, "unexpected array");
868 arr = [1,2,,4];
869 tmp = arr.shift();
870 ok(tmp === 1, "[1,2,,4].shift() = " + tmp);
871 ok(arr.toString() === "2,,4", "arr = " + arr.toString());
873 arr = [];
874 tmp = arr.shift();
875 ok(tmp === undefined, "[].shift() = " + tmp);
876 ok(arr.toString() === "", "arr = " + arr.toString());
878 arr = [1,2,,4];
879 tmp = arr.shift(2);
880 ok(tmp === 1, "[1,2,,4].shift(2) = " + tmp);
881 ok(arr.toString() === "2,,4", "arr = " + arr.toString());
883 arr = [1,];
884 tmp = arr.shift();
885 ok(tmp === 1, "[1,].shift() = " + tmp);
886 ok(arr.toString() === "", "arr = " + arr.toString());
888 obj = new Object();
889 obj[0] = "test";
890 obj[2] = 3;
891 obj.length = 3;
892 tmp = Array.prototype.shift.call(obj);
893 ok(tmp === "test", "obj.shift() = " + tmp);
894 ok(obj.length == 2, "obj.length = " + obj.length);
895 ok(obj[1] === 3, "obj[1] = " + obj[1]);
897 var num = new Number(6);
898 arr = [0,1,2];
899 tmp = arr.concat(3, [4,5], num);
900 ok(tmp !== arr, "tmp === arr");
901 for(var i=0; i<6; i++)
902     ok(tmp[i] === i, "tmp[" + i + "] = " + tmp[i]);
903 ok(tmp[6] === num, "tmp[6] !== num");
904 ok(tmp.length === 7, "tmp.length = " + tmp.length);
906 arr = [].concat();
907 ok(arr.length === 0, "arr.length = " + arr.length);
909 arr = [1,];
910 tmp = arr.concat([2]);
911 ok(tmp.length === 3, "tmp.length = " + tmp.length);
912 ok(tmp[1] === undefined, "tmp[1] = " + tmp[1]);
914 arr = [1,false,'a',null,undefined,'a'];
915 ok(arr.slice(0,6).toString() === "1,false,a,,,a", "arr.slice(0,6).toString() = " + arr.slice(0,6));
916 ok(arr.slice(0,6).length === 6, "arr.slice(0,6).length = " + arr.slice(0,6).length);
917 ok(arr.slice().toString() === "1,false,a,,,a", "arr.slice().toString() = " + arr.slice());
918 ok(arr.slice("abc").toString() === "1,false,a,,,a", "arr.slice(\"abc\").toString() = " + arr.slice("abc"));
919 ok(arr.slice(3,8).toString() === ",,a", "arr.slice(3,8).toString() = " + arr.slice(3,8));
920 ok(arr.slice(3,8).length === 3, "arr.slice(3,8).length = " + arr.slice(3,8).length);
921 ok(arr.slice(1).toString() === "false,a,,,a", "arr.slice(1).toString() = " + arr.slice(1));
922 ok(arr.slice(-2).toString() === ",a", "arr.slice(-2).toString() = " + arr.slice(-2));
923 ok(arr.slice(3,1).toString() === "", "arr.slice(3,1).toString() = " + arr.slice(3,1));
924 tmp = arr.slice(0,6);
925 for(var i=0; i < arr.length; i++)
926     ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
927 arr[12] = 2;
928 ok(arr.slice(5).toString() === "a,,,,,,,2", "arr.slice(5).toString() = " + arr.slice(5).toString());
929 ok(arr.slice(5).length === 8, "arr.slice(5).length = " + arr.slice(5).length);
931 arr = [1,2,3,4,5];
932 tmp = arr.splice(2,2);
933 ok(tmp.toString() == "3,4", "arr.splice(2,2) returned " + tmp.toString());
934 ok(arr.toString() == "1,2,5", "arr.splice(2,2) is " + arr.toString());
936 arr = [1,2,3,4,5];
937 tmp = arr.splice(2,2,"a");
938 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a') returned " + tmp.toString());
939 ok(arr.toString() == "1,2,a,5", "arr.splice(2,2,'a') is " + arr.toString());
941 arr = [1,2,3,4,5];
942 tmp = arr.splice(2,2,'a','b','c');
943 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a','b','c') returned " + tmp.toString());
944 ok(arr.toString() == "1,2,a,b,c,5", "arr.splice(2,2,'a','b','c') is " + arr.toString());
946 arr = [1,2,3,4,];
947 tmp = arr.splice(2,2,'a','b','c');
948 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a','b','c') returned " + tmp.toString());
949 ok(arr.toString() == "1,2,a,b,c,", "arr.splice(2,2,'a','b','c') is " + arr.toString());
951 arr = [1,2,3,4,];
952 arr.splice(2,2,'a','b','c');
953 ok(arr.toString() == "1,2,a,b,c,", "arr.splice(2,2,'a','b','c') is " + arr.toString());
955 arr = [1,2,3,4,5];
956 tmp = arr.splice(2,2,'a','b');
957 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a','b') returned " + tmp.toString());
958 ok(arr.toString() == "1,2,a,b,5", "arr.splice(2,2,'a','b') is " + arr.toString());
960 arr = [1,2,3,4,5];
961 tmp = arr.splice(-1,2);
962 ok(tmp.toString() == "5", "arr.splice(-1,2) returned " + tmp.toString());
963 ok(arr.toString() == "1,2,3,4", "arr.splice(-1,2) is " + arr.toString());
965 arr = [1,2,3,4,5];
966 tmp = arr.splice(-10,3);
967 ok(tmp.toString() == "1,2,3", "arr.splice(-10,3) returned " + tmp.toString());
968 ok(arr.toString() == "4,5", "arr.splice(-10,3) is " + arr.toString());
970 arr = [1,2,3,4,5];
971 tmp = arr.splice(-10,100);
972 ok(tmp.toString() == "1,2,3,4,5", "arr.splice(-10,100) returned " + tmp.toString());
973 ok(arr.toString() == "", "arr.splice(-10,100) is " + arr.toString());
975 arr = [1,2,3,4,5];
976 tmp = arr.splice(2,-1);
977 ok(tmp.toString() == "", "arr.splice(2,-1) returned " + tmp.toString());
978 ok(arr.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr.toString());
980 arr = [1,2,3,4,5];
981 tmp = arr.splice(2);
982 ok(tmp.toString() == "", "arr.splice(2,-1) returned " + tmp.toString());
983 ok(arr.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr.toString());
985 arr = [1,2,3,4,5];
986 tmp = arr.splice();
987 ok(tmp.toString() == "", "arr.splice(2,-1) returned " + tmp.toString());
988 ok(arr.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr.toString());
990 obj = new Object();
991 obj.length = 3;
992 obj[0] = 1;
993 obj[1] = 2;
994 obj[2] = 3;
995 tmp = Array.prototype.splice.call(obj, 1, 1, 'a', 'b');
996 ok(tmp.toString() === "2", "obj.splice returned " + tmp);
997 ok(obj.length === 4, "obj.length = " + obj.length);
998 ok(obj[0] === 1, "obj[0] = " + obj[0]);
999 ok(obj[1] === 'a', "obj[1] = " + obj[1]);
1000 ok(obj[2] === 'b', "obj[2] = " + obj[2]);
1001 ok(obj[3] === 3, "obj[3] = " + obj[3]);
1003 obj = new Object();
1004 obj.length = 3;
1005 obj[0] = 1;
1006 obj[1] = 2;
1007 obj[2] = 3;
1008 tmp = Array.prototype.slice.call(obj, 1, 2);
1009 ok(tmp.length === 1, "tmp.length = " + tmp.length);
1010 ok(tmp[0] === 2, "tmp[0] = " + tmp[0]);
1012 var num = new Number(2);
1013 ok(num.toString() === "2", "num(2).toString !== 2");
1014 var num = new Number();
1015 ok(num.toString() === "0", "num().toString !== 0");
1017 ok(Number() === 0, "Number() = " + Number());
1018 ok(Number(false) === 0, "Number(false) = " + Number(false));
1019 ok(Number("43") === 43, "Number('43') = " + Number("43"));
1021 tmp = (new Number(1)).valueOf();
1022 ok(tmp === 1, "(new Number(1)).valueOf = " + tmp);
1023 tmp = (new Number(1,2)).valueOf();
1024 ok(tmp === 1, "(new Number(1,2)).valueOf = " + tmp);
1025 tmp = (new Number()).valueOf();
1026 ok(tmp === 0, "(new Number()).valueOf = " + tmp);
1027 tmp = Number.prototype.valueOf();
1028 ok(tmp === 0, "Number.prototype.valueOf = " + tmp);
1030 function equals(val, base) {
1031     var i;
1032     var num = 0;
1033     var str = val.toString(base);
1035     for(i=0; i<str.length; i++) {
1036         if(str.substring(i, i+1) == '(') break;
1037         if(str.substring(i, i+1) == '.') break;
1038         num = num*base + parseInt(str.substring(i, i+1));
1039     }
1041     if(str.substring(i, i+1) == '.') {
1042         var mult = base;
1043         for(i++; i<str.length; i++) {
1044             if(str.substring(i, i+1) == '(') break;
1045             num += parseInt(str.substring(i, i+1))/mult;
1046             mult *= base;
1047         }
1048     }
1050     if(str.substring(i, i+1) == '(') {
1051         exp = parseInt(str.substring(i+2));
1052         num *= Math.pow(base, exp);
1053     }
1055     ok(num>val-val/1000 && num<val+val/1000, "equals: num = " + num);
1058 ok((10).toString(11) === "a", "(10).toString(11) = " + (10).toString(11));
1059 ok((213213433).toString(17) === "8e2ddcb", "(213213433).toString(17) = " + (213213433).toString(17));
1060 ok((-3254343).toString(33) === "-2oicf", "(-3254343).toString(33) = " + (-3254343).toString(33));
1061 ok((NaN).toString(12) === "NaN", "(NaN).toString(11) = " + (NaN).toString(11));
1062 ok((Infinity).toString(13) === "Infinity", "(Infinity).toString(11) = " + (Infinity).toString(11));
1063 for(i=2; i<10; i++) {
1064     equals(1.123, i);
1065     equals(2305843009200000000, i);
1066     equals(5.123, i);
1067     equals(21711, i);
1068     equals(1024*1024*1024*1024*1024*1024*1.9999, i);
1069     equals(748382, i);
1070     equals(0.6, i);
1071     equals(4.65661287308e-10, i);
1072     ok((0).toString(i) === "0", "(0).toString("+i+") = " + (0).toString(i));
1075 ok(parseFloat('123') === 123, "parseFloat('123') = " + parseFloat('123'));
1076 ok(parseFloat('-13.7') === -13.7, "parseFloat('-13.7') = " + parseFloat('-13.7'));
1077 ok(parseFloat('-0.01e-2') === -0.01e-2, "parseFloat('-0.01e-2') = " + parseFloat('-0.01e-2'));
1078 ok(parseFloat('-12e+5') === -12e+5, "parseFloat('-12e+5') = " + parseFloat('-12e+5'));
1079 ok(parseFloat('1E5 not parsed') === 1E5, "parseFloat('1E5 not parsed') = " + parseFloat('1E5 not parsed'));
1080 ok(isNaN(parseFloat('not a number')), "parseFloat('not a number') is not NaN");
1081 ok(parseFloat('+13.2e-3') === 13.2e-3, "parseFloat('+13.2e-3') = " + parseFloat('+13.2e-3'));
1082 ok(parseFloat('.12') === 0.12, "parseFloat('.12') = " + parseFloat('.12'));
1083 ok(parseFloat('1e') === 1, "parseFloat('1e') = " + parseFloat('1e'));
1085 tmp = Math.min(1);
1086 ok(tmp === 1, "Math.min(1) = " + tmp);
1088 tmp = Math.min(1, false);
1089 ok(tmp === 0, "Math.min(1, false) = " + tmp);
1091 tmp = Math.min();
1092 ok(tmp === Infinity, "Math.min() = " + tmp);
1094 tmp = Math.min(1, NaN, -Infinity, false);
1095 ok(isNaN(tmp), "Math.min(1, NaN, -Infinity, false) is not NaN");
1097 tmp = Math.min(1, false, true, null, -3);
1098 ok(tmp === -3, "Math.min(1, false, true, null, -3) = " + tmp);
1100 tmp = Math.max(1);
1101 ok(tmp === 1, "Math.max(1) = " + tmp);
1103 tmp = Math.max(true, 0);
1104 ok(tmp === 1, "Math.max(true, 0) = " + tmp);
1106 tmp = Math.max(-2, false, true, null, 1);
1107 ok(tmp === 1, "Math.max(-2, false, true, null, 1) = " + tmp);
1109 tmp = Math.max();
1110 ok(tmp === -Infinity, "Math.max() = " + tmp);
1112 tmp = Math.max(true, NaN, 0);
1113 ok(isNaN(tmp), "Math.max(true, NaN, 0) is not NaN");
1115 tmp = Math.round(0.5);
1116 ok(tmp === 1, "Math.round(0.5) = " + tmp);
1118 tmp = Math.round(-0.5);
1119 ok(tmp === 0, "Math.round(-0.5) = " + tmp);
1121 tmp = Math.round(1.1);
1122 ok(tmp === 1, "Math.round(1.1) = " + tmp);
1124 tmp = Math.round(true);
1125 ok(tmp === 1, "Math.round(true) = " + tmp);
1127 tmp = Math.round(1.1, 3, 4);
1128 ok(tmp === 1, "Math.round(1.1, 3, 4) = " + tmp);
1130 tmp = Math.round();
1131 ok(isNaN(tmp), "Math.round() is not NaN");
1133 tmp = Math.ceil(0.5);
1134 ok(tmp === 1, "Math.ceil(0.5) = " + tmp);
1136 tmp = Math.ceil(-0.5);
1137 ok(tmp === 0, "Math.ceil(-0.5) = " + tmp);
1139 tmp = Math.ceil(1.1);
1140 ok(tmp === 2, "Math.round(1.1) = " + tmp);
1142 tmp = Math.ceil(true);
1143 ok(tmp === 1, "Math.ceil(true) = " + tmp);
1145 tmp = Math.ceil(1.1, 3, 4);
1146 ok(tmp === 2, "Math.ceil(1.1, 3, 4) = " + tmp);
1148 tmp = Math.ceil();
1149 ok(isNaN(tmp), "ceil() is not NaN");
1151 tmp = Math.floor(0.5);
1152 ok(tmp === 0, "Math.floor(0.5) = " + tmp);
1154 tmp = Math.floor(-0.5);
1155 ok(tmp === -1, "Math.floor(-0.5) = " + tmp);
1157 tmp = Math.floor(1.1);
1158 ok(tmp === 1, "Math.floor(1.1) = " + tmp);
1160 tmp = Math.floor(true);
1161 ok(tmp === 1, "Math.floor(true) = " + tmp);
1163 tmp = Math.floor(1.1, 3, 4);
1164 ok(tmp === 1, "Math.floor(1.1, 3, 4) = " + tmp);
1166 tmp = Math.floor();
1167 ok(isNaN(tmp), "floor is not NaN");
1169 tmp = Math.abs(3);
1170 ok(tmp === 3, "Math.abs(3) = " + tmp);
1172 tmp = Math.abs(-3);
1173 ok(tmp === 3, "Math.abs(-3) = " + tmp);
1175 tmp = Math.abs(true);
1176 ok(tmp === 1, "Math.abs(true) = " + tmp);
1178 tmp = Math.abs();
1179 ok(isNaN(tmp), "Math.abs() is not NaN");
1181 tmp = Math.abs(NaN);
1182 ok(isNaN(tmp), "Math.abs() is not NaN");
1184 tmp = Math.abs(-Infinity);
1185 ok(tmp === Infinity, "Math.abs(-Infinite) = " + tmp);
1187 tmp = Math.abs(-3, 2);
1188 ok(tmp === 3, "Math.abs(-3, 2) = " + tmp);
1190 tmp = Math.cos(0);
1191 ok(tmp === 1, "Math.cos(0) = " + tmp);
1193 tmp = Math.cos(Math.PI/2);
1194 ok(Math.floor(tmp*100) === 0, "Math.cos(Math.PI/2) = " + tmp);
1196 tmp = Math.cos(-Math.PI/2);
1197 ok(Math.floor(tmp*100) === 0, "Math.cos(-Math.PI/2) = " + tmp);
1199 tmp = Math.cos(Math.PI/3, 2);
1200 ok(Math.floor(tmp*100) === 50, "Math.cos(Math.PI/3, 2) = " + tmp);
1202 tmp = Math.cos(true);
1203 ok(Math.floor(tmp*100) === 54, "Math.cos(true) = " + tmp);
1205 tmp = Math.cos(false);
1206 ok(tmp === 1, "Math.cos(false) = " + tmp);
1208 tmp = Math.cos();
1209 ok(isNaN(tmp), "Math.cos() is not NaN");
1211 tmp = Math.cos(NaN);
1212 ok(isNaN(tmp), "Math.cos(NaN) is not NaN");
1214 tmp = Math.cos(Infinity);
1215 ok(isNaN(tmp), "Math.cos(Infinity) is not NaN");
1217 tmp = Math.cos(-Infinity);
1218 ok(isNaN(tmp), "Math.cos(-Infinity) is not NaN");
1220 tmp = Math.pow(2, 2);
1221 ok(tmp === 4, "Math.pow(2, 2) = " + tmp);
1223 tmp = Math.pow(4, 0.5);
1224 ok(tmp === 2, "Math.pow(2, 2) = " + tmp);
1226 tmp = Math.pow(2, 2, 3);
1227 ok(tmp === 4, "Math.pow(2, 2, 3) = " + tmp);
1229 tmp = Math.pow(2);
1230 ok(isNaN(tmp), "Math.pow(2) is not NaN");
1232 tmp = Math.pow();
1233 ok(isNaN(tmp), "Math.pow() is not NaN");
1235 tmp = Math.random();
1236 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
1237 ok(0 <= tmp && tmp <= 1, "Math.random() = " + tmp);
1239 tmp = Math.random(100);
1240 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
1241 ok(0 <= tmp && tmp <= 1, "Math.random(100) = " + tmp);
1243 tmp = Math.acos(0);
1244 ok(Math.floor(tmp*100) === 157, "Math.acos(0) = " + tmp);
1246 tmp = Math.acos(1);
1247 ok(Math.floor(tmp*100) === 0, "Math.acos(1) = " + tmp);
1249 tmp = Math.acos(-1);
1250 ok(Math.floor(tmp*100) === 314, "Math.acos(-1) = " + tmp);
1252 tmp = Math.acos(Math.PI/4, 2);
1253 ok(Math.floor(tmp*100) === 66, "Math.acos(Math.PI/4, 2) = " + tmp);
1255 tmp = Math.acos(true);
1256 ok(Math.floor(tmp*100) === 0, "Math.acos(true) = " + tmp);
1258 tmp = Math.acos(false);
1259 ok(Math.floor(tmp*100) === 157, "Math.acos(false) = " + tmp);
1261 tmp = Math.acos(1.1);
1262 ok(isNaN(tmp), "Math.acos(1.1) is not NaN");
1264 tmp = Math.acos();
1265 ok(isNaN(tmp), "Math.acos() is not NaN");
1267 tmp = Math.acos(NaN);
1268 ok(isNaN(tmp), "Math.acos(NaN) is not NaN");
1270 tmp = Math.acos(Infinity);
1271 ok(isNaN(tmp), "Math.acos(Infinity) is not NaN");
1273 tmp = Math.acos(-Infinity);
1274 ok(isNaN(tmp), "Math.acos(-Infinity) is not NaN");
1276 tmp = Math.asin(0);
1277 ok(Math.floor(tmp*100) === 0, "Math.asin(0) = " + tmp);
1279 tmp = Math.asin(1);
1280 ok(Math.floor(tmp*100) === 157, "Math.asin(1) = " + tmp);
1282 tmp = Math.asin(-1);
1283 ok(Math.floor(tmp*100) === -158, "Math.asin(-1) = " + tmp);
1285 tmp = Math.asin(Math.PI/4, 2);
1286 ok(Math.floor(tmp*100) === 90, "Math.asin(Math.PI/4, 2) = " + tmp);
1288 tmp = Math.asin(true);
1289 ok(Math.floor(tmp*100) === 157, "Math.asin(true) = " + tmp);
1291 tmp = Math.asin(false);
1292 ok(Math.floor(tmp*100) === 0, "Math.asin(false) = " + tmp);
1294 tmp = Math.asin(1.1);
1295 ok(isNaN(tmp), "Math.asin(1.1) is not NaN");
1297 tmp = Math.asin();
1298 ok(isNaN(tmp), "Math.asin() is not NaN");
1300 tmp = Math.asin(NaN);
1301 ok(isNaN(tmp), "Math.asin(NaN) is not NaN");
1303 tmp = Math.asin(Infinity);
1304 ok(isNaN(tmp), "Math.asin(Infinity) is not NaN");
1306 tmp = Math.asin(-Infinity);
1307 ok(isNaN(tmp), "Math.asin(-Infinity) is not NaN");
1309 tmp = Math.atan(0);
1310 ok(Math.floor(tmp*100) === 0, "Math.atan(0) = " + tmp);
1312 tmp = Math.atan(1);
1313 ok(Math.floor(tmp*100) === 78, "Math.atan(1) = " + tmp);
1315 tmp = Math.atan(-1);
1316 ok(Math.floor(tmp*100) === -79, "Math.atan(-1) = " + tmp);
1318 tmp = Math.atan(true);
1319 ok(Math.floor(tmp*100) === 78, "Math.atan(true) = " + tmp);
1321 tmp = Math.atan(false);
1322 ok(Math.floor(tmp*100) === 0, "Math.atan(false) = " + tmp);
1324 tmp = Math.atan();
1325 ok(isNaN(tmp), "Math.atan() is not NaN");
1327 tmp = Math.atan(NaN);
1328 ok(isNaN(tmp), "Math.atan(NaN) is not NaN");
1330 tmp = Math.atan(Infinity);
1331 ok(Math.floor(tmp*100) === 157, "Math.atan(Infinity) = " + tmp);
1333 tmp = Math.atan(-Infinity);
1334 ok(Math.floor(tmp*100) === -158, "Math.atan(Infinity) = " + tmp);
1336 tmp = Math.atan2(0, 0);
1337 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 0) = " + tmp);
1339 tmp = Math.atan2(0, 1);
1340 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 1) = " + tmp);
1342 tmp = Math.atan2(0, Infinity);
1343 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, Infinity) = " + tmp);
1345 tmp = Math.atan2(0, -1);
1346 ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -1) = " + tmp);
1348 tmp = Math.atan2(0, -Infinity);
1349 ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -Infinity) = " + tmp);
1351 tmp = Math.atan2(1, 0);
1352 ok(Math.floor(tmp*100) === 157, "Math.atan2(1, 0) = " + tmp);
1354 tmp = Math.atan2(Infinity, 0);
1355 ok(Math.floor(tmp*100) === 157, "Math.atan2(Infinity, 0) = " + tmp);
1357 tmp = Math.atan2(-1, 0);
1358 ok(Math.floor(tmp*100) === -158, "Math.atan2(-1, 0) = " + tmp);
1360 tmp = Math.atan2(-Infinity, 0);
1361 ok(Math.floor(tmp*100) === -158, "Math.atan2(-Infinity, 0) = " + tmp);
1363 tmp = Math.atan2(1, 1);
1364 ok(Math.floor(tmp*100) === 78, "Math.atan2(1, 1) = " + tmp);
1366 tmp = Math.atan2(-1, -1);
1367 ok(Math.floor(tmp*100) === -236, "Math.atan2(-1, -1) = " + tmp);
1369 tmp = Math.atan2(-1, 1);
1370 ok(Math.floor(tmp*100) === -79, "Math.atan2(-1, 1) = " + tmp);
1372 tmp = Math.atan2(Infinity, Infinity);
1373 ok(Math.floor(tmp*100) === 78, "Math.atan2(Infinity, Infinity) = " + tmp);
1375 tmp = Math.atan2(Infinity, -Infinity, 1);
1376 ok(Math.floor(tmp*100) === 235, "Math.atan2(Infinity, -Infinity, 1) = " + tmp);
1378 tmp = Math.atan2();
1379 ok(isNaN(tmp), "Math.atan2() is not NaN");
1381 tmp = Math.atan2(1);
1382 ok(isNaN(tmp), "Math.atan2(1) is not NaN");
1384 tmp = Math.exp(0);
1385 ok(tmp === 1, "Math.exp(0) = " + tmp);
1387 tmp = Math.exp(1);
1388 ok(Math.floor(tmp*100) === 271, "Math.exp(1) = " + tmp);
1390 tmp = Math.exp(-1);
1391 ok(Math.floor(tmp*100) === 36, "Math.exp(-1) = " + tmp);
1393 tmp = Math.exp(true);
1394 ok(Math.floor(tmp*100) === 271, "Math.exp(true) = " + tmp);
1396 tmp = Math.exp(1, 1);
1397 ok(Math.floor(tmp*100) === 271, "Math.exp(1, 1) = " + tmp);
1399 tmp = Math.exp();
1400 ok(isNaN(tmp), "Math.exp() is not NaN");
1402 tmp = Math.exp(NaN);
1403 ok(isNaN(tmp), "Math.exp(NaN) is not NaN");
1405 tmp = Math.exp(Infinity);
1406 ok(tmp === Infinity, "Math.exp(Infinity) = " + tmp);
1408 tmp = Math.exp(-Infinity);
1409 ok(tmp === 0, "Math.exp(-Infinity) = " + tmp);
1411 tmp = Math.log(1);
1412 ok(Math.floor(tmp*100) === 0, "Math.log(1) = " + tmp);
1414 tmp = Math.log(-1);
1415 ok(isNaN(tmp), "Math.log(-1) is not NaN");
1417 tmp = Math.log(true);
1418 ok(Math.floor(tmp*100) === 0, "Math.log(true) = " + tmp);
1420 tmp = Math.log(1, 1);
1421 ok(Math.floor(tmp*100) === 0, "Math.log(1, 1) = " + tmp);
1423 tmp = Math.log();
1424 ok(isNaN(tmp), "Math.log() is not NaN");
1426 tmp = Math.log(NaN);
1427 ok(isNaN(tmp), "Math.log(NaN) is not NaN");
1429 tmp = Math.log(Infinity);
1430 ok(tmp === Infinity, "Math.log(Infinity) = " + tmp);
1432 tmp = Math.log(-Infinity);
1433 ok(isNaN(tmp), "Math.log(-Infinity) is not NaN");
1435 tmp = Math.sin(0);
1436 ok(tmp === 0, "Math.sin(0) = " + tmp);
1438 tmp = Math.sin(Math.PI/2);
1439 ok(tmp === 1, "Math.sin(Math.PI/2) = " + tmp);
1441 tmp = Math.sin(-Math.PI/2);
1442 ok(tmp === -1, "Math.sin(-Math.PI/2) = " + tmp);
1444 tmp = Math.sin(Math.PI/3, 2);
1445 ok(Math.floor(tmp*100) === 86, "Math.sin(Math.PI/3, 2) = " + tmp);
1447 tmp = Math.sin(true);
1448 ok(Math.floor(tmp*100) === 84, "Math.sin(true) = " + tmp);
1450 tmp = Math.sin(false);
1451 ok(tmp === 0, "Math.sin(false) = " + tmp);
1453 tmp = Math.sin();
1454 ok(isNaN(tmp), "Math.sin() is not NaN");
1456 tmp = Math.sin(NaN);
1457 ok(isNaN(tmp), "Math.sin(NaN) is not NaN");
1459 tmp = Math.sin(Infinity);
1460 ok(isNaN(tmp), "Math.sin(Infinity) is not NaN");
1462 tmp = Math.sin(-Infinity);
1463 ok(isNaN(tmp), "Math.sin(-Infinity) is not NaN");
1465 tmp = Math.sqrt(0);
1466 ok(tmp === 0, "Math.sqrt(0) = " + tmp);
1468 tmp = Math.sqrt(4);
1469 ok(tmp === 2, "Math.sqrt(4) = " + tmp);
1471 tmp = Math.sqrt(-1);
1472 ok(isNaN(tmp), "Math.sqrt(-1) is not NaN");
1474 tmp = Math.sqrt(2, 2);
1475 ok(Math.floor(tmp*100) === 141, "Math.sqrt(2, 2) = " + tmp);
1477 tmp = Math.sqrt(true);
1478 ok(tmp === 1, "Math.sqrt(true) = " + tmp);
1480 tmp = Math.sqrt(false);
1481 ok(tmp === 0, "Math.sqrt(false) = " + tmp);
1483 tmp = Math.sqrt();
1484 ok(isNaN(tmp), "Math.sqrt() is not NaN");
1486 tmp = Math.sqrt(NaN);
1487 ok(isNaN(tmp), "Math.sqrt(NaN) is not NaN");
1489 tmp = Math.sqrt(Infinity);
1490 ok(tmp === Infinity, "Math.sqrt(Infinity) = " + tmp);
1492 tmp = Math.sqrt(-Infinity);
1493 ok(isNaN(tmp), "Math.sqrt(-Infinity) is not NaN");
1495 tmp = Math.tan(0);
1496 ok(tmp === 0, "Math.tan(0) = " + tmp);
1498 tmp = Math.tan(Math.PI);
1499 ok(Math.floor(tmp*100) === -1, "Math.tan(Math.PI) = " + tmp);
1501 tmp = Math.tan(2, 2);
1502 ok(Math.floor(tmp*100) === -219, "Math.tan(2, 2) = " + tmp);
1504 tmp = Math.tan(true);
1505 ok(Math.floor(tmp*100) === 155, "Math.tan(true) = " + tmp);
1507 tmp = Math.tan(false);
1508 ok(tmp === 0, "Math.tan(false) = " + tmp);
1510 tmp = Math.tan();
1511 ok(isNaN(tmp), "Math.tan() is not NaN");
1513 tmp = Math.tan(NaN);
1514 ok(isNaN(tmp), "Math.tan(NaN) is not NaN");
1516 tmp = Math.tan(Infinity);
1517 ok(isNaN(tmp), "Math.tan(Infinity) is not NaN");
1519 tmp = Math.tan(-Infinity);
1520 ok(isNaN(tmp), "Math.tan(-Infinity) is not NaN");
1522 var func = function  (a) {
1523         var a = 1;
1524         if(a) return;
1525     };
1526 ok(func.toString() === "function  (a) {\n        var a = 1;\n        if(a) return;\n    }",
1527    "func.toString() = " + func.toString());
1528 ok("" + func === "function  (a) {\n        var a = 1;\n        if(a) return;\n    }",
1529    "'' + func.toString() = " + func);
1531 ok(func.valueOf === Object.prototype.valueOf, "func.valueOf !== Object.prototype.valueOf");
1532 ok(func === func.valueOf(), "func !== func.valueOf()");
1534 function testFuncToString(x,y) {
1535     return x+y;
1537 ok(testFuncToString.toString() === "function testFuncToString(x,y) {\n    return x+y;\n}",
1538    "testFuncToString.toString() = " + testFuncToString.toString());
1539 ok("" + testFuncToString === "function testFuncToString(x,y) {\n    return x+y;\n}",
1540    "'' + testFuncToString = " + testFuncToString);
1542 tmp = new Object();
1544 function callTest(argc) {
1545     ok(this === tmp, "this !== tmp\n");
1546     ok(arguments.length === argc+1, "arguments.length = " + arguments.length + " expected " + (argc+1));
1547     for(var i=1; i <= argc; i++)
1548         ok(arguments[i] === i, "arguments[i] = " + arguments[i]);
1551 callTest.call(tmp, 1, 1);
1552 callTest.call(tmp, 2, 1, 2);
1554 callTest.apply(tmp, [1, 1]);
1555 callTest.apply(tmp, [2, 1, 2]);
1556 (function () { callTest.apply(tmp, arguments); })(2,1,2);
1558 function callTest2() {
1559     ok(this === tmp, "this !== tmp\n");
1560     ok(arguments.length === 0, "callTest2: arguments.length = " + arguments.length + " expected 0");
1563 callTest2.call(tmp);
1564 callTest2.apply(tmp, []);
1565 callTest2.apply(tmp);
1566 (function () { callTest2.apply(tmp, arguments); })();
1568 function callTest3() {
1569     testThis(this);
1570     ok(arguments.length === 0, "arguments.length = " + arguments.length + " expected 0");
1573 callTest3.call();
1574 callTest3.call(undefined);
1575 callTest3.call(null);
1576 callTest3.apply();
1577 callTest3.apply(undefined);
1578 callTest3.apply(null);
1580 tmp = Number.prototype.toString.call(3);
1581 ok(tmp === "3", "Number.prototype.toString.call(3) = " + tmp);
1583 var func = new Function("return 3;");
1585 tmp = func();
1586 ok(tmp === 3, "func() = " + tmp);
1587 ok(func.call() === 3, "func.call() = " + tmp);
1588 ok(func.length === 0, "func.length = " + func.length);
1589 tmp = func.toString();
1590 ok(tmp === "function anonymous() {\nreturn 3;\n}", "func.toString() = " + tmp);
1592 func = new Function("x", "return x+2;");
1593 tmp = func(1);
1594 ok(tmp === 3, "func(1) = " + tmp);
1595 tmp = func.toString();
1596 ok(tmp === "function anonymous(x) {\nreturn x+2;\n}", "func.toString() = " + tmp);
1598 tmp = (new Function("x ", "return x+2;")).toString();
1599 ok(tmp === "function anonymous(x ) {\nreturn x+2;\n}", "func.toString() = " + tmp);
1601 func = new Function("x", "y", "return x+y");
1602 tmp = func(1,3);
1603 ok(tmp === 4, "func(1,3) = " + tmp);
1604 tmp = func.toString();
1605 ok(tmp === "function anonymous(x, y) {\nreturn x+y\n}", "func.toString() = " + tmp);
1607 func = new Function(" x, \ty", "\tz", "return x+y+z;");
1608 tmp = func(1,3,2);
1609 ok(tmp === 6, "func(1,3,2) = " + tmp);
1610 ok(func.length === 3, "func.length = " + func.length);
1611 tmp = func.toString();
1612 ok(tmp === "function anonymous( x, \ty, \tz) {\nreturn x+y+z;\n}", "func.toString() = " + tmp);
1614 func = new Function();
1615 tmp = func();
1616 ok(tmp === undefined, "func() = " + tmp);
1617 tmp = func.toString();
1618 ok(tmp == "function anonymous() {\n\n}", "func.toString() = " + tmp);
1620 func = (function() {
1621         var tmp = 3;
1622         return new Function("return tmp;");
1623     })();
1624 tmp = 2;
1625 tmp = func();
1626 ok(tmp === 2, "func() = " + tmp);
1628 var date = new Date();
1630 date = new Date(100);
1631 ok(date.getTime() === 100, "date.getTime() = " + date.getTime());
1632 ok(Date.prototype.getTime() === 0, "date.prototype.getTime() = " + Date.prototype.getTime());
1633 date = new Date(8.64e15);
1634 ok(date.getTime() === 8.64e15, "date.getTime() = " + date.getTime());
1635 date = new Date(8.64e15+1);
1636 ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
1637 date = new Date(Infinity);
1638 ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
1639 date = new Date("3 July 2009 22:28:00 UTC+0100");
1640 ok(date.getTime() === 1246656480000, "date.getTime() = " + date.getTime());
1641 date = new Date(1984, 11, 29, 13, 51, 24, 120);
1642 ok(date.getFullYear() === 1984, "date.getFullYear() = " + date.getFullYear());
1643 ok(date.getMonth() === 11, "date.getMonth() = " + date.getMonth());
1644 ok(date.getDate() === 29, "date.getDate() = " + date.getDate());
1645 ok(date.getHours() === 13, "date.getHours() = " + date.getHours());
1646 ok(date.getMinutes() === 51, "date.getMinutes() = " + date.getMinutes());
1647 ok(date.getSeconds() === 24, "date.getSeconds() = " + date.getSeconds());
1648 ok(date.getMilliseconds() === 120, "date.getMilliseconds() = " + date.getMilliseconds());
1649 date = new Date(731, -32, 40, -1, 70, 65, -13);
1650 ok(date.getFullYear() === 728, "date.getFullYear() = " + date.getFullYear());
1651 ok(date.getMonth() === 5, "date.getMonth() = " + date.getMonth());
1652 ok(date.getDate() === 9, "date.getDate() = " + date.getDate());
1653 ok(date.getHours() === 0, "date.getHours() = " + date.getHours());
1654 ok(date.getMinutes() === 11, "date.getMinutes() = " + date.getMinutes());
1655 ok(date.getSeconds() === 4, "date.getSeconds() = " + date.getSeconds());
1656 ok(date.getMilliseconds() === 987, "date.getMilliseconds() = " + date.getMilliseconds());
1658 ok(date.setTime(123) === 123, "date.setTime(123) !== 123");
1659 ok(date.setTime("123", NaN) === 123, "date.setTime(\"123\") !== 123");
1660 ok(isNaN(date.setTime(NaN)), "date.setTime(NaN) is not NaN");
1662 ok(date.setTime(0) === date.getTime(), "date.setTime(0) !== date.getTime()");
1663 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
1664 ok(date.getUTCMonth() === 0, "date.getUTCMonth() = " + date.getUTCMonth());
1665 ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
1666 ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
1667 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
1668 ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
1669 ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
1670 ok(date.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1672 date.setTime(60*24*60*60*1000);
1673 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
1674 ok(date.getUTCMonth() === 2, "date.getUTCMonth() = " + date.getUTCMonth());
1675 ok(date.getUTCDate() === 2, "date.getUTCDate() = " + date.getUTCDate());
1676 ok(date.getUTCDay() === 1, "date.getUTCDay() = " + date.getUTCDay());
1677 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
1678 ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
1679 ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
1680 ok(date.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1682 date.setTime(59*24*60*60*1000 + 4*365*24*60*60*1000 + 60*60*1000 + 2*60*1000 + 2*1000 + 640);
1683 ok(date.getUTCFullYear() === 1974, "date.getUTCFullYear() = " + date.getUTCFullYear());
1684 ok(date.getUTCMonth() === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1685 ok(date.getUTCMonth(123) === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1686 ok(date.getUTCDate() === 28, "date.getUTCDate() = " + date.getUTCDate());
1687 ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
1688 ok(date.getUTCHours() === 1, "date.getUTCHours() = " + date.getUTCHours());
1689 ok(date.getUTCMinutes() === 2, "date.getUTCMinutes() = " + date.getUTCMinutes());
1690 ok(date.getUTCSeconds() === 2, "date.getUTCSeconds() = " + date.getUTCSeconds());
1691 ok(date.getUTCMilliseconds() === 640, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1693 tmp = date.setYear(96);
1694 ok(date.getYear() === 96, "date.getYear() = " + date.getYear());
1695 ok(date.getFullYear() === 1996, "date.getFullYear() = " + date.getYear());
1696 ok(date.getUTCMonth() === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1697 ok(date.getUTCMonth(123) === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1698 ok(date.getUTCMilliseconds() === 640, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1700 tmp = date.setYear(2010);
1701 ok(tmp === date.getTime(), "date.setYear(2010) = " + tmp);
1702 ok(date.getYear() === 2010, "date.getYear() = " + date.getYear());
1703 ok(date.getFullYear() === 2010, "date.getFullYear() = " + date.getYear());
1704 ok(date.getUTCMonth() === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1705 ok(date.getUTCMonth(123) === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1706 ok(date.getUTCMilliseconds() === 640, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1708 date.setTime(Infinity);
1709 ok(isNaN(date.getUTCFullYear()), "date.getUTCFullYear() is not NaN");
1710 ok(isNaN(date.getUTCMonth()), "date.getUTCMonth() is not NaN");
1711 ok(isNaN(date.getUTCDate()), "date.getUTCDate() is not NaN");
1712 ok(isNaN(date.getUTCDay()), "date.getUTCDay() is not NaN");
1713 ok(isNaN(date.getUTCHours()), "date.getUTCHours() is not NaN");
1714 ok(isNaN(date.getUTCMinutes()), "date.getUTCMinutes() is not NaN");
1715 ok(isNaN(date.getUTCSeconds()), "date.getUTCSeconds() is not NaN");
1716 ok(isNaN(date.getUTCMilliseconds()), "date.getUTCMilliseconds() is not NaN");
1717 ok(isNaN(date.setMilliseconds(0)), "date.setMilliseconds() is not NaN");
1719 date.setTime(0);
1720 tmp = date.setYear(NaN);
1721 ok(isNaN(tmp), "date.setYear(NaN) = " + tmp);
1722 ok(isNaN(date.getUTCFullYear()), "date.getUTCFullYear() is not NaN");
1723 ok(isNaN(date.getUTCMonth()), "date.getUTCMonth() is not NaN");
1725 date.setTime(0);
1726 date.setUTCMilliseconds(-10, 2);
1727 ok(date.getUTCMilliseconds() === 990, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1728 date.setUTCMilliseconds(10);
1729 ok(date.getUTCMilliseconds() === 10, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1730 date.setUTCSeconds(-10);
1731 ok(date.getUTCSeconds() === 50, "date.getUTCSeconds() = " + date.getUTCSeconds());
1732 date.setUTCMinutes(-10);
1733 ok(date.getUTCMinutes() === 50, "date.getUTCMinutes() = " + date.getUTCMinutes());
1734 date.setUTCHours(-10);
1735 ok(date.getUTCHours() === 14, "date.getUTCHours() = " + date.getUTCHours());
1736 date.setUTCHours(-123);
1737 ok(date.getTime() === -612549990, "date.getTime() = " + date.getTime());
1738 date.setUTCHours(20);
1739 ok(date.getUTCHours() === 20, "date.getUTCHours() = " + date.getUTCHours());
1740 date.setUTCDate(32);
1741 ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
1742 date.setUTCMonth(22, 37);
1743 ok(date.getTime() === 60987050010, "date.getTime() = " + date.getTime());
1744 date.setUTCFullYear(83, 21, 321);
1745 ok(date.getTime() === -59464984149990, "date.getTime() = " + date.getTime());
1746 ok(Math.abs(date) === 59464984149990, "Math.abs(date) = " + Math.abs(date));
1747 ok(getVT(date+1) === "VT_BSTR", "getVT(date+1) = " + getVT(date+1));
1749 ok(isNaN(Date.parse()), "Date.parse() is not NaN");
1750 ok(isNaN(Date.parse("")), "Date.parse(\"\") is not NaN");
1751 ok(isNaN(Date.parse("Jan Jan 20 2009")), "Date.parse(\"Jan Jan 20 2009\") is not NaN");
1752 ok(Date.parse("Jan 20 2009 UTC") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC\") = " + Date.parse("Jan 20 2009 UTC"));
1753 ok(Date.parse("Jan 20 2009 GMT") === 1232409600000, "Date.parse(\"Jan 20 2009 GMT\") = " + Date.parse("Jan 20 2009 GMT"));
1754 ok(Date.parse("Jan 20 2009 UTC-0") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC-0\") = " + Date.parse("Jan 20 2009 UTC-0"));
1755 ok(Date.parse("Jan 20 2009 UTC+0000") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC+0000\") = " + Date.parse("Jan 20 2009 UTC+0000"));
1756 ok(Date.parse("Ju 13 79 UTC") === 300672000000, "Date.parse(\"Ju 13 79 UTC\") = " + Date.parse("Ju 13 79 UTC"));
1757 ok(Date.parse("12Au91 UTC") === 681955200000, "Date.parse(\"12Au91 UTC\") = " + Date.parse("12Au91 UTC"));
1758 ok(Date.parse("7/02/17 UTC") === -1656806400000, "Date.parse(\"7/02/17 UTC\") = " + Date.parse("7/02/17 UTC"));
1759 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"));
1760 ok(Date.parse("February 31   UTC, 2000 12:31:17 PM") === 952000277000,
1761         "Date.parse(\"February 31   UTC, 2000 12:31:17 PM\") = " + Date.parse("February 31   UTC, 2000 12:31:17 PM"));
1762 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 "));
1763 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"));
1765 ok(typeof(Math.PI) === "number", "typeof(Math.PI) = " + typeof(Math.PI));
1766 ok(Math.floor(Math.PI*100) === 314, "Math.PI = " + Math.PI);
1767 Math.PI = "test";
1768 ok(Math.floor(Math.PI*100) === 314, "modified Math.PI = " + Math.PI);
1770 ok(typeof(Math.E) === "number", "typeof(Math.E) = " + typeof(Math.E));
1771 ok(Math.floor(Math.E*100) === 271, "Math.E = " + Math.E);
1772 Math.E = "test";
1773 ok(Math.floor(Math.E*100) === 271, "modified Math.E = " + Math.E);
1775 ok(typeof(Math.LOG2E) === "number", "typeof(Math.LOG2E) = " + typeof(Math.LOG2E));
1776 ok(Math.floor(Math.LOG2E*100) === 144, "Math.LOG2E = " + Math.LOG2E);
1777 Math.LOG2E = "test";
1778 ok(Math.floor(Math.LOG2E*100) === 144, "modified Math.LOG2E = " + Math.LOG2E);
1780 ok(typeof(Math.LOG10E) === "number", "typeof(Math.LOG10E) = " + typeof(Math.LOG10E));
1781 ok(Math.floor(Math.LOG10E*100) === 43, "Math.LOG10E = " + Math.LOG10E);
1782 Math.LOG10E = "test";
1783 ok(Math.floor(Math.LOG10E*100) === 43, "modified Math.LOG10E = " + Math.LOG10E);
1785 ok(typeof(Math.LN2) === "number", "typeof(Math.LN2) = " + typeof(Math.LN2));
1786 ok(Math.floor(Math.LN2*100) === 69, "Math.LN2 = " + Math.LN2);
1787 Math.LN2 = "test";
1788 ok(Math.floor(Math.LN2*100) === 69, "modified Math.LN2 = " + Math.LN2);
1790 ok(typeof(Math.LN10) === "number", "typeof(Math.LN10) = " + typeof(Math.LN10));
1791 ok(Math.floor(Math.LN10*100) === 230, "Math.LN10 = " + Math.LN10);
1792 Math.LN10 = "test";
1793 ok(Math.floor(Math.LN10*100) === 230, "modified Math.LN10 = " + Math.LN10);
1795 ok(typeof(Math.SQRT2) === "number", "typeof(Math.SQRT2) = " + typeof(Math.SQRT2));
1796 ok(Math.floor(Math.SQRT2*100) === 141, "Math.SQRT2 = " + Math.SQRT2);
1797 Math.SQRT2 = "test";
1798 ok(Math.floor(Math.SQRT2*100) === 141, "modified Math.SQRT2 = " + Math.SQRT2);
1800 ok(typeof(Math.SQRT1_2) === "number", "typeof(Math.SQRT1_2) = " + typeof(Math.SQRT1_2));
1801 ok(Math.floor(Math.SQRT1_2*100) === 70, "Math.SQRT1_2 = " + Math.SQRT1_2);
1802 Math.SQRT1_2 = "test";
1803 ok(Math.floor(Math.SQRT1_2*100) === 70, "modified Math.SQRT1_2 = " + Math.SQRT1_2);
1805 ok(isNaN.toString() === "\nfunction isNaN() {\n    [native code]\n}\n",
1806    "isNaN.toString = '" + isNaN.toString() + "'");
1807 ok(Array.toString() === "\nfunction Array() {\n    [native code]\n}\n",
1808    "isNaN.toString = '" + Array.toString() + "'");
1809 ok(Function.toString() === "\nfunction Function() {\n    [native code]\n}\n",
1810    "isNaN.toString = '" + Function.toString() + "'");
1811 ok(Function.prototype.toString() === "\nfunction prototype() {\n    [native code]\n}\n",
1812    "isNaN.toString = '" + Function.prototype.toString() + "'");
1813 ok("".substr.toString() === "\nfunction substr() {\n    [native code]\n}\n",
1814    "''.substr.toString = '" + "".substr.toString() + "'");
1816 var bool = new Boolean();
1817 ok(bool.toString() === "false", "bool.toString() = " + bool.toString());
1818 var bool = new Boolean("false");
1819 ok(bool.toString() === "true", "bool.toString() = " + bool.toString());
1820 ok(bool.valueOf() === Boolean(1), "bool.valueOf() = " + bool.valueOf());
1821 ok(bool.toLocaleString() === bool.toString(), "bool.toLocaleString() = " + bool.toLocaleString());
1823 ok(ActiveXObject instanceof Function, "ActiveXObject is not instance of Function");
1824 ok(ActiveXObject.prototype instanceof Object, "ActiveXObject.prototype is not instance of Object");
1826 ok(Error.prototype !== TypeError.prototype, "Error.prototype === TypeError.prototype");
1827 ok(RangeError.prototype !== TypeError.prototype, "RangeError.prototype === TypeError.prototype");
1828 ok(Error.prototype.toLocaleString === Object.prototype.toLocaleString,
1829         "Error.prototype.toLocaleString !== Object.prototype.toLocaleString");
1830 err = new Error();
1831 ok(err.valueOf === Object.prototype.valueOf, "err.valueOf !== Object.prototype.valueOf");
1832 ok(Error.prototype.name === "Error", "Error.prototype.name = " + Error.prototype.name);
1833 ok(err.name === "Error", "err.name = " + err.name);
1834 EvalError.prototype.message = "test";
1835 ok(err.toString !== Object.prototype.toString, "err.toString === Object.prototype.toString");
1836 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "Error"), "err.toString() = " + err.toString());
1837 err = new EvalError();
1838 ok(EvalError.prototype.name === "EvalError", "EvalError.prototype.name = " + EvalError.prototype.name);
1839 ok(err.name === "EvalError", "err.name = " + err.name);
1840 ok(err.toString === Error.prototype.toString, "err.toString !== Error.prototype.toString");
1841 ok(err.message === "", "err.message != ''");
1842 err.message = date;
1843 ok(err.message === date, "err.message != date");
1844 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "EvalError: "+err.message),
1845    "err.toString() = " + err.toString());
1846 ok(err.toString !== Object.prototype.toString, "err.toString === Object.prototype.toString");
1847 err = new RangeError();
1848 ok(RangeError.prototype.name === "RangeError", "RangeError.prototype.name = " + RangeError.prototype.name);
1849 ok(err.name === "RangeError", "err.name = " + err.name);
1850 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "RangeError"), "err.toString() = " + err.toString());
1851 err = new ReferenceError();
1852 ok(ReferenceError.prototype.name === "ReferenceError", "ReferenceError.prototype.name = " + ReferenceError.prototype.name);
1853 ok(err.name === "ReferenceError", "err.name = " + err.name);
1854 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "ReferenceError"), "err.toString() = " + err.toString());
1855 err = new SyntaxError();
1856 ok(SyntaxError.prototype.name === "SyntaxError", "SyntaxError.prototype.name = " + SyntaxError.prototype.name);
1857 ok(err.name === "SyntaxError", "err.name = " + err.name);
1858 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "SyntaxError"), "err.toString() = " + err.toString());
1859 err = new TypeError();
1860 ok(TypeError.prototype.name === "TypeError", "TypeError.prototype.name = " + TypeError.prototype.name);
1861 ok(err.name === "TypeError", "err.name = " + err.name);
1862 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "TypeError"), "err.toString() = " + err.toString());
1863 err = new URIError();
1864 ok(URIError.prototype.name === "URIError", "URIError.prototype.name = " + URIError.prototype.name);
1865 ok(err.name === "URIError", "err.name = " + err.name);
1866 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "URIError"), "err.toString() = " + err.toString());
1867 err = new Error("message");
1868 ok(err.message === "message", "err.message !== 'message'");
1869 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "Error: message"), "err.toString() = " + err.toString());
1870 err = new Error(123);
1871 ok(err.number === 123, "err.number = " + err.number);
1872 err.number = 254;
1873 ok(err.number === 254, "err.number = " + err.number);
1874 err = new Error(0, "message");
1875 ok(err.number === 0, "err.number = " + err.number);
1876 ok(err.message === "message", "err.message = " + err.message);
1877 ok(err.description === "message", "err.description = " + err.description);
1878 err = new Error();
1879 ok(err.number === 0, "err.number = " + err.number);
1880 ok(err.description === "", "err.description = " + err.description);
1881 err.description = 5;
1882 ok(err.description === 5, "err.description = " + err.description);
1883 ok(err.message === "", "err.message = " + err.message);
1884 err.message = 4;
1885 ok(err.message === 4, "err.message = " + err.message);
1887 ok(!("number" in Error), "number is in Error");
1889 tmp = new Object();
1890 ok(tmp.hasOwnProperty("toString") === false, "toString property should be inherited");
1891 tmp.toString = function() { return "test"; };
1892 ok(tmp.hasOwnProperty("toString") === true, "toString own property should exist");
1893 ok(tmp.hasOwnProperty("nonExisting") === false, "nonExisting property should not exist");
1895 tmp = Error.prototype.toString.call(tmp);
1896 ok(tmp === "[object Error]", "Error.prototype.toString.call(tmp) = " + tmp);
1898 tmp = function() { return 0; };
1899 tmp[0] = true;
1900 ok(tmp.hasOwnProperty("toString") === false, "toString property should be inherited");
1901 ok(tmp.hasOwnProperty("0") === true, "hasOwnProperty(0) returned false");
1902 ok(tmp.hasOwnProperty() === false, "hasOwnProperty() returned true");
1904 ok(Object.prototype.hasOwnProperty.call(testObj) === false, "hasOwnProperty without name returned true");
1906 if(invokeVersion >= 2) {
1907     obj = new Object();
1908     obj.name = "test";
1909     tmp = Error.prototype.toString.call(obj);
1910     ok(tmp === "test", "Error.prototype.toString.call(obj) = " + tmp);
1912     obj = new Object();
1913     obj.name = 6;
1914     obj.message = false;
1915     tmp = Error.prototype.toString.call(obj);
1916     ok(tmp === "6: false", "Error.prototype.toString.call(obj) = " + tmp);
1918     obj = new Object();
1919     obj.message = "test";
1920     tmp = Error.prototype.toString.call(obj);
1921     ok(tmp === "test", "Error.prototype.toString.call(obj) = " + tmp);
1923     obj = new Object();
1924     obj.name = "";
1925     obj.message = "test";
1926     tmp = Error.prototype.toString.call(obj);
1927     ok(tmp === "test", "Error.prototype.toString.call(obj) = " + tmp);
1930 tmp = Error.prototype.toString.call(testObj);
1931 ok(tmp === "[object Error]", "Error.prototype.toString.call(testObj) = " + tmp);
1933 err = new Error();
1934 err.name = null;
1935 ok(err.name === null, "err.name = " + err.name + " expected null");
1936 if(invokeVersion >= 2)
1937     ok(err.toString() === "null", "err.toString() = " + err.toString());
1939 err = new Error();
1940 err.message = false;
1941 ok(err.message === false, "err.message = " + err.message + " expected false");
1942 if(invokeVersion >= 2)
1943     ok(err.toString() === "Error: false", "err.toString() = " + err.toString());
1945 err = new Error();
1946 err.message = new Object();
1947 err.message.toString = function() { return ""; };
1948 if(invokeVersion >= 2)
1949     ok(err.toString() === "Error", "err.toString() = " + err.toString());
1951 err = new Error();
1952 err.message = undefined;
1953 if(invokeVersion >= 2)
1954     ok(err.toString() === "Error", "err.toString() = " + err.toString());
1956 var exception_array = {
1957     E_INVALID_LENGTH:  { type: "RangeError",  number: -2146823259 },
1959     E_NOT_DATE:            { type: "TypeError",   number: -2146823282 },
1960     E_NOT_BOOL:            { type: "TypeError",   number: -2146823278 },
1961     E_ARG_NOT_OPT:         { type: "TypeError",   number: -2146827839 },
1962     E_NO_PROPERTY:         { type: "TypeError",   number: -2146827850 },
1963     E_NOT_NUM:             { type: "TypeError",   number: -2146823287 },
1964     E_INVALID_CALL_ARG:    { type: "TypeError",   number: -2146828283 },
1965     E_NOT_FUNC:            { type: "TypeError",   number: -2146823286 },
1966     E_OBJECT_EXPECTED:     { type: "TypeError", number: -2146823281 },
1967     E_OBJECT_REQUIRED:     { type: "TypeError", number: -2146827864 },
1968     E_UNSUPPORTED_ACTION:  { type: "TypeError", number: -2146827843 },
1969     E_NOT_VBARRAY:         { type: "TypeError", number: -2146823275 },
1970     E_INVALID_DELETE:      { type: "TypeError", number: -2146823276 },
1971     E_UNDEFINED:           { type: "TypeError", number: -2146823279 },
1972     E_JSCRIPT_EXPECTED:    { type: "TypeError", number: -2146823274 },
1973     E_NOT_ARRAY:           { type: "TypeError", number: -2146823257 },
1975     E_SYNTAX_ERROR:      { type: "SyntaxError",  number: -2146827286 },
1976     E_LBRACKET:          { type: "SyntaxError",  number: -2146827283 },
1977     E_RBRACKET:          { type: "SyntaxError",  number: -2146827282 },
1978     E_SEMICOLON:         { type: "SyntaxError",  number: -2146827284 },
1979     E_UNTERMINATED_STR:  { type: "SyntaxError",  number: -2146827273 },
1980     E_DISABLED_CC:       { type: "SyntaxError",  number: -2146827258 },
1982     E_ILLEGAL_ASSIGN:  { type: "ReferenceError", number: -2146823280 },
1984     E_SUBSCRIPT_OUT_OF_RANGE:  {type: "RangeError", number: -2146828279 },
1986     E_REGEXP_SYNTAX_ERROR:  { type: "RegExpError", number: -2146823271 },
1988     E_URI_INVALID_CHAR:     { type: "URIError", number: -2146823264 },
1989     E_URI_INVALID_CODING:   { type: "URIError", number: -2146823263 }
1992 function testException(func, id) {
1993     var ex = exception_array[id];
1994     var ret = "", num = "";
1996     try {
1997         func();
1998     } catch(e) {
1999         ret = e.name;
2000         num = e.number;
2001     }
2003     ok(ret === ex.type, "Exception test, ret = " + ret + ", expected " + ex.type +". Executed function: " + func.toString());
2004     ok(num === ex.number, "Exception test, num = " + num + ", expected " + ex.number + ". Executed function: " + func.toString());
2007 // RangeError tests
2008 testException(function() {Array(-3);}, "E_INVALID_LENGTH");
2009 testException(function() {createArray().lbound("aaa");}, "E_SUBSCRIPT_OUT_OF_RANGE");
2010 testException(function() {createArray().lbound(3);}, "E_SUBSCRIPT_OUT_OF_RANGE");
2011 testException(function() {createArray().getItem(3);}, "E_SUBSCRIPT_OUT_OF_RANGE");
2013 // TypeError tests
2014 testException(function() {date.setTime();}, "E_ARG_NOT_OPT");
2015 testException(function() {date.setYear();}, "E_ARG_NOT_OPT");
2016 testException(function() {arr.test();}, "E_NO_PROPERTY");
2017 testException(function() {arr.toString = Number.prototype.toString; arr.toString();}, "E_NOT_NUM");
2018 testException(function() {(new Number(3)).toString(1);}, "E_INVALID_CALL_ARG");
2019 testException(function() {not_existing_variable.something();}, "E_UNDEFINED");
2020 testException(function() {date();}, "E_NOT_FUNC");
2021 testException(function() {arr();}, "E_NOT_FUNC");
2022 testException(function() {(new Object) instanceof (new Object);}, "E_NOT_FUNC");
2023 testException(function() {eval("nonexistingfunc()")}, "E_OBJECT_EXPECTED");
2024 testException(function() {(new Object()) instanceof 3;}, "E_NOT_FUNC");
2025 testException(function() {(new Object()) instanceof null;}, "E_NOT_FUNC");
2026 testException(function() {(new Object()) instanceof nullDisp;}, "E_NOT_FUNC");
2027 testException(function() {"test" in 3;}, "E_OBJECT_EXPECTED");
2028 testException(function() {"test" in null;}, "E_OBJECT_EXPECTED");
2029 testException(function() {"test" in nullDisp;}, "E_OBJECT_EXPECTED");
2030 testException(function() {new 3;}, "E_UNSUPPORTED_ACTION");
2031 testException(function() {new null;}, "E_OBJECT_EXPECTED");
2032 testException(function() {new nullDisp;}, "E_NO_PROPERTY");
2033 testException(function() {new VBArray();}, "E_NOT_VBARRAY");
2034 testException(function() {new VBArray(new VBArray(createArray()));}, "E_NOT_VBARRAY");
2035 testException(function() {VBArray.prototype.lbound.call(new Object());}, "E_NOT_VBARRAY");
2036 testException(function() {+nullDisp.prop;}, "E_OBJECT_REQUIRED");
2037 testException(function() {+nullDisp["prop"];}, "E_OBJECT_REQUIRED");
2038 testException(function() {delete (new Object());}, "E_INVALID_DELETE");
2039 testException(function() {delete false;}, "E_INVALID_DELETE");
2041 obj = new Object();
2042 obj.prop = 1;
2043 tmp = false;
2044 testException(function() {delete ((tmp = true) ? obj.prop : obj.prop);}, "E_INVALID_DELETE");
2045 ok(tmp, "delete (..) expression not evaluated");
2047 //FIXME: testException(function() {nonexistent++;}, "E_OBJECT_EXPECTED");
2048 //FIXME: testException(function() {undefined.nonexistent++;}, "E_OBJECT_EXPECTED");
2051 // SyntaxError tests
2052 function testSyntaxError(code, id) {
2053     var ex = exception_array[id];
2054     var ret = "", num = "";
2056     try {
2057         eval(code);
2058     } catch(e) {
2059         ret = e.name;
2060         num = e.number;
2061     }
2063     ok(ret === ex.type, "Syntax exception test, ret = " + ret + ", expected " + ex.type +". Executed code: " + code);
2064     ok(num === ex.number, "Syntax exception test, num = " + num + ", expected " + ex.number + ". Executed code: " + code);
2067 testSyntaxError("for(i=0;) {}", "E_SYNTAX_ERROR");
2068 testSyntaxError("function {};", "E_LBRACKET");
2069 testSyntaxError("if", "E_LBRACKET");
2070 testSyntaxError("do i=0; while", "E_LBRACKET");
2071 testSyntaxError("while", "E_LBRACKET");
2072 testSyntaxError("for", "E_LBRACKET");
2073 testSyntaxError("with", "E_LBRACKET");
2074 testSyntaxError("switch", "E_LBRACKET");
2075 testSyntaxError("if(false", "E_RBRACKET");
2076 testSyntaxError("for(i=0; i<10; i++", "E_RBRACKET");
2077 testSyntaxError("while(true", "E_RBRACKET");
2078 testSyntaxError("for(i=0", "E_SEMICOLON");
2079 testSyntaxError("for(i=0;i<10", "E_SEMICOLON");
2080 testSyntaxError("while(", "E_SYNTAX_ERROR");
2081 testSyntaxError("if(", "E_SYNTAX_ERROR");
2082 testSyntaxError("'unterminated", "E_UNTERMINATED_STR");
2083 testSyntaxError("*", "E_SYNTAX_ERROR");
2084 testSyntaxError("@_jscript_version", "E_DISABLED_CC");
2085 testSyntaxError("@a", "E_DISABLED_CC");
2086 testSyntaxError("/* @cc_on @*/ @_jscript_version", "E_DISABLED_CC");
2088 // ReferenceError tests
2089 testException(function() {test = function() {}}, "E_ILLEGAL_ASSIGN");
2091 tmp = false;
2092 testException(function() {test = (tmp = true);}, "E_ILLEGAL_ASSIGN");
2093 ok(tmp, "expr value on invalid assign not evaluated");
2095 tmp = false;
2096 testException(function() {(tmp = true) = false;}, "E_ILLEGAL_ASSIGN");
2097 ok(tmp, "expr assign not evaluated");
2099 tmp = false;
2100 testException(function() {true = (tmp = true);}, "E_ILLEGAL_ASSIGN");
2101 ok(tmp, "expr value assign not evaluated");
2103 tmp = "";
2104 testException(function() {(tmp = tmp+"1") = (tmp = tmp+"2");}, "E_ILLEGAL_ASSIGN");
2105 ok(tmp === "12", "assign evaluated in unexpected order");
2107 tmp = false;
2108 testException(function() { ((tmp = true) && false)++; }, "E_ILLEGAL_ASSIGN")
2109 ok(tmp, "incremented expression not evaluated");
2111 // RegExpError tests
2112 testException(function() {RegExp(/a/, "g");}, "E_REGEXP_SYNTAX_ERROR");
2114 // URIError tests
2115 testException(function() {encodeURI('\udcaa');}, "E_URI_INVALID_CHAR");
2116 testException(function() {encodeURIComponent('\udcaa');}, "E_URI_INVALID_CHAR");
2117 testException(function() {decodeURI('%');}, "E_URI_INVALID_CODING");
2118 testException(function() {decodeURI('%aaaa');}, "E_URI_INVALID_CODING");
2120 function testThisExcept(func, e) {
2121     testException(function() {func.call(new Object())}, e);
2124 function testBoolThis(func) {
2125     testThisExcept(Boolean.prototype[func], "E_NOT_BOOL");
2128 testBoolThis("toString");
2129 testBoolThis("valueOf");
2131 function testDateThis(func) {
2132     testThisExcept(Date.prototype[func], "E_NOT_DATE");
2135 testDateThis("getDate");
2136 testDateThis("getDay");
2137 testDateThis("getFullYear");
2138 testDateThis("getHours");
2139 testDateThis("getMilliseconds");
2140 testDateThis("getMinutes");
2141 testDateThis("getMonth");
2142 testDateThis("getSeconds");
2143 testDateThis("getTime");
2144 testDateThis("getTimezoneOffset");
2145 testDateThis("getUTCDate");
2146 testDateThis("getUTCDay");
2147 testDateThis("getUTCFullYear");
2148 testDateThis("getUTCHours");
2149 testDateThis("getUTCMilliseconds");
2150 testDateThis("getUTCMinutes");
2151 testDateThis("getUTCMonth");
2152 testDateThis("getUTCSeconds");
2153 testDateThis("getYear");
2154 testDateThis("setDate");
2155 testDateThis("setFullYear");
2156 testDateThis("setHours");
2157 testDateThis("setMilliseconds");
2158 testDateThis("setMinutes");
2159 testDateThis("setMonth");
2160 testDateThis("setSeconds");
2161 testDateThis("setTime");
2162 testDateThis("setUTCDate");
2163 testDateThis("setUTCFullYear");
2164 testDateThis("setUTCHours");
2165 testDateThis("setUTCMilliseconds");
2166 testDateThis("setUTCMinutes");
2167 testDateThis("setUTCMonth");
2168 testDateThis("setUTCSeconds");
2169 testDateThis("setYear");
2170 testDateThis("toDateString");
2171 testDateThis("toLocaleDateString");
2172 testDateThis("toLocaleString");
2173 testDateThis("toLocaleTimeString");
2174 testDateThis("toString");
2175 testDateThis("toTimeString");
2176 testDateThis("toUTCString");
2177 testDateThis("valueOf");
2179 function testArrayThis(func) {
2180     testThisExcept(Array.prototype[func], "E_NOT_ARRAY");
2183 testArrayThis("toString");
2185 function testFunctionThis(func) {
2186     testThisExcept(Function.prototype[func], "E_NOT_FUNC");
2189 testFunctionThis("toString");
2190 testFunctionThis("call");
2191 testFunctionThis("apply");
2193 function testArrayHostThis(func) {
2194     testException(function() { Array.prototype[func].call(testObj); }, "E_JSCRIPT_EXPECTED");
2197 testArrayHostThis("push");
2198 testArrayHostThis("shift");
2199 testArrayHostThis("slice");
2200 testArrayHostThis("splice");
2201 testArrayHostThis("unshift");
2202 testArrayHostThis("reverse");
2203 testArrayHostThis("join");
2204 testArrayHostThis("pop");
2205 testArrayHostThis("sort");
2207 function testObjectInherit(obj, constr, ts, tls, vo) {
2208     ok(obj instanceof Object, "obj is not instance of Object");
2209     ok(obj instanceof constr, "obj is not instance of its constructor");
2211     ok(obj.hasOwnProperty === Object.prototype.hasOwnProperty,
2212        "obj.hasOwnProperty !== Object.prototype.hasOwnProprty");
2213     ok(obj.isPrototypeOf === Object.prototype.isPrototypeOf,
2214        "obj.isPrototypeOf !== Object.prototype.isPrototypeOf");
2215     ok(obj.propertyIsEnumerable === Object.prototype.propertyIsEnumerable,
2216        "obj.propertyIsEnumerable !== Object.prototype.propertyIsEnumerable");
2218     if(ts)
2219         ok(obj.toString === Object.prototype.toString,
2220            "obj.toString !== Object.prototype.toString");
2221     else
2222         ok(obj.toString != Object.prototype.toString,
2223            "obj.toString == Object.prototype.toString");
2225     if(tls)
2226         ok(obj.toLocaleString === Object.prototype.toLocaleString,
2227            "obj.toLocaleString !== Object.prototype.toLocaleString");
2228     else
2229         ok(obj.toLocaleString != Object.prototype.toLocaleString,
2230            "obj.toLocaleString == Object.prototype.toLocaleString");
2232     if(vo)
2233         ok(obj.valueOf === Object.prototype.valueOf,
2234            "obj.valueOf !== Object.prototype.valueOf");
2235     else
2236         ok(obj.valueOf != Object.prototype.valueOf,
2237            "obj.valueOf == Object.prototype.valueOf");
2239     ok(obj._test === "test", "obj.test = " + obj._test);
2242 Object.prototype._test = "test";
2243 testObjectInherit(new String("test"), String, false, true, false);
2244 testObjectInherit(/test/g, RegExp, false, true, true);
2245 testObjectInherit(new Number(1), Number, false, false, false);
2246 testObjectInherit(new Date(), Date, false, false, false);
2247 testObjectInherit(new Boolean(true), Boolean, false, true, false);
2248 testObjectInherit(new Array(), Array, false, false, true);
2249 testObjectInherit(new Error(), Error, false, true, true);
2250 testObjectInherit(testObjectInherit, Function, false, true, true);
2251 testObjectInherit(Math, Object, true, true, true);
2253 (function() { testObjectInherit(arguments, Object, true, true, true); })();
2255 function testFunctions(obj, arr) {
2256     var l;
2258     for(var i=0; i<arr.length; i++) {
2259         l = obj[arr[i][0]].length;
2260         ok(l === arr[i][1], arr[i][0] + ".length = " + l);
2261     }
2264 testFunctions(Boolean.prototype, [
2265         ["valueOf", 0],
2266         ["toString", 0]
2267     ]);
2269 testFunctions(Number.prototype, [
2270         ["valueOf", 0],
2271         ["toString", 1],
2272         ["toExponential", 1],
2273         ["toLocaleString", 0],
2274         ["toPrecision", 1]
2275     ]);
2277 testFunctions(String.prototype, [
2278         ["valueOf", 0],
2279         ["toString", 0],
2280         ["anchor", 1],
2281         ["big", 0],
2282         ["blink", 0],
2283         ["bold", 0],
2284         ["charAt", 1],
2285         ["charCodeAt", 1],
2286         ["concat", 1],
2287         ["fixed", 0],
2288         ["fontcolor", 1],
2289         ["fontsize", 1],
2290         ["indexOf", 2],
2291         ["italics", 0],
2292         ["lastIndexOf", 2],
2293         ["link", 1],
2294         ["localeCompare", 1],
2295         ["match", 1],
2296         ["replace", 1],
2297         ["search", 0],
2298         ["slice", 0],
2299         ["small", 0],
2300         ["split", 2],
2301         ["strike", 0],
2302         ["sub", 0],
2303         ["substr", 2],
2304         ["substring", 2],
2305         ["sup", 0],
2306         ["toLocaleLowerCase", 0],
2307         ["toLocaleUpperCase", 0],
2308         ["toLowerCase", 0],
2309         ["toUpperCase", 0]
2310     ]);
2312 testFunctions(RegExp.prototype, [
2313         ["toString", 0],
2314         ["exec", 1],
2315         ["test", 1]
2316     ]);
2318 testFunctions(Date.prototype, [
2319         ["getDate", 0],
2320         ["getDay", 0],
2321         ["getFullYear", 0],
2322         ["getHours", 0],
2323         ["getMilliseconds", 0],
2324         ["getMinutes", 0],
2325         ["getMonth", 0],
2326         ["getSeconds", 0],
2327         ["getTime", 0],
2328         ["getTimezoneOffset", 0],
2329         ["getUTCDate", 0],
2330         ["getUTCDay", 0],
2331         ["getUTCFullYear", 0],
2332         ["getUTCHours", 0],
2333         ["getUTCMilliseconds", 0],
2334         ["getUTCMinutes", 0],
2335         ["getUTCMonth", 0],
2336         ["getUTCSeconds", 0],
2337         ["getYear", 0],
2338         ["setDate", 1],
2339         ["setFullYear", 3],
2340         ["setHours", 4],
2341         ["setMilliseconds", 1],
2342         ["setMinutes", 3],
2343         ["setMonth", 2],
2344         ["setSeconds", 2],
2345         ["setTime", 1],
2346         ["setUTCDate", 1],
2347         ["setUTCFullYear", 3],
2348         ["setUTCHours", 4],
2349         ["setUTCMilliseconds", 1],
2350         ["setUTCMinutes", 3],
2351         ["setUTCMonth", 2],
2352         ["setUTCSeconds", 2],
2353         ["setYear", 1],
2354         ["toDateString", 0],
2355         ["toLocaleDateString", 0],
2356         ["toLocaleString", 0],
2357         ["toLocaleTimeString", 0],
2358         ["toString", 0],
2359         ["toTimeString", 0],
2360         ["toUTCString", 0],
2361         ["toGMTString", 0],
2362         ["valueOf", 0]
2363     ]);
2365 testFunctions(Array.prototype, [
2366         ["concat", 1],
2367         ["join", 1],
2368         ["push", 1],
2369         ["pop", 0],
2370         ["reverse", 0],
2371         ["shift", 0],
2372         ["slice", 2],
2373         ["sort", 1],
2374         ["splice", 2],
2375         ["toLocaleString", 0],
2376         ["toString", 0],
2377         ["unshift", 1]
2378     ]);
2380 testFunctions(Error.prototype, [
2381         ["toString", 0]
2382     ]);
2384 testFunctions(Math, [
2385         ["abs", 1],
2386         ["acos", 1],
2387         ["asin", 1],
2388         ["atan", 1],
2389         ["atan2", 2],
2390         ["ceil", 1],
2391         ["cos", 1],
2392         ["exp", 1],
2393         ["floor", 1],
2394         ["log", 1],
2395         ["max", 2],
2396         ["min", 2],
2397         ["pow", 2],
2398         ["random", 0],
2399         ["round", 1],
2400         ["sin", 1],
2401         ["sqrt", 1],
2402         ["tan", 1]
2403     ]);
2405 testFunctions(Object.prototype, [
2406         ["hasOwnProperty", 1],
2407         ["isPrototypeOf", 1],
2408         ["propertyIsEnumerable", 1],
2409         ["toLocaleString", 0],
2410         ["toString", 0],
2411         ["valueOf", 0]
2412     ]);
2414 testFunctions(Function.prototype, [
2415         ["apply", 2],
2416         ["call", 1],
2417         ["toString", 0]
2418     ]);
2420 testFunctions(VBArray.prototype, [
2421         ["dimensions", 0],
2422         ["getItem", 1],
2423         ["lbound", 0],
2424         ["toArray", 0],
2425         ["ubound", 0]
2426     ]);
2428 ok(ActiveXObject.length == 1, "ActiveXObject.length = " + ActiveXObject.length);
2429 ok(Array.length == 1, "Array.length = " + Array.length);
2430 ok(Boolean.length == 1, "Boolean.length = " + Boolean.length);
2431 ok(CollectGarbage.length == 0, "CollectGarbage.length = " + CollectGarbage.length);
2432 ok(Date.length == 7, "Date.length = " + Date.length);
2433 ok(Enumerator.length == 7, "Enumerator.length = " + Enumerator.length);
2434 ok(Error.length == 1, "Error.length = " + Error.length);
2435 ok(EvalError.length == 1, "EvalError.length = " + EvalError.length);
2436 ok(Function.length == 1, "Function.length = " + Function.length);
2437 ok(GetObject.length == 2, "GetObject.length = " + GetObject.length);
2438 ok(Number.length == 1, "Number.length = " + Number.length);
2439 ok(Object.length == 0, "Object.length = " + Object.length);
2440 ok(RangeError.length == 1, "RangeError.length = " + RangeError.length);
2441 ok(ReferenceError.length == 1, "ReferenceError.length = " + ReferenceError.length);
2442 ok(RegExp.length == 2, "RegExp.length = " + RegExp.length);
2443 ok(ScriptEngine.length == 0, "ScriptEngine.length = " + ScriptEngine.length);
2444 ok(ScriptEngineBuildVersion.length == 0,
2445     "ScriptEngineBuildVersion.length = " + ScriptEngineBuildVersion.length);
2446 ok(ScriptEngineMajorVersion.length == 0,
2447     "ScriptEngineMajorVersion.length = " + ScriptEngineMajorVersion.length);
2448 ok(ScriptEngineMinorVersion.length == 0,
2449     "ScriptEngineMinorVersion.length = " + ScriptEngineMinorVersion.length);
2450 ok(String.length == 1, "String.length = " + String.length);
2451 ok(SyntaxError.length == 1, "SyntaxError.length = " + SyntaxError.length);
2452 ok(TypeError.length == 1, "TypeError.length = " + TypeError.length);
2453 ok(URIError.length == 1, "URIError.length = " + URIError.length);
2454 ok(VBArray.length == 1, "VBArray.length = " + VBArray.length);
2455 ok(decodeURI.length == 1, "decodeURI.length = " + decodeURI.length);
2456 ok(decodeURIComponent.length == 1, "decodeURIComponent.length = " + decodeURIComponent.length);
2457 ok(encodeURI.length == 1, "encodeURI.length = " + encodeURI.length);
2458 ok(encodeURIComponent.length == 1, "encodeURIComponent.length = " + encodeURIComponent.length);
2459 ok(escape.length == 1, "escape.length = " + escape.length);
2460 ok(eval.length == 1, "eval.length = " + eval.length);
2461 ok(isFinite.length == 1, "isFinite.length = " + isFinite.length);
2462 ok(isNaN.length == 1, "isNaN.length = " + isNaN.length);
2463 ok(parseFloat.length == 1, "parseFloat.length = " + parseFloat.length);
2464 ok(parseInt.length == 2, "parseInt.length = " + parseInt.length);
2465 ok(unescape.length == 1, "unescape.length = " + unescape.length);
2467 String.length = 3;
2468 ok(String.length == 1, "String.length = " + String.length);
2470 var tmp = createArray();
2471 ok(getVT(tmp) == "VT_ARRAY|VT_VARIANT", "getVT(createArray()) = " + getVT(tmp));
2472 ok(getVT(VBArray(tmp)) == "VT_ARRAY|VT_VARIANT", "getVT(VBArray(tmp)) = " + getVT(VBArray(tmp)));
2473 tmp = new VBArray(tmp);
2474 tmp = new VBArray(VBArray(createArray()));
2475 ok(tmp.dimensions() == 2, "tmp.dimensions() = " + tmp.dimensions());
2476 ok(tmp.lbound() == 0, "tmp.lbound() = " + tmp.lbound());
2477 ok(tmp.lbound(1) == 0, "tmp.lbound(1) = " + tmp.lbound(1));
2478 ok(tmp.lbound(2, 1) == 2, "tmp.lbound(2, 1) = " + tmp.lbound(2, 1));
2479 ok(tmp.ubound() == 4, "tmp.ubound() = " + tmp.ubound());
2480 ok(tmp.ubound("2") == 3, "tmp.ubound(\"2\") = " + tmp.ubound("2"));
2481 ok(tmp.getItem(1, 2) == 3, "tmp.getItem(1, 2) = " + tmp.getItem(1, 2));
2482 ok(tmp.getItem(2, 3) == 33, "tmp.getItem(2, 3) = " + tmp.getItem(2, 3));
2483 ok(tmp.getItem(3, 2) == 13, "tmp.getItem(3, 2) = " + tmp.getItem(3, 2));
2484 ok(tmp.toArray() == "2,3,12,13,22,23,32,33,42,43", "tmp.toArray() = " + tmp.toArray());
2485 ok(createArray().toArray() == "2,3,12,13,22,23,32,33,42,43",
2486         "createArray.toArray()=" + createArray().toArray());
2488 reportSuccess();