jscript: Added more enumerable attribute tests.
[wine] / dlls / jscript / tests / api.js
1 /*
2  * Copyright 2008 Jacek Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 var tmp, i;
20
21 var bigInt = Math.pow(2,40);
22
23 ok(ScriptEngine() === "JScript", "ScriptEngine() = " + ScriptEngine());
24 ok(ScriptEngine(3) === "JScript", "ScriptEngine(3) = " + ScriptEngine(3));
25 ok(ScriptEngineMajorVersion() === ScriptEngineMajorVersion(2), "ScriptEngineMajorVersion() !== ScriptEngineMajorVersion(2)");
26 ok(ScriptEngineMinorVersion() === ScriptEngineMinorVersion(2), "ScriptEngineMinorVersion() !== ScriptEngineMinorVersion(2)");
27 ok(ScriptEngineBuildVersion() === ScriptEngineBuildVersion(2), "ScriptEngineBuildVersion() !== ScriptEngineBuildVersion(2)");
28
29 function testNoEnumerables(expr) {
30     for(var iter in obj)
31         ok(false, expr + " has property " + iter);
32 }
33
34 testNoEnumerables("Object");
35 testNoEnumerables("Object.prototype");
36 testNoEnumerables("new Object()");
37 testNoEnumerables("Math");
38 testNoEnumerables("String");
39 testNoEnumerables("String.prototype");
40 testNoEnumerables("new String()");
41 testNoEnumerables("Number");
42 testNoEnumerables("Number.prototype");
43 testNoEnumerables("new Number(1)");
44 testNoEnumerables("ActiveXObject");
45 testNoEnumerables("Array");
46 testNoEnumerables("Array.prototype");
47 testNoEnumerables("new Array()");
48 testNoEnumerables("Boolean");
49 testNoEnumerables("Boolean.prototype");
50 testNoEnumerables("new Boolean()");
51 testNoEnumerables("Date");
52 testNoEnumerables("Date.prototype");
53 testNoEnumerables("new Date()");
54 testNoEnumerables("TypeError");
55 testNoEnumerables("TypeError.prototype");
56 testNoEnumerables("new TypeError()");
57 testNoEnumerables("Function");
58 testNoEnumerables("Function.prototype");
59 testNoEnumerables("testNoEnumerates");
60 testNoEnumerables("VBArray");
61
62 ok(Object.propertyIsEnumerable("prototype") === false, "Object.prototype is enumerable");
63 ok(Math.propertyIsEnumerable("E") === false, "Math.E is enumerable");
64 ok(Math.propertyIsEnumerable("SQRT2") === false, "Math.SQRT2 is enumerable");
65 ok(Math.propertyIsEnumerable("PI") === false, "Math.PI is enumerable");
66 ok("test".propertyIsEnumerable("length") === false, "'test'.length is enumerable");
67 ok([1].propertyIsEnumerable("length") === false, "[1].length is enumerable");
68 ok((new TypeError()).propertyIsEnumerable("message") === true, "(new TypeError()).message is not enumerable");
69 ok((new TypeError()).propertyIsEnumerable("description") === false, "(new TypeError()).description is enumerable");
70 ok((new TypeError()).propertyIsEnumerable("name") === false, "(new TypeError()).name is enumerable");
71 ok((new TypeError()).propertyIsEnumerable("number") === false, "(new TypeError()).number is enumerable");
72 ok(Object.propertyIsEnumerable.propertyIsEnumerable("length") === false, "Object.propertyIsEnumerable.length is enumerable");
73
74 tmp = new Object();
75 tmp.test = "1";
76 ok(tmp.propertyIsEnumerable("test"), "tmp.test is not enumerable");
77
78 tmp = { test: 1 };
79 ok(tmp.propertyIsEnumerable("test"), "tmp.test is not enumerable");
80
81 ok([1].concat([2]).propertyIsEnumerable("1"), "[1].concat([2]).1 is not enumerable");
82 ok("t.e.s.t".split(".").propertyIsEnumerable("0"), "'test'.split().0 is not enumerable");
83
84 (function() {
85     ok(arguments.propertyIsEnumerable("0") === false, "arguments.0 is enumerable");
86     ok(arguments.propertyIsEnumerable("length") === false, "arguments.length is enumerable");
87     ok(arguments.propertyIsEnumerable("calee") === false, "arguments.calee is enumerable");
88 })();
89
90 tmp = [1];
91 tmp.push("");
92 ok(tmp.propertyIsEnumerable("1"), "[1].push() ... 1 is not enumerable");
93
94 ok([1,2].reverse().propertyIsEnumerable("1"), "[1,2].rverse().1 is not enumerable");
95 ok([1,2].propertyIsEnumerable("0"), "[1,2].0 is not enumerable");
96
97 i = parseInt("0");
98 ok(i === 0, "parseInt('0') = " + i);
99 i = parseInt("123");
100 ok(i === 123, "parseInt('123') = " + i);
101 i = parseInt("-123");
102 ok(i === -123, "parseInt('-123') = " + i);
103 i = parseInt("0xff");
104 ok(i === 0xff, "parseInt('0xff') = " + i);
105 i = parseInt("11", 8);
106 ok(i === 9, "parseInt('11', 8) = " + i);
107 i = parseInt("1j", 22);
108 ok(i === 41, "parseInt('1j', 32) = " + i);
109 i = parseInt("123", 0);
110 ok(i === 123, "parseInt('123', 0) = " + i);
111 i = parseInt("123", 10, "test");
112 ok(i === 123, "parseInt('123', 10, 'test') = " + i);
113 i = parseInt("11", "8");
114 ok(i === 9, "parseInt('11', '8') = " + i);
115 i = parseInt("010");
116 ok(i === 8, "parseInt('010') = " + i);
117 i = parseInt("");
118 ok(isNaN(i), "parseInt('') = " + i);
119 i = parseInt("0x");
120 ok(isNaN(i), "parseInt('0x') = " + i);
121 i = parseInt("+");
122 ok(isNaN(i), "parseInt('+') = " + i);
123 i = parseInt("-");
124 ok(isNaN(i), "parseInt('-') = " + i);
125 i = parseInt("0x10", 11);
126 ok(i === 0, "parseInt('0x10', 11) = " + i);
127 i = parseInt("010", 7);
128 ok(i === 7, "parseInt('010', 7) = " + i);
129 i = parseInt("123abc");
130 ok(i === 123, "parseInt('123abc') = " + i);
131 i = parseInt("   \t123abc");
132 ok(i === 123, "parseInt('   \\t123abc') = " + i);
133 i = parseInt("abc");
134 ok(isNaN(i), "parseInt('123abc') = " + i);
135 i = parseInt("-12", 11);
136 ok(i === -13, "parseInt('-12') = " + i);
137 i = parseInt("-0x10");
138 ok(i === -16, "parseInt('-0x10') = " + i);
139 i = parseInt("-010");
140 ok(i === -8, "parseInt('-010') = " + i);
141 i = parseInt("123", 0);
142 ok(i === 123, "parseInt('123', 0) = " + i);
143 i = parseInt("0x10", 0);
144 ok(i === 16, "parseInt('123', 0) = " + i);
145 i = parseInt("0x10", 10);
146 ok(i === 0, "parseInt('0x10', 10) = " + i);
147 i = parseInt("0xz");
148 ok(isNaN(i), "parseInt('0xz') = " + i);
149 i = parseInt("1", 1);
150 ok(isNaN(i), "parseInt('1', 1) = " + i);
151 i = parseInt("1", -1);
152 ok(isNaN(i), "parseInt('1', -1) = " + i);
153 i = parseInt("1", 37);
154 ok(isNaN(i), "parseInt('1', 37) = " + i);
155 i = parseInt("1", 36);
156 ok(i === 1, "parseInt('1', 36) = " + i);
157
158 tmp = encodeURI("abc");
159 ok(tmp === "abc", "encodeURI('abc') = " + tmp);
160 tmp = encodeURI("{abc}");
161 ok(tmp === "%7Babc%7D", "encodeURI('{abc}') = " + tmp);
162 tmp = encodeURI("");
163 ok(tmp === "", "encodeURI('') = " + tmp);
164 tmp = encodeURI("\01\02\03\04");
165 ok(tmp === "%01%02%03%04", "encodeURI('\\01\\02\\03\\04') = " + tmp);
166 tmp = encodeURI("{#@}");
167 ok(tmp === "%7B#@%7D", "encodeURI('{#@}') = " + tmp);
168 tmp = encodeURI("\xa1 ");
169 ok(tmp === "%C2%A1%20", "encodeURI(\\xa1 ) = " + tmp);
170 tmp = encodeURI("\xffff");
171 ok(tmp.length === 8, "encodeURI('\\xffff').length = " + tmp.length);
172 tmp = encodeURI("abcABC123;/?:@&=+$,-_.!~*'()");
173 ok(tmp === "abcABC123;/?:@&=+$,-_.!~*'()", "encodeURI('abcABC123;/?:@&=+$,-_.!~*'()') = " + tmp);
174 tmp = encodeURI("%");
175 ok(tmp === "%25", "encodeURI('%') = " + tmp);
176 tmp = encodeURI();
177 ok(tmp === "undefined", "encodeURI() = " + tmp);
178 tmp = encodeURI("abc", "test");
179 ok(tmp === "abc", "encodeURI('abc') = " + tmp);
180
181 tmp = decodeURI("abc");
182 ok(tmp === "abc", "decodeURI('abc') = " + tmp);
183 tmp = decodeURI("{abc}");
184 ok(tmp === "{abc}", "decodeURI('{abc}') = " + tmp);
185 tmp = decodeURI("");
186 ok(tmp === "", "decodeURI('') = " + tmp);
187 tmp = decodeURI("\01\02\03\04");
188 ok(tmp === "\01\02\03\04", "decodeURI('\\01\\02\\03\\04') = " + tmp);
189 tmp = decodeURI();
190 ok(tmp === "undefined", "decodeURI() = " + tmp);
191 tmp = decodeURI("abc", "test");
192 ok(tmp === "abc", "decodeURI('abc') = " + tmp);
193 tmp = decodeURI("%7babc%7d");
194 ok(tmp === "{abc}", "decodeURI('%7Babc%7D') = " + tmp);
195 tmp = decodeURI("%01%02%03%04");
196 ok(tmp === "\01\02\03\04", "decodeURI('%01%02%03%04') = " + tmp);
197 tmp = decodeURI("%C2%A1%20");
198 ok(tmp === "\xa1 ", "decodeURI('%C2%A1%20') = " + tmp);
199 tmp = decodeURI("%C3%BFff");
200 ok(tmp.length === 3, "decodeURI('%C3%BFff').length = " + tmp.length);
201
202 tmp = encodeURIComponent("abc");
203 ok(tmp === "abc", "encodeURIComponent('abc') = " + tmp);
204 dec = decodeURIComponent(tmp);
205 ok(dec === "abc", "decodeURIComponent('" + tmp + "') = " + dec);
206 tmp = encodeURIComponent("{abc}");
207 ok(tmp === "%7Babc%7D", "encodeURIComponent('{abc}') = " + tmp);
208 dec = decodeURIComponent(tmp);
209 ok(dec === "{abc}", "decodeURIComponent('" + tmp + "') = " + dec);
210 tmp = encodeURIComponent("");
211 ok(tmp === "", "encodeURIComponent('') = " + tmp);
212 dec = decodeURIComponent(tmp);
213 ok(dec === "", "decodeURIComponent('" + tmp + "') = " + dec);
214 tmp = encodeURIComponent("\01\02\03\04");
215 ok(tmp === "%01%02%03%04", "encodeURIComponent('\\01\\02\\03\\04') = " + tmp);
216 dec = decodeURIComponent(tmp);
217 ok(dec === "\01\02\03\04", "decodeURIComponent('" + tmp + "') = " + dec);
218 tmp = encodeURIComponent("{#@}");
219 ok(tmp === "%7B%23%40%7D", "encodeURIComponent('{#@}') = " + tmp);
220 dec = decodeURIComponent(tmp);
221 ok(dec === "{#@}", "decodeURIComponent('" + tmp + "') = " + dec);
222 tmp = encodeURIComponent("\xa1 ");
223 ok(tmp === "%C2%A1%20", "encodeURIComponent(\\xa1 ) = " + tmp);
224 dec = decodeURIComponent(tmp);
225 ok(dec === "\xa1 ", "decodeURIComponent('" + tmp + "') = " + dec);
226 tmp = encodeURIComponent("\xffff");
227 ok(tmp.length === 8, "encodeURIComponent('\\xffff').length = " + tmp.length);
228 dec = decodeURIComponent(tmp);
229 ok(dec === "\xffff", "decodeURIComponent('" + tmp + "') = " + dec);
230 tmp = encodeURIComponent("abcABC123;/?:@&=+$,-_.!~*'()");
231 ok(tmp === "abcABC123%3B%2F%3F%3A%40%26%3D%2B%24%2C-_.!~*'()", "encodeURIComponent('abcABC123;/?:@&=+$,-_.!~*'()') = " + tmp);
232 dec = decodeURIComponent(tmp);
233 ok(dec === "abcABC123;/?:@&=+$,-_.!~*'()", "decodeURIComponent('" + tmp + "') = " + dec);
234 tmp = encodeURIComponent();
235 ok(tmp === "undefined", "encodeURIComponent() = " + tmp);
236 tmp = encodeURIComponent("abc", "test");
237 ok(tmp === "abc", "encodeURIComponent('abc') = " + tmp);
238 dec = decodeURIComponent();
239 ok(dec === "undefined", "decodeURIComponent() = " + dec);
240 dec = decodeURIComponent("abc", "test");
241 ok(dec === "abc", "decodeURIComponent('abc') = " + dec);
242
243 tmp = escape("abc");
244 ok(tmp === "abc", "escape('abc') = " + tmp);
245 tmp = escape("");
246 ok(tmp === "", "escape('') = " + tmp);
247 tmp = escape("a1b c!d+e@*-_+./,");
248 ok(tmp === "a1b%20c%21d+e@*-_+./%2C", "escape('a1b c!d+e@*-_+./,') = " + tmp);
249 tmp = escape();
250 ok(tmp === "undefined", "escape() = " + tmp);
251 tmp = escape('\u1234\123\xf3');
252 ok(tmp == "%u1234S%F3", "escape('\u1234\123\xf3') = " + tmp);
253
254 tmp = unescape("abc");
255 ok(tmp === "abc", "unescape('abc') = " + tmp);
256 tmp = unescape("");
257 ok(tmp === "", "unescape('') = " + tmp);
258 tmp = unescape("%%%");
259 ok(tmp === "%%%", "unescape('%%%') = " + tmp);
260 tmp = unescape();
261 ok(tmp === "undefined", "unescape() = " + tmp);
262 tmp = unescape("%54%65s%u0074");
263 ok(tmp === "Test", "unescape('%54%65s%u0074') = " + tmp);
264
265 tmp = "aA1~`!@#$%^&*()_+=-][{}';:/.,<>?\|";
266 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));
267 ok(unescape(escape(tmp)) === tmp, "unescape(escape('" + tmp + "')) = " + unescape(escape(tmp)));
268
269 ok(Object.prototype.hasOwnProperty('toString'), "Object.prototype.hasOwnProperty('toString') is false");
270 ok(Object.prototype.hasOwnProperty('isPrototypeOf'), "Object.prototype.hasOwnProperty('isPrototypeOf') is false");
271 ok(Function.prototype.hasOwnProperty('call'), "Function.prototype.hasOwnProperty('call') is false");
272
273 obj = new Object();
274
275 ok(!obj.hasOwnProperty('toString'), "obj.hasOwnProperty('toString') is true");
276 ok(!obj.hasOwnProperty('isPrototypeOf'), "obj.hasOwnProperty('isPrototypeOf') is true");
277 ok(!Object.hasOwnProperty('toString'), "Object.hasOwnProperty('toString') is true");
278 ok(!Object.hasOwnProperty('isPrototypeOf'), "Object.hasOwnProperty('isPrototypeOf') is true");
279 ok(!parseFloat.hasOwnProperty('call'), "parseFloat.hasOwnProperty('call') is true");
280 ok(!Function.hasOwnProperty('call'), "Function.hasOwnProperty('call') is true");
281
282 obj = new Array();
283 ok(Array.prototype.hasOwnProperty('sort'), "Array.prototype.hasOwnProperty('sort') is false");
284 ok(Array.prototype.hasOwnProperty('length'), "Array.prototype.hasOwnProperty('length') is false");
285 ok(!obj.hasOwnProperty('sort'), "obj.hasOwnProperty('sort') is true");
286 ok(obj.hasOwnProperty('length'), "obj.hasOwnProperty('length') is true");
287
288 obj = new Boolean(false);
289 ok(!obj.hasOwnProperty('toString'), "obj.hasOwnProperty('toString') is true");
290 ok(!Boolean.hasOwnProperty('toString'), "Boolean.hasOwnProperty('toString') is true");
291 ok(Boolean.prototype.hasOwnProperty('toString'), "Boolean.prototype.hasOwnProperty('toString') is false");
292
293 obj = new Date();
294 ok(!obj.hasOwnProperty('getTime'), "obj.hasOwnProperty('getTime') is true");
295 ok(!Date.hasOwnProperty('getTime'), "Date.hasOwnProperty('getTime') is true");
296 ok(Date.prototype.hasOwnProperty('getTime'), "Date.prototype.hasOwnProperty('getTime') is false");
297
298 obj = new Number();
299 ok(!obj.hasOwnProperty('toFixed'), "obj.hasOwnProperty('toFixed') is true");
300 ok(!Number.hasOwnProperty('toFixed'), "Number.hasOwnProperty('toFixed') is true");
301 ok(Number.prototype.hasOwnProperty('toFixed'), "Number.prototype.hasOwnProperty('toFixed') is false");
302
303 obj = /x/;
304 ok(!obj.hasOwnProperty('exec'), "obj.hasOwnProperty('exec') is true");
305 ok(obj.hasOwnProperty('source'), "obj.hasOwnProperty('source') is false");
306 ok(!RegExp.hasOwnProperty('exec'), "RegExp.hasOwnProperty('exec') is true");
307 ok(!RegExp.hasOwnProperty('source'), "RegExp.hasOwnProperty('source') is true");
308 ok(RegExp.prototype.hasOwnProperty('source'), "RegExp.prototype.hasOwnProperty('source') is false");
309
310 obj = new String();
311 ok(!obj.hasOwnProperty('charAt'), "obj.hasOwnProperty('charAt') is true");
312 ok(obj.hasOwnProperty('length'), "obj.hasOwnProperty('length') is false");
313 ok(!String.hasOwnProperty('charAt'), "String.hasOwnProperty('charAt') is true");
314 ok(String.prototype.hasOwnProperty('charAt'), "String.prototype.hasOwnProperty('charAt') is false");
315 ok(String.prototype.hasOwnProperty('length'), "String.prototype.hasOwnProperty('length') is false");
316
317 tmp = "" + new Object();
318 ok(tmp === "[object Object]", "'' + new Object() = " + tmp);
319 (tmp = new Array).f = Object.prototype.toString;
320 ok(tmp.f() === "[object Array]", "tmp.f() = " + tmp.f());
321 (tmp = new Boolean).f = Object.prototype.toString;
322 ok(tmp.f() === "[object Boolean]", "tmp.f() = " + tmp.f());
323 (tmp = new Date).f = Object.prototype.toString;
324 ok(tmp.f() === "[object Date]", "tmp.f() = " + tmp.f());
325 (tmp = function() {}).f = Object.prototype.toString;
326 ok(tmp.f() === "[object Function]", "tmp.f() = " + tmp.f());
327 Math.f = Object.prototype.toString;
328 ok(Math.f() === "[object Math]", "tmp.f() = " + tmp.f());
329 (tmp = new Number).f = Object.prototype.toString;
330 ok(tmp.f() === "[object Number]", "tmp.f() = " + tmp.f());
331 (tmp = new RegExp("")).f = Object.prototype.toString;
332 ok(tmp.f() === "[object RegExp]", "tmp.f() = " + tmp.f());
333 (tmp = new String).f = Object.prototype.toString;
334 ok(tmp.f() === "[object String]", "tmp.f() = " + tmp.f());
335 tmp = Object.prototype.toString.call(testObj);
336 ok(tmp === "[object Object]", "toString.call(testObj) = " + tmp);
337 tmp = Object.prototype.toString.call(this);
338 ok(tmp === "[object Object]", "toString.call(this) = " + tmp);
339 (function () { tmp = Object.prototype.toString.call(arguments); })();
340 ok(tmp === "[object Object]", "toString.call(arguments) = " + tmp);
341 tmp = Object.prototype.toString.call(new VBArray(createArray()));
342 ok(tmp === "[object Object]", "toString.call(new VBArray()) = " + tmp);
343
344 function TSTestConstr() {}
345 TSTestConstr.prototype = { toString: function() { return "test"; } };
346 obj = new TSTestConstr();
347 ok(obj.toString() === "test", "obj.toString() = " + obj.toString());
348
349 ok(Object(1) instanceof Number, "Object(1) is not instance of Number");
350 ok(Object("") instanceof String, "Object('') is not instance of String");
351 ok(Object(false) instanceof Boolean, "Object(false) is not instance of Boolean");
352
353 obj = new Object();
354 ok(Object(obj) === obj, "Object(obj) !== obj");
355
356 ok(typeof(Object()) === "object", "typeof(Object()) !== 'object'");
357 ok(typeof(Object(undefined)) === "object", "typeof(Object(undefined)) !== 'object'");
358 ok(typeof(Object(null)) === "object", "typeof(Object(null)) !== 'object'");
359
360 var obj = new Object();
361 obj.toString = function (x) {
362     ok(arguments.length === 0, "arguments.length = " + arguments.length);
363     return "test";
364 };
365 ok((tmp = obj.toLocaleString()) === "test", "obj.toLocaleString() = " + tmp);
366 ok((tmp = obj.toLocaleString(1)) === "test", "obj.toLocaleString(1) = " + tmp);
367 ok(obj === obj.valueOf(), "obj !== obj.valueOf");
368
369 ok("".length === 0, "\"\".length = " + "".length);
370 ok(getVT("".length) == "VT_I4", "\"\".length = " + "".length);
371 ok("abc".length === 3, "\"abc\".length = " + "abc".length);
372 ok(String.prototype.length === 0, "String.prototype.length = " + String.prototype.length);
373
374 tmp = "".toString();
375 ok(tmp === "", "''.toString() = " + tmp);
376 tmp = "test".toString();
377 ok(tmp === "test", "''.toString() = " + tmp);
378 tmp = "test".toString(3);
379 ok(tmp === "test", "''.toString(3) = " + tmp);
380
381 tmp = "".valueOf();
382 ok(tmp === "", "''.valueOf() = " + tmp);
383 tmp = "test".valueOf();
384 ok(tmp === "test", "''.valueOf() = " + tmp);
385 tmp = "test".valueOf(3);
386 ok(tmp === "test", "''.valueOf(3) = " + tmp);
387
388 var str = new String("test");
389 ok(str.toString() === "test", "str.toString() = " + str.toString());
390 var str = new String();
391 ok(str.toString() === "", "str.toString() = " + str.toString());
392 var str = new String("test", "abc");
393 ok(str.toString() === "test", "str.toString() = " + str.toString());
394
395 var strObj = new Object();
396 strObj.toString = function() { return "abcd" };
397 strObj.substr = String.prototype.substr;
398 strObj.lastIndexOf = String.prototype.lastIndexOf;
399
400 tmp = "value " + str;
401 ok(tmp === "value test", "'value ' + str = " + tmp);
402
403 tmp = String();
404 ok(tmp === "", "String() = " + tmp);
405 tmp = String(false);
406 ok(tmp === "false", "String(false) = " + tmp);
407 tmp = String(null);
408 ok(tmp === "null", "String(null) = " + tmp);
409 tmp = String("test");
410 ok(tmp === "test", "String('test') = " + tmp);
411 tmp = String("test", "abc");
412 ok(tmp === "test", "String('test','abc') = " + tmp);
413
414 tmp = "abc".charAt(0);
415 ok(tmp === "a", "'abc',charAt(0) = " + tmp);
416 tmp = "abc".charAt(1);
417 ok(tmp === "b", "'abc',charAt(1) = " + tmp);
418 tmp = "abc".charAt(2);
419 ok(tmp === "c", "'abc',charAt(2) = " + tmp);
420 tmp = "abc".charAt(3);
421 ok(tmp === "", "'abc',charAt(3) = " + tmp);
422 tmp = "abc".charAt(4);
423 ok(tmp === "", "'abc',charAt(4) = " + tmp);
424 tmp = "abc".charAt();
425 ok(tmp === "a", "'abc',charAt() = " + tmp);
426 tmp = "abc".charAt(-1);
427 ok(tmp === "", "'abc',charAt(-1) = " + tmp);
428 tmp = "abc".charAt(0,2);
429 ok(tmp === "a", "'abc',charAt(0.2) = " + tmp);
430 tmp = "abc".charAt(NaN);
431 ok(tmp === "a", "'abc',charAt(NaN) = " + tmp);
432 tmp = "abc".charAt(bigInt);
433 ok(tmp === "", "'abc',charAt(bigInt) = " + tmp);
434
435 tmp = "abc".charCodeAt(0);
436 ok(tmp === 0x61, "'abc'.charCodeAt(0) = " + tmp);
437 tmp = "abc".charCodeAt(1);
438 ok(tmp === 0x62, "'abc'.charCodeAt(1) = " + tmp);
439 tmp = "abc".charCodeAt(2);
440 ok(tmp === 0x63, "'abc'.charCodeAt(2) = " + tmp);
441 tmp = "abc".charCodeAt();
442 ok(tmp === 0x61, "'abc'.charCodeAt() = " + tmp);
443 tmp = "abc".charCodeAt(true);
444 ok(tmp === 0x62, "'abc'.charCodeAt(true) = " + tmp);
445 tmp = "abc".charCodeAt(0,2);
446 ok(tmp === 0x61, "'abc'.charCodeAt(0,2) = " + tmp);
447 tmp = "\u49F4".charCodeAt(0);
448 ok(tmp === 0x49F4, "'\u49F4'.charCodeAt(0) = " + tmp);
449 tmp = "\052".charCodeAt(0);
450 ok(tmp === 0x2A, "'\052'.charCodeAt(0) = " + tmp);
451 tmp = "\xa2".charCodeAt(0);
452 ok(tmp === 0xA2, "'\xa2'.charCodeAt(0) = " + tmp);
453 tmp = "abc".charCodeAt(bigInt);
454 ok(isNaN(tmp), "'abc'.charCodeAt(bigInt) = " + tmp);
455
456 tmp = "abcd".substring(1,3);
457 ok(tmp === "bc", "'abcd'.substring(1,3) = " + tmp);
458 tmp = "abcd".substring(-1,3);
459 ok(tmp === "abc", "'abcd'.substring(-1,3) = " + tmp);
460 tmp = "abcd".substring(1,6);
461 ok(tmp === "bcd", "'abcd'.substring(1,6) = " + tmp);
462 tmp = "abcd".substring(3,1);
463 ok(tmp === "bc", "'abcd'.substring(3,1) = " + tmp);
464 tmp = "abcd".substring(2,2);
465 ok(tmp === "", "'abcd'.substring(2,2) = " + tmp);
466 tmp = "abcd".substring(true,"3");
467 ok(tmp === "bc", "'abcd'.substring(true,'3') = " + tmp);
468 tmp = "abcd".substring(1,3,2);
469 ok(tmp === "bc", "'abcd'.substring(1,3,2) = " + tmp);
470 tmp = "abcd".substring();
471 ok(tmp === "abcd", "'abcd'.substring() = " + tmp);
472
473 tmp = "abcd".substr(1,3);
474 ok(tmp === "bcd", "'abcd'.substr(1,3) = " + tmp);
475 tmp = "abcd".substr(-1,3);
476 ok(tmp === "abc", "'abcd'.substr(-1,3) = " + tmp);
477 tmp = "abcd".substr(1,6);
478 ok(tmp === "bcd", "'abcd'.substr(1,6) = " + tmp);
479 tmp = "abcd".substr(2,-1);
480 ok(tmp === "", "'abcd'.substr(3,1) = " + tmp);
481 tmp = "abcd".substr(2,0);
482 ok(tmp === "", "'abcd'.substr(2,2) = " + tmp);
483 tmp = "abcd".substr(true,"3");
484 ok(tmp === "bcd", "'abcd'.substr(true,'3') = " + tmp);
485 tmp = "abcd".substr(1,3,2);
486 ok(tmp === "bcd", "'abcd'.substr(1,3,2) = " + tmp);
487 tmp = "abcd".substr();
488 ok(tmp === "abcd", "'abcd'.substr() = " + tmp);
489 tmp = strObj.substr(1,1);
490 ok(tmp === "b", "'abcd'.substr(1,3) = " + tmp);
491
492 tmp = "abcd".slice(1,3);
493 ok(tmp === "bc", "'abcd'.slice(1,3) = " + tmp);
494 tmp = "abcd".slice(1,-1);
495 ok(tmp === "bc", "'abcd'.slice(1,-1) = " + tmp);
496 tmp = "abcd".slice(-3,3);
497 ok(tmp === "bc", "'abcd'.slice(-3,3) = " + tmp);
498 tmp = "abcd".slice(-6,3);
499 ok(tmp === "abc", "'abcd'.slice(-6,3) = " + tmp);
500 tmp = "abcd".slice(3,1);
501 ok(tmp === "", "'abcd'.slice(3,1) = " + tmp);
502 tmp = "abcd".slice(true,3);
503 ok(tmp === "bc", "'abcd'.slice(true,3) = " + tmp);
504 tmp = "abcd".slice();
505 ok(tmp === "abcd", "'abcd'.slice() = " + tmp);
506 tmp = "abcd".slice(1);
507 ok(tmp === "bcd", "'abcd'.slice(1) = " + tmp);
508
509 tmp = "abc".concat(["d",1],2,false);
510 ok(tmp === "abcd,12false", "concat returned " + tmp);
511 var arr = new Array(2,"a");
512 arr.concat = String.prototype.concat;
513 tmp = arr.concat("d");
514 ok(tmp === "2,ad", "arr.concat = " + tmp);
515
516 m = "a+bcabc".match("a+");
517 ok(typeof(m) === "object", "typeof m is not object");
518 ok(m.length === 1, "m.length is not 1");
519 ok(m["0"] === "a", "m[0] is not \"a\"");
520
521 r = "- [test] -".replace("[test]", "success");
522 ok(r === "- success -", "r = " + r + " expected '- success -'");
523
524 r = "- [test] -".replace("[test]", "success", "test");
525 ok(r === "- success -", "r = " + r + " expected '- success -'");
526
527 r = "test".replace();
528 ok(r === "test", "r = " + r + " expected 'test'");
529
530 function replaceFunc3(m, off, str) {
531     ok(arguments.length === 3, "arguments.length = " + arguments.length);
532     ok(m === "[test]", "m = " + m + " expected [test]");
533     ok(off === 1, "off = " + off + " expected 0");
534     ok(str === "-[test]-", "str = " + arguments[3]);
535     return "ret";
536 }
537
538 r = "-[test]-".replace("[test]", replaceFunc3);
539 ok(r === "-ret-", "r = " + r + " expected '-ret-'");
540
541 r = "-[test]-".replace("[test]", replaceFunc3, "test");
542 ok(r === "-ret-", "r = " + r + " expected '-ret-'");
543
544 r = "x,x,x".replace("x", "y");
545 ok(r === "y,x,x", "r = " + r + " expected 'y,x,x'");
546
547 r = "x,x,x".replace("", "y");
548 ok(r === "yx,x,x", "r = " + r + " expected 'yx,x,x'");
549
550 r = "x,x,x".replace("", "");
551 ok(r === "x,x,x", "r = " + r + " expected 'x,x,x'");
552
553 r = "1,2,3".split(",");
554 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
555 ok(r.length === 3, "r.length = " + r.length);
556 ok(r[0] === "1", "r[0] = " + r[0]);
557 ok(r[1] === "2", "r[1] = " + r[1]);
558 ok(r[2] === "3", "r[2] = " + r[2]);
559
560 r = "1,2,3".split(",*");
561 ok(r.length === 1, "r.length = " + r.length);
562 ok(r[0] === "1,2,3", "r[0] = " + r[0]);
563
564 r = "123".split("");
565 ok(r.length === 3, "r.length = " + r.length);
566 ok(r[0] === "1", "r[0] = " + r[0]);
567 ok(r[1] === "2", "r[1] = " + r[1]);
568 ok(r[2] === "3", "r[2] = " + r[2]);
569
570 r = "123".split(2);
571 ok(r.length === 2, "r.length = " + r.length);
572 ok(r[0] === "1", "r[0] = " + r[0]);
573 ok(r[1] === "3", "r[1] = " + r[1]);
574
575 r = "1,2,".split(",");
576 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
577 ok(r.length === 3, "r.length = " + r.length);
578 ok(r[0] === "1", "r[0] = " + r[0]);
579 ok(r[1] === "2", "r[1] = " + r[1]);
580 ok(r[2] === "", "r[2] = " + r[2]);
581
582 r = "1,2,3".split(",", 2);
583 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
584 ok(r.length === 2, "r.length = " + r.length);
585 ok(r[0] === "1", "r[0] = " + r[0]);
586 ok(r[1] === "2", "r[1] = " + r[1]);
587
588 r = "1,2,3".split(",", 0);
589 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
590 ok(r.length === 0, "r.length = " + r.length);
591
592 r = "1,2,3".split(",", -1);
593 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
594 ok(r.length === 3, "r.length = " + r.length);
595 ok(r[0] === "1", "r[0] = " + r[0]);
596 ok(r[1] === "2", "r[1] = " + r[1]);
597 ok(r[2] === "3", "r[1] = " + r[1]);
598
599 tmp = "abcd".indexOf("bc",0);
600 ok(tmp === 1, "indexOf = " + tmp);
601 tmp = "abcd".indexOf("bc",1);
602 ok(tmp === 1, "indexOf = " + tmp);
603 tmp = "abcd".indexOf("bc");
604 ok(tmp === 1, "indexOf = " + tmp);
605 tmp = "abcd".indexOf("ac");
606 ok(tmp === -1, "indexOf = " + tmp);
607 tmp = "abcd".indexOf("bc",2);
608 ok(tmp === -1, "indexOf = " + tmp);
609 tmp = "abcd".indexOf("a",0);
610 ok(tmp === 0, "indexOf = " + tmp);
611 tmp = "abcd".indexOf("bc",0,"test");
612 ok(tmp === 1, "indexOf = " + tmp);
613 tmp = "abcd".indexOf();
614 ok(tmp == -1, "indexOf = " + tmp);
615 tmp = "abcd".indexOf("b", bigInt);
616 ok(tmp == -1, "indexOf = " + tmp);
617
618 tmp = "abcd".lastIndexOf("bc",1);
619 ok(tmp === 1, "lastIndexOf = " + tmp);
620 tmp = "abcd".lastIndexOf("bc",2);
621 ok(tmp === 1, "lastIndexOf = " + tmp);
622 tmp = "abcd".lastIndexOf("bc");
623 ok(tmp === 1, "lastIndexOf = " + tmp);
624 tmp = "abcd".lastIndexOf("ac");
625 ok(tmp === -1, "lastIndexOf = " + tmp);
626 tmp = "abcd".lastIndexOf("d",10);
627 ok(tmp === 3, "lastIndexOf = " + tmp);
628 tmp = "abcd".lastIndexOf("bc",0,"test");
629 ok(tmp === -1, "lastIndexOf = " + tmp);
630 tmp = "abcd".lastIndexOf();
631 ok(tmp === -1, "lastIndexOf = " + tmp);
632 tmp = "aaaa".lastIndexOf("a",2);
633 ok(tmp == 2, "lastIndexOf = " + tmp);
634 tmp = strObj.lastIndexOf("b");
635 ok(tmp === 1, "lastIndexOf = " + tmp);
636 tmp = "bbb".lastIndexOf("b", bigInt);
637 ok(tmp === 2, "lastIndexOf = " + tmp);
638
639 tmp = "".toLowerCase();
640 ok(tmp === "", "''.toLowerCase() = " + tmp);
641 tmp = "test".toLowerCase();
642 ok(tmp === "test", "''.toLowerCase() = " + tmp);
643 tmp = "test".toLowerCase(3);
644 ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
645 tmp = "tEsT".toLowerCase();
646 ok(tmp === "test", "''.toLowerCase() = " + tmp);
647 tmp = "tEsT".toLowerCase(3);
648 ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
649
650 tmp = "".toUpperCase();
651 ok(tmp === "", "''.toUpperCase() = " + tmp);
652 tmp = "TEST".toUpperCase();
653 ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
654 tmp = "TEST".toUpperCase(3);
655 ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
656 tmp = "tEsT".toUpperCase();
657 ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
658 tmp = "tEsT".toUpperCase(3);
659 ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
660
661 tmp = "".anchor();
662 ok(tmp === "<A NAME=\"undefined\"></A>", "''.anchor() = " + tmp);
663 tmp = "".anchor(3);
664 ok(tmp === "<A NAME=\"3\"></A>", "''.anchor(3) = " + tmp);
665 tmp = "".anchor("red");
666 ok(tmp === "<A NAME=\"red\"></A>", "''.anchor('red') = " + tmp);
667 tmp = "test".anchor();
668 ok(tmp === "<A NAME=\"undefined\">test</A>", "'test'.anchor() = " + tmp);
669 tmp = "test".anchor(3);
670 ok(tmp === "<A NAME=\"3\">test</A>", "'test'.anchor(3) = " + tmp);
671 tmp = "test".anchor("green");
672 ok(tmp === "<A NAME=\"green\">test</A>", "'test'.anchor('green') = " + tmp);
673
674 tmp = "".big();
675 ok(tmp === "<BIG></BIG>", "''.big() = " + tmp);
676 tmp = "".big(3);
677 ok(tmp === "<BIG></BIG>", "''.big(3) = " + tmp);
678 tmp = "test".big();
679 ok(tmp === "<BIG>test</BIG>", "'test'.big() = " + tmp);
680 tmp = "test".big(3);
681 ok(tmp === "<BIG>test</BIG>", "'test'.big(3) = " + tmp);
682
683 tmp = "".blink();
684 ok(tmp === "<BLINK></BLINK>", "''.blink() = " + tmp);
685 tmp = "".blink(3);
686 ok(tmp === "<BLINK></BLINK>", "''.blink(3) = " + tmp);
687 tmp = "test".blink();
688 ok(tmp === "<BLINK>test</BLINK>", "'test'.blink() = " + tmp);
689 tmp = "test".blink(3);
690 ok(tmp === "<BLINK>test</BLINK>", "'test'.blink(3) = " + tmp);
691
692 tmp = "".bold();
693 ok(tmp === "<B></B>", "''.bold() = " + tmp);
694 tmp = "".bold(3);
695 ok(tmp === "<B></B>", "''.bold(3) = " + tmp);
696 tmp = "test".bold();
697 ok(tmp === "<B>test</B>", "'test'.bold() = " + tmp);
698 tmp = "test".bold(3);
699 ok(tmp === "<B>test</B>", "'test'.bold(3) = " + tmp);
700
701 tmp = "".fixed();
702 ok(tmp === "<TT></TT>", "''.fixed() = " + tmp);
703 tmp = "".fixed(3);
704 ok(tmp === "<TT></TT>", "''.fixed(3) = " + tmp);
705 tmp = "test".fixed();
706 ok(tmp === "<TT>test</TT>", "'test'.fixed() = " + tmp);
707 tmp = "test".fixed(3);
708 ok(tmp === "<TT>test</TT>", "'test'.fixed(3) = " + tmp);
709
710 tmp = "".fontcolor();
711 ok(tmp === "<FONT COLOR=\"undefined\"></FONT>", "''.fontcolor() = " + tmp);
712 tmp = "".fontcolor(3);
713 ok(tmp === "<FONT COLOR=\"3\"></FONT>", "''.fontcolor(3) = " + tmp);
714 tmp = "".fontcolor("red");
715 ok(tmp === "<FONT COLOR=\"red\"></FONT>", "''.fontcolor('red') = " + tmp);
716 tmp = "test".fontcolor();
717 ok(tmp === "<FONT COLOR=\"undefined\">test</FONT>", "'test'.fontcolor() = " + tmp);
718 tmp = "test".fontcolor(3);
719 ok(tmp === "<FONT COLOR=\"3\">test</FONT>", "'test'.fontcolor(3) = " + tmp);
720 tmp = "test".fontcolor("green");
721 ok(tmp === "<FONT COLOR=\"green\">test</FONT>", "'test'.fontcolor('green') = " + tmp);
722
723 tmp = "".fontsize();
724 ok(tmp === "<FONT SIZE=\"undefined\"></FONT>", "''.fontsize() = " + tmp);
725 tmp = "".fontsize(3);
726 ok(tmp === "<FONT SIZE=\"3\"></FONT>", "''.fontsize(3) = " + tmp);
727 tmp = "".fontsize("red");
728 ok(tmp === "<FONT SIZE=\"red\"></FONT>", "''.fontsize('red') = " + tmp);
729 tmp = "test".fontsize();
730 ok(tmp === "<FONT SIZE=\"undefined\">test</FONT>", "'test'.fontsize() = " + tmp);
731 tmp = "test".fontsize(3);
732 ok(tmp === "<FONT SIZE=\"3\">test</FONT>", "'test'.fontsize(3) = " + tmp);
733 tmp = "test".fontsize("green");
734 ok(tmp === "<FONT SIZE=\"green\">test</FONT>", "'test'.fontsize('green') = " + tmp);
735
736 tmp = ("".fontcolor()).fontsize();
737 ok(tmp === "<FONT SIZE=\"undefined\"><FONT COLOR=\"undefined\"></FONT></FONT>", "(''.fontcolor()).fontsize() = " + tmp);
738
739 tmp = "".italics();
740 ok(tmp === "<I></I>", "''.italics() = " + tmp);
741 tmp = "".italics(3);
742 ok(tmp === "<I></I>", "''.italics(3) = " + tmp);
743 tmp = "test".italics();
744 ok(tmp === "<I>test</I>", "'test'.italics() = " + tmp);
745 tmp = "test".italics(3);
746 ok(tmp === "<I>test</I>", "'test'.italics(3) = " + tmp);
747
748 tmp = "".link();
749 ok(tmp === "<A HREF=\"undefined\"></A>", "''.link() = " + tmp);
750 tmp = "".link(3);
751 ok(tmp === "<A HREF=\"3\"></A>", "''.link(3) = " + tmp);
752 tmp = "".link("red");
753 ok(tmp === "<A HREF=\"red\"></A>", "''.link('red') = " + tmp);
754 tmp = "test".link();
755 ok(tmp === "<A HREF=\"undefined\">test</A>", "'test'.link() = " + tmp);
756 tmp = "test".link(3);
757 ok(tmp === "<A HREF=\"3\">test</A>", "'test'.link(3) = " + tmp);
758 tmp = "test".link("green");
759 ok(tmp === "<A HREF=\"green\">test</A>", "'test'.link('green') = " + tmp);
760
761 tmp = "".small();
762 ok(tmp === "<SMALL></SMALL>", "''.small() = " + tmp);
763 tmp = "".small(3);
764 ok(tmp === "<SMALL></SMALL>", "''.small(3) = " + tmp);
765 tmp = "test".small();
766 ok(tmp === "<SMALL>test</SMALL>", "'test'.small() = " + tmp);
767 tmp = "test".small(3);
768 ok(tmp === "<SMALL>test</SMALL>", "'test'.small(3) = " + tmp);
769
770 tmp = "".strike();
771 ok(tmp === "<STRIKE></STRIKE>", "''.strike() = " + tmp);
772 tmp = "".strike(3);
773 ok(tmp === "<STRIKE></STRIKE>", "''.strike(3) = " + tmp);
774 tmp = "test".strike();
775 ok(tmp === "<STRIKE>test</STRIKE>", "'test'.strike() = " + tmp);
776 tmp = "test".strike(3);
777 ok(tmp === "<STRIKE>test</STRIKE>", "'test'.strike(3) = " + tmp);
778
779 tmp = "".sub();
780 ok(tmp === "<SUB></SUB>", "''.sub() = " + tmp);
781 tmp = "".sub(3);
782 ok(tmp === "<SUB></SUB>", "''.sub(3) = " + tmp);
783 tmp = "test".sub();
784 ok(tmp === "<SUB>test</SUB>", "'test'.sub() = " + tmp);
785 tmp = "test".sub(3);
786 ok(tmp === "<SUB>test</SUB>", "'test'.sub(3) = " + tmp);
787
788 tmp = "".sup();
789 ok(tmp === "<SUP></SUP>", "''.sup() = " + tmp);
790 tmp = "".sup(3);
791 ok(tmp === "<SUP></SUP>", "''.sup(3) = " + tmp);
792 tmp = "test".sup();
793 ok(tmp === "<SUP>test</SUP>", "'test'.sup() = " + tmp);
794 tmp = "test".sup(3);
795 ok(tmp === "<SUP>test</SUP>", "'test'.sup(3) = " + tmp);
796
797 ok(String.fromCharCode() === "", "String.fromCharCode() = " + String.fromCharCode());
798 ok(String.fromCharCode(65,"66",67) === "ABC", "String.fromCharCode(65,'66',67) = " + String.fromCharCode(65,"66",67));
799 ok(String.fromCharCode(1024*64+65, -1024*64+65) === "AA",
800         "String.fromCharCode(1024*64+65, -1024*64+65) = " + String.fromCharCode(1024*64+65, -1024*64+65));
801 ok(String.fromCharCode(65, NaN, undefined).length === 3,
802         "String.fromCharCode(65, NaN, undefined).length = " + String.fromCharCode(65, NaN, undefined).length);
803
804 var arr = new Array();
805 ok(typeof(arr) === "object", "arr () is not object");
806 ok((arr.length === 0), "arr.length is not 0");
807 ok(arr["0"] === undefined, "arr[0] is not undefined");
808
809 var arr = new Array(1, 2, "test");
810 ok(typeof(arr) === "object", "arr (1,2,test) is not object");
811 ok((arr.length === 3), "arr.length is not 3");
812 ok(arr["0"] === 1, "arr[0] is not 1");
813 ok(arr["1"] === 2, "arr[1] is not 2");
814 ok(arr["2"] === "test", "arr[2] is not \"test\"");
815
816 arr["7"] = true;
817 ok((arr.length === 8), "arr.length is not 8");
818
819 tmp = "" + [];
820 ok(tmp === "", "'' + [] = " + tmp);
821 tmp = "" + [1,true];
822 ok(tmp === "1,true", "'' + [1,true] = " + tmp);
823
824 var arr = new Array(6);
825 ok(typeof(arr) === "object", "arr (6) is not object");
826 ok((arr.length === 6), "arr.length is not 6");
827 ok(arr["0"] === undefined, "arr[0] is not undefined");
828
829 ok(arr.push() === 6, "arr.push() !== 6");
830 ok(arr.push(1) === 7, "arr.push(1) !== 7");
831 ok(arr[6] === 1, "arr[6] != 1");
832 ok(arr.length === 7, "arr.length != 10");
833 ok(arr.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10");
834 ok(arr[8] === "b", "arr[8] != 'b'");
835 ok(arr.length === 10, "arr.length != 10");
836
837 var arr = new Object();
838 arr.push = Array.prototype.push;
839
840 arr.length = 6;
841
842 ok(arr.push() === 6, "arr.push() !== 6");
843 ok(arr.push(1) === 7, "arr.push(1) !== 7");
844 ok(arr[6] === 1, "arr[6] != 1");
845 ok(arr.length === 7, "arr.length != 10");
846 ok(arr.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10");
847 ok(arr[8] === "b", "arr[8] != 'b'");
848 ok(arr.length === 10, "arr.length != 10");
849
850 arr.pop = Array.prototype.pop;
851 ok(arr.pop() === false, "arr.pop() !== false");
852 ok(arr[8] === "b", "arr[8] !== 'b'");
853 ok(arr.pop() === 'b', "arr.pop() !== 'b'");
854 ok(arr[8] === undefined, "arr[8] !== undefined");
855
856 arr = [3,4,5];
857 tmp = arr.pop();
858 ok(arr.length === 2, "arr.length = " + arr.length);
859 ok(tmp === 5, "pop() = " + tmp);
860 tmp = arr.pop(2);
861 ok(arr.length === 1, "arr.length = " + arr.length);
862 ok(tmp === 4, "pop() = " + tmp);
863 tmp = arr.pop();
864 ok(arr.length === 0, "arr.length = " + arr.length);
865 ok(tmp === 3, "pop() = " + tmp);
866 for(tmp in arr)
867     ok(false, "not deleted " + tmp);
868 tmp = arr.pop();
869 ok(arr.length === 0, "arr.length = " + arr.length);
870 ok(tmp === undefined, "tmp = " + tmp);
871 arr = new Object();
872 arr.pop = Array.prototype.pop;
873 tmp = arr.pop();
874 ok(arr.length === 0, "arr.length = " + arr.length);
875 ok(tmp === undefined, "tmp = " + tmp);
876 arr = [,,,,,];
877 tmp = arr.pop();
878 ok(arr.length === 5, "arr.length = " + arr.length);
879 ok(tmp === undefined, "tmp = " + tmp);
880
881 function PseudoArray() {
882     this[0] = 0;
883 }
884 PseudoArray.prototype = {length: 1};
885 arr = new PseudoArray();
886 Array.prototype.push.call(arr, 2);
887 ok(arr.propertyIsEnumerable("length"), "arr.length is not enumerable");
888
889 arr = [1,2,null,false,undefined,,"a"];
890
891 tmp = arr.join();
892 ok(tmp === "1,2,,false,,,a", "arr.join() = " + tmp);
893 tmp = arr.join(";");
894 ok(tmp === "1;2;;false;;;a", "arr.join(';') = " + tmp);
895 tmp = arr.join(";","test");
896 ok(tmp === "1;2;;false;;;a", "arr.join(';') = " + tmp);
897 tmp = arr.join("");
898 ok(tmp === "12falsea", "arr.join('') = " + tmp);
899
900 tmp = arr.toString();
901 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
902 tmp = arr.toString("test");
903 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
904
905 arr = new Object();
906 arr.length = 3;
907 arr[0] = "aa";
908 arr[2] = 2;
909 arr[7] = 3;
910 arr.join = Array.prototype.join;
911 tmp = arr.join(",");
912 ok(arr.length === 3, "arr.length = " + arr.length);
913 ok(tmp === "aa,,2", "tmp = " + tmp);
914
915 arr = [5,true,2,-1,3,false,"2.5"];
916 tmp = arr.sort(function(x,y) { return y-x; });
917 ok(tmp === arr, "tmp !== arr");
918 tmp = [5,3,"2.5",2,true,false,-1];
919 for(var i=0; i < arr.length; i++)
920     ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
921
922 arr = [5,false,2,0,"abc",3,"a",-1];
923 tmp = arr.sort();
924 ok(tmp === arr, "tmp !== arr");
925 tmp = [-1,0,2,3,5,"a","abc",false];
926 for(var i=0; i < arr.length; i++)
927     ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
928
929 arr = ["a", "b", "ab"];
930 tmp = ["a", "ab", "b"];
931 ok(arr.sort() === arr, "arr.sort() !== arr");
932 for(var i=0; i < arr.length; i++)
933     ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
934
935 arr = new Object();
936 arr.length = 3;
937 arr[0] = 1;
938 arr[2] = "aa";
939 arr.sort = Array.prototype.sort;
940 tmp = arr.sort();
941 ok(arr === tmp, "tmp !== arr");
942 ok(arr[0]===1 && arr[1]==="aa" && arr[2]===undefined, "arr is sorted incorrectly");
943
944 tmp = [["bb","aa"],["ab","aa"]].sort().toString();
945 ok(tmp === "ab,aa,bb,aa", "sort() = " + tmp);
946
947 tmp = [["bb","aa"],"ab"].sort().toString();
948 ok(tmp === "ab,bb,aa", "sort() = " + tmp);
949
950 tmp = [["bb","aa"],"cc"].sort().toString();
951 ok(tmp === "bb,aa,cc", "sort() = " + tmp);
952
953 tmp = [2,"1"].sort().toString();
954 ok(tmp === "1,2", "sort() = " + tmp);
955
956 tmp = ["2",1].sort().toString();
957 ok(tmp === "1,2", "sort() = " + tmp);
958
959 tmp = [,,0,"z"].sort().toString();
960 ok(tmp === "0,z,,", "sort() = " + tmp);
961
962 tmp = ["a,b",["a","a"],["a","c"]].sort().toString();
963 ok(tmp === "a,a,a,b,a,c", "sort() = " + tmp);
964
965 arr = ["1", "2", "3"];
966 arr.length = 1;
967 ok(arr.length === 1, "arr.length = " + arr.length);
968 arr.length = 3;
969 ok(arr.length === 3, "arr.length = " + arr.length);
970 ok(arr.toString() === "1,,", "arr.toString() = " + arr.toString());
971
972 arr = Array("a","b","c");
973 ok(arr.toString() === "a,b,c", "arr.toString() = " + arr.toString());
974
975 ok(arr.valueOf === Object.prototype.valueOf, "arr.valueOf !== Object.prototype.valueOf");
976 ok(arr === arr.valueOf(), "arr !== arr.valueOf");
977
978 arr = [1,2,3];
979 tmp = arr.reverse();
980 ok(tmp === arr, "tmp !== arr");
981 ok(arr.length === 3, "arr.length = " + arr.length);
982 ok(arr.toString() === "3,2,1", "arr.toString() = " + arr.toString());
983
984 arr = [];
985 arr[3] = 5;
986 arr[5] = 1;
987 tmp = arr.reverse();
988 ok(tmp === arr, "tmp !== arr");
989 ok(arr.length === 6, "arr.length = " + arr.length);
990 ok(arr.toString() === "1,,5,,,", "arr.toString() = " + arr.toString());
991
992 arr = new Object();
993 arr.length = 3;
994 arr[0] = "aa";
995 arr[2] = 2;
996 arr[7] = 3;
997 arr.reverse = Array.prototype.reverse;
998 tmp = arr.reverse();
999 ok(tmp === arr, "tmp !== arr");
1000 ok(arr.length === 3, "arr.length = " + arr.length);
1001 ok(arr[0] === 2 && arr[1] === undefined && arr[2] === "aa", "unexpected array");
1002
1003 arr = [1,2,3];
1004 tmp = arr.unshift(0);
1005 ok(tmp === (invokeVersion < 2 ? undefined : 4), "[1,2,3].unshift(0) returned " +tmp);
1006 ok(arr.length === 4, "arr.length = " + arr.length);
1007 ok(arr.toString() === "0,1,2,3", "arr.toString() = " + arr.toString());
1008
1009 arr = new Array(3);
1010 arr[0] = 1;
1011 arr[2] = 3;
1012 tmp = arr.unshift(-1,0);
1013 ok(tmp === (invokeVersion < 2 ? undefined : 5), "unshift returned " +tmp);
1014 ok(arr.length === 5, "arr.length = " + arr.length);
1015 ok(arr.toString() === "-1,0,1,,3", "arr.toString() = " + arr.toString());
1016
1017 arr = [1,2,3];
1018 tmp = arr.unshift();
1019 ok(tmp === (invokeVersion < 2 ? undefined : 3), "unshift returned " +tmp);
1020 ok(arr.length === 3, "arr.length = " + arr.length);
1021 ok(arr.toString() === "1,2,3", "arr.toString() = " + arr.toString());
1022
1023 arr = new Object();
1024 arr.length = 2;
1025 arr[0] = 1;
1026 arr[1] = 2;
1027 tmp = Array.prototype.unshift.call(arr, 0);
1028 ok(tmp === (invokeVersion < 2 ? undefined : 3), "unshift returned " +tmp);
1029 ok(arr.length === 3, "arr.length = " + arr.length);
1030 ok(arr[0] === 0 && arr[1] === 1 && arr[2] === 2, "unexpected array");
1031
1032 arr = [1,2,,4];
1033 tmp = arr.shift();
1034 ok(tmp === 1, "[1,2,,4].shift() = " + tmp);
1035 ok(arr.toString() === "2,,4", "arr = " + arr.toString());
1036
1037 arr = [];
1038 tmp = arr.shift();
1039 ok(tmp === undefined, "[].shift() = " + tmp);
1040 ok(arr.toString() === "", "arr = " + arr.toString());
1041
1042 arr = [1,2,,4];
1043 tmp = arr.shift(2);
1044 ok(tmp === 1, "[1,2,,4].shift(2) = " + tmp);
1045 ok(arr.toString() === "2,,4", "arr = " + arr.toString());
1046
1047 arr = [1,];
1048 tmp = arr.shift();
1049 ok(tmp === 1, "[1,].shift() = " + tmp);
1050 ok(arr.toString() === "", "arr = " + arr.toString());
1051
1052 obj = new Object();
1053 obj[0] = "test";
1054 obj[2] = 3;
1055 obj.length = 3;
1056 tmp = Array.prototype.shift.call(obj);
1057 ok(tmp === "test", "obj.shift() = " + tmp);
1058 ok(obj.length == 2, "obj.length = " + obj.length);
1059 ok(obj[1] === 3, "obj[1] = " + obj[1]);
1060
1061 var num = new Number(6);
1062 arr = [0,1,2];
1063 tmp = arr.concat(3, [4,5], num);
1064 ok(tmp !== arr, "tmp === arr");
1065 for(var i=0; i<6; i++)
1066     ok(tmp[i] === i, "tmp[" + i + "] = " + tmp[i]);
1067 ok(tmp[6] === num, "tmp[6] !== num");
1068 ok(tmp.length === 7, "tmp.length = " + tmp.length);
1069
1070 arr = [].concat();
1071 ok(arr.length === 0, "arr.length = " + arr.length);
1072
1073 arr = [1,];
1074 tmp = arr.concat([2]);
1075 ok(tmp.length === 3, "tmp.length = " + tmp.length);
1076 ok(tmp[1] === undefined, "tmp[1] = " + tmp[1]);
1077
1078 arr = [1,false,'a',null,undefined,'a'];
1079 ok(arr.slice(0,6).toString() === "1,false,a,,,a", "arr.slice(0,6).toString() = " + arr.slice(0,6));
1080 ok(arr.slice(0,6).length === 6, "arr.slice(0,6).length = " + arr.slice(0,6).length);
1081 ok(arr.slice().toString() === "1,false,a,,,a", "arr.slice().toString() = " + arr.slice());
1082 ok(arr.slice("abc").toString() === "1,false,a,,,a", "arr.slice(\"abc\").toString() = " + arr.slice("abc"));
1083 ok(arr.slice(3,8).toString() === ",,a", "arr.slice(3,8).toString() = " + arr.slice(3,8));
1084 ok(arr.slice(3,8).length === 3, "arr.slice(3,8).length = " + arr.slice(3,8).length);
1085 ok(arr.slice(1).toString() === "false,a,,,a", "arr.slice(1).toString() = " + arr.slice(1));
1086 ok(arr.slice(-2).toString() === ",a", "arr.slice(-2).toString() = " + arr.slice(-2));
1087 ok(arr.slice(3,1).toString() === "", "arr.slice(3,1).toString() = " + arr.slice(3,1));
1088 tmp = arr.slice(0,6);
1089 for(var i=0; i < arr.length; i++)
1090     ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
1091 arr[12] = 2;
1092 ok(arr.slice(5).toString() === "a,,,,,,,2", "arr.slice(5).toString() = " + arr.slice(5).toString());
1093 ok(arr.slice(5).length === 8, "arr.slice(5).length = " + arr.slice(5).length);
1094
1095 arr = [1,2,3,4,5];
1096 tmp = arr.splice(2,2);
1097 ok(tmp.toString() == "3,4", "arr.splice(2,2) returned " + tmp.toString());
1098 ok(arr.toString() == "1,2,5", "arr.splice(2,2) is " + arr.toString());
1099
1100 arr = [1,2,3,4,5];
1101 tmp = arr.splice(2,2,"a");
1102 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a') returned " + tmp.toString());
1103 ok(arr.toString() == "1,2,a,5", "arr.splice(2,2,'a') is " + arr.toString());
1104
1105 arr = [1,2,3,4,5];
1106 tmp = arr.splice(2,2,'a','b','c');
1107 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a','b','c') returned " + tmp.toString());
1108 ok(arr.toString() == "1,2,a,b,c,5", "arr.splice(2,2,'a','b','c') is " + arr.toString());
1109
1110 arr = [1,2,3,4,];
1111 tmp = arr.splice(2,2,'a','b','c');
1112 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a','b','c') returned " + tmp.toString());
1113 ok(arr.toString() == "1,2,a,b,c,", "arr.splice(2,2,'a','b','c') is " + arr.toString());
1114
1115 arr = [1,2,3,4,];
1116 arr.splice(2,2,'a','b','c');
1117 ok(arr.toString() == "1,2,a,b,c,", "arr.splice(2,2,'a','b','c') is " + arr.toString());
1118
1119 arr = [1,2,3,4,5];
1120 tmp = arr.splice(2,2,'a','b');
1121 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a','b') returned " + tmp.toString());
1122 ok(arr.toString() == "1,2,a,b,5", "arr.splice(2,2,'a','b') is " + arr.toString());
1123
1124 arr = [1,2,3,4,5];
1125 tmp = arr.splice(-1,2);
1126 ok(tmp.toString() == "5", "arr.splice(-1,2) returned " + tmp.toString());
1127 ok(arr.toString() == "1,2,3,4", "arr.splice(-1,2) is " + arr.toString());
1128
1129 arr = [1,2,3,4,5];
1130 tmp = arr.splice(-10,3);
1131 ok(tmp.toString() == "1,2,3", "arr.splice(-10,3) returned " + tmp.toString());
1132 ok(arr.toString() == "4,5", "arr.splice(-10,3) is " + arr.toString());
1133
1134 arr = [1,2,3,4,5];
1135 tmp = arr.splice(-10,100);
1136 ok(tmp.toString() == "1,2,3,4,5", "arr.splice(-10,100) returned " + tmp.toString());
1137 ok(arr.toString() == "", "arr.splice(-10,100) is " + arr.toString());
1138
1139 arr = [1,2,3,4,5];
1140 tmp = arr.splice(2,-1);
1141 ok(tmp.toString() == "", "arr.splice(2,-1) returned " + tmp.toString());
1142 ok(arr.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr.toString());
1143
1144 arr = [1,2,3,4,5];
1145 tmp = arr.splice(2);
1146 ok(tmp.toString() == "", "arr.splice(2,-1) returned " + tmp.toString());
1147 ok(arr.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr.toString());
1148
1149 arr = [1,2,3,4,5];
1150 tmp = arr.splice();
1151 ok(tmp.toString() == "", "arr.splice(2,-1) returned " + tmp.toString());
1152 ok(arr.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr.toString());
1153
1154 arr = [1,2,3,4,5];
1155 tmp = arr.splice(bigInt);
1156 ok(tmp.toString() == "", "arr.splice(bigInt) returned " + tmp.toString());
1157 ok(arr.toString() == "1,2,3,4,5", "arr.splice(bigInt) is " + arr.toString());
1158
1159 arr = [1,2,3,4,5];
1160 tmp = arr.splice(-bigInt);
1161 ok(tmp.toString() == "", "arr.splice(-bigInt) returned " + tmp.toString());
1162 ok(arr.toString() == "1,2,3,4,5", "arr.splice(-bigInt) is " + arr.toString());
1163
1164 if(invokeVersion >= 2) {
1165     arr = [1,2,3,4,5];
1166     tmp = arr.splice(2, bigInt);
1167     ok(tmp.toString() == "3,4,5", "arr.splice(2, bigInt) returned " + tmp.toString());
1168     ok(arr.toString() == "1,2", "arr.splice(2, bigInt) is " + arr.toString());
1169 }
1170
1171 arr = [1,2,3,4,5];
1172 tmp = arr.splice(2, -bigInt);
1173 ok(tmp.toString() == "", "arr.splice(2, -bigInt) returned " + tmp.toString());
1174 ok(arr.toString() == "1,2,3,4,5", "arr.splice(2, -bigInt) is " + arr.toString());
1175
1176 obj = new Object();
1177 obj.length = 3;
1178 obj[0] = 1;
1179 obj[1] = 2;
1180 obj[2] = 3;
1181 tmp = Array.prototype.splice.call(obj, 1, 1, 'a', 'b');
1182 ok(tmp.toString() === "2", "obj.splice returned " + tmp);
1183 ok(obj.length === 4, "obj.length = " + obj.length);
1184 ok(obj[0] === 1, "obj[0] = " + obj[0]);
1185 ok(obj[1] === 'a', "obj[1] = " + obj[1]);
1186 ok(obj[2] === 'b', "obj[2] = " + obj[2]);
1187 ok(obj[3] === 3, "obj[3] = " + obj[3]);
1188
1189 obj = new Object();
1190 obj.length = 3;
1191 obj[0] = 1;
1192 obj[1] = 2;
1193 obj[2] = 3;
1194 tmp = Array.prototype.slice.call(obj, 1, 2);
1195 ok(tmp.length === 1, "tmp.length = " + tmp.length);
1196 ok(tmp[0] === 2, "tmp[0] = " + tmp[0]);
1197
1198 tmp = (new Number(2)).toString();
1199 ok(tmp === "2", "num(2).toString = " + tmp);
1200 tmp = (new Number()).toString();
1201 ok(tmp === "0", "num().toString = " + tmp);
1202 tmp = (new Number(5.5)).toString(2);
1203 ok(tmp === "101.1", "num(5.5).toString(2) = " + tmp);
1204
1205 tmp = (new Number(3)).toFixed(3);
1206 ok(tmp === "3.000", "num(3).toFixed(3) = " + tmp);
1207 tmp = (new Number(1.76)).toFixed(1);
1208 ok(tmp === "1.8", "num(1.76).toFixed(1) = " + tmp);
1209 tmp = (new Number(7.92)).toFixed(5);
1210 ok(tmp === "7.92000", "num(7.92).toFixed(5) = " + tmp);
1211 tmp = (new Number(2.88)).toFixed();
1212 ok(tmp === "3", "num(2.88).toFixed = " + tmp);
1213 tmp = (new Number(-2.5)).toFixed();
1214 ok(tmp === "-3", "num(-2.5).toFixed = " + tmp);
1215 tmp = (new Number(1000000000000000128)).toFixed(0);
1216 //todo_wine ok(tmp === "1000000000000000100", "num(1000000000000000128) = " + tmp);
1217 tmp = (new Number(3.14).toFixed(NaN));
1218 ok(tmp === "3", "num(3.14).toFixed = " + tmp);
1219 tmp = (new Number(0.95).toFixed(1));
1220 ok(tmp === "1.0", "num(0.95).toFixed(1) = " + tmp);
1221 tmp = (new Number(1e900)).toFixed(0);
1222 ok(tmp === "Infinity", "num(1000000000000000128) = " + tmp);
1223 tmp = (new Number(0.12345678901234567890123)).toFixed(20);
1224 ok(tmp === "0.12345678901234568000", "num(0.12345678901234567890123) = " + tmp);
1225
1226 tmp = (new Number(2)).toExponential(3);
1227 ok(tmp === "2.000e+0", "num(2).toExponential(3) = " + tmp);
1228 tmp = (new Number(1.17e-32)).toExponential(20);
1229 ok(tmp === "1.17000000000000000000e-32", "num(1.17e-32).toExponential(20) = " + tmp);
1230 tmp = (new Number(0)).toExponential(7);
1231 ok(tmp === "0.0000000e+0", "num(0).toExponential(7) = " + tmp);
1232 tmp = (new Number(0)).toExponential(0);
1233 ok(tmp === "0e+0", "num(0).toExponential() = " + tmp);
1234 tmp = (new Number(-13.7567)).toExponential();
1235 ok(tmp === "-1.37567e+1", "num(-13.7567).toExponential() = " + tmp);
1236 tmp = (new Number(-32.1)).toExponential();
1237 ok(tmp === "-3.21e+1", "num(-32.1).toExponential() = " + tmp);
1238 tmp = (new Number(4723.4235)).toExponential();
1239 ok(tmp === "4.7234235e+3", "num(4723.4235).toExponential() = " + tmp);
1240
1241 tmp = (new Number(5)).toPrecision(12);
1242 ok(tmp == "5.00000000000", "num(5).toPrecision(12) = " + tmp);
1243 tmp = (new Number(7.73)).toPrecision(7);
1244 ok(tmp == "7.730000", "num(7.73).toPrecision(7) = " + tmp);
1245 tmp = (new Number(-127547.47472)).toPrecision(17);
1246 ok(tmp == "-127547.47472000000", "num(-127547.47472).toPrecision(17) = " + tmp);
1247 tmp = (new Number(0)).toPrecision(3);
1248 ok(tmp == "0.00", "num(0).toPrecision(3) = " + tmp);
1249 tmp = (new Number(42345.52342465464562334)).toPrecision(15);
1250 ok(tmp == "42345.5234246546", "num(42345.52342465464562334).toPrecision(15) = " + tmp);
1251 tmp = (new Number(1.182e30)).toPrecision(5);
1252 ok(tmp == "1.1820e+30", "num(1.182e30)).toPrecision(5) = " + tmp);
1253 tmp = (new Number(1.123)).toPrecision();
1254 ok(tmp == "1.123", "num(1.123).toPrecision() = " + tmp);
1255
1256 ok(Number() === 0, "Number() = " + Number());
1257 ok(Number(false) === 0, "Number(false) = " + Number(false));
1258 ok(Number("43") === 43, "Number('43') = " + Number("43"));
1259
1260 tmp = (new Number(1)).valueOf();
1261 ok(tmp === 1, "(new Number(1)).valueOf = " + tmp);
1262 tmp = (new Number(1,2)).valueOf();
1263 ok(tmp === 1, "(new Number(1,2)).valueOf = " + tmp);
1264 tmp = (new Number()).valueOf();
1265 ok(tmp === 0, "(new Number()).valueOf = " + tmp);
1266 tmp = Number.prototype.valueOf();
1267 ok(tmp === 0, "Number.prototype.valueOf = " + tmp);
1268
1269 function equals(val, base) {
1270     var i;
1271     var num = 0;
1272     var str = val.toString(base);
1273
1274     for(i=0; i<str.length; i++) {
1275         if(str.substring(i, i+1) == '(') break;
1276         if(str.substring(i, i+1) == '.') break;
1277         num = num*base + parseInt(str.substring(i, i+1));
1278     }
1279
1280     if(str.substring(i, i+1) == '.') {
1281         var mult = base;
1282         for(i++; i<str.length; i++) {
1283             if(str.substring(i, i+1) == '(') break;
1284             num += parseInt(str.substring(i, i+1))/mult;
1285             mult *= base;
1286         }
1287     }
1288
1289     if(str.substring(i, i+1) == '(') {
1290         exp = parseInt(str.substring(i+2));
1291         num *= Math.pow(base, exp);
1292     }
1293
1294     ok(num>val-val/1000 && num<val+val/1000, "equals: num = " + num);
1295 }
1296
1297 ok((10).toString(11) === "a", "(10).toString(11) = " + (10).toString(11));
1298 ok((213213433).toString(17) === "8e2ddcb", "(213213433).toString(17) = " + (213213433).toString(17));
1299 ok((-3254343).toString(33) === "-2oicf", "(-3254343).toString(33) = " + (-3254343).toString(33));
1300 ok((NaN).toString(12) === "NaN", "(NaN).toString(11) = " + (NaN).toString(11));
1301 ok((Infinity).toString(13) === "Infinity", "(Infinity).toString(11) = " + (Infinity).toString(11));
1302 for(i=2; i<10; i++) {
1303     equals(1.123, i);
1304     equals(2305843009200000000, i);
1305     equals(5.123, i);
1306     equals(21711, i);
1307     equals(1024*1024*1024*1024*1024*1024*1.9999, i);
1308     equals(748382, i);
1309     equals(0.6, i);
1310     equals(4.65661287308e-10, i);
1311     ok((0).toString(i) === "0", "(0).toString("+i+") = " + (0).toString(i));
1312 }
1313
1314 ok(parseFloat('123') === 123, "parseFloat('123') = " + parseFloat('123'));
1315 ok(parseFloat('-13.7') === -13.7, "parseFloat('-13.7') = " + parseFloat('-13.7'));
1316 ok(parseFloat('-0.01e-2') === -0.01e-2, "parseFloat('-0.01e-2') = " + parseFloat('-0.01e-2'));
1317 ok(parseFloat('-12e+5') === -12e+5, "parseFloat('-12e+5') = " + parseFloat('-12e+5'));
1318 ok(parseFloat('1E5 not parsed') === 1E5, "parseFloat('1E5 not parsed') = " + parseFloat('1E5 not parsed'));
1319 ok(isNaN(parseFloat('not a number')), "parseFloat('not a number') is not NaN");
1320 ok(parseFloat('+13.2e-3') === 13.2e-3, "parseFloat('+13.2e-3') = " + parseFloat('+13.2e-3'));
1321 ok(parseFloat('.12') === 0.12, "parseFloat('.12') = " + parseFloat('.12'));
1322 ok(parseFloat('1e') === 1, "parseFloat('1e') = " + parseFloat('1e'));
1323
1324 tmp = Math.min(1);
1325 ok(tmp === 1, "Math.min(1) = " + tmp);
1326
1327 tmp = Math.min(1, false);
1328 ok(tmp === 0, "Math.min(1, false) = " + tmp);
1329
1330 tmp = Math.min();
1331 ok(tmp === Infinity, "Math.min() = " + tmp);
1332
1333 tmp = Math.min(1, NaN, -Infinity, false);
1334 ok(isNaN(tmp), "Math.min(1, NaN, -Infinity, false) is not NaN");
1335
1336 tmp = Math.min(1, false, true, null, -3);
1337 ok(tmp === -3, "Math.min(1, false, true, null, -3) = " + tmp);
1338
1339 tmp = Math.max(1);
1340 ok(tmp === 1, "Math.max(1) = " + tmp);
1341
1342 tmp = Math.max(true, 0);
1343 ok(tmp === 1, "Math.max(true, 0) = " + tmp);
1344
1345 tmp = Math.max(-2, false, true, null, 1);
1346 ok(tmp === 1, "Math.max(-2, false, true, null, 1) = " + tmp);
1347
1348 tmp = Math.max();
1349 ok(tmp === -Infinity, "Math.max() = " + tmp);
1350
1351 tmp = Math.max(true, NaN, 0);
1352 ok(isNaN(tmp), "Math.max(true, NaN, 0) is not NaN");
1353
1354 tmp = Math.round(0.5);
1355 ok(tmp === 1, "Math.round(0.5) = " + tmp);
1356
1357 tmp = Math.round(-0.5);
1358 ok(tmp === 0, "Math.round(-0.5) = " + tmp);
1359
1360 tmp = Math.round(1.1);
1361 ok(tmp === 1, "Math.round(1.1) = " + tmp);
1362
1363 tmp = Math.round(true);
1364 ok(tmp === 1, "Math.round(true) = " + tmp);
1365
1366 tmp = Math.round(1.1, 3, 4);
1367 ok(tmp === 1, "Math.round(1.1, 3, 4) = " + tmp);
1368
1369 tmp = Math.round();
1370 ok(isNaN(tmp), "Math.round() is not NaN");
1371
1372 tmp = Math.ceil(0.5);
1373 ok(tmp === 1, "Math.ceil(0.5) = " + tmp);
1374
1375 tmp = Math.ceil(-0.5);
1376 ok(tmp === 0, "Math.ceil(-0.5) = " + tmp);
1377
1378 tmp = Math.ceil(1.1);
1379 ok(tmp === 2, "Math.round(1.1) = " + tmp);
1380
1381 tmp = Math.ceil(true);
1382 ok(tmp === 1, "Math.ceil(true) = " + tmp);
1383
1384 tmp = Math.ceil(1.1, 3, 4);
1385 ok(tmp === 2, "Math.ceil(1.1, 3, 4) = " + tmp);
1386
1387 tmp = Math.ceil();
1388 ok(isNaN(tmp), "ceil() is not NaN");
1389
1390 tmp = Math.floor(0.5);
1391 ok(tmp === 0, "Math.floor(0.5) = " + tmp);
1392
1393 tmp = Math.floor(-0.5);
1394 ok(tmp === -1, "Math.floor(-0.5) = " + tmp);
1395
1396 tmp = Math.floor(1.1);
1397 ok(tmp === 1, "Math.floor(1.1) = " + tmp);
1398
1399 tmp = Math.floor(true);
1400 ok(tmp === 1, "Math.floor(true) = " + tmp);
1401
1402 tmp = Math.floor(1.1, 3, 4);
1403 ok(tmp === 1, "Math.floor(1.1, 3, 4) = " + tmp);
1404
1405 tmp = Math.floor();
1406 ok(isNaN(tmp), "floor is not NaN");
1407
1408 tmp = Math.abs(3);
1409 ok(tmp === 3, "Math.abs(3) = " + tmp);
1410
1411 tmp = Math.abs(-3);
1412 ok(tmp === 3, "Math.abs(-3) = " + tmp);
1413
1414 tmp = Math.abs(true);
1415 ok(tmp === 1, "Math.abs(true) = " + tmp);
1416
1417 tmp = Math.abs();
1418 ok(isNaN(tmp), "Math.abs() is not NaN");
1419
1420 tmp = Math.abs(NaN);
1421 ok(isNaN(tmp), "Math.abs() is not NaN");
1422
1423 tmp = Math.abs(-Infinity);
1424 ok(tmp === Infinity, "Math.abs(-Infinite) = " + tmp);
1425
1426 tmp = Math.abs(-3, 2);
1427 ok(tmp === 3, "Math.abs(-3, 2) = " + tmp);
1428
1429 tmp = Math.cos(0);
1430 ok(tmp === 1, "Math.cos(0) = " + tmp);
1431
1432 tmp = Math.cos(Math.PI/2);
1433 ok(Math.floor(tmp*100) === 0, "Math.cos(Math.PI/2) = " + tmp);
1434
1435 tmp = Math.cos(-Math.PI/2);
1436 ok(Math.floor(tmp*100) === 0, "Math.cos(-Math.PI/2) = " + tmp);
1437
1438 tmp = Math.cos(Math.PI/3, 2);
1439 ok(Math.floor(tmp*100) === 50, "Math.cos(Math.PI/3, 2) = " + tmp);
1440
1441 tmp = Math.cos(true);
1442 ok(Math.floor(tmp*100) === 54, "Math.cos(true) = " + tmp);
1443
1444 tmp = Math.cos(false);
1445 ok(tmp === 1, "Math.cos(false) = " + tmp);
1446
1447 tmp = Math.cos();
1448 ok(isNaN(tmp), "Math.cos() is not NaN");
1449
1450 tmp = Math.cos(NaN);
1451 ok(isNaN(tmp), "Math.cos(NaN) is not NaN");
1452
1453 tmp = Math.cos(Infinity);
1454 ok(isNaN(tmp), "Math.cos(Infinity) is not NaN");
1455
1456 tmp = Math.cos(-Infinity);
1457 ok(isNaN(tmp), "Math.cos(-Infinity) is not NaN");
1458
1459 tmp = Math.pow(2, 2);
1460 ok(tmp === 4, "Math.pow(2, 2) = " + tmp);
1461
1462 tmp = Math.pow(4, 0.5);
1463 ok(tmp === 2, "Math.pow(2, 2) = " + tmp);
1464
1465 tmp = Math.pow(2, 2, 3);
1466 ok(tmp === 4, "Math.pow(2, 2, 3) = " + tmp);
1467
1468 tmp = Math.pow(2);
1469 ok(isNaN(tmp), "Math.pow(2) is not NaN");
1470
1471 tmp = Math.pow();
1472 ok(isNaN(tmp), "Math.pow() is not NaN");
1473
1474 tmp = Math.random();
1475 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
1476 ok(0 <= tmp && tmp <= 1, "Math.random() = " + tmp);
1477
1478 tmp = Math.random(100);
1479 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
1480 ok(0 <= tmp && tmp <= 1, "Math.random(100) = " + tmp);
1481
1482 tmp = Math.acos(0);
1483 ok(Math.floor(tmp*100) === 157, "Math.acos(0) = " + tmp);
1484
1485 tmp = Math.acos(1);
1486 ok(Math.floor(tmp*100) === 0, "Math.acos(1) = " + tmp);
1487
1488 tmp = Math.acos(-1);
1489 ok(Math.floor(tmp*100) === 314, "Math.acos(-1) = " + tmp);
1490
1491 tmp = Math.acos(Math.PI/4, 2);
1492 ok(Math.floor(tmp*100) === 66, "Math.acos(Math.PI/4, 2) = " + tmp);
1493
1494 tmp = Math.acos(true);
1495 ok(Math.floor(tmp*100) === 0, "Math.acos(true) = " + tmp);
1496
1497 tmp = Math.acos(false);
1498 ok(Math.floor(tmp*100) === 157, "Math.acos(false) = " + tmp);
1499
1500 tmp = Math.acos(1.1);
1501 ok(isNaN(tmp), "Math.acos(1.1) is not NaN");
1502
1503 tmp = Math.acos();
1504 ok(isNaN(tmp), "Math.acos() is not NaN");
1505
1506 tmp = Math.acos(NaN);
1507 ok(isNaN(tmp), "Math.acos(NaN) is not NaN");
1508
1509 tmp = Math.acos(Infinity);
1510 ok(isNaN(tmp), "Math.acos(Infinity) is not NaN");
1511
1512 tmp = Math.acos(-Infinity);
1513 ok(isNaN(tmp), "Math.acos(-Infinity) is not NaN");
1514
1515 tmp = Math.asin(0);
1516 ok(Math.floor(tmp*100) === 0, "Math.asin(0) = " + tmp);
1517
1518 tmp = Math.asin(1);
1519 ok(Math.floor(tmp*100) === 157, "Math.asin(1) = " + tmp);
1520
1521 tmp = Math.asin(-1);
1522 ok(Math.floor(tmp*100) === -158, "Math.asin(-1) = " + tmp);
1523
1524 tmp = Math.asin(Math.PI/4, 2);
1525 ok(Math.floor(tmp*100) === 90, "Math.asin(Math.PI/4, 2) = " + tmp);
1526
1527 tmp = Math.asin(true);
1528 ok(Math.floor(tmp*100) === 157, "Math.asin(true) = " + tmp);
1529
1530 tmp = Math.asin(false);
1531 ok(Math.floor(tmp*100) === 0, "Math.asin(false) = " + tmp);
1532
1533 tmp = Math.asin(1.1);
1534 ok(isNaN(tmp), "Math.asin(1.1) is not NaN");
1535
1536 tmp = Math.asin();
1537 ok(isNaN(tmp), "Math.asin() is not NaN");
1538
1539 tmp = Math.asin(NaN);
1540 ok(isNaN(tmp), "Math.asin(NaN) is not NaN");
1541
1542 tmp = Math.asin(Infinity);
1543 ok(isNaN(tmp), "Math.asin(Infinity) is not NaN");
1544
1545 tmp = Math.asin(-Infinity);
1546 ok(isNaN(tmp), "Math.asin(-Infinity) is not NaN");
1547
1548 tmp = Math.atan(0);
1549 ok(Math.floor(tmp*100) === 0, "Math.atan(0) = " + tmp);
1550
1551 tmp = Math.atan(1);
1552 ok(Math.floor(tmp*100) === 78, "Math.atan(1) = " + tmp);
1553
1554 tmp = Math.atan(-1);
1555 ok(Math.floor(tmp*100) === -79, "Math.atan(-1) = " + tmp);
1556
1557 tmp = Math.atan(true);
1558 ok(Math.floor(tmp*100) === 78, "Math.atan(true) = " + tmp);
1559
1560 tmp = Math.atan(false);
1561 ok(Math.floor(tmp*100) === 0, "Math.atan(false) = " + tmp);
1562
1563 tmp = Math.atan();
1564 ok(isNaN(tmp), "Math.atan() is not NaN");
1565
1566 tmp = Math.atan(NaN);
1567 ok(isNaN(tmp), "Math.atan(NaN) is not NaN");
1568
1569 tmp = Math.atan(Infinity);
1570 ok(Math.floor(tmp*100) === 157, "Math.atan(Infinity) = " + tmp);
1571
1572 tmp = Math.atan(-Infinity);
1573 ok(Math.floor(tmp*100) === -158, "Math.atan(Infinity) = " + tmp);
1574
1575 tmp = Math.atan2(0, 0);
1576 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 0) = " + tmp);
1577
1578 tmp = Math.atan2(0, 1);
1579 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 1) = " + tmp);
1580
1581 tmp = Math.atan2(0, Infinity);
1582 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, Infinity) = " + tmp);
1583
1584 tmp = Math.atan2(0, -1);
1585 ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -1) = " + tmp);
1586
1587 tmp = Math.atan2(0, -Infinity);
1588 ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -Infinity) = " + tmp);
1589
1590 tmp = Math.atan2(1, 0);
1591 ok(Math.floor(tmp*100) === 157, "Math.atan2(1, 0) = " + tmp);
1592
1593 tmp = Math.atan2(Infinity, 0);
1594 ok(Math.floor(tmp*100) === 157, "Math.atan2(Infinity, 0) = " + tmp);
1595
1596 tmp = Math.atan2(-1, 0);
1597 ok(Math.floor(tmp*100) === -158, "Math.atan2(-1, 0) = " + tmp);
1598
1599 tmp = Math.atan2(-Infinity, 0);
1600 ok(Math.floor(tmp*100) === -158, "Math.atan2(-Infinity, 0) = " + tmp);
1601
1602 tmp = Math.atan2(1, 1);
1603 ok(Math.floor(tmp*100) === 78, "Math.atan2(1, 1) = " + tmp);
1604
1605 tmp = Math.atan2(-1, -1);
1606 ok(Math.floor(tmp*100) === -236, "Math.atan2(-1, -1) = " + tmp);
1607
1608 tmp = Math.atan2(-1, 1);
1609 ok(Math.floor(tmp*100) === -79, "Math.atan2(-1, 1) = " + tmp);
1610
1611 tmp = Math.atan2(Infinity, Infinity);
1612 ok(Math.floor(tmp*100) === 78, "Math.atan2(Infinity, Infinity) = " + tmp);
1613
1614 tmp = Math.atan2(Infinity, -Infinity, 1);
1615 ok(Math.floor(tmp*100) === 235, "Math.atan2(Infinity, -Infinity, 1) = " + tmp);
1616
1617 tmp = Math.atan2();
1618 ok(isNaN(tmp), "Math.atan2() is not NaN");
1619
1620 tmp = Math.atan2(1);
1621 ok(isNaN(tmp), "Math.atan2(1) is not NaN");
1622
1623 tmp = Math.exp(0);
1624 ok(tmp === 1, "Math.exp(0) = " + tmp);
1625
1626 tmp = Math.exp(1);
1627 ok(Math.floor(tmp*100) === 271, "Math.exp(1) = " + tmp);
1628
1629 tmp = Math.exp(-1);
1630 ok(Math.floor(tmp*100) === 36, "Math.exp(-1) = " + tmp);
1631
1632 tmp = Math.exp(true);
1633 ok(Math.floor(tmp*100) === 271, "Math.exp(true) = " + tmp);
1634
1635 tmp = Math.exp(1, 1);
1636 ok(Math.floor(tmp*100) === 271, "Math.exp(1, 1) = " + tmp);
1637
1638 tmp = Math.exp();
1639 ok(isNaN(tmp), "Math.exp() is not NaN");
1640
1641 tmp = Math.exp(NaN);
1642 ok(isNaN(tmp), "Math.exp(NaN) is not NaN");
1643
1644 tmp = Math.exp(Infinity);
1645 ok(tmp === Infinity, "Math.exp(Infinity) = " + tmp);
1646
1647 tmp = Math.exp(-Infinity);
1648 ok(tmp === 0, "Math.exp(-Infinity) = " + tmp);
1649
1650 tmp = Math.log(1);
1651 ok(Math.floor(tmp*100) === 0, "Math.log(1) = " + tmp);
1652
1653 tmp = Math.log(-1);
1654 ok(isNaN(tmp), "Math.log(-1) is not NaN");
1655
1656 tmp = Math.log(true);
1657 ok(Math.floor(tmp*100) === 0, "Math.log(true) = " + tmp);
1658
1659 tmp = Math.log(1, 1);
1660 ok(Math.floor(tmp*100) === 0, "Math.log(1, 1) = " + tmp);
1661
1662 tmp = Math.log();
1663 ok(isNaN(tmp), "Math.log() is not NaN");
1664
1665 tmp = Math.log(NaN);
1666 ok(isNaN(tmp), "Math.log(NaN) is not NaN");
1667
1668 tmp = Math.log(Infinity);
1669 ok(tmp === Infinity, "Math.log(Infinity) = " + tmp);
1670
1671 tmp = Math.log(-Infinity);
1672 ok(isNaN(tmp), "Math.log(-Infinity) is not NaN");
1673
1674 tmp = Math.sin(0);
1675 ok(tmp === 0, "Math.sin(0) = " + tmp);
1676
1677 tmp = Math.sin(Math.PI/2);
1678 ok(tmp === 1, "Math.sin(Math.PI/2) = " + tmp);
1679
1680 tmp = Math.sin(-Math.PI/2);
1681 ok(tmp === -1, "Math.sin(-Math.PI/2) = " + tmp);
1682
1683 tmp = Math.sin(Math.PI/3, 2);
1684 ok(Math.floor(tmp*100) === 86, "Math.sin(Math.PI/3, 2) = " + tmp);
1685
1686 tmp = Math.sin(true);
1687 ok(Math.floor(tmp*100) === 84, "Math.sin(true) = " + tmp);
1688
1689 tmp = Math.sin(false);
1690 ok(tmp === 0, "Math.sin(false) = " + tmp);
1691
1692 tmp = Math.sin();
1693 ok(isNaN(tmp), "Math.sin() is not NaN");
1694
1695 tmp = Math.sin(NaN);
1696 ok(isNaN(tmp), "Math.sin(NaN) is not NaN");
1697
1698 tmp = Math.sin(Infinity);
1699 ok(isNaN(tmp), "Math.sin(Infinity) is not NaN");
1700
1701 tmp = Math.sin(-Infinity);
1702 ok(isNaN(tmp), "Math.sin(-Infinity) is not NaN");
1703
1704 tmp = Math.sqrt(0);
1705 ok(tmp === 0, "Math.sqrt(0) = " + tmp);
1706
1707 tmp = Math.sqrt(4);
1708 ok(tmp === 2, "Math.sqrt(4) = " + tmp);
1709
1710 tmp = Math.sqrt(-1);
1711 ok(isNaN(tmp), "Math.sqrt(-1) is not NaN");
1712
1713 tmp = Math.sqrt(2, 2);
1714 ok(Math.floor(tmp*100) === 141, "Math.sqrt(2, 2) = " + tmp);
1715
1716 tmp = Math.sqrt(true);
1717 ok(tmp === 1, "Math.sqrt(true) = " + tmp);
1718
1719 tmp = Math.sqrt(false);
1720 ok(tmp === 0, "Math.sqrt(false) = " + tmp);
1721
1722 tmp = Math.sqrt();
1723 ok(isNaN(tmp), "Math.sqrt() is not NaN");
1724
1725 tmp = Math.sqrt(NaN);
1726 ok(isNaN(tmp), "Math.sqrt(NaN) is not NaN");
1727
1728 tmp = Math.sqrt(Infinity);
1729 ok(tmp === Infinity, "Math.sqrt(Infinity) = " + tmp);
1730
1731 tmp = Math.sqrt(-Infinity);
1732 ok(isNaN(tmp), "Math.sqrt(-Infinity) is not NaN");
1733
1734 tmp = Math.tan(0);
1735 ok(tmp === 0, "Math.tan(0) = " + tmp);
1736
1737 tmp = Math.tan(Math.PI);
1738 ok(Math.floor(tmp*100) === -1, "Math.tan(Math.PI) = " + tmp);
1739
1740 tmp = Math.tan(2, 2);
1741 ok(Math.floor(tmp*100) === -219, "Math.tan(2, 2) = " + tmp);
1742
1743 tmp = Math.tan(true);
1744 ok(Math.floor(tmp*100) === 155, "Math.tan(true) = " + tmp);
1745
1746 tmp = Math.tan(false);
1747 ok(tmp === 0, "Math.tan(false) = " + tmp);
1748
1749 tmp = Math.tan();
1750 ok(isNaN(tmp), "Math.tan() is not NaN");
1751
1752 tmp = Math.tan(NaN);
1753 ok(isNaN(tmp), "Math.tan(NaN) is not NaN");
1754
1755 tmp = Math.tan(Infinity);
1756 ok(isNaN(tmp), "Math.tan(Infinity) is not NaN");
1757
1758 tmp = Math.tan(-Infinity);
1759 ok(isNaN(tmp), "Math.tan(-Infinity) is not NaN");
1760
1761 var func = function  (a) {
1762         var a = 1;
1763         if(a) return;
1764     };
1765 ok(func.toString() === "function  (a) {\n        var a = 1;\n        if(a) return;\n    }",
1766    "func.toString() = " + func.toString());
1767 ok("" + func === "function  (a) {\n        var a = 1;\n        if(a) return;\n    }",
1768    "'' + func.toString() = " + func);
1769
1770 ok(func.valueOf === Object.prototype.valueOf, "func.valueOf !== Object.prototype.valueOf");
1771 ok(func === func.valueOf(), "func !== func.valueOf()");
1772
1773 function testFuncToString(x,y) {
1774     return x+y;
1775 }
1776 ok(testFuncToString.toString() === "function testFuncToString(x,y) {\n    return x+y;\n}",
1777    "testFuncToString.toString() = " + testFuncToString.toString());
1778 ok("" + testFuncToString === "function testFuncToString(x,y) {\n    return x+y;\n}",
1779    "'' + testFuncToString = " + testFuncToString);
1780
1781 tmp = new Object();
1782
1783 function callTest(argc) {
1784     ok(this === tmp, "this !== tmp\n");
1785     ok(arguments.length === argc+1, "arguments.length = " + arguments.length + " expected " + (argc+1));
1786     for(var i=1; i <= argc; i++)
1787         ok(arguments[i] === i, "arguments[i] = " + arguments[i]);
1788 }
1789
1790 callTest.call(tmp, 1, 1);
1791 callTest.call(tmp, 2, 1, 2);
1792 callTest.call(tmp, 3, 1, 2, 3);
1793
1794 callTest.apply(tmp, [1, 1]);
1795 callTest.apply(tmp, [2, 1, 2]);
1796 callTest.apply(tmp, [3, 1, 2, 3]);
1797 (function () { callTest.apply(tmp, arguments); })(2,1,2);
1798
1799 function callTest2() {
1800     ok(this === tmp, "this !== tmp\n");
1801     ok(arguments.length === 0, "callTest2: arguments.length = " + arguments.length + " expected 0");
1802 }
1803
1804 callTest2.call(tmp);
1805 callTest2.apply(tmp, []);
1806 callTest2.apply(tmp);
1807 (function () { callTest2.apply(tmp, arguments); })();
1808
1809 function callTest3() {
1810     testThis(this);
1811     ok(arguments.length === 0, "arguments.length = " + arguments.length + " expected 0");
1812 }
1813
1814 callTest3.call();
1815 callTest3.call(undefined);
1816 callTest3.call(null);
1817 callTest3.apply();
1818 callTest3.apply(undefined);
1819 callTest3.apply(null);
1820
1821 tmp = Number.prototype.toString.call(3);
1822 ok(tmp === "3", "Number.prototype.toString.call(3) = " + tmp);
1823
1824 var func = new Function("return 3;");
1825
1826 tmp = func();
1827 ok(tmp === 3, "func() = " + tmp);
1828 ok(func.call() === 3, "func.call() = " + tmp);
1829 ok(func.length === 0, "func.length = " + func.length);
1830 tmp = func.toString();
1831 ok(tmp === "function anonymous() {\nreturn 3;\n}", "func.toString() = " + tmp);
1832
1833 func = new Function("x", "return x+2;");
1834 tmp = func(1);
1835 ok(tmp === 3, "func(1) = " + tmp);
1836 tmp = func.toString();
1837 ok(tmp === "function anonymous(x) {\nreturn x+2;\n}", "func.toString() = " + tmp);
1838
1839 tmp = (new Function("x ", "return x+2;")).toString();
1840 ok(tmp === "function anonymous(x ) {\nreturn x+2;\n}", "func.toString() = " + tmp);
1841
1842 func = new Function("x", "y", "return x+y");
1843 tmp = func(1,3);
1844 ok(tmp === 4, "func(1,3) = " + tmp);
1845 tmp = func.toString();
1846 ok(tmp === "function anonymous(x, y) {\nreturn x+y\n}", "func.toString() = " + tmp);
1847
1848 func = new Function(" x, \ty", "\tz", "return x+y+z;");
1849 tmp = func(1,3,2);
1850 ok(tmp === 6, "func(1,3,2) = " + tmp);
1851 ok(func.length === 3, "func.length = " + func.length);
1852 tmp = func.toString();
1853 ok(tmp === "function anonymous( x, \ty, \tz) {\nreturn x+y+z;\n}", "func.toString() = " + tmp);
1854
1855 func = new Function();
1856 tmp = func();
1857 ok(tmp === undefined, "func() = " + tmp);
1858 tmp = func.toString();
1859 ok(tmp == "function anonymous() {\n\n}", "func.toString() = " + tmp);
1860
1861 func = (function() {
1862         var tmp = 3;
1863         return new Function("return tmp;");
1864     })();
1865 tmp = 2;
1866 tmp = func();
1867 ok(tmp === 2, "func() = " + tmp);
1868
1869 var date = new Date();
1870
1871 date = new Date(100);
1872 ok(date.getTime() === 100, "date.getTime() = " + date.getTime());
1873 ok(Date.prototype.getTime() === 0, "date.prototype.getTime() = " + Date.prototype.getTime());
1874 date = new Date(8.64e15);
1875 ok(date.getTime() === 8.64e15, "date.getTime() = " + date.getTime());
1876 date = new Date(8.64e15+1);
1877 ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
1878 date = new Date(Infinity);
1879 ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
1880 date = new Date("3 July 2009 22:28:00 UTC+0100");
1881 ok(date.getTime() === 1246656480000, "date.getTime() = " + date.getTime());
1882 date = new Date(1984, 11, 29, 13, 51, 24, 120);
1883 ok(date.getFullYear() === 1984, "date.getFullYear() = " + date.getFullYear());
1884 ok(date.getMonth() === 11, "date.getMonth() = " + date.getMonth());
1885 ok(date.getDate() === 29, "date.getDate() = " + date.getDate());
1886 ok(date.getHours() === 13, "date.getHours() = " + date.getHours());
1887 ok(date.getMinutes() === 51, "date.getMinutes() = " + date.getMinutes());
1888 ok(date.getSeconds() === 24, "date.getSeconds() = " + date.getSeconds());
1889 ok(date.getMilliseconds() === 120, "date.getMilliseconds() = " + date.getMilliseconds());
1890 date = new Date(731, -32, 40, -1, 70, 65, -13);
1891 ok(date.getFullYear() === 728, "date.getFullYear() = " + date.getFullYear());
1892 ok(date.getMonth() === 5, "date.getMonth() = " + date.getMonth());
1893 ok(date.getDate() === 9, "date.getDate() = " + date.getDate());
1894 ok(date.getHours() === 0, "date.getHours() = " + date.getHours());
1895 ok(date.getMinutes() === 11, "date.getMinutes() = " + date.getMinutes());
1896 ok(date.getSeconds() === 4, "date.getSeconds() = " + date.getSeconds());
1897 ok(date.getMilliseconds() === 987, "date.getMilliseconds() = " + date.getMilliseconds());
1898
1899 ok(date.setTime(123) === 123, "date.setTime(123) !== 123");
1900 ok(date.setTime("123", NaN) === 123, "date.setTime(\"123\") !== 123");
1901 ok(isNaN(date.setTime(NaN)), "date.setTime(NaN) is not NaN");
1902
1903 ok(date.setTime(0) === date.getTime(), "date.setTime(0) !== date.getTime()");
1904 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
1905 ok(date.getUTCMonth() === 0, "date.getUTCMonth() = " + date.getUTCMonth());
1906 ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
1907 ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
1908 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
1909 ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
1910 ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
1911 ok(date.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1912
1913 date.setTime(60*24*60*60*1000);
1914 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
1915 ok(date.getUTCMonth() === 2, "date.getUTCMonth() = " + date.getUTCMonth());
1916 ok(date.getUTCDate() === 2, "date.getUTCDate() = " + date.getUTCDate());
1917 ok(date.getUTCDay() === 1, "date.getUTCDay() = " + date.getUTCDay());
1918 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
1919 ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
1920 ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
1921 ok(date.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1922
1923 date.setTime(59*24*60*60*1000 + 4*365*24*60*60*1000 + 60*60*1000 + 2*60*1000 + 2*1000 + 640);
1924 ok(date.getUTCFullYear() === 1974, "date.getUTCFullYear() = " + date.getUTCFullYear());
1925 ok(date.getUTCMonth() === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1926 ok(date.getUTCMonth(123) === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1927 ok(date.getUTCDate() === 28, "date.getUTCDate() = " + date.getUTCDate());
1928 ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
1929 ok(date.getUTCHours() === 1, "date.getUTCHours() = " + date.getUTCHours());
1930 ok(date.getUTCMinutes() === 2, "date.getUTCMinutes() = " + date.getUTCMinutes());
1931 ok(date.getUTCSeconds() === 2, "date.getUTCSeconds() = " + date.getUTCSeconds());
1932 ok(date.getUTCMilliseconds() === 640, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1933
1934 tmp = date.setYear(96);
1935 ok(date.getYear() === 96, "date.getYear() = " + date.getYear());
1936 ok(date.getFullYear() === 1996, "date.getFullYear() = " + date.getYear());
1937 ok(date.getUTCMonth() === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1938 ok(date.getUTCMonth(123) === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1939 ok(date.getUTCMilliseconds() === 640, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1940
1941 tmp = date.setYear(2010);
1942 ok(tmp === date.getTime(), "date.setYear(2010) = " + tmp);
1943 ok(date.getYear() === 2010, "date.getYear() = " + date.getYear());
1944 ok(date.getFullYear() === 2010, "date.getFullYear() = " + date.getYear());
1945 ok(date.getUTCMonth() === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1946 ok(date.getUTCMonth(123) === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1947 ok(date.getUTCMilliseconds() === 640, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1948
1949 date.setTime(Infinity);
1950 ok(isNaN(date.getUTCFullYear()), "date.getUTCFullYear() is not NaN");
1951 ok(isNaN(date.getUTCMonth()), "date.getUTCMonth() is not NaN");
1952 ok(isNaN(date.getUTCDate()), "date.getUTCDate() is not NaN");
1953 ok(isNaN(date.getUTCDay()), "date.getUTCDay() is not NaN");
1954 ok(isNaN(date.getUTCHours()), "date.getUTCHours() is not NaN");
1955 ok(isNaN(date.getUTCMinutes()), "date.getUTCMinutes() is not NaN");
1956 ok(isNaN(date.getUTCSeconds()), "date.getUTCSeconds() is not NaN");
1957 ok(isNaN(date.getUTCMilliseconds()), "date.getUTCMilliseconds() is not NaN");
1958 ok(isNaN(date.setMilliseconds(0)), "date.setMilliseconds() is not NaN");
1959
1960 date.setTime(0);
1961 tmp = date.setYear(NaN);
1962 ok(isNaN(tmp), "date.setYear(NaN) = " + tmp);
1963 ok(isNaN(date.getUTCFullYear()), "date.getUTCFullYear() is not NaN");
1964 ok(isNaN(date.getUTCMonth()), "date.getUTCMonth() is not NaN");
1965
1966 date.setTime(0);
1967 date.setUTCMilliseconds(-10, 2);
1968 ok(date.getUTCMilliseconds() === 990, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1969 date.setUTCMilliseconds(10);
1970 ok(date.getUTCMilliseconds() === 10, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1971 date.setUTCSeconds(-10);
1972 ok(date.getUTCSeconds() === 50, "date.getUTCSeconds() = " + date.getUTCSeconds());
1973 date.setUTCMinutes(-10);
1974 ok(date.getUTCMinutes() === 50, "date.getUTCMinutes() = " + date.getUTCMinutes());
1975 date.setUTCHours(-10);
1976 ok(date.getUTCHours() === 14, "date.getUTCHours() = " + date.getUTCHours());
1977 date.setUTCHours(-123);
1978 ok(date.getTime() === -612549990, "date.getTime() = " + date.getTime());
1979 date.setUTCHours(20);
1980 ok(date.getUTCHours() === 20, "date.getUTCHours() = " + date.getUTCHours());
1981 date.setUTCDate(32);
1982 ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
1983 date.setUTCMonth(22, 37);
1984 ok(date.getTime() === 60987050010, "date.getTime() = " + date.getTime());
1985 date.setUTCFullYear(83, 21, 321);
1986 ok(date.getTime() === -59464984149990, "date.getTime() = " + date.getTime());
1987 ok(Math.abs(date) === 59464984149990, "Math.abs(date) = " + Math.abs(date));
1988 ok(getVT(date+1) === "VT_BSTR", "getVT(date+1) = " + getVT(date+1));
1989
1990 ok(isNaN(Date.parse()), "Date.parse() is not NaN");
1991 ok(isNaN(Date.parse("")), "Date.parse(\"\") is not NaN");
1992 ok(isNaN(Date.parse("Jan Jan 20 2009")), "Date.parse(\"Jan Jan 20 2009\") is not NaN");
1993 ok(Date.parse("Jan 20 2009 UTC") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC\") = " + Date.parse("Jan 20 2009 UTC"));
1994 ok(Date.parse("Jan 20 2009 GMT") === 1232409600000, "Date.parse(\"Jan 20 2009 GMT\") = " + Date.parse("Jan 20 2009 GMT"));
1995 ok(Date.parse("Jan 20 2009 UTC-0") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC-0\") = " + Date.parse("Jan 20 2009 UTC-0"));
1996 ok(Date.parse("Jan 20 2009 UTC+0000") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC+0000\") = " + Date.parse("Jan 20 2009 UTC+0000"));
1997 ok(Date.parse("Ju 13 79 UTC") === 300672000000, "Date.parse(\"Ju 13 79 UTC\") = " + Date.parse("Ju 13 79 UTC"));
1998 ok(Date.parse("12Au91 UTC") === 681955200000, "Date.parse(\"12Au91 UTC\") = " + Date.parse("12Au91 UTC"));
1999 ok(Date.parse("7/02/17 UTC") === -1656806400000, "Date.parse(\"7/02/17 UTC\") = " + Date.parse("7/02/17 UTC"));
2000 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"));
2001 ok(Date.parse("February 31   UTC, 2000 12:31:17 PM") === 952000277000,
2002         "Date.parse(\"February 31   UTC, 2000 12:31:17 PM\") = " + Date.parse("February 31   UTC, 2000 12:31:17 PM"));
2003 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 "));
2004 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"));
2005
2006 ok(typeof(Math.PI) === "number", "typeof(Math.PI) = " + typeof(Math.PI));
2007 ok(Math.floor(Math.PI*100) === 314, "Math.PI = " + Math.PI);
2008 Math.PI = "test";
2009 ok(Math.floor(Math.PI*100) === 314, "modified Math.PI = " + Math.PI);
2010
2011 ok(typeof(Math.E) === "number", "typeof(Math.E) = " + typeof(Math.E));
2012 ok(Math.floor(Math.E*100) === 271, "Math.E = " + Math.E);
2013 Math.E = "test";
2014 ok(Math.floor(Math.E*100) === 271, "modified Math.E = " + Math.E);
2015
2016 ok(typeof(Math.LOG2E) === "number", "typeof(Math.LOG2E) = " + typeof(Math.LOG2E));
2017 ok(Math.floor(Math.LOG2E*100) === 144, "Math.LOG2E = " + Math.LOG2E);
2018 Math.LOG2E = "test";
2019 ok(Math.floor(Math.LOG2E*100) === 144, "modified Math.LOG2E = " + Math.LOG2E);
2020
2021 ok(typeof(Math.LOG10E) === "number", "typeof(Math.LOG10E) = " + typeof(Math.LOG10E));
2022 ok(Math.floor(Math.LOG10E*100) === 43, "Math.LOG10E = " + Math.LOG10E);
2023 Math.LOG10E = "test";
2024 ok(Math.floor(Math.LOG10E*100) === 43, "modified Math.LOG10E = " + Math.LOG10E);
2025
2026 ok(typeof(Math.LN2) === "number", "typeof(Math.LN2) = " + typeof(Math.LN2));
2027 ok(Math.floor(Math.LN2*100) === 69, "Math.LN2 = " + Math.LN2);
2028 Math.LN2 = "test";
2029 ok(Math.floor(Math.LN2*100) === 69, "modified Math.LN2 = " + Math.LN2);
2030
2031 ok(typeof(Math.LN10) === "number", "typeof(Math.LN10) = " + typeof(Math.LN10));
2032 ok(Math.floor(Math.LN10*100) === 230, "Math.LN10 = " + Math.LN10);
2033 Math.LN10 = "test";
2034 ok(Math.floor(Math.LN10*100) === 230, "modified Math.LN10 = " + Math.LN10);
2035
2036 ok(typeof(Math.SQRT2) === "number", "typeof(Math.SQRT2) = " + typeof(Math.SQRT2));
2037 ok(Math.floor(Math.SQRT2*100) === 141, "Math.SQRT2 = " + Math.SQRT2);
2038 Math.SQRT2 = "test";
2039 ok(Math.floor(Math.SQRT2*100) === 141, "modified Math.SQRT2 = " + Math.SQRT2);
2040
2041 ok(typeof(Math.SQRT1_2) === "number", "typeof(Math.SQRT1_2) = " + typeof(Math.SQRT1_2));
2042 ok(Math.floor(Math.SQRT1_2*100) === 70, "Math.SQRT1_2 = " + Math.SQRT1_2);
2043 Math.SQRT1_2 = "test";
2044 ok(Math.floor(Math.SQRT1_2*100) === 70, "modified Math.SQRT1_2 = " + Math.SQRT1_2);
2045
2046 ok(isNaN.toString() === "\nfunction isNaN() {\n    [native code]\n}\n",
2047    "isNaN.toString = '" + isNaN.toString() + "'");
2048 ok(Array.toString() === "\nfunction Array() {\n    [native code]\n}\n",
2049    "isNaN.toString = '" + Array.toString() + "'");
2050 ok(Function.toString() === "\nfunction Function() {\n    [native code]\n}\n",
2051    "isNaN.toString = '" + Function.toString() + "'");
2052 ok(Function.prototype.toString() === "\nfunction prototype() {\n    [native code]\n}\n",
2053    "isNaN.toString = '" + Function.prototype.toString() + "'");
2054 ok("".substr.toString() === "\nfunction substr() {\n    [native code]\n}\n",
2055    "''.substr.toString = '" + "".substr.toString() + "'");
2056
2057 var bool = new Boolean();
2058 ok(bool.toString() === "false", "bool.toString() = " + bool.toString());
2059 var bool = new Boolean("false");
2060 ok(bool.toString() === "true", "bool.toString() = " + bool.toString());
2061 ok(bool.valueOf() === Boolean(1), "bool.valueOf() = " + bool.valueOf());
2062 ok(bool.toLocaleString() === bool.toString(), "bool.toLocaleString() = " + bool.toLocaleString());
2063
2064 ok(ActiveXObject instanceof Function, "ActiveXObject is not instance of Function");
2065 ok(ActiveXObject.prototype instanceof Object, "ActiveXObject.prototype is not instance of Object");
2066
2067 ok(Error.prototype !== TypeError.prototype, "Error.prototype === TypeError.prototype");
2068 ok(RangeError.prototype !== TypeError.prototype, "RangeError.prototype === TypeError.prototype");
2069 ok(Error.prototype.toLocaleString === Object.prototype.toLocaleString,
2070         "Error.prototype.toLocaleString !== Object.prototype.toLocaleString");
2071 err = new Error();
2072 ok(err.valueOf === Object.prototype.valueOf, "err.valueOf !== Object.prototype.valueOf");
2073 ok(Error.prototype.name === "Error", "Error.prototype.name = " + Error.prototype.name);
2074 ok(err.name === "Error", "err.name = " + err.name);
2075 EvalError.prototype.message = "test";
2076 ok(EvalError.prototype.message === "test", "EvalError.prototype.message = " + EvalError.prototype.message);
2077 ok(err.toString !== Object.prototype.toString, "err.toString === Object.prototype.toString");
2078 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "Error"), "err.toString() = " + err.toString());
2079 err = new EvalError();
2080 ok(EvalError.prototype.name === "EvalError", "EvalError.prototype.name = " + EvalError.prototype.name);
2081 ok(err.name === "EvalError", "err.name = " + err.name);
2082 ok(err.toString === Error.prototype.toString, "err.toString !== Error.prototype.toString");
2083 ok(err.message === "", "err.message != ''");
2084 err.message = date;
2085 ok(err.message === date, "err.message != date");
2086 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "EvalError: "+err.message),
2087    "err.toString() = " + err.toString());
2088 ok(err.toString !== Object.prototype.toString, "err.toString === Object.prototype.toString");
2089 err = new RangeError();
2090 ok(RangeError.prototype.name === "RangeError", "RangeError.prototype.name = " + RangeError.prototype.name);
2091 ok(err.name === "RangeError", "err.name = " + err.name);
2092 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "RangeError"), "err.toString() = " + err.toString());
2093 err = new ReferenceError();
2094 ok(ReferenceError.prototype.name === "ReferenceError", "ReferenceError.prototype.name = " + ReferenceError.prototype.name);
2095 ok(err.name === "ReferenceError", "err.name = " + err.name);
2096 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "ReferenceError"), "err.toString() = " + err.toString());
2097 err = new SyntaxError();
2098 ok(SyntaxError.prototype.name === "SyntaxError", "SyntaxError.prototype.name = " + SyntaxError.prototype.name);
2099 ok(err.name === "SyntaxError", "err.name = " + err.name);
2100 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "SyntaxError"), "err.toString() = " + err.toString());
2101 err = new TypeError();
2102 ok(TypeError.prototype.name === "TypeError", "TypeError.prototype.name = " + TypeError.prototype.name);
2103 ok(err.name === "TypeError", "err.name = " + err.name);
2104 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "TypeError"), "err.toString() = " + err.toString());
2105 err = new URIError();
2106 ok(URIError.prototype.name === "URIError", "URIError.prototype.name = " + URIError.prototype.name);
2107 ok(err.name === "URIError", "err.name = " + err.name);
2108 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "URIError"), "err.toString() = " + err.toString());
2109 err = new Error("message");
2110 ok(err.message === "message", "err.message !== 'message'");
2111 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "Error: message"), "err.toString() = " + err.toString());
2112 err = new Error(123);
2113 ok(err.number === 123, "err.number = " + err.number);
2114 err.number = 254;
2115 ok(err.number === 254, "err.number = " + err.number);
2116 err = new Error(0, "message");
2117 ok(err.number === 0, "err.number = " + err.number);
2118 ok(err.message === "message", "err.message = " + err.message);
2119 ok(err.description === "message", "err.description = " + err.description);
2120 err = new Error();
2121 ok(err.number === 0, "err.number = " + err.number);
2122 ok(err.description === "", "err.description = " + err.description);
2123 err.description = 5;
2124 ok(err.description === 5, "err.description = " + err.description);
2125 ok(err.message === "", "err.message = " + err.message);
2126 err.message = 4;
2127 ok(err.message === 4, "err.message = " + err.message);
2128
2129 ok(!("number" in Error), "number is in Error");
2130
2131 tmp = new Object();
2132 ok(tmp.hasOwnProperty("toString") === false, "toString property should be inherited");
2133 tmp.toString = function() { return "test"; };
2134 ok(tmp.hasOwnProperty("toString") === true, "toString own property should exist");
2135 ok(tmp.hasOwnProperty("nonExisting") === false, "nonExisting property should not exist");
2136
2137 tmp = Error.prototype.toString.call(tmp);
2138 ok(tmp === "[object Error]", "Error.prototype.toString.call(tmp) = " + tmp);
2139
2140 tmp = function() { return 0; };
2141 tmp[0] = true;
2142 ok(tmp.hasOwnProperty("toString") === false, "toString property should be inherited");
2143 ok(tmp.hasOwnProperty("0") === true, "hasOwnProperty(0) returned false");
2144 ok(tmp.hasOwnProperty() === false, "hasOwnProperty() returned true");
2145
2146 ok(Object.prototype.hasOwnProperty.call(testObj) === false, "hasOwnProperty without name returned true");
2147
2148 if(invokeVersion >= 2) {
2149     obj = new Object();
2150     obj.name = "test";
2151     tmp = Error.prototype.toString.call(obj);
2152     ok(tmp === "test", "Error.prototype.toString.call(obj) = " + tmp);
2153
2154     obj = new Object();
2155     obj.name = 6;
2156     obj.message = false;
2157     tmp = Error.prototype.toString.call(obj);
2158     ok(tmp === "6: false", "Error.prototype.toString.call(obj) = " + tmp);
2159
2160     obj = new Object();
2161     obj.message = "test";
2162     tmp = Error.prototype.toString.call(obj);
2163     ok(tmp === "test", "Error.prototype.toString.call(obj) = " + tmp);
2164
2165     obj = new Object();
2166     obj.name = "";
2167     obj.message = "test";
2168     tmp = Error.prototype.toString.call(obj);
2169     ok(tmp === "test", "Error.prototype.toString.call(obj) = " + tmp);
2170 }
2171
2172 tmp = Error.prototype.toString.call(testObj);
2173 ok(tmp === "[object Error]", "Error.prototype.toString.call(testObj) = " + tmp);
2174
2175 err = new Error();
2176 err.name = null;
2177 ok(err.name === null, "err.name = " + err.name + " expected null");
2178 if(invokeVersion >= 2)
2179     ok(err.toString() === "null", "err.toString() = " + err.toString());
2180
2181 err = new Error();
2182 err.message = false;
2183 ok(err.message === false, "err.message = " + err.message + " expected false");
2184 if(invokeVersion >= 2)
2185     ok(err.toString() === "Error: false", "err.toString() = " + err.toString());
2186
2187 err = new Error();
2188 err.message = new Object();
2189 err.message.toString = function() { return ""; };
2190 if(invokeVersion >= 2)
2191     ok(err.toString() === "Error", "err.toString() = " + err.toString());
2192
2193 err = new Error();
2194 err.message = undefined;
2195 if(invokeVersion >= 2)
2196     ok(err.toString() === "Error", "err.toString() = " + err.toString());
2197
2198 var exception_array = {
2199     E_INVALID_LENGTH:  { type: "RangeError",  number: -2146823259 },
2200
2201     E_NOT_DATE:            { type: "TypeError",   number: -2146823282 },
2202     E_NOT_BOOL:            { type: "TypeError",   number: -2146823278 },
2203     E_ARG_NOT_OPT:         { type: "TypeError",   number: -2146827839 },
2204     E_NO_PROPERTY:         { type: "TypeError",   number: -2146827850 },
2205     E_NOT_NUM:             { type: "TypeError",   number: -2146823287 },
2206     E_INVALID_CALL_ARG:    { type: "TypeError",   number: -2146828283 },
2207     E_NOT_FUNC:            { type: "TypeError",   number: -2146823286 },
2208     E_OBJECT_EXPECTED:     { type: "TypeError", number: -2146823281 },
2209     E_OBJECT_REQUIRED:     { type: "TypeError", number: -2146827864 },
2210     E_UNSUPPORTED_ACTION:  { type: "TypeError", number: -2146827843 },
2211     E_NOT_VBARRAY:         { type: "TypeError", number: -2146823275 },
2212     E_INVALID_DELETE:      { type: "TypeError", number: -2146823276 },
2213     E_UNDEFINED:           { type: "TypeError", number: -2146823279 },
2214     E_JSCRIPT_EXPECTED:    { type: "TypeError", number: -2146823274 },
2215     E_NOT_ARRAY:           { type: "TypeError", number: -2146823257 },
2216
2217     E_SYNTAX_ERROR:      { type: "SyntaxError",  number: -2146827286 },
2218     E_LBRACKET:          { type: "SyntaxError",  number: -2146827283 },
2219     E_RBRACKET:          { type: "SyntaxError",  number: -2146827282 },
2220     E_SEMICOLON:         { type: "SyntaxError",  number: -2146827284 },
2221     E_UNTERMINATED_STR:  { type: "SyntaxError",  number: -2146827273 },
2222     E_DISABLED_CC:       { type: "SyntaxError",  number: -2146827258 },
2223     E_INVALID_BREAK:     { type: "SyntaxError",  number: -2146827269 },
2224     E_INVALID_CONTINUE:  { type: "SyntaxError",  number: -2146827268 },
2225     E_LABEL_NOT_FOUND:   { type: "SyntaxError",  number: -2146827262 },
2226     E_LABEL_REDEFINED:   { type: "SyntaxError",  number: -2146827263 },
2227
2228     E_ILLEGAL_ASSIGN:  { type: "ReferenceError", number: -2146823280 },
2229
2230     E_PRECISION_OUT_OF_RANGE:        {type: "RangeError", number: -2146823261 },
2231     E_FRACTION_DIGITS_OUT_OF_RANGE:  {type: "RangeError", number: -2146823262 },
2232     E_SUBSCRIPT_OUT_OF_RANGE:        {type: "RangeError", number: -2146828279 },
2233
2234     E_REGEXP_SYNTAX_ERROR:  { type: "RegExpError", number: -2146823271 },
2235
2236     E_URI_INVALID_CHAR:     { type: "URIError", number: -2146823264 },
2237     E_URI_INVALID_CODING:   { type: "URIError", number: -2146823263 }
2238 };
2239
2240 function testException(func, id) {
2241     var ex = exception_array[id];
2242     var ret = "", num = "";
2243
2244     try {
2245         func();
2246     } catch(e) {
2247         ret = e.name;
2248         num = e.number;
2249     }
2250
2251     ok(ret === ex.type, "Exception test, ret = " + ret + ", expected " + ex.type +". Executed function: " + func.toString());
2252     ok(num === ex.number, "Exception test, num = " + num + ", expected " + ex.number + ". Executed function: " + func.toString());
2253 }
2254
2255 // RangeError tests
2256 testException(function() {Array(-3);}, "E_INVALID_LENGTH");
2257 testException(function() {createArray().lbound("aaa");}, "E_SUBSCRIPT_OUT_OF_RANGE");
2258 testException(function() {createArray().lbound(3);}, "E_SUBSCRIPT_OUT_OF_RANGE");
2259 testException(function() {createArray().getItem(3);}, "E_SUBSCRIPT_OUT_OF_RANGE");
2260
2261 // TypeError tests
2262 testException(function() {date.setTime();}, "E_ARG_NOT_OPT");
2263 testException(function() {date.setYear();}, "E_ARG_NOT_OPT");
2264 testException(function() {arr.test();}, "E_NO_PROPERTY");
2265 testException(function() {Number.prototype.toString.call(arr);}, "E_NOT_NUM");
2266 testException(function() {Number.prototype.toFixed.call(arr);}, "E_NOT_NUM");
2267 testException(function() {(new Number(3)).toString(1);}, "E_INVALID_CALL_ARG");
2268 testException(function() {(new Number(3)).toFixed(21);}, "E_FRACTION_DIGITS_OUT_OF_RANGE");
2269 testException(function() {(new Number(1)).toPrecision(0);}, "E_PRECISION_OUT_OF_RANGE");
2270 testException(function() {not_existing_variable.something();}, "E_UNDEFINED");
2271 testException(function() {date();}, "E_NOT_FUNC");
2272 testException(function() {arr();}, "E_NOT_FUNC");
2273 testException(function() {(new Object) instanceof (new Object);}, "E_NOT_FUNC");
2274 testException(function() {eval("nonexistingfunc()")}, "E_OBJECT_EXPECTED");
2275 testException(function() {(new Object()) instanceof 3;}, "E_NOT_FUNC");
2276 testException(function() {(new Object()) instanceof null;}, "E_NOT_FUNC");
2277 testException(function() {(new Object()) instanceof nullDisp;}, "E_NOT_FUNC");
2278 testException(function() {"test" in 3;}, "E_OBJECT_EXPECTED");
2279 testException(function() {"test" in null;}, "E_OBJECT_EXPECTED");
2280 testException(function() {"test" in nullDisp;}, "E_OBJECT_EXPECTED");
2281 testException(function() {new 3;}, "E_UNSUPPORTED_ACTION");
2282 testException(function() {new null;}, "E_OBJECT_EXPECTED");
2283 testException(function() {new nullDisp;}, "E_NO_PROPERTY");
2284 testException(function() {new VBArray();}, "E_NOT_VBARRAY");
2285 testException(function() {new VBArray(new VBArray(createArray()));}, "E_NOT_VBARRAY");
2286 testException(function() {VBArray.prototype.lbound.call(new Object());}, "E_NOT_VBARRAY");
2287 testException(function() {+nullDisp.prop;}, "E_OBJECT_REQUIRED");
2288 testException(function() {+nullDisp["prop"];}, "E_OBJECT_REQUIRED");
2289 testException(function() {delete (new Object());}, "E_INVALID_DELETE");
2290 testException(function() {delete false;}, "E_INVALID_DELETE");
2291
2292 obj = new Object();
2293 obj.prop = 1;
2294 tmp = false;
2295 testException(function() {delete ((tmp = true) ? obj.prop : obj.prop);}, "E_INVALID_DELETE");
2296 ok(tmp, "delete (..) expression not evaluated");
2297
2298 //FIXME: testException(function() {nonexistent++;}, "E_OBJECT_EXPECTED");
2299 //FIXME: testException(function() {undefined.nonexistent++;}, "E_OBJECT_EXPECTED");
2300
2301
2302 // SyntaxError tests
2303 function testSyntaxError(code, id) {
2304     var ex = exception_array[id];
2305     var ret = "", num = "";
2306
2307     try {
2308         eval(code);
2309     } catch(e) {
2310         ret = e.name;
2311         num = e.number;
2312     }
2313
2314     ok(ret === ex.type, "Syntax exception test, ret = " + ret + ", expected " + ex.type +". Executed code: " + code);
2315     ok(num === ex.number, "Syntax exception test, num = " + num + ", expected " + ex.number + ". Executed code: " + code);
2316 }
2317
2318 testSyntaxError("for(i=0;) {}", "E_SYNTAX_ERROR");
2319 testSyntaxError("function {};", "E_LBRACKET");
2320 testSyntaxError("if", "E_LBRACKET");
2321 testSyntaxError("do i=0; while", "E_LBRACKET");
2322 testSyntaxError("while", "E_LBRACKET");
2323 testSyntaxError("for", "E_LBRACKET");
2324 testSyntaxError("with", "E_LBRACKET");
2325 testSyntaxError("switch", "E_LBRACKET");
2326 testSyntaxError("if(false", "E_RBRACKET");
2327 testSyntaxError("for(i=0; i<10; i++", "E_RBRACKET");
2328 testSyntaxError("while(true", "E_RBRACKET");
2329 testSyntaxError("for(i=0", "E_SEMICOLON");
2330 testSyntaxError("for(i=0;i<10", "E_SEMICOLON");
2331 testSyntaxError("while(", "E_SYNTAX_ERROR");
2332 testSyntaxError("if(", "E_SYNTAX_ERROR");
2333 testSyntaxError("'unterminated", "E_UNTERMINATED_STR");
2334 testSyntaxError("*", "E_SYNTAX_ERROR");
2335 testSyntaxError("@_jscript_version", "E_DISABLED_CC");
2336 testSyntaxError("@a", "E_DISABLED_CC");
2337 testSyntaxError("/* @cc_on @*/ @_jscript_version", "E_DISABLED_CC");
2338 testSyntaxError("ok(false, 'unexpected execution'); break;", "E_INVALID_BREAK");
2339 testSyntaxError("ok(false, 'unexpected execution'); continue;", "E_INVALID_CONTINUE");
2340 testSyntaxError("ok(false, 'unexpected execution'); while(true) break unknown_label;", "E_LABEL_NOT_FOUND");
2341 testSyntaxError("ok(false, 'unexpected execution'); some_label: continue some_label;", "E_INVALID_CONTINUE");
2342 testSyntaxError("ok(false, 'unexpected execution'); while(true) continue some_label;", "E_LABEL_NOT_FOUND");
2343 testSyntaxError("ok(false, 'unexpected execution'); some_label: { while(true) continue some_label; }", "E_INVALID_CONTINUE");
2344 testSyntaxError("ok(false, 'unexpected execution'); some_label: { some_label: while(true); }", "E_LABEL_REDEFINED");
2345
2346 // ReferenceError tests
2347 testException(function() {test = function() {}}, "E_ILLEGAL_ASSIGN");
2348
2349 tmp = false;
2350 testException(function() {test = (tmp = true);}, "E_ILLEGAL_ASSIGN");
2351 ok(tmp, "expr value on invalid assign not evaluated");
2352
2353 tmp = false;
2354 testException(function() {(tmp = true) = false;}, "E_ILLEGAL_ASSIGN");
2355 ok(tmp, "expr assign not evaluated");
2356
2357 tmp = false;
2358 testException(function() {true = (tmp = true);}, "E_ILLEGAL_ASSIGN");
2359 ok(tmp, "expr value assign not evaluated");
2360
2361 tmp = "";
2362 testException(function() {(tmp = tmp+"1") = (tmp = tmp+"2");}, "E_ILLEGAL_ASSIGN");
2363 ok(tmp === "12", "assign evaluated in unexpected order");
2364
2365 tmp = false;
2366 testException(function() { ((tmp = true) && false)++; }, "E_ILLEGAL_ASSIGN")
2367 ok(tmp, "incremented expression not evaluated");
2368
2369 // RegExpError tests
2370 testException(function() {RegExp(/a/, "g");}, "E_REGEXP_SYNTAX_ERROR");
2371
2372 // URIError tests
2373 testException(function() {encodeURI('\udcaa');}, "E_URI_INVALID_CHAR");
2374 testException(function() {encodeURIComponent('\udcaa');}, "E_URI_INVALID_CHAR");
2375 testException(function() {decodeURI('%');}, "E_URI_INVALID_CODING");
2376 testException(function() {decodeURI('%aaaa');}, "E_URI_INVALID_CODING");
2377
2378 function testThisExcept(func, e) {
2379     testException(function() {func.call(new Object())}, e);
2380 }
2381
2382 function testBoolThis(func) {
2383     testThisExcept(Boolean.prototype[func], "E_NOT_BOOL");
2384 }
2385
2386 testBoolThis("toString");
2387 testBoolThis("valueOf");
2388
2389 function testDateThis(func) {
2390     testThisExcept(Date.prototype[func], "E_NOT_DATE");
2391 }
2392
2393 testDateThis("getDate");
2394 testDateThis("getDay");
2395 testDateThis("getFullYear");
2396 testDateThis("getHours");
2397 testDateThis("getMilliseconds");
2398 testDateThis("getMinutes");
2399 testDateThis("getMonth");
2400 testDateThis("getSeconds");
2401 testDateThis("getTime");
2402 testDateThis("getTimezoneOffset");
2403 testDateThis("getUTCDate");
2404 testDateThis("getUTCDay");
2405 testDateThis("getUTCFullYear");
2406 testDateThis("getUTCHours");
2407 testDateThis("getUTCMilliseconds");
2408 testDateThis("getUTCMinutes");
2409 testDateThis("getUTCMonth");
2410 testDateThis("getUTCSeconds");
2411 testDateThis("getYear");
2412 testDateThis("setDate");
2413 testDateThis("setFullYear");
2414 testDateThis("setHours");
2415 testDateThis("setMilliseconds");
2416 testDateThis("setMinutes");
2417 testDateThis("setMonth");
2418 testDateThis("setSeconds");
2419 testDateThis("setTime");
2420 testDateThis("setUTCDate");
2421 testDateThis("setUTCFullYear");
2422 testDateThis("setUTCHours");
2423 testDateThis("setUTCMilliseconds");
2424 testDateThis("setUTCMinutes");
2425 testDateThis("setUTCMonth");
2426 testDateThis("setUTCSeconds");
2427 testDateThis("setYear");
2428 testDateThis("toDateString");
2429 testDateThis("toLocaleDateString");
2430 testDateThis("toLocaleString");
2431 testDateThis("toLocaleTimeString");
2432 testDateThis("toString");
2433 testDateThis("toTimeString");
2434 testDateThis("toUTCString");
2435 testDateThis("valueOf");
2436
2437 function testArrayThis(func) {
2438     testThisExcept(Array.prototype[func], "E_NOT_ARRAY");
2439 }
2440
2441 testArrayThis("toString");
2442
2443 function testFunctionThis(func) {
2444     testThisExcept(Function.prototype[func], "E_NOT_FUNC");
2445 }
2446
2447 testFunctionThis("toString");
2448 testFunctionThis("call");
2449 testFunctionThis("apply");
2450
2451 function testArrayHostThis(func) {
2452     testException(function() { Array.prototype[func].call(testObj); }, "E_JSCRIPT_EXPECTED");
2453 }
2454
2455 testArrayHostThis("push");
2456 testArrayHostThis("shift");
2457 testArrayHostThis("slice");
2458 testArrayHostThis("splice");
2459 testArrayHostThis("unshift");
2460 testArrayHostThis("reverse");
2461 testArrayHostThis("join");
2462 testArrayHostThis("pop");
2463 testArrayHostThis("sort");
2464
2465 function testObjectInherit(obj, constr, ts, tls, vo) {
2466     ok(obj instanceof Object, "obj is not instance of Object");
2467     ok(obj instanceof constr, "obj is not instance of its constructor");
2468
2469     ok(obj.hasOwnProperty === Object.prototype.hasOwnProperty,
2470        "obj.hasOwnProperty !== Object.prototype.hasOwnProprty");
2471     ok(obj.isPrototypeOf === Object.prototype.isPrototypeOf,
2472        "obj.isPrototypeOf !== Object.prototype.isPrototypeOf");
2473     ok(obj.propertyIsEnumerable === Object.prototype.propertyIsEnumerable,
2474        "obj.propertyIsEnumerable !== Object.prototype.propertyIsEnumerable");
2475
2476     if(ts)
2477         ok(obj.toString === Object.prototype.toString,
2478            "obj.toString !== Object.prototype.toString");
2479     else
2480         ok(obj.toString != Object.prototype.toString,
2481            "obj.toString == Object.prototype.toString");
2482
2483     if(tls)
2484         ok(obj.toLocaleString === Object.prototype.toLocaleString,
2485            "obj.toLocaleString !== Object.prototype.toLocaleString");
2486     else
2487         ok(obj.toLocaleString != Object.prototype.toLocaleString,
2488            "obj.toLocaleString == Object.prototype.toLocaleString");
2489
2490     if(vo)
2491         ok(obj.valueOf === Object.prototype.valueOf,
2492            "obj.valueOf !== Object.prototype.valueOf");
2493     else
2494         ok(obj.valueOf != Object.prototype.valueOf,
2495            "obj.valueOf == Object.prototype.valueOf");
2496
2497     ok(obj._test === "test", "obj.test = " + obj._test);
2498 }
2499
2500 Object.prototype._test = "test";
2501 testObjectInherit(new String("test"), String, false, true, false);
2502 testObjectInherit(/test/g, RegExp, false, true, true);
2503 testObjectInherit(new Number(1), Number, false, false, false);
2504 testObjectInherit(new Date(), Date, false, false, false);
2505 testObjectInherit(new Boolean(true), Boolean, false, true, false);
2506 testObjectInherit(new Array(), Array, false, false, true);
2507 testObjectInherit(new Error(), Error, false, true, true);
2508 testObjectInherit(testObjectInherit, Function, false, true, true);
2509 testObjectInherit(Math, Object, true, true, true);
2510
2511 (function() { testObjectInherit(arguments, Object, true, true, true); })();
2512
2513 function testFunctions(obj, arr) {
2514     var l;
2515
2516     for(var i=0; i<arr.length; i++) {
2517         l = obj[arr[i][0]].length;
2518         ok(l === arr[i][1], arr[i][0] + ".length = " + l);
2519
2520         ok(obj.propertyIsEnumerable(arr[i][0]) === false, arr[i][0] + " is enumerable");
2521     }
2522 }
2523
2524 testFunctions(Boolean.prototype, [
2525         ["valueOf", 0],
2526         ["toString", 0]
2527     ]);
2528
2529 testFunctions(Number.prototype, [
2530         ["valueOf", 0],
2531         ["toString", 1],
2532         ["toExponential", 1],
2533         ["toLocaleString", 0],
2534         ["toPrecision", 1]
2535     ]);
2536
2537 testFunctions(String.prototype, [
2538         ["valueOf", 0],
2539         ["toString", 0],
2540         ["anchor", 1],
2541         ["big", 0],
2542         ["blink", 0],
2543         ["bold", 0],
2544         ["charAt", 1],
2545         ["charCodeAt", 1],
2546         ["concat", 1],
2547         ["fixed", 0],
2548         ["fontcolor", 1],
2549         ["fontsize", 1],
2550         ["indexOf", 2],
2551         ["italics", 0],
2552         ["lastIndexOf", 2],
2553         ["link", 1],
2554         ["localeCompare", 1],
2555         ["match", 1],
2556         ["replace", 1],
2557         ["search", 0],
2558         ["slice", 0],
2559         ["small", 0],
2560         ["split", 2],
2561         ["strike", 0],
2562         ["sub", 0],
2563         ["substr", 2],
2564         ["substring", 2],
2565         ["sup", 0],
2566         ["toLocaleLowerCase", 0],
2567         ["toLocaleUpperCase", 0],
2568         ["toLowerCase", 0],
2569         ["toUpperCase", 0]
2570     ]);
2571
2572 testFunctions(RegExp.prototype, [
2573         ["toString", 0],
2574         ["exec", 1],
2575         ["test", 1]
2576     ]);
2577
2578 testFunctions(Date.prototype, [
2579         ["getDate", 0],
2580         ["getDay", 0],
2581         ["getFullYear", 0],
2582         ["getHours", 0],
2583         ["getMilliseconds", 0],
2584         ["getMinutes", 0],
2585         ["getMonth", 0],
2586         ["getSeconds", 0],
2587         ["getTime", 0],
2588         ["getTimezoneOffset", 0],
2589         ["getUTCDate", 0],
2590         ["getUTCDay", 0],
2591         ["getUTCFullYear", 0],
2592         ["getUTCHours", 0],
2593         ["getUTCMilliseconds", 0],
2594         ["getUTCMinutes", 0],
2595         ["getUTCMonth", 0],
2596         ["getUTCSeconds", 0],
2597         ["getYear", 0],
2598         ["setDate", 1],
2599         ["setFullYear", 3],
2600         ["setHours", 4],
2601         ["setMilliseconds", 1],
2602         ["setMinutes", 3],
2603         ["setMonth", 2],
2604         ["setSeconds", 2],
2605         ["setTime", 1],
2606         ["setUTCDate", 1],
2607         ["setUTCFullYear", 3],
2608         ["setUTCHours", 4],
2609         ["setUTCMilliseconds", 1],
2610         ["setUTCMinutes", 3],
2611         ["setUTCMonth", 2],
2612         ["setUTCSeconds", 2],
2613         ["setYear", 1],
2614         ["toDateString", 0],
2615         ["toLocaleDateString", 0],
2616         ["toLocaleString", 0],
2617         ["toLocaleTimeString", 0],
2618         ["toString", 0],
2619         ["toTimeString", 0],
2620         ["toUTCString", 0],
2621         ["toGMTString", 0],
2622         ["valueOf", 0]
2623     ]);
2624
2625 testFunctions(Array.prototype, [
2626         ["concat", 1],
2627         ["join", 1],
2628         ["push", 1],
2629         ["pop", 0],
2630         ["reverse", 0],
2631         ["shift", 0],
2632         ["slice", 2],
2633         ["sort", 1],
2634         ["splice", 2],
2635         ["toLocaleString", 0],
2636         ["toString", 0],
2637         ["unshift", 1]
2638     ]);
2639
2640 testFunctions(Error.prototype, [
2641         ["toString", 0]
2642     ]);
2643
2644 testFunctions(Math, [
2645         ["abs", 1],
2646         ["acos", 1],
2647         ["asin", 1],
2648         ["atan", 1],
2649         ["atan2", 2],
2650         ["ceil", 1],
2651         ["cos", 1],
2652         ["exp", 1],
2653         ["floor", 1],
2654         ["log", 1],
2655         ["max", 2],
2656         ["min", 2],
2657         ["pow", 2],
2658         ["random", 0],
2659         ["round", 1],
2660         ["sin", 1],
2661         ["sqrt", 1],
2662         ["tan", 1]
2663     ]);
2664
2665 testFunctions(Object.prototype, [
2666         ["hasOwnProperty", 1],
2667         ["isPrototypeOf", 1],
2668         ["propertyIsEnumerable", 1],
2669         ["toLocaleString", 0],
2670         ["toString", 0],
2671         ["valueOf", 0]
2672     ]);
2673
2674 testFunctions(Function.prototype, [
2675         ["apply", 2],
2676         ["call", 1],
2677         ["toString", 0]
2678     ]);
2679
2680 testFunctions(VBArray.prototype, [
2681         ["dimensions", 0],
2682         ["getItem", 1],
2683         ["lbound", 0],
2684         ["toArray", 0],
2685         ["ubound", 0]
2686     ]);
2687
2688 ok(ActiveXObject.length == 1, "ActiveXObject.length = " + ActiveXObject.length);
2689 ok(Array.length == 1, "Array.length = " + Array.length);
2690 ok(Boolean.length == 1, "Boolean.length = " + Boolean.length);
2691 ok(CollectGarbage.length == 0, "CollectGarbage.length = " + CollectGarbage.length);
2692 ok(Date.length == 7, "Date.length = " + Date.length);
2693 ok(Enumerator.length == 7, "Enumerator.length = " + Enumerator.length);
2694 ok(Error.length == 1, "Error.length = " + Error.length);
2695 ok(EvalError.length == 1, "EvalError.length = " + EvalError.length);
2696 ok(RegExpError.length == 1, "RegExpError.length = " + RegExpError.length);
2697 ok(Function.length == 1, "Function.length = " + Function.length);
2698 ok(GetObject.length == 2, "GetObject.length = " + GetObject.length);
2699 ok(Number.length == 1, "Number.length = " + Number.length);
2700 ok(Object.length == 0, "Object.length = " + Object.length);
2701 ok(RangeError.length == 1, "RangeError.length = " + RangeError.length);
2702 ok(ReferenceError.length == 1, "ReferenceError.length = " + ReferenceError.length);
2703 ok(RegExp.length == 2, "RegExp.length = " + RegExp.length);
2704 ok(ScriptEngine.length == 0, "ScriptEngine.length = " + ScriptEngine.length);
2705 ok(ScriptEngineBuildVersion.length == 0,
2706     "ScriptEngineBuildVersion.length = " + ScriptEngineBuildVersion.length);
2707 ok(ScriptEngineMajorVersion.length == 0,
2708     "ScriptEngineMajorVersion.length = " + ScriptEngineMajorVersion.length);
2709 ok(ScriptEngineMinorVersion.length == 0,
2710     "ScriptEngineMinorVersion.length = " + ScriptEngineMinorVersion.length);
2711 ok(String.length == 1, "String.length = " + String.length);
2712 ok(SyntaxError.length == 1, "SyntaxError.length = " + SyntaxError.length);
2713 ok(TypeError.length == 1, "TypeError.length = " + TypeError.length);
2714 ok(URIError.length == 1, "URIError.length = " + URIError.length);
2715 ok(VBArray.length == 1, "VBArray.length = " + VBArray.length);
2716 ok(decodeURI.length == 1, "decodeURI.length = " + decodeURI.length);
2717 ok(decodeURIComponent.length == 1, "decodeURIComponent.length = " + decodeURIComponent.length);
2718 ok(encodeURI.length == 1, "encodeURI.length = " + encodeURI.length);
2719 ok(encodeURIComponent.length == 1, "encodeURIComponent.length = " + encodeURIComponent.length);
2720 ok(escape.length == 1, "escape.length = " + escape.length);
2721 ok(eval.length == 1, "eval.length = " + eval.length);
2722 ok(isFinite.length == 1, "isFinite.length = " + isFinite.length);
2723 ok(isNaN.length == 1, "isNaN.length = " + isNaN.length);
2724 ok(parseFloat.length == 1, "parseFloat.length = " + parseFloat.length);
2725 ok(parseInt.length == 2, "parseInt.length = " + parseInt.length);
2726 ok(unescape.length == 1, "unescape.length = " + unescape.length);
2727
2728 String.length = 3;
2729 ok(String.length == 1, "String.length = " + String.length);
2730
2731 var tmp = createArray();
2732 ok(getVT(tmp) == "VT_ARRAY|VT_VARIANT", "getVT(createArray()) = " + getVT(tmp));
2733 ok(getVT(VBArray(tmp)) == "VT_ARRAY|VT_VARIANT", "getVT(VBArray(tmp)) = " + getVT(VBArray(tmp)));
2734 tmp = new VBArray(tmp);
2735 tmp = new VBArray(VBArray(createArray()));
2736 ok(tmp.dimensions() == 2, "tmp.dimensions() = " + tmp.dimensions());
2737 ok(tmp.lbound() == 0, "tmp.lbound() = " + tmp.lbound());
2738 ok(tmp.lbound(1) == 0, "tmp.lbound(1) = " + tmp.lbound(1));
2739 ok(tmp.lbound(2, 1) == 2, "tmp.lbound(2, 1) = " + tmp.lbound(2, 1));
2740 ok(tmp.ubound() == 4, "tmp.ubound() = " + tmp.ubound());
2741 ok(tmp.ubound("2") == 3, "tmp.ubound(\"2\") = " + tmp.ubound("2"));
2742 ok(tmp.getItem(1, 2) == 3, "tmp.getItem(1, 2) = " + tmp.getItem(1, 2));
2743 ok(tmp.getItem(2, 3) == 33, "tmp.getItem(2, 3) = " + tmp.getItem(2, 3));
2744 ok(tmp.getItem(3, 2) == 13, "tmp.getItem(3, 2) = " + tmp.getItem(3, 2));
2745 ok(tmp.toArray() == "2,3,12,13,22,23,32,33,42,43", "tmp.toArray() = " + tmp.toArray());
2746 ok(createArray().toArray() == "2,3,12,13,22,23,32,33,42,43",
2747         "createArray.toArray()=" + createArray().toArray());
2748
2749 reportSuccess();