2 * Copyright 2008 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 var bigInt = Math.pow(2,40);
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)");
29 function testNoEnumerables(expr) {
31 ok(false, expr + " has property " + iter);
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 testNoEnumerables("new Enumerator()");
62 testNoEnumerables("Enumerator()");
64 ok(Object.propertyIsEnumerable("prototype") === false, "Object.prototype is enumerable");
65 ok(Math.propertyIsEnumerable("E") === false, "Math.E is enumerable");
66 ok(Math.propertyIsEnumerable("SQRT2") === false, "Math.SQRT2 is enumerable");
67 ok(Math.propertyIsEnumerable("PI") === false, "Math.PI is enumerable");
68 ok("test".propertyIsEnumerable("length") === false, "'test'.length is enumerable");
69 ok([1].propertyIsEnumerable("length") === false, "[1].length is enumerable");
70 ok((new TypeError()).propertyIsEnumerable("message") === true, "(new TypeError()).message is not enumerable");
71 ok((new TypeError()).propertyIsEnumerable("description") === false, "(new TypeError()).description is enumerable");
72 ok((new TypeError()).propertyIsEnumerable("name") === false, "(new TypeError()).name is enumerable");
73 ok((new TypeError()).propertyIsEnumerable("number") === false, "(new TypeError()).number is enumerable");
74 ok(Object.propertyIsEnumerable.propertyIsEnumerable("length") === false, "Object.propertyIsEnumerable.length is enumerable");
78 ok(tmp.propertyIsEnumerable("test"), "tmp.test is not enumerable");
81 ok(tmp.propertyIsEnumerable("test"), "tmp.test is not enumerable");
83 ok([1].concat([2]).propertyIsEnumerable("1"), "[1].concat([2]).1 is not enumerable");
84 ok("t.e.s.t".split(".").propertyIsEnumerable("0"), "'test'.split().0 is not enumerable");
87 ok(arguments.propertyIsEnumerable("0") === false, "arguments.0 is enumerable");
88 ok(arguments.propertyIsEnumerable("length") === false, "arguments.length is enumerable");
89 ok(arguments.propertyIsEnumerable("calee") === false, "arguments.calee is enumerable");
94 ok(tmp.propertyIsEnumerable("1"), "[1].push() ... 1 is not enumerable");
96 ok([1,2].reverse().propertyIsEnumerable("1"), "[1,2].rverse().1 is not enumerable");
97 ok([1,2].propertyIsEnumerable("0"), "[1,2].0 is not enumerable");
100 ok(i === 0, "parseInt('0') = " + i);
102 ok(i === 123, "parseInt('123') = " + i);
103 i = parseInt("-123");
104 ok(i === -123, "parseInt('-123') = " + i);
105 i = parseInt("0xff");
106 ok(i === 0xff, "parseInt('0xff') = " + i);
107 i = parseInt("11", 8);
108 ok(i === 9, "parseInt('11', 8) = " + i);
109 i = parseInt("1j", 22);
110 ok(i === 41, "parseInt('1j', 32) = " + i);
111 i = parseInt("123", 0);
112 ok(i === 123, "parseInt('123', 0) = " + i);
113 i = parseInt("123", 10, "test");
114 ok(i === 123, "parseInt('123', 10, 'test') = " + i);
115 i = parseInt("11", "8");
116 ok(i === 9, "parseInt('11', '8') = " + i);
118 ok(i === 8, "parseInt('010') = " + i);
120 ok(isNaN(i), "parseInt('') = " + i);
122 ok(isNaN(i), "parseInt('0x') = " + i);
124 ok(isNaN(i), "parseInt('+') = " + i);
126 ok(isNaN(i), "parseInt('-') = " + i);
127 i = parseInt("0x10", 11);
128 ok(i === 0, "parseInt('0x10', 11) = " + i);
129 i = parseInt("010", 7);
130 ok(i === 7, "parseInt('010', 7) = " + i);
131 i = parseInt("123abc");
132 ok(i === 123, "parseInt('123abc') = " + i);
133 i = parseInt(" \t123abc");
134 ok(i === 123, "parseInt(' \\t123abc') = " + i);
136 ok(isNaN(i), "parseInt('123abc') = " + i);
137 i = parseInt("-12", 11);
138 ok(i === -13, "parseInt('-12') = " + i);
139 i = parseInt("-0x10");
140 ok(i === -16, "parseInt('-0x10') = " + i);
141 i = parseInt("-010");
142 ok(i === -8, "parseInt('-010') = " + i);
143 i = parseInt("123", 0);
144 ok(i === 123, "parseInt('123', 0) = " + i);
145 i = parseInt("0x10", 0);
146 ok(i === 16, "parseInt('123', 0) = " + i);
147 i = parseInt("0x10", 10);
148 ok(i === 0, "parseInt('0x10', 10) = " + i);
150 ok(isNaN(i), "parseInt('0xz') = " + i);
151 i = parseInt("1", 1);
152 ok(isNaN(i), "parseInt('1', 1) = " + i);
153 i = parseInt("1", -1);
154 ok(isNaN(i), "parseInt('1', -1) = " + i);
155 i = parseInt("1", 37);
156 ok(isNaN(i), "parseInt('1', 37) = " + i);
157 i = parseInt("1", 36);
158 ok(i === 1, "parseInt('1', 36) = " + i);
159 i = parseInt("0x1f", 16);
160 ok(i === 31, "parseInt('0xf', 16) = " + i);
161 i = parseInt("0x", 16);
162 ok(isNaN(i), "parseInt('0x', 16) = " + i);
163 i = parseInt("0x1f", 17);
164 ok(i === 0, "parseInt('0xf', 16) = " + i);
166 tmp = encodeURI("abc");
167 ok(tmp === "abc", "encodeURI('abc') = " + tmp);
168 tmp = encodeURI("{abc}");
169 ok(tmp === "%7Babc%7D", "encodeURI('{abc}') = " + tmp);
171 ok(tmp === "", "encodeURI('') = " + tmp);
172 tmp = encodeURI("\01\02\03\04");
173 ok(tmp === "%01%02%03%04", "encodeURI('\\01\\02\\03\\04') = " + tmp);
174 tmp = encodeURI("{#@}");
175 ok(tmp === "%7B#@%7D", "encodeURI('{#@}') = " + tmp);
176 tmp = encodeURI("\xa1 ");
177 ok(tmp === "%C2%A1%20", "encodeURI(\\xa1 ) = " + tmp);
178 tmp = encodeURI("\xffff");
179 ok(tmp.length === 8, "encodeURI('\\xffff').length = " + tmp.length);
180 tmp = encodeURI("abcABC123;/?:@&=+$,-_.!~*'()");
181 ok(tmp === "abcABC123;/?:@&=+$,-_.!~*'()", "encodeURI('abcABC123;/?:@&=+$,-_.!~*'()') = " + tmp);
182 tmp = encodeURI("%");
183 ok(tmp === "%25", "encodeURI('%') = " + tmp);
185 ok(tmp === "undefined", "encodeURI() = " + tmp);
186 tmp = encodeURI("abc", "test");
187 ok(tmp === "abc", "encodeURI('abc') = " + tmp);
189 tmp = decodeURI("abc");
190 ok(tmp === "abc", "decodeURI('abc') = " + tmp);
191 tmp = decodeURI("{abc}");
192 ok(tmp === "{abc}", "decodeURI('{abc}') = " + tmp);
194 ok(tmp === "", "decodeURI('') = " + tmp);
195 tmp = decodeURI("\01\02\03\04");
196 ok(tmp === "\01\02\03\04", "decodeURI('\\01\\02\\03\\04') = " + tmp);
198 ok(tmp === "undefined", "decodeURI() = " + tmp);
199 tmp = decodeURI("abc", "test");
200 ok(tmp === "abc", "decodeURI('abc') = " + tmp);
201 tmp = decodeURI("%7babc%7d");
202 ok(tmp === "{abc}", "decodeURI('%7Babc%7D') = " + tmp);
203 tmp = decodeURI("%01%02%03%04");
204 ok(tmp === "\01\02\03\04", "decodeURI('%01%02%03%04') = " + tmp);
205 tmp = decodeURI("%C2%A1%20");
206 ok(tmp === "\xa1 ", "decodeURI('%C2%A1%20') = " + tmp);
207 tmp = decodeURI("%C3%BFff");
208 ok(tmp.length === 3, "decodeURI('%C3%BFff').length = " + tmp.length);
210 tmp = encodeURIComponent("abc");
211 ok(tmp === "abc", "encodeURIComponent('abc') = " + tmp);
212 dec = decodeURIComponent(tmp);
213 ok(dec === "abc", "decodeURIComponent('" + tmp + "') = " + dec);
214 tmp = encodeURIComponent("{abc}");
215 ok(tmp === "%7Babc%7D", "encodeURIComponent('{abc}') = " + tmp);
216 dec = decodeURIComponent(tmp);
217 ok(dec === "{abc}", "decodeURIComponent('" + tmp + "') = " + dec);
218 tmp = encodeURIComponent("");
219 ok(tmp === "", "encodeURIComponent('') = " + tmp);
220 dec = decodeURIComponent(tmp);
221 ok(dec === "", "decodeURIComponent('" + tmp + "') = " + dec);
222 tmp = encodeURIComponent("\01\02\03\04");
223 ok(tmp === "%01%02%03%04", "encodeURIComponent('\\01\\02\\03\\04') = " + tmp);
224 dec = decodeURIComponent(tmp);
225 ok(dec === "\01\02\03\04", "decodeURIComponent('" + tmp + "') = " + dec);
226 tmp = encodeURIComponent("{#@}");
227 ok(tmp === "%7B%23%40%7D", "encodeURIComponent('{#@}') = " + tmp);
228 dec = decodeURIComponent(tmp);
229 ok(dec === "{#@}", "decodeURIComponent('" + tmp + "') = " + dec);
230 tmp = encodeURIComponent("\xa1 ");
231 ok(tmp === "%C2%A1%20", "encodeURIComponent(\\xa1 ) = " + tmp);
232 dec = decodeURIComponent(tmp);
233 ok(dec === "\xa1 ", "decodeURIComponent('" + tmp + "') = " + dec);
234 tmp = encodeURIComponent("\xffff");
235 ok(tmp.length === 8, "encodeURIComponent('\\xffff').length = " + tmp.length);
236 dec = decodeURIComponent(tmp);
237 ok(dec === "\xffff", "decodeURIComponent('" + tmp + "') = " + dec);
238 tmp = encodeURIComponent("abcABC123;/?:@&=+$,-_.!~*'()");
239 ok(tmp === "abcABC123%3B%2F%3F%3A%40%26%3D%2B%24%2C-_.!~*'()", "encodeURIComponent('abcABC123;/?:@&=+$,-_.!~*'()') = " + tmp);
240 dec = decodeURIComponent(tmp);
241 ok(dec === "abcABC123;/?:@&=+$,-_.!~*'()", "decodeURIComponent('" + tmp + "') = " + dec);
242 tmp = encodeURIComponent();
243 ok(tmp === "undefined", "encodeURIComponent() = " + tmp);
244 tmp = encodeURIComponent("abc", "test");
245 ok(tmp === "abc", "encodeURIComponent('abc') = " + tmp);
246 dec = decodeURIComponent();
247 ok(dec === "undefined", "decodeURIComponent() = " + dec);
248 dec = decodeURIComponent("abc", "test");
249 ok(dec === "abc", "decodeURIComponent('abc') = " + dec);
252 ok(tmp === "abc", "escape('abc') = " + tmp);
254 ok(tmp === "", "escape('') = " + tmp);
255 tmp = escape("a1b c!d+e@*-_+./,");
256 ok(tmp === "a1b%20c%21d+e@*-_+./%2C", "escape('a1b c!d+e@*-_+./,') = " + tmp);
258 ok(tmp === "undefined", "escape() = " + tmp);
259 tmp = escape('\u1234\123\xf3');
260 ok(tmp == "%u1234S%F3", "escape('\u1234\123\xf3') = " + tmp);
262 tmp = unescape("abc");
263 ok(tmp === "abc", "unescape('abc') = " + tmp);
265 ok(tmp === "", "unescape('') = " + tmp);
266 tmp = unescape("%%%");
267 ok(tmp === "%%%", "unescape('%%%') = " + tmp);
269 ok(tmp === "undefined", "unescape() = " + tmp);
270 tmp = unescape("%54%65s%u0074");
271 ok(tmp === "Test", "unescape('%54%65s%u0074') = " + tmp);
273 tmp = "aA1~`!@#$%^&*()_+=-][{}';:/.,<>?\|";
274 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));
275 ok(unescape(escape(tmp)) === tmp, "unescape(escape('" + tmp + "')) = " + unescape(escape(tmp)));
277 ok(Object.prototype.hasOwnProperty('toString'), "Object.prototype.hasOwnProperty('toString') is false");
278 ok(Object.prototype.hasOwnProperty('isPrototypeOf'), "Object.prototype.hasOwnProperty('isPrototypeOf') is false");
279 ok(Function.prototype.hasOwnProperty('call'), "Function.prototype.hasOwnProperty('call') is false");
283 ok(!obj.hasOwnProperty('toString'), "obj.hasOwnProperty('toString') is true");
284 ok(!obj.hasOwnProperty('isPrototypeOf'), "obj.hasOwnProperty('isPrototypeOf') is true");
285 ok(!Object.hasOwnProperty('toString'), "Object.hasOwnProperty('toString') is true");
286 ok(!Object.hasOwnProperty('isPrototypeOf'), "Object.hasOwnProperty('isPrototypeOf') is true");
287 ok(!parseFloat.hasOwnProperty('call'), "parseFloat.hasOwnProperty('call') is true");
288 ok(!Function.hasOwnProperty('call'), "Function.hasOwnProperty('call') is true");
291 ok(Array.prototype.hasOwnProperty('sort'), "Array.prototype.hasOwnProperty('sort') is false");
292 ok(Array.prototype.hasOwnProperty('length'), "Array.prototype.hasOwnProperty('length') is false");
293 ok(!obj.hasOwnProperty('sort'), "obj.hasOwnProperty('sort') is true");
294 ok(obj.hasOwnProperty('length'), "obj.hasOwnProperty('length') is true");
296 obj = new Boolean(false);
297 ok(!obj.hasOwnProperty('toString'), "obj.hasOwnProperty('toString') is true");
298 ok(!Boolean.hasOwnProperty('toString'), "Boolean.hasOwnProperty('toString') is true");
299 ok(Boolean.prototype.hasOwnProperty('toString'), "Boolean.prototype.hasOwnProperty('toString') is false");
302 ok(!obj.hasOwnProperty('getTime'), "obj.hasOwnProperty('getTime') is true");
303 ok(!Date.hasOwnProperty('getTime'), "Date.hasOwnProperty('getTime') is true");
304 ok(Date.prototype.hasOwnProperty('getTime'), "Date.prototype.hasOwnProperty('getTime') is false");
305 ok(!("now" in Date), "now found in Date");
308 ok(!obj.hasOwnProperty('toFixed'), "obj.hasOwnProperty('toFixed') is true");
309 ok(!Number.hasOwnProperty('toFixed'), "Number.hasOwnProperty('toFixed') is true");
310 ok(Number.prototype.hasOwnProperty('toFixed'), "Number.prototype.hasOwnProperty('toFixed') is false");
313 ok(!obj.hasOwnProperty('exec'), "obj.hasOwnProperty('exec') is true");
314 ok(obj.hasOwnProperty('source'), "obj.hasOwnProperty('source') is false");
315 ok(!RegExp.hasOwnProperty('exec'), "RegExp.hasOwnProperty('exec') is true");
316 ok(!RegExp.hasOwnProperty('source'), "RegExp.hasOwnProperty('source') is true");
317 ok(RegExp.prototype.hasOwnProperty('source'), "RegExp.prototype.hasOwnProperty('source') is false");
320 ok(!obj.hasOwnProperty('charAt'), "obj.hasOwnProperty('charAt') is true");
321 ok(obj.hasOwnProperty('length'), "obj.hasOwnProperty('length') is false");
322 ok(!String.hasOwnProperty('charAt'), "String.hasOwnProperty('charAt') is true");
323 ok(String.prototype.hasOwnProperty('charAt'), "String.prototype.hasOwnProperty('charAt') is false");
324 ok(String.prototype.hasOwnProperty('length'), "String.prototype.hasOwnProperty('length') is false");
326 tmp = "" + new Object();
327 ok(tmp === "[object Object]", "'' + new Object() = " + tmp);
328 (tmp = new Array).f = Object.prototype.toString;
329 ok(tmp.f() === "[object Array]", "tmp.f() = " + tmp.f());
330 (tmp = new Boolean).f = Object.prototype.toString;
331 ok(tmp.f() === "[object Boolean]", "tmp.f() = " + tmp.f());
332 (tmp = new Date).f = Object.prototype.toString;
333 ok(tmp.f() === "[object Date]", "tmp.f() = " + tmp.f());
334 (tmp = function() {}).f = Object.prototype.toString;
335 ok(tmp.f() === "[object Function]", "tmp.f() = " + tmp.f());
336 Math.f = Object.prototype.toString;
337 ok(Math.f() === "[object Math]", "tmp.f() = " + tmp.f());
338 (tmp = new Number).f = Object.prototype.toString;
339 ok(tmp.f() === "[object Number]", "tmp.f() = " + tmp.f());
340 (tmp = new RegExp("")).f = Object.prototype.toString;
341 ok(tmp.f() === "[object RegExp]", "tmp.f() = " + tmp.f());
342 (tmp = new String).f = Object.prototype.toString;
343 ok(tmp.f() === "[object String]", "tmp.f() = " + tmp.f());
344 tmp = Object.prototype.toString.call(testObj);
345 ok(tmp === "[object Object]", "toString.call(testObj) = " + tmp);
346 tmp = Object.prototype.toString.call(this);
347 ok(tmp === "[object Object]", "toString.call(this) = " + tmp);
348 (function () { tmp = Object.prototype.toString.call(arguments); })();
349 ok(tmp === "[object Object]", "toString.call(arguments) = " + tmp);
350 tmp = Object.prototype.toString.call(new VBArray(createArray()));
351 ok(tmp === "[object Object]", "toString.call(new VBArray()) = " + tmp);
352 (tmp = new Enumerator()).f = Object.prototype.toString;
353 ok(tmp.f() === "[object Object]", "tmp.f() = " + tmp.f());
354 tmp = Object.prototype.toString.call(null);
355 ok(tmp === "[object Object]", "toString.call(null) = " + tmp);
356 tmp = Object.prototype.toString.call(undefined);
357 ok(tmp === "[object Object]", "toString.call(undefined) = " + tmp);
358 tmp = Object.prototype.toString.call();
359 ok(tmp === "[object Object]", "toString.call() = " + tmp);
361 function TSTestConstr() {}
362 TSTestConstr.prototype = { toString: function() { return "test"; } };
363 obj = new TSTestConstr();
364 ok(obj.toString() === "test", "obj.toString() = " + obj.toString());
366 ok(Object(1) instanceof Number, "Object(1) is not instance of Number");
367 ok(Object("") instanceof String, "Object('') is not instance of String");
368 ok(Object(false) instanceof Boolean, "Object(false) is not instance of Boolean");
370 ok(new Object(1) instanceof Number, "Object(1) is not instance of Number");
371 ok(new Object("") instanceof String, "Object('') is not instance of String");
372 ok(new Object(false) instanceof Boolean, "Object(false) is not instance of Boolean");
375 ok(Object(obj) === obj, "Object(obj) !== obj");
377 ok(typeof(Object()) === "object", "typeof(Object()) !== 'object'");
378 ok(typeof(Object(undefined)) === "object", "typeof(Object(undefined)) !== 'object'");
379 ok(typeof(Object(null)) === "object", "typeof(Object(null)) !== 'object'");
380 ok(typeof(Object(nullDisp)) === "object", "typeof(Object(nullDisp)) !== 'object'");
382 ok(Object(nullDisp) != nullDisp, "Object(nullDisp) == nullDisp");
383 ok(new Object(nullDisp) != nullDisp, "new Object(nullDisp) == nullDisp");
385 ok(Object(testObj) === testObj, "Object(testObj) != testObj\n");
386 ok(new Object(testObj) === testObj, "new Object(testObj) != testObj\n");
389 ok(Object(tmp) === tmp, "Object(tmp) != tmp");
390 ok(new Object(tmp) === tmp, "new Object(tmp) != tmp");
392 var obj = new Object();
393 obj.toString = function (x) {
394 ok(arguments.length === 0, "arguments.length = " + arguments.length);
397 ok((tmp = obj.toLocaleString()) === "test", "obj.toLocaleString() = " + tmp);
398 ok((tmp = obj.toLocaleString(1)) === "test", "obj.toLocaleString(1) = " + tmp);
399 ok(obj === obj.valueOf(), "obj !== obj.valueOf");
401 ok("".length === 0, "\"\".length = " + "".length);
402 ok(getVT("".length) == "VT_I4", "\"\".length = " + "".length);
403 ok("abc".length === 3, "\"abc\".length = " + "abc".length);
404 ok(String.prototype.length === 0, "String.prototype.length = " + String.prototype.length);
407 ok(tmp === "", "''.toString() = " + tmp);
408 tmp = "test".toString();
409 ok(tmp === "test", "''.toString() = " + tmp);
410 tmp = "test".toString(3);
411 ok(tmp === "test", "''.toString(3) = " + tmp);
414 ok(tmp === "", "''.valueOf() = " + tmp);
415 tmp = "test".valueOf();
416 ok(tmp === "test", "''.valueOf() = " + tmp);
417 tmp = "test".valueOf(3);
418 ok(tmp === "test", "''.valueOf(3) = " + tmp);
420 var str = new String("test");
421 ok(str.toString() === "test", "str.toString() = " + str.toString());
422 var str = new String();
423 ok(str.toString() === "", "str.toString() = " + str.toString());
424 var str = new String("test", "abc");
425 ok(str.toString() === "test", "str.toString() = " + str.toString());
427 str = new String("test");
428 ok(str.length === 4, "str.length = " + str.length);
431 ok(str.length === 4, "str.length = " + str.length);
433 var strObj = new Object();
434 strObj.toString = function() { return "abcd" };
435 strObj.substr = String.prototype.substr;
436 strObj.lastIndexOf = String.prototype.lastIndexOf;
438 tmp = "value " + str;
439 ok(tmp === "value test", "'value ' + str = " + tmp);
442 ok(tmp === "", "String() = " + tmp);
444 ok(tmp === "false", "String(false) = " + tmp);
446 ok(tmp === "null", "String(null) = " + tmp);
447 tmp = String("test");
448 ok(tmp === "test", "String('test') = " + tmp);
449 tmp = String("test", "abc");
450 ok(tmp === "test", "String('test','abc') = " + tmp);
452 tmp = "abc".charAt(0);
453 ok(tmp === "a", "'abc',charAt(0) = " + tmp);
454 tmp = "abc".charAt(1);
455 ok(tmp === "b", "'abc',charAt(1) = " + tmp);
456 tmp = "abc".charAt(2);
457 ok(tmp === "c", "'abc',charAt(2) = " + tmp);
458 tmp = "abc".charAt(3);
459 ok(tmp === "", "'abc',charAt(3) = " + tmp);
460 tmp = "abc".charAt(4);
461 ok(tmp === "", "'abc',charAt(4) = " + tmp);
462 tmp = "abc".charAt();
463 ok(tmp === "a", "'abc',charAt() = " + tmp);
464 tmp = "abc".charAt(-1);
465 ok(tmp === "", "'abc',charAt(-1) = " + tmp);
466 tmp = "abc".charAt(0,2);
467 ok(tmp === "a", "'abc',charAt(0.2) = " + tmp);
468 tmp = "abc".charAt(NaN);
469 ok(tmp === "a", "'abc',charAt(NaN) = " + tmp);
470 tmp = "abc".charAt(bigInt);
471 ok(tmp === "", "'abc',charAt(bigInt) = " + tmp);
473 tmp = "abc".charCodeAt(0);
474 ok(tmp === 0x61, "'abc'.charCodeAt(0) = " + tmp);
475 tmp = "abc".charCodeAt(1);
476 ok(tmp === 0x62, "'abc'.charCodeAt(1) = " + tmp);
477 tmp = "abc".charCodeAt(2);
478 ok(tmp === 0x63, "'abc'.charCodeAt(2) = " + tmp);
479 tmp = "abc".charCodeAt();
480 ok(tmp === 0x61, "'abc'.charCodeAt() = " + tmp);
481 tmp = "abc".charCodeAt(true);
482 ok(tmp === 0x62, "'abc'.charCodeAt(true) = " + tmp);
483 tmp = "abc".charCodeAt(0,2);
484 ok(tmp === 0x61, "'abc'.charCodeAt(0,2) = " + tmp);
485 tmp = "\u49F4".charCodeAt(0);
486 ok(tmp === 0x49F4, "'\u49F4'.charCodeAt(0) = " + tmp);
487 tmp = "\052".charCodeAt(0);
488 ok(tmp === 0x2A, "'\052'.charCodeAt(0) = " + tmp);
489 tmp = "\xa2".charCodeAt(0);
490 ok(tmp === 0xA2, "'\xa2'.charCodeAt(0) = " + tmp);
491 tmp = "abc".charCodeAt(bigInt);
492 ok(isNaN(tmp), "'abc'.charCodeAt(bigInt) = " + tmp);
494 tmp = "abcd".substring(1,3);
495 ok(tmp === "bc", "'abcd'.substring(1,3) = " + tmp);
496 tmp = "abcd".substring(-1,3);
497 ok(tmp === "abc", "'abcd'.substring(-1,3) = " + tmp);
498 tmp = "abcd".substring(1,6);
499 ok(tmp === "bcd", "'abcd'.substring(1,6) = " + tmp);
500 tmp = "abcd".substring(3,1);
501 ok(tmp === "bc", "'abcd'.substring(3,1) = " + tmp);
502 tmp = "abcd".substring(2,2);
503 ok(tmp === "", "'abcd'.substring(2,2) = " + tmp);
504 tmp = "abcd".substring(true,"3");
505 ok(tmp === "bc", "'abcd'.substring(true,'3') = " + tmp);
506 tmp = "abcd".substring(1,3,2);
507 ok(tmp === "bc", "'abcd'.substring(1,3,2) = " + tmp);
508 tmp = "abcd".substring();
509 ok(tmp === "abcd", "'abcd'.substring() = " + tmp);
511 tmp = "abcd".substr(1,3);
512 ok(tmp === "bcd", "'abcd'.substr(1,3) = " + tmp);
513 tmp = "abcd".substr(-1,3);
514 ok(tmp === "abc", "'abcd'.substr(-1,3) = " + tmp);
515 tmp = "abcd".substr(1,6);
516 ok(tmp === "bcd", "'abcd'.substr(1,6) = " + tmp);
517 tmp = "abcd".substr(2,-1);
518 ok(tmp === "", "'abcd'.substr(3,1) = " + tmp);
519 tmp = "abcd".substr(2,0);
520 ok(tmp === "", "'abcd'.substr(2,2) = " + tmp);
521 tmp = "abcd".substr(true,"3");
522 ok(tmp === "bcd", "'abcd'.substr(true,'3') = " + tmp);
523 tmp = "abcd".substr(1,3,2);
524 ok(tmp === "bcd", "'abcd'.substr(1,3,2) = " + tmp);
525 tmp = "abcd".substr();
526 ok(tmp === "abcd", "'abcd'.substr() = " + tmp);
527 tmp = strObj.substr(1,1);
528 ok(tmp === "b", "'abcd'.substr(1,3) = " + tmp);
530 tmp = "abcd".slice(1,3);
531 ok(tmp === "bc", "'abcd'.slice(1,3) = " + tmp);
532 tmp = "abcd".slice(1,-1);
533 ok(tmp === "bc", "'abcd'.slice(1,-1) = " + tmp);
534 tmp = "abcd".slice(-3,3);
535 ok(tmp === "bc", "'abcd'.slice(-3,3) = " + tmp);
536 tmp = "abcd".slice(-6,3);
537 ok(tmp === "abc", "'abcd'.slice(-6,3) = " + tmp);
538 tmp = "abcd".slice(3,1);
539 ok(tmp === "", "'abcd'.slice(3,1) = " + tmp);
540 tmp = "abcd".slice(true,3);
541 ok(tmp === "bc", "'abcd'.slice(true,3) = " + tmp);
542 tmp = "abcd".slice();
543 ok(tmp === "abcd", "'abcd'.slice() = " + tmp);
544 tmp = "abcd".slice(1);
545 ok(tmp === "bcd", "'abcd'.slice(1) = " + tmp);
547 tmp = "abc".concat(["d",1],2,false);
548 ok(tmp === "abcd,12false", "concat returned " + tmp);
549 var arr = new Array(2,"a");
550 arr.concat = String.prototype.concat;
551 tmp = arr.concat("d");
552 ok(tmp === "2,ad", "arr.concat = " + tmp);
554 m = "a+bcabc".match("a+");
555 ok(typeof(m) === "object", "typeof m is not object");
556 ok(m.length === 1, "m.length is not 1");
557 ok(m["0"] === "a", "m[0] is not \"a\"");
559 r = "- [test] -".replace("[test]", "success");
560 ok(r === "- success -", "r = " + r + " expected '- success -'");
562 r = "- [test] -".replace("[test]", "success", "test");
563 ok(r === "- success -", "r = " + r + " expected '- success -'");
565 r = "test".replace();
566 ok(r === "test", "r = " + r + " expected 'test'");
568 function replaceFunc3(m, off, str) {
569 ok(arguments.length === 3, "arguments.length = " + arguments.length);
570 ok(m === "[test]", "m = " + m + " expected [test]");
571 ok(off === 1, "off = " + off + " expected 0");
572 ok(str === "-[test]-", "str = " + arguments[3]);
576 r = "-[test]-".replace("[test]", replaceFunc3);
577 ok(r === "-ret-", "r = " + r + " expected '-ret-'");
579 r = "-[test]-".replace("[test]", replaceFunc3, "test");
580 ok(r === "-ret-", "r = " + r + " expected '-ret-'");
582 r = "x,x,x".replace("x", "y");
583 ok(r === "y,x,x", "r = " + r + " expected 'y,x,x'");
585 r = "x,x,x".replace("", "y");
586 ok(r === "yx,x,x", "r = " + r + " expected 'yx,x,x'");
588 r = "x,x,x".replace("", "");
589 ok(r === "x,x,x", "r = " + r + " expected 'x,x,x'");
591 r = "1,2,3".split(",");
592 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
593 ok(r.length === 3, "r.length = " + r.length);
594 ok(r[0] === "1", "r[0] = " + r[0]);
595 ok(r[1] === "2", "r[1] = " + r[1]);
596 ok(r[2] === "3", "r[2] = " + r[2]);
598 r = "1,2,3".split(",*");
599 ok(r.length === 1, "r.length = " + r.length);
600 ok(r[0] === "1,2,3", "r[0] = " + r[0]);
603 ok(r.length === 3, "r.length = " + r.length);
604 ok(r[0] === "1", "r[0] = " + r[0]);
605 ok(r[1] === "2", "r[1] = " + r[1]);
606 ok(r[2] === "3", "r[2] = " + r[2]);
609 ok(r.length === 2, "r.length = " + r.length);
610 ok(r[0] === "1", "r[0] = " + r[0]);
611 ok(r[1] === "3", "r[1] = " + r[1]);
613 r = "1,2,".split(",");
614 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
615 ok(r.length === 3, "r.length = " + r.length);
616 ok(r[0] === "1", "r[0] = " + r[0]);
617 ok(r[1] === "2", "r[1] = " + r[1]);
618 ok(r[2] === "", "r[2] = " + r[2]);
620 r = "1,2,3".split(",", 2);
621 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
622 ok(r.length === 2, "r.length = " + r.length);
623 ok(r[0] === "1", "r[0] = " + r[0]);
624 ok(r[1] === "2", "r[1] = " + r[1]);
626 r = "1,2,3".split(",", 0);
627 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
628 ok(r.length === 0, "r.length = " + r.length);
630 r = "1,2,3".split(",", -1);
631 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
632 ok(r.length === 3, "r.length = " + r.length);
633 ok(r[0] === "1", "r[0] = " + r[0]);
634 ok(r[1] === "2", "r[1] = " + r[1]);
635 ok(r[2] === "3", "r[1] = " + r[1]);
637 r = "1,2,3".split(undefined);
638 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
639 ok(r.length === 1, "r.length = " + r.length);
640 ok(r[0] === "1,2,3", "r[0] = " + r[0]);
642 r = "1,undefined2undefined,3".split(undefined);
643 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
644 ok(r.length === 3, "r.length = " + r.length);
645 ok(r[0] === "1,", "r[0] = " + r[0]);
646 ok(r[1] === "2", "r[1] = " + r[1]);
647 ok(r[2] === ",3", "r[2] = " + r[2]);
649 r = "1,undefined2undefined,3".split();
650 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
651 ok(r.length === 1, "r.length = " + r.length);
652 ok(r[0] === "1,undefined2undefined,3", "r[0] = " + r[0]);
655 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
656 ok(r.length === 1, "r.length = " + r.length);
657 ok(r[0] === "", "r[0] = " + r[0]);
660 function test(string, separator, result) {
661 var r = string.split(separator);
662 ok(r == result, "\"" + string + "\".split(" + separator + ") returned " + r + " expected " + result);
665 test("test", /^|\s+/, "test");
666 test("test", /$|\s+/, "test");
667 test("test", /^|./, "t");
668 test("test", /.*/, "");
669 test("test", /x*/, "t,e,s,t");
670 test("test", /$|x*/, "t,e,s,t");
671 test("test", /^|x*/, "t,e,s,t");
672 test("test", /t*/, "e,s");
673 test("xaabaax", /a*|b*/, "x,b,x");
674 test("xaabaax", /a+|b+/, "x,x");
675 test("xaabaax", /a+|b*/, "x,x");
676 test("xaaxbaax", /b+|a+/, "x,x,x");
677 test("test", /^|t/, "tes");
678 test("test", /^|t/, "tes");
679 test("a,,b", /,/, "a,b");
680 test("ab", /a*/, "b");
681 test("aab", "a", ",,b");
684 function test_length(string, separator, len) {
685 var r = string.split(separator);
686 ok(r.length === len, "\"" + string + "\".split(" + separator + ").length = "
687 + r.length + " expected " + len);
690 test_length("", /a*/, 0);
691 test_length("", /a+/, 1);
692 test_length("", "", 0);
693 test_length("", "x", 1);
696 tmp = "abcd".indexOf("bc",0);
697 ok(tmp === 1, "indexOf = " + tmp);
698 tmp = "abcd".indexOf("bc",1);
699 ok(tmp === 1, "indexOf = " + tmp);
700 tmp = "abcd".indexOf("bc");
701 ok(tmp === 1, "indexOf = " + tmp);
702 tmp = "abcd".indexOf("ac");
703 ok(tmp === -1, "indexOf = " + tmp);
704 tmp = "abcd".indexOf("bc",2);
705 ok(tmp === -1, "indexOf = " + tmp);
706 tmp = "abcd".indexOf("a",0);
707 ok(tmp === 0, "indexOf = " + tmp);
708 tmp = "abcd".indexOf("bc",0,"test");
709 ok(tmp === 1, "indexOf = " + tmp);
710 tmp = "abcd".indexOf();
711 ok(tmp == -1, "indexOf = " + tmp);
712 tmp = "abcd".indexOf("b", bigInt);
713 ok(tmp == -1, "indexOf = " + tmp);
714 tmp = "abcd".indexOf("abcd",0);
715 ok(tmp === 0, "indexOf = " + tmp);
716 tmp = "abcd".indexOf("abcd",1);
717 ok(tmp === -1, "indexOf = " + tmp);
718 tmp = ("ab" + String.fromCharCode(0) + "cd").indexOf(String.fromCharCode(0));
719 ok(tmp === 2, "indexOf = " + tmp);
721 tmp = "abcd".lastIndexOf("bc",1);
722 ok(tmp === 1, "lastIndexOf = " + tmp);
723 tmp = "abcd".lastIndexOf("bc",2);
724 ok(tmp === 1, "lastIndexOf = " + tmp);
725 tmp = "abcd".lastIndexOf("bc");
726 ok(tmp === 1, "lastIndexOf = " + tmp);
727 tmp = "abcd".lastIndexOf("ac");
728 ok(tmp === -1, "lastIndexOf = " + tmp);
729 tmp = "abcd".lastIndexOf("d",10);
730 ok(tmp === 3, "lastIndexOf = " + tmp);
731 tmp = "abcd".lastIndexOf("bc",0,"test");
732 ok(tmp === -1, "lastIndexOf = " + tmp);
733 tmp = "abcd".lastIndexOf();
734 ok(tmp === -1, "lastIndexOf = " + tmp);
735 tmp = "aaaa".lastIndexOf("a",2);
736 ok(tmp == 2, "lastIndexOf = " + tmp);
737 tmp = strObj.lastIndexOf("b");
738 ok(tmp === 1, "lastIndexOf = " + tmp);
739 tmp = "bbb".lastIndexOf("b", bigInt);
740 ok(tmp === 2, "lastIndexOf = " + tmp);
741 tmp = "abcd".lastIndexOf("abcd",4);
742 ok(tmp === 0, "lastIndexOf = " + tmp);
743 tmp = "abcd".lastIndexOf("abcd",0);
744 ok(tmp === 0, "lastIndexOf = " + tmp);
745 tmp = ("ab" + String.fromCharCode(0) + "cd").lastIndexOf(String.fromCharCode(0));
746 ok(tmp === 2, "lastIndexOf = " + tmp);
748 tmp = "".toLowerCase();
749 ok(tmp === "", "''.toLowerCase() = " + tmp);
750 tmp = "test".toLowerCase();
751 ok(tmp === "test", "''.toLowerCase() = " + tmp);
752 tmp = "test".toLowerCase(3);
753 ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
754 tmp = "tEsT".toLowerCase();
755 ok(tmp === "test", "''.toLowerCase() = " + tmp);
756 tmp = "tEsT".toLocaleLowerCase();
757 ok(tmp === "test", "''.toLocaleLowerCase() = " + tmp);
758 tmp = "tEsT".toLowerCase(3);
759 ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
760 tmp = ("tE" + String.fromCharCode(0) + "sT").toLowerCase();
761 ok(tmp === "te" + String.fromCharCode(0) + "st", "''.toLowerCase() = " + tmp);
762 ok(String.prototype.toLocaleLowerCase != String.prototype.toLowerCase,
763 "String.prototype.toLocaleLowerCase == String.prototype.toLowerCase");
765 tmp = "".toUpperCase();
766 ok(tmp === "", "''.toUpperCase() = " + tmp);
767 tmp = "TEST".toUpperCase();
768 ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
769 tmp = "TEST".toUpperCase(3);
770 ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
771 tmp = "tEsT".toUpperCase();
772 ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
773 tmp = "tEsT".toUpperCase(3);
774 ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
775 tmp = "tEsT".toLocaleUpperCase(3);
776 ok(tmp === "TEST", "''.toLocaleUpperCase(3) = " + tmp);
777 tmp = ("tE" + String.fromCharCode(0) + "sT").toUpperCase();
778 ok(tmp === "TE" + String.fromCharCode(0) + "ST", "''.toUpperCase() = " + tmp);
779 ok(String.prototype.toLocaleUpperCase != String.prototype.toUpperCase,
780 "String.prototype.toLocaleUpperCase == String.prototype.toUpperCase");
783 ok(tmp === "<A NAME=\"undefined\"></A>", "''.anchor() = " + tmp);
785 ok(tmp === "<A NAME=\"3\"></A>", "''.anchor(3) = " + tmp);
786 tmp = "".anchor("red");
787 ok(tmp === "<A NAME=\"red\"></A>", "''.anchor('red') = " + tmp);
788 tmp = "test".anchor();
789 ok(tmp === "<A NAME=\"undefined\">test</A>", "'test'.anchor() = " + tmp);
790 tmp = "test".anchor(3);
791 ok(tmp === "<A NAME=\"3\">test</A>", "'test'.anchor(3) = " + tmp);
792 tmp = "test".anchor("green");
793 ok(tmp === "<A NAME=\"green\">test</A>", "'test'.anchor('green') = " + tmp);
796 ok(tmp === "<BIG></BIG>", "''.big() = " + tmp);
798 ok(tmp === "<BIG></BIG>", "''.big(3) = " + tmp);
800 ok(tmp === "<BIG>test</BIG>", "'test'.big() = " + tmp);
802 ok(tmp === "<BIG>test</BIG>", "'test'.big(3) = " + tmp);
805 ok(tmp === "<BLINK></BLINK>", "''.blink() = " + tmp);
807 ok(tmp === "<BLINK></BLINK>", "''.blink(3) = " + tmp);
808 tmp = "test".blink();
809 ok(tmp === "<BLINK>test</BLINK>", "'test'.blink() = " + tmp);
810 tmp = "test".blink(3);
811 ok(tmp === "<BLINK>test</BLINK>", "'test'.blink(3) = " + tmp);
814 ok(tmp === "<B></B>", "''.bold() = " + tmp);
816 ok(tmp === "<B></B>", "''.bold(3) = " + tmp);
818 ok(tmp === "<B>test</B>", "'test'.bold() = " + tmp);
819 tmp = "test".bold(3);
820 ok(tmp === "<B>test</B>", "'test'.bold(3) = " + tmp);
823 ok(tmp === "<TT></TT>", "''.fixed() = " + tmp);
825 ok(tmp === "<TT></TT>", "''.fixed(3) = " + tmp);
826 tmp = "test".fixed();
827 ok(tmp === "<TT>test</TT>", "'test'.fixed() = " + tmp);
828 tmp = "test".fixed(3);
829 ok(tmp === "<TT>test</TT>", "'test'.fixed(3) = " + tmp);
831 tmp = "".fontcolor();
832 ok(tmp === "<FONT COLOR=\"undefined\"></FONT>", "''.fontcolor() = " + tmp);
833 tmp = "".fontcolor(3);
834 ok(tmp === "<FONT COLOR=\"3\"></FONT>", "''.fontcolor(3) = " + tmp);
835 tmp = "".fontcolor("red");
836 ok(tmp === "<FONT COLOR=\"red\"></FONT>", "''.fontcolor('red') = " + tmp);
837 tmp = "test".fontcolor();
838 ok(tmp === "<FONT COLOR=\"undefined\">test</FONT>", "'test'.fontcolor() = " + tmp);
839 tmp = "test".fontcolor(3);
840 ok(tmp === "<FONT COLOR=\"3\">test</FONT>", "'test'.fontcolor(3) = " + tmp);
841 tmp = "test".fontcolor("green");
842 ok(tmp === "<FONT COLOR=\"green\">test</FONT>", "'test'.fontcolor('green') = " + tmp);
845 ok(tmp === "<FONT SIZE=\"undefined\"></FONT>", "''.fontsize() = " + tmp);
846 tmp = "".fontsize(3);
847 ok(tmp === "<FONT SIZE=\"3\"></FONT>", "''.fontsize(3) = " + tmp);
848 tmp = "".fontsize("red");
849 ok(tmp === "<FONT SIZE=\"red\"></FONT>", "''.fontsize('red') = " + tmp);
850 tmp = "test".fontsize();
851 ok(tmp === "<FONT SIZE=\"undefined\">test</FONT>", "'test'.fontsize() = " + tmp);
852 tmp = "test".fontsize(3);
853 ok(tmp === "<FONT SIZE=\"3\">test</FONT>", "'test'.fontsize(3) = " + tmp);
854 tmp = "test".fontsize("green");
855 ok(tmp === "<FONT SIZE=\"green\">test</FONT>", "'test'.fontsize('green') = " + tmp);
857 tmp = ("".fontcolor()).fontsize();
858 ok(tmp === "<FONT SIZE=\"undefined\"><FONT COLOR=\"undefined\"></FONT></FONT>", "(''.fontcolor()).fontsize() = " + tmp);
861 ok(tmp === "<I></I>", "''.italics() = " + tmp);
863 ok(tmp === "<I></I>", "''.italics(3) = " + tmp);
864 tmp = "test".italics();
865 ok(tmp === "<I>test</I>", "'test'.italics() = " + tmp);
866 tmp = "test".italics(3);
867 ok(tmp === "<I>test</I>", "'test'.italics(3) = " + tmp);
870 ok(tmp === "<A HREF=\"undefined\"></A>", "''.link() = " + tmp);
872 ok(tmp === "<A HREF=\"3\"></A>", "''.link(3) = " + tmp);
873 tmp = "".link("red");
874 ok(tmp === "<A HREF=\"red\"></A>", "''.link('red') = " + tmp);
876 ok(tmp === "<A HREF=\"undefined\">test</A>", "'test'.link() = " + tmp);
877 tmp = "test".link(3);
878 ok(tmp === "<A HREF=\"3\">test</A>", "'test'.link(3) = " + tmp);
879 tmp = "test".link("green");
880 ok(tmp === "<A HREF=\"green\">test</A>", "'test'.link('green') = " + tmp);
883 ok(tmp === "<SMALL></SMALL>", "''.small() = " + tmp);
885 ok(tmp === "<SMALL></SMALL>", "''.small(3) = " + tmp);
886 tmp = "test".small();
887 ok(tmp === "<SMALL>test</SMALL>", "'test'.small() = " + tmp);
888 tmp = "test".small(3);
889 ok(tmp === "<SMALL>test</SMALL>", "'test'.small(3) = " + tmp);
892 ok(tmp === "<STRIKE></STRIKE>", "''.strike() = " + tmp);
894 ok(tmp === "<STRIKE></STRIKE>", "''.strike(3) = " + tmp);
895 tmp = "test".strike();
896 ok(tmp === "<STRIKE>test</STRIKE>", "'test'.strike() = " + tmp);
897 tmp = "test".strike(3);
898 ok(tmp === "<STRIKE>test</STRIKE>", "'test'.strike(3) = " + tmp);
901 ok(tmp === "<SUB></SUB>", "''.sub() = " + tmp);
903 ok(tmp === "<SUB></SUB>", "''.sub(3) = " + tmp);
905 ok(tmp === "<SUB>test</SUB>", "'test'.sub() = " + tmp);
907 ok(tmp === "<SUB>test</SUB>", "'test'.sub(3) = " + tmp);
910 ok(tmp === "<SUP></SUP>", "''.sup() = " + tmp);
912 ok(tmp === "<SUP></SUP>", "''.sup(3) = " + tmp);
914 ok(tmp === "<SUP>test</SUP>", "'test'.sup() = " + tmp);
916 ok(tmp === "<SUP>test</SUP>", "'test'.sup(3) = " + tmp);
918 ok(String.fromCharCode() === "", "String.fromCharCode() = " + String.fromCharCode());
919 ok(String.fromCharCode(65,"66",67) === "ABC", "String.fromCharCode(65,'66',67) = " + String.fromCharCode(65,"66",67));
920 ok(String.fromCharCode(1024*64+65, -1024*64+65) === "AA",
921 "String.fromCharCode(1024*64+65, -1024*64+65) = " + String.fromCharCode(1024*64+65, -1024*64+65));
922 ok(String.fromCharCode(65, NaN, undefined).length === 3,
923 "String.fromCharCode(65, NaN, undefined).length = " + String.fromCharCode(65, NaN, undefined).length);
925 var arr = new Array();
926 ok(typeof(arr) === "object", "arr () is not object");
927 ok((arr.length === 0), "arr.length is not 0");
928 ok(arr["0"] === undefined, "arr[0] is not undefined");
930 var arr = new Array(1, 2, "test");
931 ok(typeof(arr) === "object", "arr (1,2,test) is not object");
932 ok((arr.length === 3), "arr.length is not 3");
933 ok(arr["0"] === 1, "arr[0] is not 1");
934 ok(arr["1"] === 2, "arr[1] is not 2");
935 ok(arr["2"] === "test", "arr[2] is not \"test\"");
938 ok((arr.length === 8), "arr.length is not 8");
941 ok(tmp === "", "'' + [] = " + tmp);
943 ok(tmp === "1,true", "'' + [1,true] = " + tmp);
945 var arr = new Array(6);
946 ok(typeof(arr) === "object", "arr (6) is not object");
947 ok((arr.length === 6), "arr.length is not 6");
948 ok(arr["0"] === undefined, "arr[0] is not undefined");
950 ok(arr.push() === 6, "arr.push() !== 6");
951 ok(arr.push(1) === 7, "arr.push(1) !== 7");
952 ok(arr[6] === 1, "arr[6] != 1");
953 ok(arr.length === 7, "arr.length != 10");
954 ok(arr.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10");
955 ok(arr[8] === "b", "arr[8] != 'b'");
956 ok(arr.length === 10, "arr.length != 10");
958 var arr = new Object();
959 arr.push = Array.prototype.push;
963 ok(arr.push() === 6, "arr.push() !== 6");
964 ok(arr.push(1) === 7, "arr.push(1) !== 7");
965 ok(arr[6] === 1, "arr[6] != 1");
966 ok(arr.length === 7, "arr.length != 10");
967 ok(arr.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10");
968 ok(arr[8] === "b", "arr[8] != 'b'");
969 ok(arr.length === 10, "arr.length != 10");
971 arr.pop = Array.prototype.pop;
972 ok(arr.pop() === false, "arr.pop() !== false");
973 ok(arr[8] === "b", "arr[8] !== 'b'");
974 ok(arr.pop() === 'b', "arr.pop() !== 'b'");
975 ok(arr[8] === undefined, "arr[8] !== undefined");
979 ok(arr.length === 2, "arr.length = " + arr.length);
980 ok(tmp === 5, "pop() = " + tmp);
982 ok(arr.length === 1, "arr.length = " + arr.length);
983 ok(tmp === 4, "pop() = " + tmp);
985 ok(arr.length === 0, "arr.length = " + arr.length);
986 ok(tmp === 3, "pop() = " + tmp);
988 ok(false, "not deleted " + tmp);
990 ok(arr.length === 0, "arr.length = " + arr.length);
991 ok(tmp === undefined, "tmp = " + tmp);
993 arr.pop = Array.prototype.pop;
995 ok(arr.length === 0, "arr.length = " + arr.length);
996 ok(tmp === undefined, "tmp = " + tmp);
999 ok(arr.length === 5, "arr.length = " + arr.length);
1000 ok(tmp === undefined, "tmp = " + tmp);
1001 tmp = [1,2,,,].pop();
1002 ok(tmp === undefined, "tmp = " + tmp);
1004 function PseudoArray() {
1007 PseudoArray.prototype = {length: 1};
1008 arr = new PseudoArray();
1009 Array.prototype.push.call(arr, 2);
1010 ok(arr.propertyIsEnumerable("length"), "arr.length is not enumerable");
1012 arr = [1,2,null,false,undefined,,"a"];
1015 ok(tmp === "1,2,,false,,,a", "arr.join() = " + tmp);
1016 tmp = arr.join(";");
1017 ok(tmp === "1;2;;false;;;a", "arr.join(';') = " + tmp);
1018 tmp = arr.join(";","test");
1019 ok(tmp === "1;2;;false;;;a", "arr.join(';') = " + tmp);
1021 ok(tmp === "12falsea", "arr.join('') = " + tmp);
1023 tmp = arr.toString();
1024 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
1025 tmp = arr.toString("test");
1026 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
1030 tmp = arr.join(String.fromCharCode(0));
1031 ok(tmp === "a" + String.fromCharCode(0) + "b", "arr.join(String.fromCharCode(0)) = " + tmp);
1038 arr.join = Array.prototype.join;
1039 tmp = arr.join(",");
1040 ok(arr.length === 3, "arr.length = " + arr.length);
1041 ok(tmp === "aa,,2", "tmp = " + tmp);
1043 arr = [5,true,2,-1,3,false,"2.5"];
1044 tmp = arr.sort(function(x,y) { return y-x; });
1045 ok(tmp === arr, "tmp !== arr");
1046 tmp = [5,3,"2.5",2,true,false,-1];
1047 for(var i=0; i < arr.length; i++)
1048 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
1050 tmp = [3,1,2].sort(function(x,y) { return y-x; }).join();
1051 ok(tmp === "3,2,1", "reverse sorted [3,1,2] = " + tmp);
1053 tmp = [3,1,2].sort(null).join();
1054 ok(tmp === "1,2,3", "null sorted [3,1,2] = " + tmp);
1057 tmp = [3,1,2].sort(function(x,y) { return y-x; }, 1, 2, 3);
1058 ok(false, "expected sort(undefined) exception");
1060 ok(e.name === "TypeError", "got exception " + e.name);
1063 arr = [5,false,2,0,"abc",3,"a",-1];
1065 ok(tmp === arr, "tmp !== arr");
1066 tmp = [-1,0,2,3,5,"a","abc",false];
1067 for(var i=0; i < arr.length; i++)
1068 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
1070 arr = ["a", "b", "ab"];
1071 tmp = ["a", "ab", "b"];
1072 ok(arr.sort() === arr, "arr.sort() !== arr");
1073 for(var i=0; i < arr.length; i++)
1074 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
1080 arr.sort = Array.prototype.sort;
1082 ok(arr === tmp, "tmp !== arr");
1083 ok(arr[0]===1 && arr[1]==="aa" && arr[2]===undefined, "arr is sorted incorrectly");
1085 tmp = [["bb","aa"],["ab","aa"]].sort().toString();
1086 ok(tmp === "ab,aa,bb,aa", "sort() = " + tmp);
1088 tmp = [["bb","aa"],"ab"].sort().toString();
1089 ok(tmp === "ab,bb,aa", "sort() = " + tmp);
1091 tmp = [["bb","aa"],"cc"].sort().toString();
1092 ok(tmp === "bb,aa,cc", "sort() = " + tmp);
1094 tmp = [2,"1"].sort().toString();
1095 ok(tmp === "1,2", "sort() = " + tmp);
1097 tmp = ["2",1].sort().toString();
1098 ok(tmp === "1,2", "sort() = " + tmp);
1100 tmp = [,,0,"z"].sort().toString();
1101 ok(tmp === "0,z,,", "sort() = " + tmp);
1103 tmp = ["a,b",["a","a"],["a","c"]].sort().toString();
1104 ok(tmp === "a,a,a,b,a,c", "sort() = " + tmp);
1106 arr = ["1", "2", "3"];
1108 ok(arr.length === 1, "arr.length = " + arr.length);
1110 ok(arr.length === 3, "arr.length = " + arr.length);
1111 ok(arr.toString() === "1,,", "arr.toString() = " + arr.toString());
1113 arr = Array("a","b","c");
1114 ok(arr.toString() === "a,b,c", "arr.toString() = " + arr.toString());
1116 ok(arr.valueOf === Object.prototype.valueOf, "arr.valueOf !== Object.prototype.valueOf");
1117 ok(arr === arr.valueOf(), "arr !== arr.valueOf");
1120 tmp = arr.reverse();
1121 ok(tmp === arr, "tmp !== arr");
1122 ok(arr.length === 3, "arr.length = " + arr.length);
1123 ok(arr.toString() === "3,2,1", "arr.toString() = " + arr.toString());
1128 tmp = arr.reverse();
1129 ok(tmp === arr, "tmp !== arr");
1130 ok(arr.length === 6, "arr.length = " + arr.length);
1131 ok(arr.toString() === "1,,5,,,", "arr.toString() = " + arr.toString());
1138 arr.reverse = Array.prototype.reverse;
1139 tmp = arr.reverse();
1140 ok(tmp === arr, "tmp !== arr");
1141 ok(arr.length === 3, "arr.length = " + arr.length);
1142 ok(arr[0] === 2 && arr[1] === undefined && arr[2] === "aa", "unexpected array");
1145 tmp = arr.unshift(0);
1146 ok(tmp === (invokeVersion < 2 ? undefined : 4), "[1,2,3].unshift(0) returned " +tmp);
1147 ok(arr.length === 4, "arr.length = " + arr.length);
1148 ok(arr.toString() === "0,1,2,3", "arr.toString() = " + arr.toString());
1153 tmp = arr.unshift(-1,0);
1154 ok(tmp === (invokeVersion < 2 ? undefined : 5), "unshift returned " +tmp);
1155 ok(arr.length === 5, "arr.length = " + arr.length);
1156 ok(arr.toString() === "-1,0,1,,3", "arr.toString() = " + arr.toString());
1159 tmp = arr.unshift();
1160 ok(tmp === (invokeVersion < 2 ? undefined : 3), "unshift returned " +tmp);
1161 ok(arr.length === 3, "arr.length = " + arr.length);
1162 ok(arr.toString() === "1,2,3", "arr.toString() = " + arr.toString());
1168 tmp = Array.prototype.unshift.call(arr, 0);
1169 ok(tmp === (invokeVersion < 2 ? undefined : 3), "unshift returned " +tmp);
1170 ok(arr.length === 3, "arr.length = " + arr.length);
1171 ok(arr[0] === 0 && arr[1] === 1 && arr[2] === 2, "unexpected array");
1175 ok(tmp === 1, "[1,2,,4].shift() = " + tmp);
1176 ok(arr.toString() === "2,,4", "arr = " + arr.toString());
1180 ok(tmp === undefined, "[].shift() = " + tmp);
1181 ok(arr.toString() === "", "arr = " + arr.toString());
1185 ok(tmp === 1, "[1,2,,4].shift(2) = " + tmp);
1186 ok(arr.toString() === "2,,4", "arr = " + arr.toString());
1190 ok(tmp === 1, "[1,].shift() = " + tmp);
1191 ok(arr.toString() === "", "arr = " + arr.toString());
1197 tmp = Array.prototype.shift.call(obj);
1198 ok(tmp === "test", "obj.shift() = " + tmp);
1199 ok(obj.length == 2, "obj.length = " + obj.length);
1200 ok(obj[1] === 3, "obj[1] = " + obj[1]);
1202 var num = new Number(6);
1204 tmp = arr.concat(3, [4,5], num);
1205 ok(tmp !== arr, "tmp === arr");
1206 for(var i=0; i<6; i++)
1207 ok(tmp[i] === i, "tmp[" + i + "] = " + tmp[i]);
1208 ok(tmp[6] === num, "tmp[6] !== num");
1209 ok(tmp.length === 7, "tmp.length = " + tmp.length);
1212 ok(arr.length === 0, "arr.length = " + arr.length);
1215 tmp = arr.concat([2]);
1216 ok(tmp.length === 3, "tmp.length = " + tmp.length);
1217 ok(tmp[1] === undefined, "tmp[1] = " + tmp[1]);
1219 arr = [1,false,'a',null,undefined,'a'];
1220 ok(arr.slice(0,6).toString() === "1,false,a,,,a", "arr.slice(0,6).toString() = " + arr.slice(0,6));
1221 ok(arr.slice(0,6).length === 6, "arr.slice(0,6).length = " + arr.slice(0,6).length);
1222 ok(arr.slice().toString() === "1,false,a,,,a", "arr.slice().toString() = " + arr.slice());
1223 ok(arr.slice("abc").toString() === "1,false,a,,,a", "arr.slice(\"abc\").toString() = " + arr.slice("abc"));
1224 ok(arr.slice(3,8).toString() === ",,a", "arr.slice(3,8).toString() = " + arr.slice(3,8));
1225 ok(arr.slice(3,8).length === 3, "arr.slice(3,8).length = " + arr.slice(3,8).length);
1226 ok(arr.slice(1).toString() === "false,a,,,a", "arr.slice(1).toString() = " + arr.slice(1));
1227 ok(arr.slice(-2).toString() === ",a", "arr.slice(-2).toString() = " + arr.slice(-2));
1228 ok(arr.slice(3,1).toString() === "", "arr.slice(3,1).toString() = " + arr.slice(3,1));
1229 tmp = arr.slice(0,6);
1230 for(var i=0; i < arr.length; i++)
1231 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
1233 ok(arr.slice(5).toString() === "a,,,,,,,2", "arr.slice(5).toString() = " + arr.slice(5).toString());
1234 ok(arr.slice(5).length === 8, "arr.slice(5).length = " + arr.slice(5).length);
1237 tmp = arr.splice(2,2);
1238 ok(tmp.toString() == "3,4", "arr.splice(2,2) returned " + tmp.toString());
1239 ok(arr.toString() == "1,2,5", "arr.splice(2,2) is " + arr.toString());
1242 tmp = arr.splice(2,2,"a");
1243 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a') returned " + tmp.toString());
1244 ok(arr.toString() == "1,2,a,5", "arr.splice(2,2,'a') is " + arr.toString());
1247 tmp = arr.splice(2,2,'a','b','c');
1248 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a','b','c') returned " + tmp.toString());
1249 ok(arr.toString() == "1,2,a,b,c,5", "arr.splice(2,2,'a','b','c') is " + arr.toString());
1252 tmp = arr.splice(2,2,'a','b','c');
1253 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a','b','c') returned " + tmp.toString());
1254 ok(arr.toString() == "1,2,a,b,c,", "arr.splice(2,2,'a','b','c') is " + arr.toString());
1257 arr.splice(2,2,'a','b','c');
1258 ok(arr.toString() == "1,2,a,b,c,", "arr.splice(2,2,'a','b','c') is " + arr.toString());
1261 tmp = arr.splice(2,2,'a','b');
1262 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a','b') returned " + tmp.toString());
1263 ok(arr.toString() == "1,2,a,b,5", "arr.splice(2,2,'a','b') is " + arr.toString());
1266 tmp = arr.splice(-1,2);
1267 ok(tmp.toString() == "5", "arr.splice(-1,2) returned " + tmp.toString());
1268 ok(arr.toString() == "1,2,3,4", "arr.splice(-1,2) is " + arr.toString());
1271 tmp = arr.splice(-10,3);
1272 ok(tmp.toString() == "1,2,3", "arr.splice(-10,3) returned " + tmp.toString());
1273 ok(arr.toString() == "4,5", "arr.splice(-10,3) is " + arr.toString());
1276 tmp = arr.splice(-10,100);
1277 ok(tmp.toString() == "1,2,3,4,5", "arr.splice(-10,100) returned " + tmp.toString());
1278 ok(arr.toString() == "", "arr.splice(-10,100) is " + arr.toString());
1281 tmp = arr.splice(2,-1);
1282 ok(tmp.toString() == "", "arr.splice(2,-1) returned " + tmp.toString());
1283 ok(arr.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr.toString());
1286 tmp = arr.splice(2);
1287 ok(tmp.toString() == "", "arr.splice(2,-1) returned " + tmp.toString());
1288 ok(arr.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr.toString());
1292 ok(tmp.toString() == "", "arr.splice(2,-1) returned " + tmp.toString());
1293 ok(arr.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr.toString());
1296 tmp = arr.splice(bigInt);
1297 ok(tmp.toString() == "", "arr.splice(bigInt) returned " + tmp.toString());
1298 ok(arr.toString() == "1,2,3,4,5", "arr.splice(bigInt) is " + arr.toString());
1301 tmp = arr.splice(-bigInt);
1302 ok(tmp.toString() == "", "arr.splice(-bigInt) returned " + tmp.toString());
1303 ok(arr.toString() == "1,2,3,4,5", "arr.splice(-bigInt) is " + arr.toString());
1305 if(invokeVersion >= 2) {
1307 tmp = arr.splice(2, bigInt);
1308 ok(tmp.toString() == "3,4,5", "arr.splice(2, bigInt) returned " + tmp.toString());
1309 ok(arr.toString() == "1,2", "arr.splice(2, bigInt) is " + arr.toString());
1313 tmp = arr.splice(2, -bigInt);
1314 ok(tmp.toString() == "", "arr.splice(2, -bigInt) returned " + tmp.toString());
1315 ok(arr.toString() == "1,2,3,4,5", "arr.splice(2, -bigInt) is " + arr.toString());
1322 tmp = Array.prototype.splice.call(obj, 1, 1, 'a', 'b');
1323 ok(tmp.toString() === "2", "obj.splice returned " + tmp);
1324 ok(obj.length === 4, "obj.length = " + obj.length);
1325 ok(obj[0] === 1, "obj[0] = " + obj[0]);
1326 ok(obj[1] === 'a', "obj[1] = " + obj[1]);
1327 ok(obj[2] === 'b', "obj[2] = " + obj[2]);
1328 ok(obj[3] === 3, "obj[3] = " + obj[3]);
1335 tmp = Array.prototype.slice.call(obj, 1, 2);
1336 ok(tmp.length === 1, "tmp.length = " + tmp.length);
1337 ok(tmp[0] === 2, "tmp[0] = " + tmp[0]);
1339 tmp = (new Number(2)).toString();
1340 ok(tmp === "2", "num(2).toString = " + tmp);
1341 tmp = (new Number()).toString();
1342 ok(tmp === "0", "num().toString = " + tmp);
1343 tmp = (new Number(5.5)).toString(2);
1344 ok(tmp === "101.1", "num(5.5).toString(2) = " + tmp);
1346 tmp = (new Number(3)).toFixed(3);
1347 ok(tmp === "3.000", "num(3).toFixed(3) = " + tmp);
1348 tmp = (new Number(3)).toFixed();
1349 ok(tmp === "3", "Number(3).toFixed() = " + tmp);
1350 tmp = (new Number(0)).toFixed();
1351 ok(tmp === "0", "Number(0).toFixed() = " + tmp);
1352 tmp = (new Number(0)).toFixed(1);
1353 ok(tmp === "0.0", "Number(0).toFixed(1) = " + tmp);
1354 tmp = (new Number(0)).toFixed(2);
1355 ok(tmp === "0.00", "Number(0).toFixed(2) = " + tmp);
1356 tmp = (new Number(1.76)).toFixed(1);
1357 ok(tmp === "1.8", "num(1.76).toFixed(1) = " + tmp);
1358 tmp = (new Number(7.92)).toFixed(5);
1359 ok(tmp === "7.92000", "num(7.92).toFixed(5) = " + tmp);
1360 tmp = (new Number(2.88)).toFixed();
1361 ok(tmp === "3", "num(2.88).toFixed = " + tmp);
1362 tmp = (new Number(-2.5)).toFixed();
1363 ok(tmp === "-3", "num(-2.5).toFixed = " + tmp);
1364 tmp = (new Number(1000000000000000128)).toFixed(0);
1365 //todo_wine ok(tmp === "1000000000000000100", "num(1000000000000000128) = " + tmp);
1366 tmp = (new Number(3.14).toFixed(NaN));
1367 ok(tmp === "3", "num(3.14).toFixed = " + tmp);
1368 tmp = (new Number(0.95).toFixed(1));
1369 ok(tmp === "1.0", "num(0.95).toFixed(1) = " + tmp);
1370 tmp = (new Number(1e900)).toFixed(0);
1371 ok(tmp === "Infinity", "num(1000000000000000128) = " + tmp);
1372 tmp = (new Number(0.12345678901234567890123)).toFixed(20);
1373 ok(tmp === "0.12345678901234568000", "num(0.12345678901234567890123) = " + tmp);
1375 tmp = (new Number(2)).toExponential(3);
1376 ok(tmp === "2.000e+0", "num(2).toExponential(3) = " + tmp);
1377 tmp = (new Number(1.17e-32)).toExponential(20);
1378 ok(tmp === "1.17000000000000000000e-32", "num(1.17e-32).toExponential(20) = " + tmp);
1379 tmp = (new Number(0)).toExponential(7);
1380 ok(tmp === "0.0000000e+0", "num(0).toExponential(7) = " + tmp);
1381 tmp = (new Number(0)).toExponential(0);
1382 ok(tmp === "0e+0", "num(0).toExponential() = " + tmp);
1383 tmp = (new Number(-13.7567)).toExponential();
1384 ok(tmp === "-1.37567e+1", "num(-13.7567).toExponential() = " + tmp);
1385 tmp = (new Number(-32.1)).toExponential();
1386 ok(tmp === "-3.21e+1", "num(-32.1).toExponential() = " + tmp);
1387 tmp = (new Number(4723.4235)).toExponential();
1388 ok(tmp === "4.7234235e+3", "num(4723.4235).toExponential() = " + tmp);
1390 tmp = (new Number(5)).toPrecision(12);
1391 ok(tmp == "5.00000000000", "num(5).toPrecision(12) = " + tmp);
1392 tmp = (new Number(7.73)).toPrecision(7);
1393 ok(tmp == "7.730000", "num(7.73).toPrecision(7) = " + tmp);
1394 tmp = (new Number(-127547.47472)).toPrecision(17);
1395 ok(tmp == "-127547.47472000000", "num(-127547.47472).toPrecision(17) = " + tmp);
1396 tmp = (new Number(0)).toPrecision(3);
1397 ok(tmp == "0.00", "num(0).toPrecision(3) = " + tmp);
1398 tmp = (new Number(42345.52342465464562334)).toPrecision(15);
1399 ok(tmp == "42345.5234246546", "num(42345.52342465464562334).toPrecision(15) = " + tmp);
1400 tmp = (new Number(1.182e30)).toPrecision(5);
1401 ok(tmp == "1.1820e+30", "num(1.182e30)).toPrecision(5) = " + tmp);
1402 tmp = (new Number(1.123)).toPrecision();
1403 ok(tmp == "1.123", "num(1.123).toPrecision() = " + tmp);
1405 ok(Number() === 0, "Number() = " + Number());
1406 ok(Number(false) === 0, "Number(false) = " + Number(false));
1407 ok(Number("43") === 43, "Number('43') = " + Number("43"));
1409 tmp = (new Number(1)).valueOf();
1410 ok(tmp === 1, "(new Number(1)).valueOf = " + tmp);
1411 tmp = (new Number(1,2)).valueOf();
1412 ok(tmp === 1, "(new Number(1,2)).valueOf = " + tmp);
1413 tmp = (new Number()).valueOf();
1414 ok(tmp === 0, "(new Number()).valueOf = " + tmp);
1415 tmp = Number.prototype.valueOf();
1416 ok(tmp === 0, "Number.prototype.valueOf = " + tmp);
1418 function equals(val, base) {
1421 var str = val.toString(base);
1423 for(i=0; i<str.length; i++) {
1424 if(str.substring(i, i+1) == '(') break;
1425 if(str.substring(i, i+1) == '.') break;
1426 num = num*base + parseInt(str.substring(i, i+1));
1429 if(str.substring(i, i+1) == '.') {
1431 for(i++; i<str.length; i++) {
1432 if(str.substring(i, i+1) == '(') break;
1433 num += parseInt(str.substring(i, i+1))/mult;
1438 if(str.substring(i, i+1) == '(') {
1439 exp = parseInt(str.substring(i+2));
1440 num *= Math.pow(base, exp);
1443 ok(num>val-val/1000 && num<val+val/1000, "equals: num = " + num);
1446 ok((10).toString(11) === "a", "(10).toString(11) = " + (10).toString(11));
1447 ok((213213433).toString(17) === "8e2ddcb", "(213213433).toString(17) = " + (213213433).toString(17));
1448 ok((-3254343).toString(33) === "-2oicf", "(-3254343).toString(33) = " + (-3254343).toString(33));
1449 ok((NaN).toString(12) === "NaN", "(NaN).toString(11) = " + (NaN).toString(11));
1450 ok((Infinity).toString(13) === "Infinity", "(Infinity).toString(11) = " + (Infinity).toString(11));
1451 for(i=2; i<10; i++) {
1453 equals(2305843009200000000, i);
1456 equals(1024*1024*1024*1024*1024*1024*1.9999, i);
1459 equals(4.65661287308e-10, i);
1460 ok((0).toString(i) === "0", "(0).toString("+i+") = " + (0).toString(i));
1463 ok(parseFloat('123') === 123, "parseFloat('123') = " + parseFloat('123'));
1464 ok(parseFloat('-13.7') === -13.7, "parseFloat('-13.7') = " + parseFloat('-13.7'));
1465 ok(parseFloat('-0.01e-2') === -0.01e-2, "parseFloat('-0.01e-2') = " + parseFloat('-0.01e-2'));
1466 ok(parseFloat('-12e+5') === -12e+5, "parseFloat('-12e+5') = " + parseFloat('-12e+5'));
1467 ok(parseFloat('1E5 not parsed') === 1E5, "parseFloat('1E5 not parsed') = " + parseFloat('1E5 not parsed'));
1468 ok(isNaN(parseFloat('not a number')), "parseFloat('not a number') is not NaN");
1469 ok(parseFloat('+13.2e-3') === 13.2e-3, "parseFloat('+13.2e-3') = " + parseFloat('+13.2e-3'));
1470 ok(parseFloat('.12') === 0.12, "parseFloat('.12') = " + parseFloat('.12'));
1471 ok(parseFloat('1e') === 1, "parseFloat('1e') = " + parseFloat('1e'));
1472 ok(isNaN(parseFloat('\uff16')), "parseFloat('\\uD835') is not NaN");
1475 ok(tmp === 1, "Math.min(1) = " + tmp);
1477 tmp = Math.min(1, false);
1478 ok(tmp === 0, "Math.min(1, false) = " + tmp);
1481 ok(tmp === Infinity, "Math.min() = " + tmp);
1483 tmp = Math.min(1, NaN, -Infinity, false);
1484 ok(isNaN(tmp), "Math.min(1, NaN, -Infinity, false) is not NaN");
1486 tmp = Math.min(1, false, true, null, -3);
1487 ok(tmp === -3, "Math.min(1, false, true, null, -3) = " + tmp);
1490 ok(tmp === 1, "Math.max(1) = " + tmp);
1492 tmp = Math.max(true, 0);
1493 ok(tmp === 1, "Math.max(true, 0) = " + tmp);
1495 tmp = Math.max(-2, false, true, null, 1);
1496 ok(tmp === 1, "Math.max(-2, false, true, null, 1) = " + tmp);
1499 ok(tmp === -Infinity, "Math.max() = " + tmp);
1501 tmp = Math.max(true, NaN, 0);
1502 ok(isNaN(tmp), "Math.max(true, NaN, 0) is not NaN");
1504 tmp = Math.round(0.5);
1505 ok(tmp === 1, "Math.round(0.5) = " + tmp);
1507 tmp = Math.round(-0.5);
1508 ok(tmp === 0, "Math.round(-0.5) = " + tmp);
1510 tmp = Math.round(1.1);
1511 ok(tmp === 1, "Math.round(1.1) = " + tmp);
1513 tmp = Math.round(true);
1514 ok(tmp === 1, "Math.round(true) = " + tmp);
1516 tmp = Math.round(1.1, 3, 4);
1517 ok(tmp === 1, "Math.round(1.1, 3, 4) = " + tmp);
1520 ok(isNaN(tmp), "Math.round() is not NaN");
1522 tmp = Math.ceil(0.5);
1523 ok(tmp === 1, "Math.ceil(0.5) = " + tmp);
1525 tmp = Math.ceil(-0.5);
1526 ok(tmp === 0, "Math.ceil(-0.5) = " + tmp);
1528 tmp = Math.ceil(1.1);
1529 ok(tmp === 2, "Math.round(1.1) = " + tmp);
1531 tmp = Math.ceil(true);
1532 ok(tmp === 1, "Math.ceil(true) = " + tmp);
1534 tmp = Math.ceil(1.1, 3, 4);
1535 ok(tmp === 2, "Math.ceil(1.1, 3, 4) = " + tmp);
1538 ok(isNaN(tmp), "ceil() is not NaN");
1540 tmp = Math.floor(0.5);
1541 ok(tmp === 0, "Math.floor(0.5) = " + tmp);
1543 tmp = Math.floor(-0.5);
1544 ok(tmp === -1, "Math.floor(-0.5) = " + tmp);
1546 tmp = Math.floor(1.1);
1547 ok(tmp === 1, "Math.floor(1.1) = " + tmp);
1549 tmp = Math.floor(true);
1550 ok(tmp === 1, "Math.floor(true) = " + tmp);
1552 tmp = Math.floor(1.1, 3, 4);
1553 ok(tmp === 1, "Math.floor(1.1, 3, 4) = " + tmp);
1556 ok(isNaN(tmp), "floor is not NaN");
1559 ok(tmp === 3, "Math.abs(3) = " + tmp);
1562 ok(tmp === 3, "Math.abs(-3) = " + tmp);
1564 tmp = Math.abs(true);
1565 ok(tmp === 1, "Math.abs(true) = " + tmp);
1568 ok(isNaN(tmp), "Math.abs() is not NaN");
1570 tmp = Math.abs(NaN);
1571 ok(isNaN(tmp), "Math.abs() is not NaN");
1573 tmp = Math.abs(-Infinity);
1574 ok(tmp === Infinity, "Math.abs(-Infinite) = " + tmp);
1576 tmp = Math.abs(-3, 2);
1577 ok(tmp === 3, "Math.abs(-3, 2) = " + tmp);
1580 ok(tmp === 1, "Math.cos(0) = " + tmp);
1582 tmp = Math.cos(Math.PI/2);
1583 ok(Math.floor(tmp*100) === 0, "Math.cos(Math.PI/2) = " + tmp);
1585 tmp = Math.cos(-Math.PI/2);
1586 ok(Math.floor(tmp*100) === 0, "Math.cos(-Math.PI/2) = " + tmp);
1588 tmp = Math.cos(Math.PI/3, 2);
1589 ok(Math.floor(tmp*100) === 50, "Math.cos(Math.PI/3, 2) = " + tmp);
1591 tmp = Math.cos(true);
1592 ok(Math.floor(tmp*100) === 54, "Math.cos(true) = " + tmp);
1594 tmp = Math.cos(false);
1595 ok(tmp === 1, "Math.cos(false) = " + tmp);
1598 ok(isNaN(tmp), "Math.cos() is not NaN");
1600 tmp = Math.cos(NaN);
1601 ok(isNaN(tmp), "Math.cos(NaN) is not NaN");
1603 tmp = Math.cos(Infinity);
1604 ok(isNaN(tmp), "Math.cos(Infinity) is not NaN");
1606 tmp = Math.cos(-Infinity);
1607 ok(isNaN(tmp), "Math.cos(-Infinity) is not NaN");
1609 tmp = Math.pow(2, 2);
1610 ok(tmp === 4, "Math.pow(2, 2) = " + tmp);
1612 tmp = Math.pow(4, 0.5);
1613 ok(tmp === 2, "Math.pow(2, 2) = " + tmp);
1615 tmp = Math.pow(2, 2, 3);
1616 ok(tmp === 4, "Math.pow(2, 2, 3) = " + tmp);
1619 ok(isNaN(tmp), "Math.pow(2) is not NaN");
1622 ok(isNaN(tmp), "Math.pow() is not NaN");
1624 tmp = Math.random();
1625 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
1626 ok(0 <= tmp && tmp <= 1, "Math.random() = " + tmp);
1628 tmp = Math.random(100);
1629 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
1630 ok(0 <= tmp && tmp <= 1, "Math.random(100) = " + tmp);
1633 ok(Math.floor(tmp*100) === 157, "Math.acos(0) = " + tmp);
1636 ok(Math.floor(tmp*100) === 0, "Math.acos(1) = " + tmp);
1638 tmp = Math.acos(-1);
1639 ok(Math.floor(tmp*100) === 314, "Math.acos(-1) = " + tmp);
1641 tmp = Math.acos(Math.PI/4, 2);
1642 ok(Math.floor(tmp*100) === 66, "Math.acos(Math.PI/4, 2) = " + tmp);
1644 tmp = Math.acos(true);
1645 ok(Math.floor(tmp*100) === 0, "Math.acos(true) = " + tmp);
1647 tmp = Math.acos(false);
1648 ok(Math.floor(tmp*100) === 157, "Math.acos(false) = " + tmp);
1650 tmp = Math.acos(1.1);
1651 ok(isNaN(tmp), "Math.acos(1.1) is not NaN");
1654 ok(isNaN(tmp), "Math.acos() is not NaN");
1656 tmp = Math.acos(NaN);
1657 ok(isNaN(tmp), "Math.acos(NaN) is not NaN");
1659 tmp = Math.acos(Infinity);
1660 ok(isNaN(tmp), "Math.acos(Infinity) is not NaN");
1662 tmp = Math.acos(-Infinity);
1663 ok(isNaN(tmp), "Math.acos(-Infinity) is not NaN");
1666 ok(Math.floor(tmp*100) === 0, "Math.asin(0) = " + tmp);
1669 ok(Math.floor(tmp*100) === 157, "Math.asin(1) = " + tmp);
1671 tmp = Math.asin(-1);
1672 ok(Math.floor(tmp*100) === -158, "Math.asin(-1) = " + tmp);
1674 tmp = Math.asin(Math.PI/4, 2);
1675 ok(Math.floor(tmp*100) === 90, "Math.asin(Math.PI/4, 2) = " + tmp);
1677 tmp = Math.asin(true);
1678 ok(Math.floor(tmp*100) === 157, "Math.asin(true) = " + tmp);
1680 tmp = Math.asin(false);
1681 ok(Math.floor(tmp*100) === 0, "Math.asin(false) = " + tmp);
1683 tmp = Math.asin(1.1);
1684 ok(isNaN(tmp), "Math.asin(1.1) is not NaN");
1687 ok(isNaN(tmp), "Math.asin() is not NaN");
1689 tmp = Math.asin(NaN);
1690 ok(isNaN(tmp), "Math.asin(NaN) is not NaN");
1692 tmp = Math.asin(Infinity);
1693 ok(isNaN(tmp), "Math.asin(Infinity) is not NaN");
1695 tmp = Math.asin(-Infinity);
1696 ok(isNaN(tmp), "Math.asin(-Infinity) is not NaN");
1699 ok(Math.floor(tmp*100) === 0, "Math.atan(0) = " + tmp);
1702 ok(Math.floor(tmp*100) === 78, "Math.atan(1) = " + tmp);
1704 tmp = Math.atan(-1);
1705 ok(Math.floor(tmp*100) === -79, "Math.atan(-1) = " + tmp);
1707 tmp = Math.atan(true);
1708 ok(Math.floor(tmp*100) === 78, "Math.atan(true) = " + tmp);
1710 tmp = Math.atan(false);
1711 ok(Math.floor(tmp*100) === 0, "Math.atan(false) = " + tmp);
1714 ok(isNaN(tmp), "Math.atan() is not NaN");
1716 tmp = Math.atan(NaN);
1717 ok(isNaN(tmp), "Math.atan(NaN) is not NaN");
1719 tmp = Math.atan(Infinity);
1720 ok(Math.floor(tmp*100) === 157, "Math.atan(Infinity) = " + tmp);
1722 tmp = Math.atan(-Infinity);
1723 ok(Math.floor(tmp*100) === -158, "Math.atan(Infinity) = " + tmp);
1725 tmp = Math.atan2(0, 0);
1726 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 0) = " + tmp);
1728 tmp = Math.atan2(0, 1);
1729 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 1) = " + tmp);
1731 tmp = Math.atan2(0, Infinity);
1732 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, Infinity) = " + tmp);
1734 tmp = Math.atan2(0, -1);
1735 ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -1) = " + tmp);
1737 tmp = Math.atan2(0, -Infinity);
1738 ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -Infinity) = " + tmp);
1740 tmp = Math.atan2(1, 0);
1741 ok(Math.floor(tmp*100) === 157, "Math.atan2(1, 0) = " + tmp);
1743 tmp = Math.atan2(Infinity, 0);
1744 ok(Math.floor(tmp*100) === 157, "Math.atan2(Infinity, 0) = " + tmp);
1746 tmp = Math.atan2(-1, 0);
1747 ok(Math.floor(tmp*100) === -158, "Math.atan2(-1, 0) = " + tmp);
1749 tmp = Math.atan2(-Infinity, 0);
1750 ok(Math.floor(tmp*100) === -158, "Math.atan2(-Infinity, 0) = " + tmp);
1752 tmp = Math.atan2(1, 1);
1753 ok(Math.floor(tmp*100) === 78, "Math.atan2(1, 1) = " + tmp);
1755 tmp = Math.atan2(-1, -1);
1756 ok(Math.floor(tmp*100) === -236, "Math.atan2(-1, -1) = " + tmp);
1758 tmp = Math.atan2(-1, 1);
1759 ok(Math.floor(tmp*100) === -79, "Math.atan2(-1, 1) = " + tmp);
1761 tmp = Math.atan2(Infinity, Infinity);
1762 ok(Math.floor(tmp*100) === 78, "Math.atan2(Infinity, Infinity) = " + tmp);
1764 tmp = Math.atan2(Infinity, -Infinity, 1);
1765 ok(Math.floor(tmp*100) === 235, "Math.atan2(Infinity, -Infinity, 1) = " + tmp);
1768 ok(isNaN(tmp), "Math.atan2() is not NaN");
1770 tmp = Math.atan2(1);
1771 ok(isNaN(tmp), "Math.atan2(1) is not NaN");
1774 ok(tmp === 1, "Math.exp(0) = " + tmp);
1777 ok(Math.floor(tmp*100) === 271, "Math.exp(1) = " + tmp);
1780 ok(Math.floor(tmp*100) === 36, "Math.exp(-1) = " + tmp);
1782 tmp = Math.exp(true);
1783 ok(Math.floor(tmp*100) === 271, "Math.exp(true) = " + tmp);
1785 tmp = Math.exp(1, 1);
1786 ok(Math.floor(tmp*100) === 271, "Math.exp(1, 1) = " + tmp);
1789 ok(isNaN(tmp), "Math.exp() is not NaN");
1791 tmp = Math.exp(NaN);
1792 ok(isNaN(tmp), "Math.exp(NaN) is not NaN");
1794 tmp = Math.exp(Infinity);
1795 ok(tmp === Infinity, "Math.exp(Infinity) = " + tmp);
1797 tmp = Math.exp(-Infinity);
1798 ok(tmp === 0, "Math.exp(-Infinity) = " + tmp);
1801 ok(Math.floor(tmp*100) === 0, "Math.log(1) = " + tmp);
1804 ok(isNaN(tmp), "Math.log(-1) is not NaN");
1806 tmp = Math.log(true);
1807 ok(Math.floor(tmp*100) === 0, "Math.log(true) = " + tmp);
1809 tmp = Math.log(1, 1);
1810 ok(Math.floor(tmp*100) === 0, "Math.log(1, 1) = " + tmp);
1813 ok(isNaN(tmp), "Math.log() is not NaN");
1815 tmp = Math.log(NaN);
1816 ok(isNaN(tmp), "Math.log(NaN) is not NaN");
1818 tmp = Math.log(Infinity);
1819 ok(tmp === Infinity, "Math.log(Infinity) = " + tmp);
1821 tmp = Math.log(-Infinity);
1822 ok(isNaN(tmp), "Math.log(-Infinity) is not NaN");
1825 ok(tmp === 0, "Math.sin(0) = " + tmp);
1827 tmp = Math.sin(Math.PI/2);
1828 ok(tmp === 1, "Math.sin(Math.PI/2) = " + tmp);
1830 tmp = Math.sin(-Math.PI/2);
1831 ok(tmp === -1, "Math.sin(-Math.PI/2) = " + tmp);
1833 tmp = Math.sin(Math.PI/3, 2);
1834 ok(Math.floor(tmp*100) === 86, "Math.sin(Math.PI/3, 2) = " + tmp);
1836 tmp = Math.sin(true);
1837 ok(Math.floor(tmp*100) === 84, "Math.sin(true) = " + tmp);
1839 tmp = Math.sin(false);
1840 ok(tmp === 0, "Math.sin(false) = " + tmp);
1843 ok(isNaN(tmp), "Math.sin() is not NaN");
1845 tmp = Math.sin(NaN);
1846 ok(isNaN(tmp), "Math.sin(NaN) is not NaN");
1848 tmp = Math.sin(Infinity);
1849 ok(isNaN(tmp), "Math.sin(Infinity) is not NaN");
1851 tmp = Math.sin(-Infinity);
1852 ok(isNaN(tmp), "Math.sin(-Infinity) is not NaN");
1855 ok(tmp === 0, "Math.sqrt(0) = " + tmp);
1858 ok(tmp === 2, "Math.sqrt(4) = " + tmp);
1860 tmp = Math.sqrt(-1);
1861 ok(isNaN(tmp), "Math.sqrt(-1) is not NaN");
1863 tmp = Math.sqrt(2, 2);
1864 ok(Math.floor(tmp*100) === 141, "Math.sqrt(2, 2) = " + tmp);
1866 tmp = Math.sqrt(true);
1867 ok(tmp === 1, "Math.sqrt(true) = " + tmp);
1869 tmp = Math.sqrt(false);
1870 ok(tmp === 0, "Math.sqrt(false) = " + tmp);
1873 ok(isNaN(tmp), "Math.sqrt() is not NaN");
1875 tmp = Math.sqrt(NaN);
1876 ok(isNaN(tmp), "Math.sqrt(NaN) is not NaN");
1878 tmp = Math.sqrt(Infinity);
1879 ok(tmp === Infinity, "Math.sqrt(Infinity) = " + tmp);
1881 tmp = Math.sqrt(-Infinity);
1882 ok(isNaN(tmp), "Math.sqrt(-Infinity) is not NaN");
1885 ok(tmp === 0, "Math.tan(0) = " + tmp);
1887 tmp = Math.tan(Math.PI);
1888 ok(Math.floor(tmp*100) === -1, "Math.tan(Math.PI) = " + tmp);
1890 tmp = Math.tan(2, 2);
1891 ok(Math.floor(tmp*100) === -219, "Math.tan(2, 2) = " + tmp);
1893 tmp = Math.tan(true);
1894 ok(Math.floor(tmp*100) === 155, "Math.tan(true) = " + tmp);
1896 tmp = Math.tan(false);
1897 ok(tmp === 0, "Math.tan(false) = " + tmp);
1900 ok(isNaN(tmp), "Math.tan() is not NaN");
1902 tmp = Math.tan(NaN);
1903 ok(isNaN(tmp), "Math.tan(NaN) is not NaN");
1905 tmp = Math.tan(Infinity);
1906 ok(isNaN(tmp), "Math.tan(Infinity) is not NaN");
1908 tmp = Math.tan(-Infinity);
1909 ok(isNaN(tmp), "Math.tan(-Infinity) is not NaN");
1912 if(invokeVersion < 2)
1915 var stringify_tests = [
1921 [["test"], "\"test\""],
1922 [["test\"\\\b\f\n\r\t\u0002 !"], "\"test\\\"\\\\\\b\\f\\n\\r\\t\\u0002 !\""],
1924 [[Infinity], "null"],
1925 [[-Infinity], "null"],
1926 [[{prop1: true, prop2: "string"}], "{\"prop1\":true,\"prop2\":\"string\"}"],
1927 [[{prop1: true, prop2: testObj, prop3: undefined}], "{\"prop1\":true}"],
1928 [[{prop1: true, prop2: {prop: "string"}},undefined," "],
1929 "{\n \"prop1\": true,\n \"prop2\": {\n \"prop\": \"string\"\n }\n}"],
1930 [[{ },undefined," "], "{}"],
1931 [[[,2,undefined,3,{ },]],"[null,2,null,3,{},null]"],
1932 [[[,2,undefined,3,{prop:0},],undefined," "],"[\n null,\n 2,\n null,\n 3,\n {\n \"prop\": 0\n },\n null\n]"]
1937 for(i=0; i < stringify_tests.length; i++) {
1938 s = JSON.stringify.apply(null, stringify_tests[i][0]);
1939 ok(s === stringify_tests[i][1],
1940 "["+i+"] stringify(" + stringify_tests[i][0] + ") returned " + s + " expected " + stringify_tests[i][1]);
1943 s = JSON.stringify();
1944 ok(s === undefined, "stringify() returned " + s + " expected undefined");
1946 s = JSON.stringify(testObj);
1947 ok(s === undefined || s === "undefined" /* broken on some old versions */,
1948 "stringify(testObj) returned " + s + " expected undefined");
1950 s = JSON.stringify(undefined);
1951 ok(s === undefined || s === "undefined" /* broken on some old versions */,
1952 "stringify(undefined) returned " + s + " expected undefined");
1958 ["\"\\r\\n test\\u1111\"", "\r\n test\u1111"],
1959 ["{\"x\" :\n true}", {x:true}],
1960 ["{\"x y\": {}, \"z\": {\"x\":null}}", {"x y":{}, z:{x:null}}],
1962 ["[false,{},{\"x\": []}]", [false,{},{x:[]}]],
1965 ["1e2147483648", Infinity],
1971 function json_cmp(x, y) {
1975 if(!(x instanceof Object) || !(y instanceof Object))
1978 for(var prop in x) {
1979 if(!x.hasOwnProperty(prop))
1981 if(!x.hasOwnProperty(prop))
1983 if(!json_cmp(x[prop], y[prop]))
1987 for(var prop in y) {
1988 if(!x.hasOwnProperty(prop) && y.hasOwnProperty(prop))
1995 for(i=0; i < parse_tests.length; i++) {
1996 v = JSON.parse(parse_tests[i][0]);
1997 ok(json_cmp(v, parse_tests[i][1]), "parse[" + i + "] returned " + v + ", expected " + parse_tests[i][1]);
2001 var func = function (a) {
2005 ok(func.toString() === "function (a) {\n var a = 1;\n if(a) return;\n }",
2006 "func.toString() = " + func.toString());
2007 ok("" + func === "function (a) {\n var a = 1;\n if(a) return;\n }",
2008 "'' + func.toString() = " + func);
2010 ok(func.valueOf === Object.prototype.valueOf, "func.valueOf !== Object.prototype.valueOf");
2011 ok(func === func.valueOf(), "func !== func.valueOf()");
2013 function testFuncToString(x,y) {
2016 ok(testFuncToString.toString() === "function testFuncToString(x,y) {\n return x+y;\n}",
2017 "testFuncToString.toString() = " + testFuncToString.toString());
2018 ok("" + testFuncToString === "function testFuncToString(x,y) {\n return x+y;\n}",
2019 "'' + testFuncToString = " + testFuncToString);
2023 function callTest(argc) {
2024 ok(this === tmp, "this !== tmp\n");
2025 ok(arguments.length === argc+1, "arguments.length = " + arguments.length + " expected " + (argc+1));
2026 for(var i=1; i <= argc; i++)
2027 ok(arguments[i] === i, "arguments[i] = " + arguments[i]);
2029 for(var i=1; i <= argc; i++)
2030 ok(a[i] === i, "a[i] = " + a[i]);
2033 callTest.call(tmp, 1, 1);
2034 callTest.call(tmp, 2, 1, 2);
2035 callTest.call(tmp, 3, 1, 2, 3);
2037 callTest.apply(tmp, [1, 1]);
2038 callTest.apply(tmp, [2, 1, 2]);
2039 callTest.apply(tmp, [3, 1, 2, 3]);
2040 (function () { callTest.apply(tmp, arguments); })(2,1,2);
2042 function callTest2() {
2043 ok(this === tmp, "this !== tmp\n");
2044 ok(arguments.length === 0, "callTest2: arguments.length = " + arguments.length + " expected 0");
2047 callTest2.call(tmp);
2048 callTest2.apply(tmp, []);
2049 callTest2.apply(tmp);
2050 (function () { callTest2.apply(tmp, arguments); })();
2052 function callTest3() {
2054 ok(arguments.length === 0, "arguments.length = " + arguments.length + " expected 0");
2058 callTest3.call(undefined);
2059 callTest3.call(null);
2061 callTest3.apply(undefined);
2062 callTest3.apply(null);
2064 tmp = Number.prototype.toString.call(3);
2065 ok(tmp === "3", "Number.prototype.toString.call(3) = " + tmp);
2067 var func = new Function("return 3;");
2070 ok(tmp === 3, "func() = " + tmp);
2071 ok(func.call() === 3, "func.call() = " + tmp);
2072 ok(func.length === 0, "func.length = " + func.length);
2073 tmp = func.toString();
2074 ok(tmp === "function anonymous() {\nreturn 3;\n}", "func.toString() = " + tmp);
2076 func = new Function("x", "return x+2;");
2078 ok(tmp === 3, "func(1) = " + tmp);
2079 tmp = func.toString();
2080 ok(tmp === "function anonymous(x) {\nreturn x+2;\n}", "func.toString() = " + tmp);
2082 tmp = (new Function("x ", "return x+2;")).toString();
2083 ok(tmp === "function anonymous(x ) {\nreturn x+2;\n}", "func.toString() = " + tmp);
2085 func = new Function("x", "y", "return x+y");
2087 ok(tmp === 4, "func(1,3) = " + tmp);
2088 tmp = func.toString();
2089 ok(tmp === "function anonymous(x, y) {\nreturn x+y\n}", "func.toString() = " + tmp);
2091 func = new Function(" x, \ty", "\tz", "return x+y+z;");
2093 ok(tmp === 6, "func(1,3,2) = " + tmp);
2094 ok(func.length === 3, "func.length = " + func.length);
2095 tmp = func.toString();
2096 ok(tmp === "function anonymous( x, \ty, \tz) {\nreturn x+y+z;\n}", "func.toString() = " + tmp);
2098 func = new Function();
2100 ok(tmp === undefined, "func() = " + tmp);
2101 tmp = func.toString();
2102 ok(tmp == "function anonymous() {\n\n}", "func.toString() = " + tmp);
2104 // Function constructor called as function
2105 func = Function("return 3;");
2108 ok(tmp === 3, "func() = " + tmp);
2109 ok(func.call() === 3, "func.call() = " + tmp);
2110 ok(func.length === 0, "func.length = " + func.length);
2111 tmp = func.toString();
2112 ok(tmp === "function anonymous() {\nreturn 3;\n}", "func.toString() = " + tmp);
2114 func = (function() {
2116 return new Function("return tmp;");
2120 ok(tmp === 2, "func() = " + tmp);
2122 var date = new Date();
2124 date = new Date(100);
2125 ok(date.getTime() === 100, "date.getTime() = " + date.getTime());
2126 ok(Date.prototype.getTime() === 0, "date.prototype.getTime() = " + Date.prototype.getTime());
2127 date = new Date(8.64e15);
2128 ok(date.getTime() === 8.64e15, "date.getTime() = " + date.getTime());
2129 date = new Date(8.64e15+1);
2130 ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
2131 date = new Date(Infinity);
2132 ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
2133 date = new Date("3 July 2009 22:28:00 UTC+0100");
2134 ok(date.getTime() === 1246656480000, "date.getTime() = " + date.getTime());
2135 date = new Date(1984, 11, 29, 13, 51, 24, 120);
2136 ok(date.getFullYear() === 1984, "date.getFullYear() = " + date.getFullYear());
2137 ok(date.getMonth() === 11, "date.getMonth() = " + date.getMonth());
2138 ok(date.getDate() === 29, "date.getDate() = " + date.getDate());
2139 ok(date.getHours() === 13, "date.getHours() = " + date.getHours());
2140 ok(date.getMinutes() === 51, "date.getMinutes() = " + date.getMinutes());
2141 ok(date.getSeconds() === 24, "date.getSeconds() = " + date.getSeconds());
2142 ok(date.getMilliseconds() === 120, "date.getMilliseconds() = " + date.getMilliseconds());
2143 date = new Date(731, -32, 40, -1, 70, 65, -13);
2144 ok(date.getFullYear() === 728, "date.getFullYear() = " + date.getFullYear());
2145 ok(date.getMonth() === 5, "date.getMonth() = " + date.getMonth());
2146 ok(date.getDate() === 9, "date.getDate() = " + date.getDate());
2147 ok(date.getHours() === 0, "date.getHours() = " + date.getHours());
2148 ok(date.getMinutes() === 11, "date.getMinutes() = " + date.getMinutes());
2149 ok(date.getSeconds() === 4, "date.getSeconds() = " + date.getSeconds());
2150 ok(date.getMilliseconds() === 987, "date.getMilliseconds() = " + date.getMilliseconds());
2152 ok(date.setTime(123) === 123, "date.setTime(123) !== 123");
2153 ok(date.setTime("123", NaN) === 123, "date.setTime(\"123\") !== 123");
2154 ok(isNaN(date.setTime(NaN)), "date.setTime(NaN) is not NaN");
2156 ok(date.setTime(0) === date.getTime(), "date.setTime(0) !== date.getTime()");
2157 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
2158 ok(date.getUTCMonth() === 0, "date.getUTCMonth() = " + date.getUTCMonth());
2159 ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
2160 ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
2161 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
2162 ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
2163 ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
2164 ok(date.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
2166 date.setTime(60*24*60*60*1000);
2167 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
2168 ok(date.getUTCMonth() === 2, "date.getUTCMonth() = " + date.getUTCMonth());
2169 ok(date.getUTCDate() === 2, "date.getUTCDate() = " + date.getUTCDate());
2170 ok(date.getUTCDay() === 1, "date.getUTCDay() = " + date.getUTCDay());
2171 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
2172 ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
2173 ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
2174 ok(date.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
2176 date.setTime(59*24*60*60*1000 + 4*365*24*60*60*1000 + 60*60*1000 + 2*60*1000 + 2*1000 + 640);
2177 ok(date.getUTCFullYear() === 1974, "date.getUTCFullYear() = " + date.getUTCFullYear());
2178 ok(date.getUTCMonth() === 1, "date.getUTCMonth() = " + date.getUTCMonth());
2179 ok(date.getUTCMonth(123) === 1, "date.getUTCMonth() = " + date.getUTCMonth());
2180 ok(date.getUTCDate() === 28, "date.getUTCDate() = " + date.getUTCDate());
2181 ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
2182 ok(date.getUTCHours() === 1, "date.getUTCHours() = " + date.getUTCHours());
2183 ok(date.getUTCMinutes() === 2, "date.getUTCMinutes() = " + date.getUTCMinutes());
2184 ok(date.getUTCSeconds() === 2, "date.getUTCSeconds() = " + date.getUTCSeconds());
2185 ok(date.getUTCMilliseconds() === 640, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
2187 tmp = date.setYear(96);
2188 ok(date.getYear() === 96, "date.getYear() = " + date.getYear());
2189 ok(date.getFullYear() === 1996, "date.getFullYear() = " + date.getYear());
2190 ok(date.getUTCMonth() === 1, "date.getUTCMonth() = " + date.getUTCMonth());
2191 ok(date.getUTCMonth(123) === 1, "date.getUTCMonth() = " + date.getUTCMonth());
2192 ok(date.getUTCMilliseconds() === 640, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
2194 tmp = date.setYear(2010);
2195 ok(tmp === date.getTime(), "date.setYear(2010) = " + tmp);
2196 ok(date.getYear() === 2010, "date.getYear() = " + date.getYear());
2197 ok(date.getFullYear() === 2010, "date.getFullYear() = " + date.getYear());
2198 ok(date.getUTCMonth() === 1, "date.getUTCMonth() = " + date.getUTCMonth());
2199 ok(date.getUTCMonth(123) === 1, "date.getUTCMonth() = " + date.getUTCMonth());
2200 ok(date.getUTCMilliseconds() === 640, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
2202 date.setTime(Infinity);
2203 ok(isNaN(date.getUTCFullYear()), "date.getUTCFullYear() is not NaN");
2204 ok(isNaN(date.getUTCMonth()), "date.getUTCMonth() is not NaN");
2205 ok(isNaN(date.getUTCDate()), "date.getUTCDate() is not NaN");
2206 ok(isNaN(date.getUTCDay()), "date.getUTCDay() is not NaN");
2207 ok(isNaN(date.getUTCHours()), "date.getUTCHours() is not NaN");
2208 ok(isNaN(date.getUTCMinutes()), "date.getUTCMinutes() is not NaN");
2209 ok(isNaN(date.getUTCSeconds()), "date.getUTCSeconds() is not NaN");
2210 ok(isNaN(date.getUTCMilliseconds()), "date.getUTCMilliseconds() is not NaN");
2211 ok(isNaN(date.setMilliseconds(0)), "date.setMilliseconds() is not NaN");
2214 tmp = date.setYear(NaN);
2215 ok(isNaN(tmp), "date.setYear(NaN) = " + tmp);
2216 ok(isNaN(date.getUTCFullYear()), "date.getUTCFullYear() is not NaN");
2217 ok(isNaN(date.getUTCMonth()), "date.getUTCMonth() is not NaN");
2220 date.setUTCMilliseconds(-10, 2);
2221 ok(date.getUTCMilliseconds() === 990, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
2222 date.setUTCMilliseconds(10);
2223 ok(date.getUTCMilliseconds() === 10, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
2224 date.setUTCSeconds(-10);
2225 ok(date.getUTCSeconds() === 50, "date.getUTCSeconds() = " + date.getUTCSeconds());
2226 date.setUTCMinutes(-10);
2227 ok(date.getUTCMinutes() === 50, "date.getUTCMinutes() = " + date.getUTCMinutes());
2228 date.setUTCHours(-10);
2229 ok(date.getUTCHours() === 14, "date.getUTCHours() = " + date.getUTCHours());
2230 date.setUTCHours(-123);
2231 ok(date.getTime() === -612549990, "date.getTime() = " + date.getTime());
2232 date.setUTCHours(20);
2233 ok(date.getUTCHours() === 20, "date.getUTCHours() = " + date.getUTCHours());
2234 date.setUTCDate(32);
2235 ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
2236 date.setUTCMonth(22, 37);
2237 ok(date.getTime() === 60987050010, "date.getTime() = " + date.getTime());
2238 date.setUTCFullYear(83, 21, 321);
2239 ok(date.getTime() === -59464984149990, "date.getTime() = " + date.getTime());
2240 ok(Math.abs(date) === 59464984149990, "Math.abs(date) = " + Math.abs(date));
2241 ok(getVT(date+1) === "VT_BSTR", "getVT(date+1) = " + getVT(date+1));
2243 ok(isNaN(Date.parse()), "Date.parse() is not NaN");
2244 ok(isNaN(Date.parse("")), "Date.parse(\"\") is not NaN");
2245 ok(isNaN(Date.parse("Jan Jan 20 2009")), "Date.parse(\"Jan Jan 20 2009\") is not NaN");
2246 ok(Date.parse("Jan 20 2009 UTC") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC\") = " + Date.parse("Jan 20 2009 UTC"));
2247 ok(Date.parse("Jan 20 2009 GMT") === 1232409600000, "Date.parse(\"Jan 20 2009 GMT\") = " + Date.parse("Jan 20 2009 GMT"));
2248 ok(Date.parse("Jan 20 2009 UTC-0") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC-0\") = " + Date.parse("Jan 20 2009 UTC-0"));
2249 ok(Date.parse("Jan 20 2009 UTC+0000") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC+0000\") = " + Date.parse("Jan 20 2009 UTC+0000"));
2250 ok(Date.parse("Jan 20 2009 UTC-1") === 1232413200000, "Date.parse(\"Jan 20 2009 UTC-1\") = " + Date.parse("Jan 20 2009 UTC-1"));
2251 ok(Date.parse("Jan 20 2009 UTC+1") === 1232406000000, "Date.parse(\"Jan 20 2009 UTC+1\") = " + Date.parse("Jan 20 2009 UTC+1"));
2252 ok(Date.parse("Ju 13 79 UTC") === 300672000000, "Date.parse(\"Ju 13 79 UTC\") = " + Date.parse("Ju 13 79 UTC"));
2253 ok(Date.parse("12Au91 UTC") === 681955200000, "Date.parse(\"12Au91 UTC\") = " + Date.parse("12Au91 UTC"));
2254 ok(Date.parse("7/02/17 UTC") === -1656806400000, "Date.parse(\"7/02/17 UTC\") = " + Date.parse("7/02/17 UTC"));
2255 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"));
2256 ok(Date.parse("February 31 UTC, 2000 12:31:17 PM") === 952000277000,
2257 "Date.parse(\"February 31 UTC, 2000 12:31:17 PM\") = " + Date.parse("February 31 UTC, 2000 12:31:17 PM"));
2258 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 "));
2259 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"));
2260 ok(Date.parse("1970/01/01") === Date.parse("01/01/1970"), "Date.parse(\"1970/01/01\") = " + Date.parse("1970/01/01"));
2261 ok(Date.parse("71/12/14") === Date.parse("12/14/1971"), "Date.parse(\"71/12/14\") = " + Date.parse("71/12/14"));
2262 ok(Date.parse("Tue, 22 Mar 2016 09:57:55 -0300") === Date.parse("Tue, 22 Mar 2016 09:57:55 GMT-0300"),
2263 "Date.parse(\"Tue, 22 Mar 2016 09:57:55 -0300\") = " + Date.parse("Tue, 22 Mar 2016 09:57:55 -0300"));
2264 ok(Date.parse("Tue, 22 Mar 2016 09:57:55 +0400") === Date.parse("Tue, 22 Mar 2016 09:57:55 UTC+0400"),
2265 "Date.parse(\"Tue, 22 Mar 2016 09:57:55 +0400\") = " + Date.parse("Tue, 22 Mar 2016 09:57:55 +0400"));
2267 tmp = (new Date()).toGMTString();
2268 ok(tmp.indexOf(String.fromCharCode(0)) == -1, "invalid null byte");
2269 tmp = (new Date()).toLocaleDateString();
2270 ok(tmp.indexOf(String.fromCharCode(0)) == -1, "invalid null byte");
2271 tmp = (new Date(1600, 1, 1, 0, 0, 0, 0)).toLocaleDateString();
2272 ok(tmp.indexOf(String.fromCharCode(0)) == -1, "invalid null byte");
2273 tmp = (new Date(1600, 1, 1, 0, 0, 0, 0)).toLocaleString();
2274 ok(tmp.indexOf(String.fromCharCode(0)) == -1, "invalid null byte");
2275 tmp = (new Date()).toLocaleTimeString();
2276 ok(tmp.indexOf(String.fromCharCode(0)) == -1, "invalid null byte");
2277 tmp = (new Date()).toString();
2278 ok(tmp.indexOf(String.fromCharCode(0)) == -1, "invalid null byte");
2279 tmp = (new Date()).toTimeString();
2280 ok(tmp.indexOf(String.fromCharCode(0)) == -1, "invalid null byte");
2281 tmp = (new Date()).toUTCString();
2282 ok(tmp.indexOf(String.fromCharCode(0)) == -1, "invalid null byte");
2284 ok(typeof(Math.PI) === "number", "typeof(Math.PI) = " + typeof(Math.PI));
2285 ok(Math.floor(Math.PI*100) === 314, "Math.PI = " + Math.PI);
2287 ok(Math.floor(Math.PI*100) === 314, "modified Math.PI = " + Math.PI);
2289 ok(typeof(Math.E) === "number", "typeof(Math.E) = " + typeof(Math.E));
2290 ok(Math.floor(Math.E*100) === 271, "Math.E = " + Math.E);
2292 ok(Math.floor(Math.E*100) === 271, "modified Math.E = " + Math.E);
2294 ok(typeof(Math.LOG2E) === "number", "typeof(Math.LOG2E) = " + typeof(Math.LOG2E));
2295 ok(Math.floor(Math.LOG2E*100) === 144, "Math.LOG2E = " + Math.LOG2E);
2296 Math.LOG2E = "test";
2297 ok(Math.floor(Math.LOG2E*100) === 144, "modified Math.LOG2E = " + Math.LOG2E);
2299 ok(typeof(Math.LOG10E) === "number", "typeof(Math.LOG10E) = " + typeof(Math.LOG10E));
2300 ok(Math.floor(Math.LOG10E*100) === 43, "Math.LOG10E = " + Math.LOG10E);
2301 Math.LOG10E = "test";
2302 ok(Math.floor(Math.LOG10E*100) === 43, "modified Math.LOG10E = " + Math.LOG10E);
2304 ok(typeof(Math.LN2) === "number", "typeof(Math.LN2) = " + typeof(Math.LN2));
2305 ok(Math.floor(Math.LN2*100) === 69, "Math.LN2 = " + Math.LN2);
2307 ok(Math.floor(Math.LN2*100) === 69, "modified Math.LN2 = " + Math.LN2);
2309 ok(typeof(Math.LN10) === "number", "typeof(Math.LN10) = " + typeof(Math.LN10));
2310 ok(Math.floor(Math.LN10*100) === 230, "Math.LN10 = " + Math.LN10);
2312 ok(Math.floor(Math.LN10*100) === 230, "modified Math.LN10 = " + Math.LN10);
2314 ok(typeof(Math.SQRT2) === "number", "typeof(Math.SQRT2) = " + typeof(Math.SQRT2));
2315 ok(Math.floor(Math.SQRT2*100) === 141, "Math.SQRT2 = " + Math.SQRT2);
2316 Math.SQRT2 = "test";
2317 ok(Math.floor(Math.SQRT2*100) === 141, "modified Math.SQRT2 = " + Math.SQRT2);
2319 ok(typeof(Math.SQRT1_2) === "number", "typeof(Math.SQRT1_2) = " + typeof(Math.SQRT1_2));
2320 ok(Math.floor(Math.SQRT1_2*100) === 70, "Math.SQRT1_2 = " + Math.SQRT1_2);
2321 Math.SQRT1_2 = "test";
2322 ok(Math.floor(Math.SQRT1_2*100) === 70, "modified Math.SQRT1_2 = " + Math.SQRT1_2);
2324 ok(isNaN.toString() === "\nfunction isNaN() {\n [native code]\n}\n",
2325 "isNaN.toString = '" + isNaN.toString() + "'");
2326 ok(Array.toString() === "\nfunction Array() {\n [native code]\n}\n",
2327 "Array.toString = '" + Array.toString() + "'");
2328 ok(Function.toString() === "\nfunction Function() {\n [native code]\n}\n",
2329 "Function.toString = '" + Function.toString() + "'");
2330 ok(Function.prototype.toString() === "\nfunction prototype() {\n [native code]\n}\n",
2331 "Function.prototype.toString = '" + Function.prototype.toString() + "'");
2332 ok("".substr.toString() === "\nfunction substr() {\n [native code]\n}\n",
2333 "''.substr.toString = '" + "".substr.toString() + "'");
2335 var bool = new Boolean();
2336 ok(bool.toString() === "false", "bool.toString() = " + bool.toString());
2337 var bool = new Boolean("false");
2338 ok(bool.toString() === "true", "bool.toString() = " + bool.toString());
2339 ok(bool.valueOf() === Boolean(1), "bool.valueOf() = " + bool.valueOf());
2340 ok(bool.toLocaleString() === bool.toString(), "bool.toLocaleString() = " + bool.toLocaleString());
2342 ok(ActiveXObject instanceof Function, "ActiveXObject is not instance of Function");
2343 ok(ActiveXObject.prototype instanceof Object, "ActiveXObject.prototype is not instance of Object");
2345 ok(Error.prototype !== TypeError.prototype, "Error.prototype === TypeError.prototype");
2346 ok(RangeError.prototype !== TypeError.prototype, "RangeError.prototype === TypeError.prototype");
2347 ok(Error.prototype.toLocaleString === Object.prototype.toLocaleString,
2348 "Error.prototype.toLocaleString !== Object.prototype.toLocaleString");
2350 ok(err.valueOf === Object.prototype.valueOf, "err.valueOf !== Object.prototype.valueOf");
2351 ok(Error.prototype.name === "Error", "Error.prototype.name = " + Error.prototype.name);
2352 ok(err.name === "Error", "err.name = " + err.name);
2353 EvalError.prototype.message = "test";
2354 ok(EvalError.prototype.message === "test", "EvalError.prototype.message = " + EvalError.prototype.message);
2355 ok(err.toString !== Object.prototype.toString, "err.toString === Object.prototype.toString");
2356 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "Error"), "err.toString() = " + err.toString());
2357 err = new EvalError();
2358 ok(EvalError.prototype.name === "EvalError", "EvalError.prototype.name = " + EvalError.prototype.name);
2359 ok(err.name === "EvalError", "err.name = " + err.name);
2360 ok(err.toString === Error.prototype.toString, "err.toString !== Error.prototype.toString");
2361 ok(err.message === "", "err.message != ''");
2363 ok(err.message === date, "err.message != date");
2364 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "EvalError: "+err.message),
2365 "err.toString() = " + err.toString());
2366 ok(err.toString !== Object.prototype.toString, "err.toString === Object.prototype.toString");
2367 err = new RangeError();
2368 ok(RangeError.prototype.name === "RangeError", "RangeError.prototype.name = " + RangeError.prototype.name);
2369 ok(err.name === "RangeError", "err.name = " + err.name);
2370 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "RangeError"), "err.toString() = " + err.toString());
2371 err = new ReferenceError();
2372 ok(ReferenceError.prototype.name === "ReferenceError", "ReferenceError.prototype.name = " + ReferenceError.prototype.name);
2373 ok(err.name === "ReferenceError", "err.name = " + err.name);
2374 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "ReferenceError"), "err.toString() = " + err.toString());
2375 err = new SyntaxError();
2376 ok(SyntaxError.prototype.name === "SyntaxError", "SyntaxError.prototype.name = " + SyntaxError.prototype.name);
2377 ok(err.name === "SyntaxError", "err.name = " + err.name);
2378 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "SyntaxError"), "err.toString() = " + err.toString());
2379 err = new TypeError();
2380 ok(TypeError.prototype.name === "TypeError", "TypeError.prototype.name = " + TypeError.prototype.name);
2381 ok(err.name === "TypeError", "err.name = " + err.name);
2382 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "TypeError"), "err.toString() = " + err.toString());
2383 err = new URIError();
2384 ok(URIError.prototype.name === "URIError", "URIError.prototype.name = " + URIError.prototype.name);
2385 ok(err.name === "URIError", "err.name = " + err.name);
2386 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "URIError"), "err.toString() = " + err.toString());
2387 err = new Error("message");
2388 ok(err.message === "message", "err.message !== 'message'");
2389 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "Error: message"), "err.toString() = " + err.toString());
2390 err = new Error(123);
2391 ok(err.number === 123, "err.number = " + err.number);
2393 ok(err.number === 254, "err.number = " + err.number);
2394 err = new Error(0, "message");
2395 ok(err.number === 0, "err.number = " + err.number);
2396 ok(err.message === "message", "err.message = " + err.message);
2397 ok(err.description === "message", "err.description = " + err.description);
2399 ok(err.number === 0, "err.number = " + err.number);
2400 ok(err.description === "", "err.description = " + err.description);
2401 err.description = 5;
2402 ok(err.description === 5, "err.description = " + err.description);
2403 ok(err.message === "", "err.message = " + err.message);
2405 ok(err.message === 4, "err.message = " + err.message);
2407 ok(!("number" in Error), "number is in Error");
2410 ok(tmp.hasOwnProperty("toString") === false, "toString property should be inherited");
2411 tmp.toString = function() { return "test"; };
2412 ok(tmp.hasOwnProperty("toString") === true, "toString own property should exist");
2413 ok(tmp.hasOwnProperty("nonExisting") === false, "nonExisting property should not exist");
2415 tmp = Error.prototype.toString.call(tmp);
2416 ok(tmp === "[object Error]", "Error.prototype.toString.call(tmp) = " + tmp);
2418 tmp = function() { return 0; };
2420 ok(tmp.hasOwnProperty("toString") === false, "toString property should be inherited");
2421 ok(tmp.hasOwnProperty("0") === true, "hasOwnProperty(0) returned false");
2422 ok(tmp.hasOwnProperty() === false, "hasOwnProperty() returned true");
2424 ok(Object.prototype.hasOwnProperty.call(testObj) === false, "hasOwnProperty without name returned true");
2426 if(invokeVersion >= 2) {
2429 tmp = Error.prototype.toString.call(obj);
2430 ok(tmp === "test", "Error.prototype.toString.call(obj) = " + tmp);
2434 obj.message = false;
2435 tmp = Error.prototype.toString.call(obj);
2436 ok(tmp === "6: false", "Error.prototype.toString.call(obj) = " + tmp);
2439 obj.message = "test";
2440 tmp = Error.prototype.toString.call(obj);
2441 ok(tmp === "test", "Error.prototype.toString.call(obj) = " + tmp);
2445 obj.message = "test";
2446 tmp = Error.prototype.toString.call(obj);
2447 ok(tmp === "test", "Error.prototype.toString.call(obj) = " + tmp);
2450 tmp = Error.prototype.toString.call(testObj);
2451 ok(tmp === "[object Error]", "Error.prototype.toString.call(testObj) = " + tmp);
2455 ok(err.name === null, "err.name = " + err.name + " expected null");
2456 if(invokeVersion >= 2)
2457 ok(err.toString() === "null", "err.toString() = " + err.toString());
2460 err.message = false;
2461 ok(err.message === false, "err.message = " + err.message + " expected false");
2462 if(invokeVersion >= 2)
2463 ok(err.toString() === "Error: false", "err.toString() = " + err.toString());
2466 err.message = new Object();
2467 err.message.toString = function() { return ""; };
2468 if(invokeVersion >= 2)
2469 ok(err.toString() === "Error", "err.toString() = " + err.toString());
2472 err.message = undefined;
2473 if(invokeVersion >= 2)
2474 ok(err.toString() === "Error", "err.toString() = " + err.toString());
2476 var exception_array = {
2477 E_INVALID_LENGTH: { type: "RangeError", number: -2146823259 },
2479 E_NOT_DATE: { type: "TypeError", number: -2146823282 },
2480 E_NOT_BOOL: { type: "TypeError", number: -2146823278 },
2481 E_ARG_NOT_OPT: { type: "TypeError", number: -2146827839 },
2482 E_NO_PROPERTY: { type: "TypeError", number: -2146827850 },
2483 E_NOT_NUM: { type: "TypeError", number: -2146823287 },
2484 E_INVALID_CALL_ARG: { type: "TypeError", number: -2146828283 },
2485 E_NOT_FUNC: { type: "TypeError", number: -2146823286 },
2486 E_OBJECT_EXPECTED: { type: "TypeError", number: -2146823281 },
2487 E_OBJECT_REQUIRED: { type: "TypeError", number: -2146827864 },
2488 E_UNSUPPORTED_ACTION: { type: "TypeError", number: -2146827843 },
2489 E_REGEXP_EXPECTED: { type: "TypeError", number: -2146823272 },
2490 E_NOT_ENUMERATOR: { type: "TypeError", number: -2146823273 },
2491 E_NOT_VBARRAY: { type: "TypeError", number: -2146823275 },
2492 E_INVALID_DELETE: { type: "TypeError", number: -2146823276 },
2493 E_UNDEFINED: { type: "TypeError", number: -2146823279 },
2494 E_JSCRIPT_EXPECTED: { type: "TypeError", number: -2146823274 },
2495 E_NOT_ARRAY: { type: "TypeError", number: -2146823257 },
2497 E_SYNTAX_ERROR: { type: "SyntaxError", number: -2146827286 },
2498 E_LBRACKET: { type: "SyntaxError", number: -2146827283 },
2499 E_RBRACKET: { type: "SyntaxError", number: -2146827282 },
2500 E_SEMICOLON: { type: "SyntaxError", number: -2146827284 },
2501 E_UNTERMINATED_STR: { type: "SyntaxError", number: -2146827273 },
2502 E_DISABLED_CC: { type: "SyntaxError", number: -2146827258 },
2503 E_INVALID_BREAK: { type: "SyntaxError", number: -2146827269 },
2504 E_INVALID_CONTINUE: { type: "SyntaxError", number: -2146827268 },
2505 E_LABEL_NOT_FOUND: { type: "SyntaxError", number: -2146827262 },
2506 E_LABEL_REDEFINED: { type: "SyntaxError", number: -2146827263 },
2507 E_MISPLACED_RETURN: { type: "SyntaxError", number: -2146827270 },
2509 E_ILLEGAL_ASSIGN: { type: "ReferenceError", number: -2146823280 },
2511 E_PRECISION_OUT_OF_RANGE: {type: "RangeError", number: -2146823261 },
2512 E_FRACTION_DIGITS_OUT_OF_RANGE: {type: "RangeError", number: -2146823262 },
2513 E_SUBSCRIPT_OUT_OF_RANGE: {type: "RangeError", number: -2146828279 },
2515 E_REGEXP_SYNTAX_ERROR: { type: "RegExpError", number: -2146823271 },
2517 E_URI_INVALID_CHAR: { type: "URIError", number: -2146823264 },
2518 E_URI_INVALID_CODING: { type: "URIError", number: -2146823263 },
2520 E_STACK_OVERFLOW: { type: "Error", number: -2146828260 }
2523 function testException(func, id) {
2524 var ex = exception_array[id];
2525 var ret = "", num = "";
2534 ok(ret === ex.type, "Exception test, ret = " + ret + ", expected " + ex.type +". Executed function: " + func.toString());
2535 ok(num === ex.number, "Exception test, num = " + num + " (" + (num + 0x80000000).toString(16) + "), expected " + ex.number
2536 + ". Executed function: " + func.toString());
2540 testException(function() {Array(-3);}, "E_INVALID_LENGTH");
2541 testException(function() {createArray().lbound("aaa");}, "E_SUBSCRIPT_OUT_OF_RANGE");
2542 testException(function() {createArray().lbound(3);}, "E_SUBSCRIPT_OUT_OF_RANGE");
2543 testException(function() {createArray().getItem(3);}, "E_SUBSCRIPT_OUT_OF_RANGE");
2546 testException(function() {date.setTime();}, "E_ARG_NOT_OPT");
2547 testException(function() {date.setYear();}, "E_ARG_NOT_OPT");
2548 testException(function() {arr.test();}, "E_NO_PROPERTY");
2549 testException(function() {Number.prototype.toString.call(arr);}, "E_NOT_NUM");
2550 testException(function() {Number.prototype.toFixed.call(arr);}, "E_NOT_NUM");
2551 testException(function() {(new Number(3)).toString(1);}, "E_INVALID_CALL_ARG");
2552 testException(function() {(new Number(3)).toFixed(21);}, "E_FRACTION_DIGITS_OUT_OF_RANGE");
2553 testException(function() {(new Number(1)).toPrecision(0);}, "E_PRECISION_OUT_OF_RANGE");
2554 testException(function() {not_existing_variable.something();}, "E_UNDEFINED");
2555 testException(function() {date();}, "E_NOT_FUNC");
2556 testException(function() {arr();}, "E_NOT_FUNC");
2557 testException(function() {(new Object) instanceof (new Object);}, "E_NOT_FUNC");
2558 testException(function() {eval("nonexistingfunc()")}, "E_OBJECT_EXPECTED");
2559 testException(function() {(new Object()) instanceof 3;}, "E_NOT_FUNC");
2560 testException(function() {(new Object()) instanceof null;}, "E_NOT_FUNC");
2561 testException(function() {(new Object()) instanceof nullDisp;}, "E_NOT_FUNC");
2562 testException(function() {"test" in 3;}, "E_OBJECT_EXPECTED");
2563 testException(function() {"test" in null;}, "E_OBJECT_EXPECTED");
2564 testException(function() {"test" in nullDisp;}, "E_OBJECT_EXPECTED");
2565 testException(function() {new 3;}, "E_UNSUPPORTED_ACTION");
2566 testException(function() {new null;}, "E_OBJECT_EXPECTED");
2567 testException(function() {new nullDisp;}, "E_NO_PROPERTY");
2568 testException(function() {new VBArray();}, "E_NOT_VBARRAY");
2569 testException(function() {new VBArray(new VBArray(createArray()));}, "E_NOT_VBARRAY");
2570 testException(function() {VBArray.prototype.lbound.call(new Object());}, "E_NOT_VBARRAY");
2571 testException(function() {+nullDisp.prop;}, "E_OBJECT_REQUIRED");
2572 testException(function() {+nullDisp["prop"];}, "E_OBJECT_REQUIRED");
2573 testException(function() {delete (new Object());}, "E_INVALID_DELETE");
2574 testException(function() {delete false;}, "E_INVALID_DELETE");
2575 testException(function() {undefined.toString();}, "E_OBJECT_EXPECTED");
2576 testException(function() {null.toString();}, "E_OBJECT_EXPECTED");
2577 testException(function() {RegExp.prototype.toString.call(new Object());}, "E_REGEXP_EXPECTED");
2579 testException(function() { return arguments.callee(); }, "E_STACK_OVERFLOW");
2584 testException(function() {delete ((tmp = true) ? obj.prop : obj.prop);}, "E_INVALID_DELETE");
2585 ok(tmp, "delete (..) expression not evaluated");
2587 //FIXME: testException(function() {nonexistent++;}, "E_OBJECT_EXPECTED");
2588 //FIXME: testException(function() {undefined.nonexistent++;}, "E_OBJECT_EXPECTED");
2591 // SyntaxError tests
2592 function testSyntaxError(code, id) {
2593 var ex = exception_array[id];
2594 var ret = "", num = "";
2603 ok(ret === ex.type, "Syntax exception test, ret = " + ret + ", expected " + ex.type +". Executed code: " + code);
2604 ok(num === ex.number, "Syntax exception test, num = " + num + ", expected " + ex.number + ". Executed code: " + code);
2607 testSyntaxError("for(i=0;) {}", "E_SYNTAX_ERROR");
2608 testSyntaxError("function {};", "E_LBRACKET");
2609 testSyntaxError("if", "E_LBRACKET");
2610 testSyntaxError("do i=0; while", "E_LBRACKET");
2611 testSyntaxError("while", "E_LBRACKET");
2612 testSyntaxError("for", "E_LBRACKET");
2613 testSyntaxError("with", "E_LBRACKET");
2614 testSyntaxError("switch", "E_LBRACKET");
2615 testSyntaxError("if(false", "E_RBRACKET");
2616 testSyntaxError("for(i=0; i<10; i++", "E_RBRACKET");
2617 testSyntaxError("while(true", "E_RBRACKET");
2618 testSyntaxError("for(i=0", "E_SEMICOLON");
2619 testSyntaxError("for(i=0;i<10", "E_SEMICOLON");
2620 testSyntaxError("while(", "E_SYNTAX_ERROR");
2621 testSyntaxError("if(", "E_SYNTAX_ERROR");
2622 testSyntaxError("'unterminated", "E_UNTERMINATED_STR");
2623 testSyntaxError("*", "E_SYNTAX_ERROR");
2624 testSyntaxError("@_jscript_version", "E_DISABLED_CC");
2625 testSyntaxError("@a", "E_DISABLED_CC");
2626 testSyntaxError("/* @cc_on @*/ @_jscript_version", "E_DISABLED_CC");
2627 testSyntaxError("ok(false, 'unexpected execution'); break;", "E_INVALID_BREAK");
2628 testSyntaxError("ok(false, 'unexpected execution'); continue;", "E_INVALID_CONTINUE");
2629 testSyntaxError("ok(false, 'unexpected execution'); while(true) break unknown_label;", "E_LABEL_NOT_FOUND");
2630 testSyntaxError("ok(false, 'unexpected execution'); some_label: continue some_label;", "E_INVALID_CONTINUE");
2631 testSyntaxError("ok(false, 'unexpected execution'); while(true) continue some_label;", "E_LABEL_NOT_FOUND");
2632 testSyntaxError("ok(false, 'unexpected execution'); some_label: { while(true) continue some_label; }", "E_INVALID_CONTINUE");
2633 testSyntaxError("ok(false, 'unexpected execution'); some_label: { some_label: while(true); }", "E_LABEL_REDEFINED");
2634 testSyntaxError("return;", "E_MISPLACED_RETURN");
2635 testSyntaxError("001.5;", "E_SEMICOLON");
2636 testSyntaxError("001.5", "E_SEMICOLON");
2637 testSyntaxError("0a", "E_SEMICOLON");
2638 testSyntaxError("01a", "E_SEMICOLON");
2639 testSyntaxError("0x1r", "E_SEMICOLON");
2640 testSyntaxError("1a", "E_SEMICOLON");
2641 testSyntaxError("1_", "E_SEMICOLON");
2643 // ReferenceError tests
2644 testException(function() {test = function() {}}, "E_ILLEGAL_ASSIGN");
2647 testException(function() {test = (tmp = true);}, "E_ILLEGAL_ASSIGN");
2648 ok(tmp, "expr value on invalid assign not evaluated");
2651 testException(function() {(tmp = true) = false;}, "E_ILLEGAL_ASSIGN");
2652 ok(tmp, "expr assign not evaluated");
2655 testException(function() {true = (tmp = true);}, "E_ILLEGAL_ASSIGN");
2656 ok(tmp, "expr value assign not evaluated");
2659 testException(function() {(tmp = tmp+"1") = (tmp = tmp+"2");}, "E_ILLEGAL_ASSIGN");
2660 ok(tmp === "12", "assign evaluated in unexpected order");
2663 testException(function() { ((tmp = true) && false)++; }, "E_ILLEGAL_ASSIGN")
2664 ok(tmp, "incremented expression not evaluated");
2666 // RegExpError tests
2667 testException(function() {RegExp(/a/, "g");}, "E_REGEXP_SYNTAX_ERROR");
2670 testException(function() {encodeURI('\udcaa');}, "E_URI_INVALID_CHAR");
2671 testException(function() {encodeURIComponent('\udcaa');}, "E_URI_INVALID_CHAR");
2672 testException(function() {decodeURI('%');}, "E_URI_INVALID_CODING");
2673 testException(function() {decodeURI('%aaaa');}, "E_URI_INVALID_CODING");
2675 function testThisExcept(func, e) {
2676 testException(function() {func.call(new Object())}, e);
2679 function testBoolThis(func) {
2680 testThisExcept(Boolean.prototype[func], "E_NOT_BOOL");
2683 testBoolThis("toString");
2684 testBoolThis("valueOf");
2686 function testDateThis(func) {
2687 testThisExcept(Date.prototype[func], "E_NOT_DATE");
2690 testDateThis("getDate");
2691 testDateThis("getDay");
2692 testDateThis("getFullYear");
2693 testDateThis("getHours");
2694 testDateThis("getMilliseconds");
2695 testDateThis("getMinutes");
2696 testDateThis("getMonth");
2697 testDateThis("getSeconds");
2698 testDateThis("getTime");
2699 testDateThis("getTimezoneOffset");
2700 testDateThis("getUTCDate");
2701 testDateThis("getUTCDay");
2702 testDateThis("getUTCFullYear");
2703 testDateThis("getUTCHours");
2704 testDateThis("getUTCMilliseconds");
2705 testDateThis("getUTCMinutes");
2706 testDateThis("getUTCMonth");
2707 testDateThis("getUTCSeconds");
2708 testDateThis("getYear");
2709 testDateThis("setDate");
2710 testDateThis("setFullYear");
2711 testDateThis("setHours");
2712 testDateThis("setMilliseconds");
2713 testDateThis("setMinutes");
2714 testDateThis("setMonth");
2715 testDateThis("setSeconds");
2716 testDateThis("setTime");
2717 testDateThis("setUTCDate");
2718 testDateThis("setUTCFullYear");
2719 testDateThis("setUTCHours");
2720 testDateThis("setUTCMilliseconds");
2721 testDateThis("setUTCMinutes");
2722 testDateThis("setUTCMonth");
2723 testDateThis("setUTCSeconds");
2724 testDateThis("setYear");
2725 testDateThis("toDateString");
2726 testDateThis("toLocaleDateString");
2727 testDateThis("toLocaleString");
2728 testDateThis("toLocaleTimeString");
2729 testDateThis("toString");
2730 testDateThis("toTimeString");
2731 testDateThis("toUTCString");
2732 testDateThis("valueOf");
2734 function testArrayThis(func) {
2735 testThisExcept(Array.prototype[func], "E_NOT_ARRAY");
2738 testArrayThis("toString");
2740 function testFunctionThis(func) {
2741 testThisExcept(Function.prototype[func], "E_NOT_FUNC");
2744 testFunctionThis("toString");
2745 testFunctionThis("call");
2746 testFunctionThis("apply");
2748 function testArrayHostThis(func) {
2749 testException(function() { Array.prototype[func].call(testObj); }, "E_JSCRIPT_EXPECTED");
2752 testArrayHostThis("push");
2753 testArrayHostThis("shift");
2754 testArrayHostThis("slice");
2755 testArrayHostThis("splice");
2756 testArrayHostThis("unshift");
2757 testArrayHostThis("reverse");
2758 testArrayHostThis("join");
2759 testArrayHostThis("pop");
2760 testArrayHostThis("sort");
2762 function testEnumeratorThis(func) {
2763 testThisExcept(Enumerator.prototype[func], "E_NOT_ENUMERATOR");
2766 testEnumeratorThis("atEnd");
2767 testEnumeratorThis("item");
2768 testEnumeratorThis("moveFirst");
2769 testEnumeratorThis("moveNext");
2771 function testObjectInherit(obj, constr, ts, tls, vo) {
2772 ok(obj instanceof Object, "obj is not instance of Object");
2773 ok(obj instanceof constr, "obj is not instance of its constructor");
2775 ok(obj.hasOwnProperty === Object.prototype.hasOwnProperty,
2776 "obj.hasOwnProperty !== Object.prototype.hasOwnProprty");
2777 ok(obj.isPrototypeOf === Object.prototype.isPrototypeOf,
2778 "obj.isPrototypeOf !== Object.prototype.isPrototypeOf");
2779 ok(obj.propertyIsEnumerable === Object.prototype.propertyIsEnumerable,
2780 "obj.propertyIsEnumerable !== Object.prototype.propertyIsEnumerable");
2783 ok(obj.toString === Object.prototype.toString,
2784 "obj.toString !== Object.prototype.toString");
2786 ok(obj.toString != Object.prototype.toString,
2787 "obj.toString == Object.prototype.toString");
2790 ok(obj.toLocaleString === Object.prototype.toLocaleString,
2791 "obj.toLocaleString !== Object.prototype.toLocaleString");
2793 ok(obj.toLocaleString != Object.prototype.toLocaleString,
2794 "obj.toLocaleString == Object.prototype.toLocaleString");
2797 ok(obj.valueOf === Object.prototype.valueOf,
2798 "obj.valueOf !== Object.prototype.valueOf");
2800 ok(obj.valueOf != Object.prototype.valueOf,
2801 "obj.valueOf == Object.prototype.valueOf");
2803 ok(obj._test === "test", "obj.test = " + obj._test);
2806 Object.prototype._test = "test";
2807 testObjectInherit(new String("test"), String, false, true, false);
2808 testObjectInherit(/test/g, RegExp, false, true, true);
2809 testObjectInherit(new Number(1), Number, false, false, false);
2810 testObjectInherit(new Date(), Date, false, false, false);
2811 testObjectInherit(new Boolean(true), Boolean, false, true, false);
2812 testObjectInherit(new Array(), Array, false, false, true);
2813 testObjectInherit(new Error(), Error, false, true, true);
2814 testObjectInherit(testObjectInherit, Function, false, true, true);
2815 testObjectInherit(Math, Object, true, true, true);
2817 (function() { testObjectInherit(arguments, Object, true, true, true); })();
2819 function testFunctions(obj, arr) {
2822 for(var i=0; i<arr.length; i++) {
2823 l = obj[arr[i][0]].length;
2824 ok(l === arr[i][1], arr[i][0] + ".length = " + l);
2826 ok(obj.propertyIsEnumerable(arr[i][0]) === false, arr[i][0] + " is enumerable");
2830 testFunctions(Boolean.prototype, [
2835 testFunctions(Number.prototype, [
2838 ["toExponential", 1],
2839 ["toLocaleString", 0],
2843 testFunctions(String.prototype, [
2860 ["localeCompare", 1],
2872 ["toLocaleLowerCase", 0],
2873 ["toLocaleUpperCase", 0],
2878 testFunctions(RegExp.prototype, [
2884 testFunctions(Date.prototype, [
2889 ["getMilliseconds", 0],
2894 ["getTimezoneOffset", 0],
2897 ["getUTCFullYear", 0],
2899 ["getUTCMilliseconds", 0],
2900 ["getUTCMinutes", 0],
2902 ["getUTCSeconds", 0],
2907 ["setMilliseconds", 1],
2913 ["setUTCFullYear", 3],
2915 ["setUTCMilliseconds", 1],
2916 ["setUTCMinutes", 3],
2918 ["setUTCSeconds", 2],
2920 ["toDateString", 0],
2921 ["toLocaleDateString", 0],
2922 ["toLocaleString", 0],
2923 ["toLocaleTimeString", 0],
2925 ["toTimeString", 0],
2931 testFunctions(Array.prototype, [
2941 ["toLocaleString", 0],
2946 testFunctions(Error.prototype, [
2950 testFunctions(Math, [
2971 testFunctions(Object.prototype, [
2972 ["hasOwnProperty", 1],
2973 ["isPrototypeOf", 1],
2974 ["propertyIsEnumerable", 1],
2975 ["toLocaleString", 0],
2980 testFunctions(Function.prototype, [
2986 testFunctions(VBArray.prototype, [
2994 if(invokeVersion < 2)
2995 ok(typeof(JSON) === "undefined", "JSON is not undefined");
2997 testFunctions(JSON, [
3002 ok(ActiveXObject.length == 1, "ActiveXObject.length = " + ActiveXObject.length);
3003 ok(Array.length == 1, "Array.length = " + Array.length);
3004 ok(Boolean.length == 1, "Boolean.length = " + Boolean.length);
3005 ok(CollectGarbage.length == 0, "CollectGarbage.length = " + CollectGarbage.length);
3006 ok(Date.length == 7, "Date.length = " + Date.length);
3007 ok(Enumerator.length == 7, "Enumerator.length = " + Enumerator.length);
3008 ok(Error.length == 1, "Error.length = " + Error.length);
3009 ok(EvalError.length == 1, "EvalError.length = " + EvalError.length);
3010 ok(RegExpError.length == 1, "RegExpError.length = " + RegExpError.length);
3011 ok(Function.length == 1, "Function.length = " + Function.length);
3012 ok(GetObject.length == 2, "GetObject.length = " + GetObject.length);
3013 ok(Number.length == 1, "Number.length = " + Number.length);
3014 ok(Object.length == 0, "Object.length = " + Object.length);
3015 ok(RangeError.length == 1, "RangeError.length = " + RangeError.length);
3016 ok(ReferenceError.length == 1, "ReferenceError.length = " + ReferenceError.length);
3017 ok(RegExp.length == 2, "RegExp.length = " + RegExp.length);
3018 ok(ScriptEngine.length == 0, "ScriptEngine.length = " + ScriptEngine.length);
3019 ok(ScriptEngineBuildVersion.length == 0,
3020 "ScriptEngineBuildVersion.length = " + ScriptEngineBuildVersion.length);
3021 ok(ScriptEngineMajorVersion.length == 0,
3022 "ScriptEngineMajorVersion.length = " + ScriptEngineMajorVersion.length);
3023 ok(ScriptEngineMinorVersion.length == 0,
3024 "ScriptEngineMinorVersion.length = " + ScriptEngineMinorVersion.length);
3025 ok(String.length == 1, "String.length = " + String.length);
3026 ok(SyntaxError.length == 1, "SyntaxError.length = " + SyntaxError.length);
3027 ok(TypeError.length == 1, "TypeError.length = " + TypeError.length);
3028 ok(URIError.length == 1, "URIError.length = " + URIError.length);
3029 ok(VBArray.length == 1, "VBArray.length = " + VBArray.length);
3030 ok(decodeURI.length == 1, "decodeURI.length = " + decodeURI.length);
3031 ok(decodeURIComponent.length == 1, "decodeURIComponent.length = " + decodeURIComponent.length);
3032 ok(encodeURI.length == 1, "encodeURI.length = " + encodeURI.length);
3033 ok(encodeURIComponent.length == 1, "encodeURIComponent.length = " + encodeURIComponent.length);
3034 ok(escape.length == 1, "escape.length = " + escape.length);
3035 ok(eval.length == 1, "eval.length = " + eval.length);
3036 ok(isFinite.length == 1, "isFinite.length = " + isFinite.length);
3037 ok(isNaN.length == 1, "isNaN.length = " + isNaN.length);
3038 ok(parseFloat.length == 1, "parseFloat.length = " + parseFloat.length);
3039 ok(parseInt.length == 2, "parseInt.length = " + parseInt.length);
3040 ok(unescape.length == 1, "unescape.length = " + unescape.length);
3043 ok(String.length == 1, "String.length = " + String.length);
3045 var tmp = createArray();
3046 ok(getVT(tmp) == "VT_ARRAY|VT_VARIANT", "getVT(createArray()) = " + getVT(tmp));
3047 ok(getVT(VBArray(tmp)) == "VT_ARRAY|VT_VARIANT", "getVT(VBArray(tmp)) = " + getVT(VBArray(tmp)));
3048 tmp = new VBArray(tmp);
3049 tmp = new VBArray(VBArray(createArray()));
3050 ok(tmp.dimensions() == 2, "tmp.dimensions() = " + tmp.dimensions());
3051 ok(tmp.lbound() == 0, "tmp.lbound() = " + tmp.lbound());
3052 ok(tmp.lbound(1) == 0, "tmp.lbound(1) = " + tmp.lbound(1));
3053 ok(tmp.lbound(2, 1) == 2, "tmp.lbound(2, 1) = " + tmp.lbound(2, 1));
3054 ok(tmp.ubound() == 4, "tmp.ubound() = " + tmp.ubound());
3055 ok(tmp.ubound("2") == 3, "tmp.ubound(\"2\") = " + tmp.ubound("2"));
3056 ok(tmp.getItem(1, 2) == 3, "tmp.getItem(1, 2) = " + tmp.getItem(1, 2));
3057 ok(tmp.getItem(2, 3) == 33, "tmp.getItem(2, 3) = " + tmp.getItem(2, 3));
3058 ok(tmp.getItem(3, 2) == 13, "tmp.getItem(3, 2) = " + tmp.getItem(3, 2));
3059 ok(tmp.toArray() == "2,3,12,13,22,23,32,33,42,43", "tmp.toArray() = " + tmp.toArray());
3060 ok(createArray().toArray() == "2,3,12,13,22,23,32,33,42,43",
3061 "createArray.toArray()=" + createArray().toArray());
3063 obj = new Enumerator();
3064 ok(obj.atEnd(), "atEnd() = " + obj.atEnd());
3066 ok(obj.atEnd(), "atEnd() = " + obj.atEnd());