2 * Copyright 2008 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 ok(ScriptEngine() === "JScript", "ScriptEngine() = " + ScriptEngine());
22 ok(ScriptEngine(3) === "JScript", "ScriptEngine(3) = " + ScriptEngine(3));
23 ok(ScriptEngineMajorVersion() === ScriptEngineMajorVersion(2), "ScriptEngineMajorVersion() !== ScriptEngineMajorVersion(2)");
24 ok(ScriptEngineMinorVersion() === ScriptEngineMinorVersion(2), "ScriptEngineMinorVersion() !== ScriptEngineMinorVersion(2)");
25 ok(ScriptEngineBuildVersion() === ScriptEngineBuildVersion(2), "ScriptEngineBuildVersion() !== ScriptEngineBuildVersion(2)");
28 ok(i === 0, "parseInt('0') = " + i);
30 ok(i === 123, "parseInt('123') = " + i);
32 ok(i === -123, "parseInt('-123') = " + i);
34 ok(i === 0xff, "parseInt('0xff') = " + i);
35 i = parseInt("11", 8);
36 ok(i === 9, "parseInt('11', 8) = " + i);
37 i = parseInt("1j", 22);
38 ok(i === 41, "parseInt('1j', 32) = " + i);
39 i = parseInt("123", 0);
40 ok(i === 123, "parseInt('123', 0) = " + i);
41 i = parseInt("123", 10, "test");
42 ok(i === 123, "parseInt('123', 10, 'test') = " + i);
43 i = parseInt("11", "8");
44 ok(i === 9, "parseInt('11', '8') = " + i);
46 ok(i === 8, "parseInt('010') = " + i);
48 ok(isNaN(i), "parseInt('') = " + i);
50 ok(isNaN(i), "parseInt('0x') = " + i);
52 ok(isNaN(i), "parseInt('+') = " + i);
54 ok(isNaN(i), "parseInt('-') = " + i);
55 i = parseInt("0x10", 11);
56 ok(i === 0, "parseInt('0x10', 11) = " + i);
57 i = parseInt("010", 7);
58 ok(i === 7, "parseInt('010', 7) = " + i);
59 i = parseInt("123abc");
60 ok(i === 123, "parseInt('123abc') = " + i);
61 i = parseInt(" \t123abc");
62 ok(i === 123, "parseInt(' \\t123abc') = " + i);
64 ok(isNaN(i), "parseInt('123abc') = " + i);
65 i = parseInt("-12", 11);
66 ok(i === -13, "parseInt('-12') = " + i);
67 i = parseInt("-0x10");
68 ok(i === -16, "parseInt('-0x10') = " + i);
70 ok(i === -8, "parseInt('-010') = " + i);
71 i = parseInt("123", 0);
72 ok(i === 123, "parseInt('123', 0) = " + i);
73 i = parseInt("0x10", 0);
74 ok(i === 16, "parseInt('123', 0) = " + i);
75 i = parseInt("0x10", 10);
76 ok(i === 0, "parseInt('0x10', 10) = " + i);
78 ok(isNaN(i), "parseInt('0xz') = " + i);
80 ok(isNaN(i), "parseInt('1', 1) = " + i);
81 i = parseInt("1", -1);
82 ok(isNaN(i), "parseInt('1', -1) = " + i);
83 i = parseInt("1", 37);
84 ok(isNaN(i), "parseInt('1', 37) = " + i);
85 i = parseInt("1", 36);
86 ok(i === 1, "parseInt('1', 36) = " + i);
88 tmp = encodeURI("abc");
89 ok(tmp === "abc", "encodeURI('abc') = " + tmp);
90 tmp = encodeURI("{abc}");
91 ok(tmp === "%7Babc%7D", "encodeURI('{abc}') = " + tmp);
93 ok(tmp === "", "encodeURI('') = " + tmp);
94 tmp = encodeURI("\01\02\03\04");
95 ok(tmp === "%01%02%03%04", "encodeURI('\\01\\02\\03\\04') = " + tmp);
96 tmp = encodeURI("{#@}");
97 ok(tmp === "%7B#@%7D", "encodeURI('{#@}') = " + tmp);
98 tmp = encodeURI("\xa1 ");
99 ok(tmp === "%C2%A1%20", "encodeURI(\\xa1 ) = " + tmp);
100 tmp = encodeURI("\xffff");
101 ok(tmp.length === 8, "encodeURI('\\xffff').length = " + tmp.length);
102 tmp = encodeURI("abcABC123;/?:@&=+$,-_.!~*'()");
103 ok(tmp === "abcABC123;/?:@&=+$,-_.!~*'()", "encodeURI('abcABC123;/?:@&=+$,-_.!~*'()') = " + tmp);
104 tmp = encodeURI("%");
105 ok(tmp === "%25", "encodeURI('%') = " + tmp);
107 ok(tmp === "undefined", "encodeURI() = " + tmp);
108 tmp = encodeURI("abc", "test");
109 ok(tmp === "abc", "encodeURI('abc') = " + tmp);
111 tmp = decodeURI("abc");
112 ok(tmp === "abc", "decodeURI('abc') = " + tmp);
113 tmp = decodeURI("{abc}");
114 ok(tmp === "{abc}", "decodeURI('{abc}') = " + tmp);
116 ok(tmp === "", "decodeURI('') = " + tmp);
117 tmp = decodeURI("\01\02\03\04");
118 ok(tmp === "\01\02\03\04", "decodeURI('\\01\\02\\03\\04') = " + tmp);
120 ok(tmp === "undefined", "decodeURI() = " + tmp);
121 tmp = decodeURI("abc", "test");
122 ok(tmp === "abc", "decodeURI('abc') = " + tmp);
123 tmp = decodeURI("%7babc%7d");
124 ok(tmp === "{abc}", "decodeURI('%7Babc%7D') = " + tmp);
125 tmp = decodeURI("%01%02%03%04");
126 ok(tmp === "\01\02\03\04", "decodeURI('%01%02%03%04') = " + tmp);
127 tmp = decodeURI("%C2%A1%20");
128 ok(tmp === "\xa1 ", "decodeURI('%C2%A1%20') = " + tmp);
129 tmp = decodeURI("%C3%BFff");
130 ok(tmp.length === 3, "decodeURI('%C3%BFff').length = " + tmp.length);
132 tmp = encodeURIComponent("abc");
133 ok(tmp === "abc", "encodeURIComponent('abc') = " + tmp);
134 dec = decodeURIComponent(tmp);
135 ok(dec === "abc", "decodeURIComponent('" + tmp + "') = " + dec);
136 tmp = encodeURIComponent("{abc}");
137 ok(tmp === "%7Babc%7D", "encodeURIComponent('{abc}') = " + tmp);
138 dec = decodeURIComponent(tmp);
139 ok(dec === "{abc}", "decodeURIComponent('" + tmp + "') = " + dec);
140 tmp = encodeURIComponent("");
141 ok(tmp === "", "encodeURIComponent('') = " + tmp);
142 dec = decodeURIComponent(tmp);
143 ok(dec === "", "decodeURIComponent('" + tmp + "') = " + dec);
144 tmp = encodeURIComponent("\01\02\03\04");
145 ok(tmp === "%01%02%03%04", "encodeURIComponent('\\01\\02\\03\\04') = " + tmp);
146 dec = decodeURIComponent(tmp);
147 ok(dec === "\01\02\03\04", "decodeURIComponent('" + tmp + "') = " + dec);
148 tmp = encodeURIComponent("{#@}");
149 ok(tmp === "%7B%23%40%7D", "encodeURIComponent('{#@}') = " + tmp);
150 dec = decodeURIComponent(tmp);
151 ok(dec === "{#@}", "decodeURIComponent('" + tmp + "') = " + dec);
152 tmp = encodeURIComponent("\xa1 ");
153 ok(tmp === "%C2%A1%20", "encodeURIComponent(\\xa1 ) = " + tmp);
154 dec = decodeURIComponent(tmp);
155 ok(dec === "\xa1 ", "decodeURIComponent('" + tmp + "') = " + dec);
156 tmp = encodeURIComponent("\xffff");
157 ok(tmp.length === 8, "encodeURIComponent('\\xffff').length = " + tmp.length);
158 dec = decodeURIComponent(tmp);
159 ok(dec === "\xffff", "decodeURIComponent('" + tmp + "') = " + dec);
160 tmp = encodeURIComponent("abcABC123;/?:@&=+$,-_.!~*'()");
161 ok(tmp === "abcABC123%3B%2F%3F%3A%40%26%3D%2B%24%2C-_.!~*'()", "encodeURIComponent('abcABC123;/?:@&=+$,-_.!~*'()') = " + tmp);
162 dec = decodeURIComponent(tmp);
163 ok(dec === "abcABC123;/?:@&=+$,-_.!~*'()", "decodeURIComponent('" + tmp + "') = " + dec);
164 tmp = encodeURIComponent();
165 ok(tmp === "undefined", "encodeURIComponent() = " + tmp);
166 tmp = encodeURIComponent("abc", "test");
167 ok(tmp === "abc", "encodeURIComponent('abc') = " + tmp);
168 dec = decodeURIComponent();
169 ok(dec === "undefined", "decodeURIComponent() = " + dec);
170 dec = decodeURIComponent("abc", "test");
171 ok(dec === "abc", "decodeURIComponent('abc') = " + dec);
174 ok(tmp === "abc", "escape('abc') = " + tmp);
176 ok(tmp === "", "escape('') = " + tmp);
177 tmp = escape("a1b c!d+e@*-_+./,");
178 ok(tmp === "a1b%20c%21d+e@*-_+./%2C", "escape('a1b c!d+e@*-_+./,') = " + tmp);
180 ok(tmp === "undefined", "escape() = " + tmp);
181 tmp = escape('\u1234\123\xf3');
182 ok(tmp == "%u1234S%F3", "escape('\u1234\123\xf3') = " + tmp);
184 tmp = unescape("abc");
185 ok(tmp === "abc", "unescape('abc') = " + tmp);
187 ok(tmp === "", "unescape('') = " + tmp);
188 tmp = unescape("%%%");
189 ok(tmp === "%%%", "unescape('%%%') = " + tmp);
191 ok(tmp === "undefined", "unescape() = " + tmp);
192 tmp = unescape("%54%65s%u0074");
193 ok(tmp === "Test", "unescape('%54%65s%u0074') = " + tmp);
195 tmp = "aA1~`!@#$%^&*()_+=-][{}';:/.,<>?\|";
196 ok(escape(tmp) === "aA1%7E%60%21@%23%24%25%5E%26*%28%29_+%3D-%5D%5B%7B%7D%27%3B%3A/.%2C%3C%3E%3F%7C", "escape('" + tmp + "') = " + escape(tmp));
197 ok(unescape(escape(tmp)) === tmp, "unescape(escape('" + tmp + "')) = " + unescape(escape(tmp)));
199 tmp = "" + new Object();
200 ok(tmp === "[object Object]", "'' + new Object() = " + tmp);
201 (tmp = new Array).f = Object.prototype.toString;
202 ok(tmp.f() === "[object Array]", "tmp.f() = " + tmp.f());
203 (tmp = new Boolean).f = Object.prototype.toString;
204 ok(tmp.f() === "[object Boolean]", "tmp.f() = " + tmp.f());
205 (tmp = new Date).f = Object.prototype.toString;
206 ok(tmp.f() === "[object Date]", "tmp.f() = " + tmp.f());
207 (tmp = function() {}).f = Object.prototype.toString;
208 ok(tmp.f() === "[object Function]", "tmp.f() = " + tmp.f());
209 Math.f = Object.prototype.toString;
210 ok(Math.f() === "[object Math]", "tmp.f() = " + tmp.f());
211 (tmp = new Number).f = Object.prototype.toString;
212 ok(tmp.f() === "[object Number]", "tmp.f() = " + tmp.f());
213 (tmp = new RegExp("")).f = Object.prototype.toString;
214 ok(tmp.f() === "[object RegExp]", "tmp.f() = " + tmp.f());
215 (tmp = new String).f = Object.prototype.toString;
216 ok(tmp.f() === "[object String]", "tmp.f() = " + tmp.f());
217 tmp = Object.prototype.toString.call(testObj);
218 ok(tmp === "[object Object]", "toString.call(testObj) = " + tmp);
219 tmp = Object.prototype.toString.call(this);
220 ok(tmp === "[object Object]", "toString.call(this) = " + tmp);
221 (function () { tmp = Object.prototype.toString.call(arguments); })();
222 ok(tmp === "[object Object]", "toString.call(arguments) = " + tmp);
223 tmp = Object.prototype.toString.call(new VBArray(createArray()));
224 ok(tmp === "[object Object]", "toString.call(new VBArray()) = " + tmp);
226 ok(Object(1) instanceof Number, "Object(1) is not instance of Number");
227 ok(Object("") instanceof String, "Object('') is not instance of String");
228 ok(Object(false) instanceof Boolean, "Object(false) is not instance of Boolean");
231 ok(Object(obj) === obj, "Object(obj) !== obj");
233 ok(typeof(Object()) === "object", "typeof(Object()) !== 'object'");
234 ok(typeof(Object(undefined)) === "object", "typeof(Object(undefined)) !== 'object'");
235 ok(typeof(Object(null)) === "object", "typeof(Object(null)) !== 'object'");
237 var obj = new Object();
238 obj.toString = function (x) {
239 ok(arguments.length === 0, "arguments.length = " + arguments.length);
242 ok((tmp = obj.toLocaleString()) === "test", "obj.toLocaleString() = " + tmp);
243 ok((tmp = obj.toLocaleString(1)) === "test", "obj.toLocaleString(1) = " + tmp);
244 ok(obj === obj.valueOf(), "obj !== obj.valueOf");
246 ok("".length === 0, "\"\".length = " + "".length);
247 ok(getVT("".length) == "VT_I4", "\"\".length = " + "".length);
248 ok("abc".length === 3, "\"abc\".length = " + "abc".length);
249 ok(String.prototype.length === 0, "String.prototype.length = " + String.prototype.length);
252 ok(tmp === "", "''.toString() = " + tmp);
253 tmp = "test".toString();
254 ok(tmp === "test", "''.toString() = " + tmp);
255 tmp = "test".toString(3);
256 ok(tmp === "test", "''.toString(3) = " + tmp);
259 ok(tmp === "", "''.valueOf() = " + tmp);
260 tmp = "test".valueOf();
261 ok(tmp === "test", "''.valueOf() = " + tmp);
262 tmp = "test".valueOf(3);
263 ok(tmp === "test", "''.valueOf(3) = " + tmp);
265 var str = new String("test");
266 ok(str.toString() === "test", "str.toString() = " + str.toString());
267 var str = new String();
268 ok(str.toString() === "", "str.toString() = " + str.toString());
269 var str = new String("test", "abc");
270 ok(str.toString() === "test", "str.toString() = " + str.toString());
272 var strObj = new Object();
273 strObj.toString = function() { return "abcd" };
274 strObj.substr = String.prototype.substr;
275 strObj.lastIndexOf = String.prototype.lastIndexOf;
277 tmp = "value " + str;
278 ok(tmp === "value test", "'value ' + str = " + tmp);
281 ok(tmp === "", "String() = " + tmp);
283 ok(tmp === "false", "String(false) = " + tmp);
285 ok(tmp === "null", "String(null) = " + tmp);
286 tmp = String("test");
287 ok(tmp === "test", "String('test') = " + tmp);
288 tmp = String("test", "abc");
289 ok(tmp === "test", "String('test','abc') = " + tmp);
291 tmp = "abc".charAt(0);
292 ok(tmp === "a", "'abc',charAt(0) = " + tmp);
293 tmp = "abc".charAt(1);
294 ok(tmp === "b", "'abc',charAt(1) = " + tmp);
295 tmp = "abc".charAt(2);
296 ok(tmp === "c", "'abc',charAt(2) = " + tmp);
297 tmp = "abc".charAt(3);
298 ok(tmp === "", "'abc',charAt(3) = " + tmp);
299 tmp = "abc".charAt(4);
300 ok(tmp === "", "'abc',charAt(4) = " + tmp);
301 tmp = "abc".charAt();
302 ok(tmp === "a", "'abc',charAt() = " + tmp);
303 tmp = "abc".charAt(-1);
304 ok(tmp === "", "'abc',charAt(-1) = " + tmp);
305 tmp = "abc".charAt(0,2);
306 ok(tmp === "a", "'abc',charAt(0.2) = " + tmp);
307 tmp = "abc".charAt(NaN);
308 ok(tmp === "a", "'abc',charAt(NaN) = " + tmp);
310 tmp = "abc".charCodeAt(0);
311 ok(tmp === 0x61, "'abc'.charCodeAt(0) = " + tmp);
312 tmp = "abc".charCodeAt(1);
313 ok(tmp === 0x62, "'abc'.charCodeAt(1) = " + tmp);
314 tmp = "abc".charCodeAt(2);
315 ok(tmp === 0x63, "'abc'.charCodeAt(2) = " + tmp);
316 tmp = "abc".charCodeAt();
317 ok(tmp === 0x61, "'abc'.charCodeAt() = " + tmp);
318 tmp = "abc".charCodeAt(true);
319 ok(tmp === 0x62, "'abc'.charCodeAt(true) = " + tmp);
320 tmp = "abc".charCodeAt(0,2);
321 ok(tmp === 0x61, "'abc'.charCodeAt(0,2) = " + tmp);
322 tmp = "\u49F4".charCodeAt(0);
323 ok(tmp === 0x49F4, "'\u49F4'.charCodeAt(0) = " + tmp);
324 tmp = "\052".charCodeAt(0);
325 ok(tmp === 0x2A, "'\052'.charCodeAt(0) = " + tmp);
326 tmp = "\xa2".charCodeAt(0);
327 ok(tmp === 0xA2, "'\xa2'.charCodeAt(0) = " + tmp);
329 tmp = "abcd".substring(1,3);
330 ok(tmp === "bc", "'abcd'.substring(1,3) = " + tmp);
331 tmp = "abcd".substring(-1,3);
332 ok(tmp === "abc", "'abcd'.substring(-1,3) = " + tmp);
333 tmp = "abcd".substring(1,6);
334 ok(tmp === "bcd", "'abcd'.substring(1,6) = " + tmp);
335 tmp = "abcd".substring(3,1);
336 ok(tmp === "bc", "'abcd'.substring(3,1) = " + tmp);
337 tmp = "abcd".substring(2,2);
338 ok(tmp === "", "'abcd'.substring(2,2) = " + tmp);
339 tmp = "abcd".substring(true,"3");
340 ok(tmp === "bc", "'abcd'.substring(true,'3') = " + tmp);
341 tmp = "abcd".substring(1,3,2);
342 ok(tmp === "bc", "'abcd'.substring(1,3,2) = " + tmp);
343 tmp = "abcd".substring();
344 ok(tmp === "abcd", "'abcd'.substring() = " + tmp);
346 tmp = "abcd".substr(1,3);
347 ok(tmp === "bcd", "'abcd'.substr(1,3) = " + tmp);
348 tmp = "abcd".substr(-1,3);
349 ok(tmp === "abc", "'abcd'.substr(-1,3) = " + tmp);
350 tmp = "abcd".substr(1,6);
351 ok(tmp === "bcd", "'abcd'.substr(1,6) = " + tmp);
352 tmp = "abcd".substr(2,-1);
353 ok(tmp === "", "'abcd'.substr(3,1) = " + tmp);
354 tmp = "abcd".substr(2,0);
355 ok(tmp === "", "'abcd'.substr(2,2) = " + tmp);
356 tmp = "abcd".substr(true,"3");
357 ok(tmp === "bcd", "'abcd'.substr(true,'3') = " + tmp);
358 tmp = "abcd".substr(1,3,2);
359 ok(tmp === "bcd", "'abcd'.substr(1,3,2) = " + tmp);
360 tmp = "abcd".substr();
361 ok(tmp === "abcd", "'abcd'.substr() = " + tmp);
362 tmp = strObj.substr(1,1);
363 ok(tmp === "b", "'abcd'.substr(1,3) = " + tmp);
365 tmp = "abcd".slice(1,3);
366 ok(tmp === "bc", "'abcd'.slice(1,3) = " + tmp);
367 tmp = "abcd".slice(1,-1);
368 ok(tmp === "bc", "'abcd'.slice(1,-1) = " + tmp);
369 tmp = "abcd".slice(-3,3);
370 ok(tmp === "bc", "'abcd'.slice(-3,3) = " + tmp);
371 tmp = "abcd".slice(-6,3);
372 ok(tmp === "abc", "'abcd'.slice(-6,3) = " + tmp);
373 tmp = "abcd".slice(3,1);
374 ok(tmp === "", "'abcd'.slice(3,1) = " + tmp);
375 tmp = "abcd".slice(true,3);
376 ok(tmp === "bc", "'abcd'.slice(true,3) = " + tmp);
377 tmp = "abcd".slice();
378 ok(tmp === "abcd", "'abcd'.slice() = " + tmp);
379 tmp = "abcd".slice(1);
380 ok(tmp === "bcd", "'abcd'.slice(1) = " + tmp);
382 tmp = "abc".concat(["d",1],2,false);
383 ok(tmp === "abcd,12false", "concat returned " + tmp);
384 var arr = new Array(2,"a");
385 arr.concat = String.prototype.concat;
386 tmp = arr.concat("d");
387 ok(tmp === "2,ad", "arr.concat = " + tmp);
389 m = "a+bcabc".match("a+");
390 ok(typeof(m) === "object", "typeof m is not object");
391 ok(m.length === 1, "m.length is not 1");
392 ok(m["0"] === "a", "m[0] is not \"ab\"");
394 r = "- [test] -".replace("[test]", "success");
395 ok(r === "- success -", "r = " + r + " expected '- success -'");
397 r = "- [test] -".replace("[test]", "success", "test");
398 ok(r === "- success -", "r = " + r + " expected '- success -'");
400 r = "test".replace();
401 ok(r === "test", "r = " + r + " expected 'test'");
403 function replaceFunc3(m, off, str) {
404 ok(arguments.length === 3, "arguments.length = " + arguments.length);
405 ok(m === "[test]", "m = " + m + " expected [test1]");
406 ok(off === 1, "off = " + off + " expected 0");
407 ok(str === "-[test]-", "str = " + arguments[3]);
411 r = "-[test]-".replace("[test]", replaceFunc3);
412 ok(r === "-ret-", "r = " + r + " expected '-ret-'");
414 r = "-[test]-".replace("[test]", replaceFunc3, "test");
415 ok(r === "-ret-", "r = " + r + " expected '-ret-'");
417 r = "x,x,x".replace("x", "y");
418 ok(r === "y,x,x", "r = " + r + " expected 'y,x,x'");
420 r = "x,x,x".replace("", "y");
421 ok(r === "yx,x,x", "r = " + r + " expected 'yx,x,x'");
423 r = "x,x,x".replace("", "");
424 ok(r === "x,x,x", "r = " + r + " expected 'x,x,x'");
426 r = "1,2,3".split(",");
427 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
428 ok(r.length === 3, "r.length = " + r.length);
429 ok(r[0] === "1", "r[0] = " + r[0]);
430 ok(r[1] === "2", "r[1] = " + r[1]);
431 ok(r[2] === "3", "r[2] = " + r[2]);
434 r = "1,2,3".split(",*");
435 ok(r.length === 1, "r.length = " + r.length);
436 ok(r[0] === "1,2,3", "r[0] = " + r[0]);
439 ok(r.length === 3, "r.length = " + r.length);
440 ok(r[0] === "1", "r[0] = " + r[0]);
441 ok(r[1] === "2", "r[1] = " + r[1]);
442 ok(r[2] === "3", "r[2] = " + r[2]);
445 ok(r.length === 2, "r.length = " + r.length);
446 ok(r[0] === "1", "r[0] = " + r[0]);
447 ok(r[1] === "3", "r[1] = " + r[1]);
449 r = "1,2,".split(",");
450 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
451 ok(r.length === 3, "r.length = " + r.length);
452 ok(r[0] === "1", "r[0] = " + r[0]);
453 ok(r[1] === "2", "r[1] = " + r[1]);
454 ok(r[2] === "", "r[2] = " + r[2]);
456 tmp = "abcd".indexOf("bc",0);
457 ok(tmp === 1, "indexOf = " + tmp);
458 tmp = "abcd".indexOf("bc",1);
459 ok(tmp === 1, "indexOf = " + tmp);
460 tmp = "abcd".indexOf("bc");
461 ok(tmp === 1, "indexOf = " + tmp);
462 tmp = "abcd".indexOf("ac");
463 ok(tmp === -1, "indexOf = " + tmp);
464 tmp = "abcd".indexOf("bc",2);
465 ok(tmp === -1, "indexOf = " + tmp);
466 tmp = "abcd".indexOf("a",0);
467 ok(tmp === 0, "indexOf = " + tmp);
468 tmp = "abcd".indexOf("bc",0,"test");
469 ok(tmp === 1, "indexOf = " + tmp);
470 tmp = "abcd".indexOf();
471 ok(tmp == -1, "indexOf = " + tmp);
473 tmp = "abcd".lastIndexOf("bc",1);
474 ok(tmp === 1, "lastIndexOf = " + tmp);
475 tmp = "abcd".lastIndexOf("bc",2);
476 ok(tmp === 1, "lastIndexOf = " + tmp);
477 tmp = "abcd".lastIndexOf("bc");
478 ok(tmp === 1, "lastIndexOf = " + tmp);
479 tmp = "abcd".lastIndexOf("ac");
480 ok(tmp === -1, "lastIndexOf = " + tmp);
481 tmp = "abcd".lastIndexOf("d",10);
482 ok(tmp === 3, "lastIndexOf = " + tmp);
483 tmp = "abcd".lastIndexOf("bc",0,"test");
484 ok(tmp === -1, "lastIndexOf = " + tmp);
485 tmp = "abcd".lastIndexOf();
486 ok(tmp === -1, "lastIndexOf = " + tmp);
487 tmp = "aaaa".lastIndexOf("a",2);
488 ok(tmp == 2, "lastIndexOf = " + tmp);
489 tmp = strObj.lastIndexOf("b");
490 ok(tmp === 1, "lastIndexOf = " + tmp);
492 tmp = "".toLowerCase();
493 ok(tmp === "", "''.toLowerCase() = " + tmp);
494 tmp = "test".toLowerCase();
495 ok(tmp === "test", "''.toLowerCase() = " + tmp);
496 tmp = "test".toLowerCase(3);
497 ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
498 tmp = "tEsT".toLowerCase();
499 ok(tmp === "test", "''.toLowerCase() = " + tmp);
500 tmp = "tEsT".toLowerCase(3);
501 ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
503 tmp = "".toUpperCase();
504 ok(tmp === "", "''.toUpperCase() = " + tmp);
505 tmp = "TEST".toUpperCase();
506 ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
507 tmp = "TEST".toUpperCase(3);
508 ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
509 tmp = "tEsT".toUpperCase();
510 ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
511 tmp = "tEsT".toUpperCase(3);
512 ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
515 ok(tmp === "<A NAME=\"undefined\"></A>", "''.anchor() = " + tmp);
517 ok(tmp === "<A NAME=\"3\"></A>", "''.anchor(3) = " + tmp);
518 tmp = "".anchor("red");
519 ok(tmp === "<A NAME=\"red\"></A>", "''.anchor('red') = " + tmp);
520 tmp = "test".anchor();
521 ok(tmp === "<A NAME=\"undefined\">test</A>", "'test'.anchor() = " + tmp);
522 tmp = "test".anchor(3);
523 ok(tmp === "<A NAME=\"3\">test</A>", "'test'.anchor(3) = " + tmp);
524 tmp = "test".anchor("green");
525 ok(tmp === "<A NAME=\"green\">test</A>", "'test'.anchor('green') = " + tmp);
528 ok(tmp === "<BIG></BIG>", "''.big() = " + tmp);
530 ok(tmp === "<BIG></BIG>", "''.big(3) = " + tmp);
532 ok(tmp === "<BIG>test</BIG>", "'test'.big() = " + tmp);
534 ok(tmp === "<BIG>test</BIG>", "'test'.big(3) = " + tmp);
537 ok(tmp === "<BLINK></BLINK>", "''.blink() = " + tmp);
539 ok(tmp === "<BLINK></BLINK>", "''.blink(3) = " + tmp);
540 tmp = "test".blink();
541 ok(tmp === "<BLINK>test</BLINK>", "'test'.blink() = " + tmp);
542 tmp = "test".blink(3);
543 ok(tmp === "<BLINK>test</BLINK>", "'test'.blink(3) = " + tmp);
546 ok(tmp === "<B></B>", "''.bold() = " + tmp);
548 ok(tmp === "<B></B>", "''.bold(3) = " + tmp);
550 ok(tmp === "<B>test</B>", "'test'.bold() = " + tmp);
551 tmp = "test".bold(3);
552 ok(tmp === "<B>test</B>", "'test'.bold(3) = " + tmp);
555 ok(tmp === "<TT></TT>", "''.fixed() = " + tmp);
557 ok(tmp === "<TT></TT>", "''.fixed(3) = " + tmp);
558 tmp = "test".fixed();
559 ok(tmp === "<TT>test</TT>", "'test'.fixed() = " + tmp);
560 tmp = "test".fixed(3);
561 ok(tmp === "<TT>test</TT>", "'test'.fixed(3) = " + tmp);
563 tmp = "".fontcolor();
564 ok(tmp === "<FONT COLOR=\"undefined\"></FONT>", "''.fontcolor() = " + tmp);
565 tmp = "".fontcolor(3);
566 ok(tmp === "<FONT COLOR=\"3\"></FONT>", "''.fontcolor(3) = " + tmp);
567 tmp = "".fontcolor("red");
568 ok(tmp === "<FONT COLOR=\"red\"></FONT>", "''.fontcolor('red') = " + tmp);
569 tmp = "test".fontcolor();
570 ok(tmp === "<FONT COLOR=\"undefined\">test</FONT>", "'test'.fontcolor() = " + tmp);
571 tmp = "test".fontcolor(3);
572 ok(tmp === "<FONT COLOR=\"3\">test</FONT>", "'test'.fontcolor(3) = " + tmp);
573 tmp = "test".fontcolor("green");
574 ok(tmp === "<FONT COLOR=\"green\">test</FONT>", "'test'.fontcolor('green') = " + tmp);
577 ok(tmp === "<FONT SIZE=\"undefined\"></FONT>", "''.fontsize() = " + tmp);
578 tmp = "".fontsize(3);
579 ok(tmp === "<FONT SIZE=\"3\"></FONT>", "''.fontsize(3) = " + tmp);
580 tmp = "".fontsize("red");
581 ok(tmp === "<FONT SIZE=\"red\"></FONT>", "''.fontsize('red') = " + tmp);
582 tmp = "test".fontsize();
583 ok(tmp === "<FONT SIZE=\"undefined\">test</FONT>", "'test'.fontsize() = " + tmp);
584 tmp = "test".fontsize(3);
585 ok(tmp === "<FONT SIZE=\"3\">test</FONT>", "'test'.fontsize(3) = " + tmp);
586 tmp = "test".fontsize("green");
587 ok(tmp === "<FONT SIZE=\"green\">test</FONT>", "'test'.fontsize('green') = " + tmp);
589 tmp = ("".fontcolor()).fontsize();
590 ok(tmp === "<FONT SIZE=\"undefined\"><FONT COLOR=\"undefined\"></FONT></FONT>", "(''.fontcolor()).fontsize() = " + tmp);
593 ok(tmp === "<I></I>", "''.italics() = " + tmp);
595 ok(tmp === "<I></I>", "''.italics(3) = " + tmp);
596 tmp = "test".italics();
597 ok(tmp === "<I>test</I>", "'test'.italics() = " + tmp);
598 tmp = "test".italics(3);
599 ok(tmp === "<I>test</I>", "'test'.italics(3) = " + tmp);
602 ok(tmp === "<A HREF=\"undefined\"></A>", "''.link() = " + tmp);
604 ok(tmp === "<A HREF=\"3\"></A>", "''.link(3) = " + tmp);
605 tmp = "".link("red");
606 ok(tmp === "<A HREF=\"red\"></A>", "''.link('red') = " + tmp);
608 ok(tmp === "<A HREF=\"undefined\">test</A>", "'test'.link() = " + tmp);
609 tmp = "test".link(3);
610 ok(tmp === "<A HREF=\"3\">test</A>", "'test'.link(3) = " + tmp);
611 tmp = "test".link("green");
612 ok(tmp === "<A HREF=\"green\">test</A>", "'test'.link('green') = " + tmp);
615 ok(tmp === "<SMALL></SMALL>", "''.small() = " + tmp);
617 ok(tmp === "<SMALL></SMALL>", "''.small(3) = " + tmp);
618 tmp = "test".small();
619 ok(tmp === "<SMALL>test</SMALL>", "'test'.small() = " + tmp);
620 tmp = "test".small(3);
621 ok(tmp === "<SMALL>test</SMALL>", "'test'.small(3) = " + tmp);
624 ok(tmp === "<STRIKE></STRIKE>", "''.strike() = " + tmp);
626 ok(tmp === "<STRIKE></STRIKE>", "''.strike(3) = " + tmp);
627 tmp = "test".strike();
628 ok(tmp === "<STRIKE>test</STRIKE>", "'test'.strike() = " + tmp);
629 tmp = "test".strike(3);
630 ok(tmp === "<STRIKE>test</STRIKE>", "'test'.strike(3) = " + tmp);
633 ok(tmp === "<SUB></SUB>", "''.sub() = " + tmp);
635 ok(tmp === "<SUB></SUB>", "''.sub(3) = " + tmp);
637 ok(tmp === "<SUB>test</SUB>", "'test'.sub() = " + tmp);
639 ok(tmp === "<SUB>test</SUB>", "'test'.sub(3) = " + tmp);
642 ok(tmp === "<SUP></SUP>", "''.sup() = " + tmp);
644 ok(tmp === "<SUP></SUP>", "''.sup(3) = " + tmp);
646 ok(tmp === "<SUP>test</SUP>", "'test'.sup() = " + tmp);
648 ok(tmp === "<SUP>test</SUP>", "'test'.sup(3) = " + tmp);
650 ok(String.fromCharCode() === "", "String.fromCharCode() = " + String.fromCharCode());
651 ok(String.fromCharCode(65,"66",67) === "ABC", "String.fromCharCode(65,'66',67) = " + String.fromCharCode(65,"66",67));
652 ok(String.fromCharCode(1024*64+65, -1024*64+65) === "AA",
653 "String.fromCharCode(1024*64+65, -1024*64+65) = " + String.fromCharCode(1024*64+65, -1024*64+65));
654 ok(String.fromCharCode(65, NaN, undefined).length === 3,
655 "String.fromCharCode(65, NaN, undefined).length = " + String.fromCharCode(65, NaN, undefined).length);
657 var arr = new Array();
658 ok(typeof(arr) === "object", "arr () is not object");
659 ok((arr.length === 0), "arr.length is not 0");
660 ok(arr["0"] === undefined, "arr[0] is not undefined");
662 var arr = new Array(1, 2, "test");
663 ok(typeof(arr) === "object", "arr (1,2,test) is not object");
664 ok((arr.length === 3), "arr.length is not 3");
665 ok(arr["0"] === 1, "arr[0] is not 1");
666 ok(arr["1"] === 2, "arr[1] is not 2");
667 ok(arr["2"] === "test", "arr[2] is not \"test\"");
670 ok((arr.length === 8), "arr.length is not 8");
673 ok(tmp === "", "'' + [] = " + tmp);
675 ok(tmp === "1,true", "'' + [1,true] = " + tmp);
677 var arr = new Array(6);
678 ok(typeof(arr) === "object", "arr (6) is not object");
679 ok((arr.length === 6), "arr.length is not 6");
680 ok(arr["0"] === undefined, "arr[0] is not undefined");
682 ok(arr.push() === 6, "arr.push() !== 6");
683 ok(arr.push(1) === 7, "arr.push(1) !== 7");
684 ok(arr[6] === 1, "arr[6] != 1");
685 ok(arr.length === 7, "arr.length != 10");
686 ok(arr.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10");
687 ok(arr[8] === "b", "arr[8] != 'b'");
688 ok(arr.length === 10, "arr.length != 10");
690 var arr = new Object();
691 arr.push = Array.prototype.push;
695 ok(arr.push() === 6, "arr.push() !== 6");
696 ok(arr.push(1) === 7, "arr.push(1) !== 7");
697 ok(arr[6] === 1, "arr[6] != 1");
698 ok(arr.length === 7, "arr.length != 10");
699 ok(arr.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10");
700 ok(arr[8] === "b", "arr[8] != 'b'");
701 ok(arr.length === 10, "arr.length != 10");
703 arr.pop = Array.prototype.pop;
704 ok(arr.pop() === false, "arr.pop() !== false");
705 ok(arr[8] === "b", "arr[8] !== 'b'");
706 ok(arr.pop() === 'b', "arr.pop() !== 'b'");
707 ok(arr[8] === undefined, "arr[8] !== undefined");
711 ok(arr.length === 2, "arr.length = " + arr.length);
712 ok(tmp === 5, "pop() = " + tmp);
714 ok(arr.length === 1, "arr.length = " + arr.length);
715 ok(tmp === 4, "pop() = " + tmp);
717 ok(arr.length === 0, "arr.length = " + arr.length);
718 ok(tmp === 3, "pop() = " + tmp);
720 ok(false, "not deleted " + tmp);
722 ok(arr.length === 0, "arr.length = " + arr.length);
723 ok(tmp === undefined, "tmp = " + tmp);
725 arr.pop = Array.prototype.pop;
727 ok(arr.length === 0, "arr.length = " + arr.length);
728 ok(tmp === undefined, "tmp = " + tmp);
731 ok(arr.length === 5, "arr.length = " + arr.length);
732 ok(tmp === undefined, "tmp = " + tmp);
734 arr = [1,2,null,false,undefined,,"a"];
737 ok(tmp === "1,2,,false,,,a", "arr.join() = " + tmp);
739 ok(tmp === "1;2;;false;;;a", "arr.join(';') = " + tmp);
740 tmp = arr.join(";","test");
741 ok(tmp === "1;2;;false;;;a", "arr.join(';') = " + tmp);
743 ok(tmp === "12falsea", "arr.join('') = " + tmp);
745 tmp = arr.toString();
746 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
747 tmp = arr.toString("test");
748 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
755 arr.join = Array.prototype.join;
757 ok(arr.length === 3, "arr.length = " + arr.length);
758 ok(tmp === "aa,,2", "tmp = " + tmp);
760 arr = [5,true,2,-1,3,false,"2.5"];
761 tmp = arr.sort(function(x,y) { return y-x; });
762 ok(tmp === arr, "tmp !== arr");
763 tmp = [5,3,"2.5",2,true,false,-1];
764 for(var i=0; i < arr.length; i++)
765 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
767 arr = [5,false,2,0,"abc",3,"a",-1];
769 ok(tmp === arr, "tmp !== arr");
770 tmp = [-1,0,2,3,5,"a","abc",false];
771 for(var i=0; i < arr.length; i++)
772 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
774 arr = ["a", "b", "ab"];
775 tmp = ["a", "ab", "b"];
776 ok(arr.sort() === arr, "arr.sort() !== arr");
777 for(var i=0; i < arr.length; i++)
778 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
784 arr.sort = Array.prototype.sort;
786 ok(arr === tmp, "tmp !== arr");
787 ok(arr[0]===1 && arr[1]==="aa" && arr[2]===undefined, "arr is sorted incorrectly");
789 tmp = [["bb","aa"],["ab","aa"]].sort().toString();
790 ok(tmp === "ab,aa,bb,aa", "sort() = " + tmp);
792 tmp = [["bb","aa"],"ab"].sort().toString();
793 ok(tmp === "ab,bb,aa", "sort() = " + tmp);
795 tmp = [["bb","aa"],"cc"].sort().toString();
796 ok(tmp === "bb,aa,cc", "sort() = " + tmp);
798 tmp = [2,"1"].sort().toString();
799 ok(tmp === "1,2", "sort() = " + tmp);
801 tmp = ["2",1].sort().toString();
802 ok(tmp === "1,2", "sort() = " + tmp);
804 tmp = [,,0,"z"].sort().toString();
805 ok(tmp === "0,z,,", "sort() = " + tmp);
807 tmp = ["a,b",["a","a"],["a","c"]].sort().toString();
808 ok(tmp === "a,a,a,b,a,c", "sort() = " + tmp);
810 arr = ["1", "2", "3"];
812 ok(arr.length === 1, "arr.length = " + arr.length);
814 ok(arr.length === 3, "arr.length = " + arr.length);
815 ok(arr.toString() === "1,,", "arr.toString() = " + arr.toString());
817 arr = Array("a","b","c");
818 ok(arr.toString() === "a,b,c", "arr.toString() = " + arr.toString());
820 ok(arr.valueOf === Object.prototype.valueOf, "arr.valueOf !== Object.prototype.valueOf");
821 ok(arr === arr.valueOf(), "arr !== arr.valueOf");
825 ok(tmp === arr, "tmp !== arr");
826 ok(arr.length === 3, "arr.length = " + arr.length);
827 ok(arr.toString() === "3,2,1", "arr.toString() = " + arr.toString());
833 ok(tmp === arr, "tmp !== arr");
834 ok(arr.length === 6, "arr.length = " + arr.length);
835 ok(arr.toString() === "1,,5,,,", "arr.toString() = " + arr.toString());
842 arr.reverse = Array.prototype.reverse;
844 ok(tmp === arr, "tmp !== arr");
845 ok(arr.length === 3, "arr.length = " + arr.length);
846 ok(arr[0] === 2 && arr[1] === undefined && arr[2] === "aa", "unexpected array");
849 tmp = arr.unshift(0);
850 ok(tmp === (invokeVersion < 2 ? undefined : 4), "[1,2,3].unshift(0) returned " +tmp);
851 ok(arr.length === 4, "arr.length = " + arr.length);
852 ok(arr.toString() === "0,1,2,3", "arr.toString() = " + arr.toString());
857 tmp = arr.unshift(-1,0);
858 ok(tmp === (invokeVersion < 2 ? undefined : 5), "unshift returned " +tmp);
859 ok(arr.length === 5, "arr.length = " + arr.length);
860 ok(arr.toString() === "-1,0,1,,3", "arr.toString() = " + arr.toString());
864 ok(tmp === (invokeVersion < 2 ? undefined : 3), "unshift returned " +tmp);
865 ok(arr.length === 3, "arr.length = " + arr.length);
866 ok(arr.toString() === "1,2,3", "arr.toString() = " + arr.toString());
872 tmp = Array.prototype.unshift.call(arr, 0);
873 ok(tmp === (invokeVersion < 2 ? undefined : 3), "unshift returned " +tmp);
874 ok(arr.length === 3, "arr.length = " + arr.length);
875 ok(arr[0] === 0 && arr[1] === 1 && arr[2] === 2, "unexpected array");
879 ok(tmp === 1, "[1,2,,4].shift() = " + tmp);
880 ok(arr.toString() === "2,,4", "arr = " + arr.toString());
884 ok(tmp === undefined, "[].shift() = " + tmp);
885 ok(arr.toString() === "", "arr = " + arr.toString());
889 ok(tmp === 1, "[1,2,,4].shift(2) = " + tmp);
890 ok(arr.toString() === "2,,4", "arr = " + arr.toString());
894 ok(tmp === 1, "[1,].shift() = " + tmp);
895 ok(arr.toString() === "", "arr = " + arr.toString());
901 tmp = Array.prototype.shift.call(obj);
902 ok(tmp === "test", "obj.shift() = " + tmp);
903 ok(obj.length == 2, "obj.length = " + obj.length);
904 ok(obj[1] === 3, "obj[1] = " + obj[1]);
906 var num = new Number(6);
908 tmp = arr.concat(3, [4,5], num);
909 ok(tmp !== arr, "tmp === arr");
910 for(var i=0; i<6; i++)
911 ok(tmp[i] === i, "tmp[" + i + "] = " + tmp[i]);
912 ok(tmp[6] === num, "tmp[6] !== num");
913 ok(tmp.length === 7, "tmp.length = " + tmp.length);
916 ok(arr.length === 0, "arr.length = " + arr.length);
919 tmp = arr.concat([2]);
920 ok(tmp.length === 3, "tmp.length = " + tmp.length);
921 ok(tmp[1] === undefined, "tmp[1] = " + tmp[1]);
923 arr = [1,false,'a',null,undefined,'a'];
924 ok(arr.slice(0,6).toString() === "1,false,a,,,a", "arr.slice(0,6).toString() = " + arr.slice(0,6));
925 ok(arr.slice(0,6).length === 6, "arr.slice(0,6).length = " + arr.slice(0,6).length);
926 ok(arr.slice().toString() === "1,false,a,,,a", "arr.slice().toString() = " + arr.slice());
927 ok(arr.slice("abc").toString() === "1,false,a,,,a", "arr.slice(\"abc\").toString() = " + arr.slice("abc"));
928 ok(arr.slice(3,8).toString() === ",,a", "arr.slice(3,8).toString() = " + arr.slice(3,8));
929 ok(arr.slice(3,8).length === 3, "arr.slice(3,8).length = " + arr.slice(3,8).length);
930 ok(arr.slice(1).toString() === "false,a,,,a", "arr.slice(1).toString() = " + arr.slice(1));
931 ok(arr.slice(-2).toString() === ",a", "arr.slice(-2).toString() = " + arr.slice(-2));
932 ok(arr.slice(3,1).toString() === "", "arr.slice(3,1).toString() = " + arr.slice(3,1));
933 tmp = arr.slice(0,6);
934 for(var i=0; i < arr.length; i++)
935 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
937 ok(arr.slice(5).toString() === "a,,,,,,,2", "arr.slice(5).toString() = " + arr.slice(5).toString());
938 ok(arr.slice(5).length === 8, "arr.slice(5).length = " + arr.slice(5).length);
941 tmp = arr.splice(2,2);
942 ok(tmp.toString() == "3,4", "arr.splice(2,2) returned " + tmp.toString());
943 ok(arr.toString() == "1,2,5", "arr.splice(2,2) is " + arr.toString());
946 tmp = arr.splice(2,2,"a");
947 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a') returned " + tmp.toString());
948 ok(arr.toString() == "1,2,a,5", "arr.splice(2,2,'a') is " + arr.toString());
951 tmp = arr.splice(2,2,'a','b','c');
952 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a','b','c') returned " + tmp.toString());
953 ok(arr.toString() == "1,2,a,b,c,5", "arr.splice(2,2,'a','b','c') is " + arr.toString());
956 tmp = arr.splice(2,2,'a','b','c');
957 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a','b','c') returned " + tmp.toString());
958 ok(arr.toString() == "1,2,a,b,c,", "arr.splice(2,2,'a','b','c') is " + arr.toString());
961 arr.splice(2,2,'a','b','c');
962 ok(arr.toString() == "1,2,a,b,c,", "arr.splice(2,2,'a','b','c') is " + arr.toString());
965 tmp = arr.splice(2,2,'a','b');
966 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a','b') returned " + tmp.toString());
967 ok(arr.toString() == "1,2,a,b,5", "arr.splice(2,2,'a','b') is " + arr.toString());
970 tmp = arr.splice(-1,2);
971 ok(tmp.toString() == "5", "arr.splice(-1,2) returned " + tmp.toString());
972 ok(arr.toString() == "1,2,3,4", "arr.splice(-1,2) is " + arr.toString());
975 tmp = arr.splice(-10,3);
976 ok(tmp.toString() == "1,2,3", "arr.splice(-10,3) returned " + tmp.toString());
977 ok(arr.toString() == "4,5", "arr.splice(-10,3) is " + arr.toString());
980 tmp = arr.splice(-10,100);
981 ok(tmp.toString() == "1,2,3,4,5", "arr.splice(-10,100) returned " + tmp.toString());
982 ok(arr.toString() == "", "arr.splice(-10,100) is " + arr.toString());
985 tmp = arr.splice(2,-1);
986 ok(tmp.toString() == "", "arr.splice(2,-1) returned " + tmp.toString());
987 ok(arr.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr.toString());
991 ok(tmp.toString() == "", "arr.splice(2,-1) returned " + tmp.toString());
992 ok(arr.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr.toString());
996 ok(tmp.toString() == "", "arr.splice(2,-1) returned " + tmp.toString());
997 ok(arr.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr.toString());
1004 tmp = Array.prototype.splice.call(obj, 1, 1, 'a', 'b');
1005 ok(tmp.toString() === "2", "obj.splice returned " + tmp);
1006 ok(obj.length === 4, "obj.length = " + obj.length);
1007 ok(obj[0] === 1, "obj[0] = " + obj[0]);
1008 ok(obj[1] === 'a', "obj[1] = " + obj[1]);
1009 ok(obj[2] === 'b', "obj[2] = " + obj[2]);
1010 ok(obj[3] === 3, "obj[3] = " + obj[3]);
1017 tmp = Array.prototype.slice.call(obj, 1, 2);
1018 ok(tmp.length === 1, "tmp.length = " + tmp.length);
1019 ok(tmp[0] === 2, "tmp[0] = " + tmp[0]);
1021 tmp = (new Number(2)).toString();
1022 ok(tmp === "2", "num(2).toString = " + tmp);
1023 tmp = (new Number()).toString();
1024 ok(tmp === "0", "num().toString = " + tmp);
1025 tmp = (new Number(5.5)).toString(2);
1026 ok(tmp === "101.1", "num(5.5).toString(2) = " + tmp);
1028 tmp = (new Number(3)).toFixed(3);
1029 ok(tmp === "3.000", "num(3).toFixed(3) = " + tmp);
1030 tmp = (new Number(1.76)).toFixed(1);
1031 ok(tmp === "1.8", "num(1.76).toFixed(1) = " + tmp);
1032 tmp = (new Number(7.92)).toFixed(5);
1033 ok(tmp === "7.92000", "num(7.92).toFixed(5) = " + tmp);
1034 tmp = (new Number(2.88)).toFixed();
1035 ok(tmp === "3", "num(2.88).toFixed = " + tmp);
1036 tmp = (new Number(-2.5)).toFixed();
1037 ok(tmp === "-3", "num(-2.5).toFixed = " + tmp);
1038 tmp = (new Number(1000000000000000128)).toFixed(0);
1039 //todo_wine ok(tmp === "1000000000000000100", "num(1000000000000000128) = " + tmp);
1040 tmp = (new Number(3.14).toFixed(NaN));
1041 ok(tmp === "3", "num(3.14).toFixed = " + tmp);
1042 tmp = (new Number(0.95).toFixed(1));
1043 ok(tmp === "1.0", "num(0.95).toFixed(1) = " + tmp);
1044 tmp = (new Number(1e900)).toFixed(0);
1045 ok(tmp === "Infinity", "num(1000000000000000128) = " + tmp);
1046 tmp = (new Number(0.12345678901234567890123)).toFixed(20);
1047 ok(tmp === "0.12345678901234568000", "num(0.12345678901234567890123) = " + tmp);
1049 tmp = (new Number(2)).toExponential(3);
1050 ok(tmp === "2.000e+0", "num(2).toExponential(3) = " + tmp);
1051 tmp = (new Number(1.17e-32)).toExponential(20);
1052 ok(tmp === "1.17000000000000000000e-32", "num(1.17e-32).toExponential(20) = " + tmp);
1053 tmp = (new Number(0)).toExponential(7);
1054 ok(tmp === "0.0000000e+0", "num(0).toExponential(7) = " + tmp);
1055 tmp = (new Number(0)).toExponential(0);
1056 ok(tmp === "0e+0", "num(0).toExponential() = " + tmp);
1057 tmp = (new Number(-13.7567)).toExponential();
1058 ok(tmp === "-1.37567e+1", "num(-13.7567).toExponential() = " + tmp);
1059 tmp = (new Number(-32.1)).toExponential();
1060 ok(tmp === "-3.21e+1", "num(-32.1).toExponential() = " + tmp);
1061 tmp = (new Number(4723.4235)).toExponential();
1062 ok(tmp === "4.7234235e+3", "num(4723.4235).toExponential() = " + tmp);
1064 tmp = (new Number(5)).toPrecision(12);
1065 ok(tmp == "5.00000000000", "num(5).toPrecision(12) = " + tmp);
1066 tmp = (new Number(7.73)).toPrecision(7);
1067 ok(tmp == "7.730000", "num(7.73).toPrecision(7) = " + tmp);
1068 tmp = (new Number(-127547.47472)).toPrecision(17);
1069 ok(tmp == "-127547.47472000000", "num(-127547.47472).toPrecision(17) = " + tmp);
1070 tmp = (new Number(0)).toPrecision(3);
1071 ok(tmp == "0.00", "num(0).toPrecision(3) = " + tmp);
1072 tmp = (new Number(42345.52342465464562334)).toPrecision(15);
1073 ok(tmp == "42345.5234246546", "num(42345.52342465464562334).toPrecision(15) = " + tmp);
1074 tmp = (new Number(1.182e30)).toPrecision(5);
1075 ok(tmp == "1.1820e+30", "num(1.182e30)).toPrecision(5) = " + tmp);
1076 tmp = (new Number(1.123)).toPrecision();
1077 ok(tmp == "1.123", "num(1.123).toPrecision() = " + tmp);
1079 ok(Number() === 0, "Number() = " + Number());
1080 ok(Number(false) === 0, "Number(false) = " + Number(false));
1081 ok(Number("43") === 43, "Number('43') = " + Number("43"));
1083 tmp = (new Number(1)).valueOf();
1084 ok(tmp === 1, "(new Number(1)).valueOf = " + tmp);
1085 tmp = (new Number(1,2)).valueOf();
1086 ok(tmp === 1, "(new Number(1,2)).valueOf = " + tmp);
1087 tmp = (new Number()).valueOf();
1088 ok(tmp === 0, "(new Number()).valueOf = " + tmp);
1089 tmp = Number.prototype.valueOf();
1090 ok(tmp === 0, "Number.prototype.valueOf = " + tmp);
1092 function equals(val, base) {
1095 var str = val.toString(base);
1097 for(i=0; i<str.length; i++) {
1098 if(str.substring(i, i+1) == '(') break;
1099 if(str.substring(i, i+1) == '.') break;
1100 num = num*base + parseInt(str.substring(i, i+1));
1103 if(str.substring(i, i+1) == '.') {
1105 for(i++; i<str.length; i++) {
1106 if(str.substring(i, i+1) == '(') break;
1107 num += parseInt(str.substring(i, i+1))/mult;
1112 if(str.substring(i, i+1) == '(') {
1113 exp = parseInt(str.substring(i+2));
1114 num *= Math.pow(base, exp);
1117 ok(num>val-val/1000 && num<val+val/1000, "equals: num = " + num);
1120 ok((10).toString(11) === "a", "(10).toString(11) = " + (10).toString(11));
1121 ok((213213433).toString(17) === "8e2ddcb", "(213213433).toString(17) = " + (213213433).toString(17));
1122 ok((-3254343).toString(33) === "-2oicf", "(-3254343).toString(33) = " + (-3254343).toString(33));
1123 ok((NaN).toString(12) === "NaN", "(NaN).toString(11) = " + (NaN).toString(11));
1124 ok((Infinity).toString(13) === "Infinity", "(Infinity).toString(11) = " + (Infinity).toString(11));
1125 for(i=2; i<10; i++) {
1127 equals(2305843009200000000, i);
1130 equals(1024*1024*1024*1024*1024*1024*1.9999, i);
1133 equals(4.65661287308e-10, i);
1134 ok((0).toString(i) === "0", "(0).toString("+i+") = " + (0).toString(i));
1137 ok(parseFloat('123') === 123, "parseFloat('123') = " + parseFloat('123'));
1138 ok(parseFloat('-13.7') === -13.7, "parseFloat('-13.7') = " + parseFloat('-13.7'));
1139 ok(parseFloat('-0.01e-2') === -0.01e-2, "parseFloat('-0.01e-2') = " + parseFloat('-0.01e-2'));
1140 ok(parseFloat('-12e+5') === -12e+5, "parseFloat('-12e+5') = " + parseFloat('-12e+5'));
1141 ok(parseFloat('1E5 not parsed') === 1E5, "parseFloat('1E5 not parsed') = " + parseFloat('1E5 not parsed'));
1142 ok(isNaN(parseFloat('not a number')), "parseFloat('not a number') is not NaN");
1143 ok(parseFloat('+13.2e-3') === 13.2e-3, "parseFloat('+13.2e-3') = " + parseFloat('+13.2e-3'));
1144 ok(parseFloat('.12') === 0.12, "parseFloat('.12') = " + parseFloat('.12'));
1145 ok(parseFloat('1e') === 1, "parseFloat('1e') = " + parseFloat('1e'));
1148 ok(tmp === 1, "Math.min(1) = " + tmp);
1150 tmp = Math.min(1, false);
1151 ok(tmp === 0, "Math.min(1, false) = " + tmp);
1154 ok(tmp === Infinity, "Math.min() = " + tmp);
1156 tmp = Math.min(1, NaN, -Infinity, false);
1157 ok(isNaN(tmp), "Math.min(1, NaN, -Infinity, false) is not NaN");
1159 tmp = Math.min(1, false, true, null, -3);
1160 ok(tmp === -3, "Math.min(1, false, true, null, -3) = " + tmp);
1163 ok(tmp === 1, "Math.max(1) = " + tmp);
1165 tmp = Math.max(true, 0);
1166 ok(tmp === 1, "Math.max(true, 0) = " + tmp);
1168 tmp = Math.max(-2, false, true, null, 1);
1169 ok(tmp === 1, "Math.max(-2, false, true, null, 1) = " + tmp);
1172 ok(tmp === -Infinity, "Math.max() = " + tmp);
1174 tmp = Math.max(true, NaN, 0);
1175 ok(isNaN(tmp), "Math.max(true, NaN, 0) is not NaN");
1177 tmp = Math.round(0.5);
1178 ok(tmp === 1, "Math.round(0.5) = " + tmp);
1180 tmp = Math.round(-0.5);
1181 ok(tmp === 0, "Math.round(-0.5) = " + tmp);
1183 tmp = Math.round(1.1);
1184 ok(tmp === 1, "Math.round(1.1) = " + tmp);
1186 tmp = Math.round(true);
1187 ok(tmp === 1, "Math.round(true) = " + tmp);
1189 tmp = Math.round(1.1, 3, 4);
1190 ok(tmp === 1, "Math.round(1.1, 3, 4) = " + tmp);
1193 ok(isNaN(tmp), "Math.round() is not NaN");
1195 tmp = Math.ceil(0.5);
1196 ok(tmp === 1, "Math.ceil(0.5) = " + tmp);
1198 tmp = Math.ceil(-0.5);
1199 ok(tmp === 0, "Math.ceil(-0.5) = " + tmp);
1201 tmp = Math.ceil(1.1);
1202 ok(tmp === 2, "Math.round(1.1) = " + tmp);
1204 tmp = Math.ceil(true);
1205 ok(tmp === 1, "Math.ceil(true) = " + tmp);
1207 tmp = Math.ceil(1.1, 3, 4);
1208 ok(tmp === 2, "Math.ceil(1.1, 3, 4) = " + tmp);
1211 ok(isNaN(tmp), "ceil() is not NaN");
1213 tmp = Math.floor(0.5);
1214 ok(tmp === 0, "Math.floor(0.5) = " + tmp);
1216 tmp = Math.floor(-0.5);
1217 ok(tmp === -1, "Math.floor(-0.5) = " + tmp);
1219 tmp = Math.floor(1.1);
1220 ok(tmp === 1, "Math.floor(1.1) = " + tmp);
1222 tmp = Math.floor(true);
1223 ok(tmp === 1, "Math.floor(true) = " + tmp);
1225 tmp = Math.floor(1.1, 3, 4);
1226 ok(tmp === 1, "Math.floor(1.1, 3, 4) = " + tmp);
1229 ok(isNaN(tmp), "floor is not NaN");
1232 ok(tmp === 3, "Math.abs(3) = " + tmp);
1235 ok(tmp === 3, "Math.abs(-3) = " + tmp);
1237 tmp = Math.abs(true);
1238 ok(tmp === 1, "Math.abs(true) = " + tmp);
1241 ok(isNaN(tmp), "Math.abs() is not NaN");
1243 tmp = Math.abs(NaN);
1244 ok(isNaN(tmp), "Math.abs() is not NaN");
1246 tmp = Math.abs(-Infinity);
1247 ok(tmp === Infinity, "Math.abs(-Infinite) = " + tmp);
1249 tmp = Math.abs(-3, 2);
1250 ok(tmp === 3, "Math.abs(-3, 2) = " + tmp);
1253 ok(tmp === 1, "Math.cos(0) = " + tmp);
1255 tmp = Math.cos(Math.PI/2);
1256 ok(Math.floor(tmp*100) === 0, "Math.cos(Math.PI/2) = " + tmp);
1258 tmp = Math.cos(-Math.PI/2);
1259 ok(Math.floor(tmp*100) === 0, "Math.cos(-Math.PI/2) = " + tmp);
1261 tmp = Math.cos(Math.PI/3, 2);
1262 ok(Math.floor(tmp*100) === 50, "Math.cos(Math.PI/3, 2) = " + tmp);
1264 tmp = Math.cos(true);
1265 ok(Math.floor(tmp*100) === 54, "Math.cos(true) = " + tmp);
1267 tmp = Math.cos(false);
1268 ok(tmp === 1, "Math.cos(false) = " + tmp);
1271 ok(isNaN(tmp), "Math.cos() is not NaN");
1273 tmp = Math.cos(NaN);
1274 ok(isNaN(tmp), "Math.cos(NaN) is not NaN");
1276 tmp = Math.cos(Infinity);
1277 ok(isNaN(tmp), "Math.cos(Infinity) is not NaN");
1279 tmp = Math.cos(-Infinity);
1280 ok(isNaN(tmp), "Math.cos(-Infinity) is not NaN");
1282 tmp = Math.pow(2, 2);
1283 ok(tmp === 4, "Math.pow(2, 2) = " + tmp);
1285 tmp = Math.pow(4, 0.5);
1286 ok(tmp === 2, "Math.pow(2, 2) = " + tmp);
1288 tmp = Math.pow(2, 2, 3);
1289 ok(tmp === 4, "Math.pow(2, 2, 3) = " + tmp);
1292 ok(isNaN(tmp), "Math.pow(2) is not NaN");
1295 ok(isNaN(tmp), "Math.pow() is not NaN");
1297 tmp = Math.random();
1298 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
1299 ok(0 <= tmp && tmp <= 1, "Math.random() = " + tmp);
1301 tmp = Math.random(100);
1302 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
1303 ok(0 <= tmp && tmp <= 1, "Math.random(100) = " + tmp);
1306 ok(Math.floor(tmp*100) === 157, "Math.acos(0) = " + tmp);
1309 ok(Math.floor(tmp*100) === 0, "Math.acos(1) = " + tmp);
1311 tmp = Math.acos(-1);
1312 ok(Math.floor(tmp*100) === 314, "Math.acos(-1) = " + tmp);
1314 tmp = Math.acos(Math.PI/4, 2);
1315 ok(Math.floor(tmp*100) === 66, "Math.acos(Math.PI/4, 2) = " + tmp);
1317 tmp = Math.acos(true);
1318 ok(Math.floor(tmp*100) === 0, "Math.acos(true) = " + tmp);
1320 tmp = Math.acos(false);
1321 ok(Math.floor(tmp*100) === 157, "Math.acos(false) = " + tmp);
1323 tmp = Math.acos(1.1);
1324 ok(isNaN(tmp), "Math.acos(1.1) is not NaN");
1327 ok(isNaN(tmp), "Math.acos() is not NaN");
1329 tmp = Math.acos(NaN);
1330 ok(isNaN(tmp), "Math.acos(NaN) is not NaN");
1332 tmp = Math.acos(Infinity);
1333 ok(isNaN(tmp), "Math.acos(Infinity) is not NaN");
1335 tmp = Math.acos(-Infinity);
1336 ok(isNaN(tmp), "Math.acos(-Infinity) is not NaN");
1339 ok(Math.floor(tmp*100) === 0, "Math.asin(0) = " + tmp);
1342 ok(Math.floor(tmp*100) === 157, "Math.asin(1) = " + tmp);
1344 tmp = Math.asin(-1);
1345 ok(Math.floor(tmp*100) === -158, "Math.asin(-1) = " + tmp);
1347 tmp = Math.asin(Math.PI/4, 2);
1348 ok(Math.floor(tmp*100) === 90, "Math.asin(Math.PI/4, 2) = " + tmp);
1350 tmp = Math.asin(true);
1351 ok(Math.floor(tmp*100) === 157, "Math.asin(true) = " + tmp);
1353 tmp = Math.asin(false);
1354 ok(Math.floor(tmp*100) === 0, "Math.asin(false) = " + tmp);
1356 tmp = Math.asin(1.1);
1357 ok(isNaN(tmp), "Math.asin(1.1) is not NaN");
1360 ok(isNaN(tmp), "Math.asin() is not NaN");
1362 tmp = Math.asin(NaN);
1363 ok(isNaN(tmp), "Math.asin(NaN) is not NaN");
1365 tmp = Math.asin(Infinity);
1366 ok(isNaN(tmp), "Math.asin(Infinity) is not NaN");
1368 tmp = Math.asin(-Infinity);
1369 ok(isNaN(tmp), "Math.asin(-Infinity) is not NaN");
1372 ok(Math.floor(tmp*100) === 0, "Math.atan(0) = " + tmp);
1375 ok(Math.floor(tmp*100) === 78, "Math.atan(1) = " + tmp);
1377 tmp = Math.atan(-1);
1378 ok(Math.floor(tmp*100) === -79, "Math.atan(-1) = " + tmp);
1380 tmp = Math.atan(true);
1381 ok(Math.floor(tmp*100) === 78, "Math.atan(true) = " + tmp);
1383 tmp = Math.atan(false);
1384 ok(Math.floor(tmp*100) === 0, "Math.atan(false) = " + tmp);
1387 ok(isNaN(tmp), "Math.atan() is not NaN");
1389 tmp = Math.atan(NaN);
1390 ok(isNaN(tmp), "Math.atan(NaN) is not NaN");
1392 tmp = Math.atan(Infinity);
1393 ok(Math.floor(tmp*100) === 157, "Math.atan(Infinity) = " + tmp);
1395 tmp = Math.atan(-Infinity);
1396 ok(Math.floor(tmp*100) === -158, "Math.atan(Infinity) = " + tmp);
1398 tmp = Math.atan2(0, 0);
1399 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 0) = " + tmp);
1401 tmp = Math.atan2(0, 1);
1402 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 1) = " + tmp);
1404 tmp = Math.atan2(0, Infinity);
1405 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, Infinity) = " + tmp);
1407 tmp = Math.atan2(0, -1);
1408 ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -1) = " + tmp);
1410 tmp = Math.atan2(0, -Infinity);
1411 ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -Infinity) = " + tmp);
1413 tmp = Math.atan2(1, 0);
1414 ok(Math.floor(tmp*100) === 157, "Math.atan2(1, 0) = " + tmp);
1416 tmp = Math.atan2(Infinity, 0);
1417 ok(Math.floor(tmp*100) === 157, "Math.atan2(Infinity, 0) = " + tmp);
1419 tmp = Math.atan2(-1, 0);
1420 ok(Math.floor(tmp*100) === -158, "Math.atan2(-1, 0) = " + tmp);
1422 tmp = Math.atan2(-Infinity, 0);
1423 ok(Math.floor(tmp*100) === -158, "Math.atan2(-Infinity, 0) = " + tmp);
1425 tmp = Math.atan2(1, 1);
1426 ok(Math.floor(tmp*100) === 78, "Math.atan2(1, 1) = " + tmp);
1428 tmp = Math.atan2(-1, -1);
1429 ok(Math.floor(tmp*100) === -236, "Math.atan2(-1, -1) = " + tmp);
1431 tmp = Math.atan2(-1, 1);
1432 ok(Math.floor(tmp*100) === -79, "Math.atan2(-1, 1) = " + tmp);
1434 tmp = Math.atan2(Infinity, Infinity);
1435 ok(Math.floor(tmp*100) === 78, "Math.atan2(Infinity, Infinity) = " + tmp);
1437 tmp = Math.atan2(Infinity, -Infinity, 1);
1438 ok(Math.floor(tmp*100) === 235, "Math.atan2(Infinity, -Infinity, 1) = " + tmp);
1441 ok(isNaN(tmp), "Math.atan2() is not NaN");
1443 tmp = Math.atan2(1);
1444 ok(isNaN(tmp), "Math.atan2(1) is not NaN");
1447 ok(tmp === 1, "Math.exp(0) = " + tmp);
1450 ok(Math.floor(tmp*100) === 271, "Math.exp(1) = " + tmp);
1453 ok(Math.floor(tmp*100) === 36, "Math.exp(-1) = " + tmp);
1455 tmp = Math.exp(true);
1456 ok(Math.floor(tmp*100) === 271, "Math.exp(true) = " + tmp);
1458 tmp = Math.exp(1, 1);
1459 ok(Math.floor(tmp*100) === 271, "Math.exp(1, 1) = " + tmp);
1462 ok(isNaN(tmp), "Math.exp() is not NaN");
1464 tmp = Math.exp(NaN);
1465 ok(isNaN(tmp), "Math.exp(NaN) is not NaN");
1467 tmp = Math.exp(Infinity);
1468 ok(tmp === Infinity, "Math.exp(Infinity) = " + tmp);
1470 tmp = Math.exp(-Infinity);
1471 ok(tmp === 0, "Math.exp(-Infinity) = " + tmp);
1474 ok(Math.floor(tmp*100) === 0, "Math.log(1) = " + tmp);
1477 ok(isNaN(tmp), "Math.log(-1) is not NaN");
1479 tmp = Math.log(true);
1480 ok(Math.floor(tmp*100) === 0, "Math.log(true) = " + tmp);
1482 tmp = Math.log(1, 1);
1483 ok(Math.floor(tmp*100) === 0, "Math.log(1, 1) = " + tmp);
1486 ok(isNaN(tmp), "Math.log() is not NaN");
1488 tmp = Math.log(NaN);
1489 ok(isNaN(tmp), "Math.log(NaN) is not NaN");
1491 tmp = Math.log(Infinity);
1492 ok(tmp === Infinity, "Math.log(Infinity) = " + tmp);
1494 tmp = Math.log(-Infinity);
1495 ok(isNaN(tmp), "Math.log(-Infinity) is not NaN");
1498 ok(tmp === 0, "Math.sin(0) = " + tmp);
1500 tmp = Math.sin(Math.PI/2);
1501 ok(tmp === 1, "Math.sin(Math.PI/2) = " + tmp);
1503 tmp = Math.sin(-Math.PI/2);
1504 ok(tmp === -1, "Math.sin(-Math.PI/2) = " + tmp);
1506 tmp = Math.sin(Math.PI/3, 2);
1507 ok(Math.floor(tmp*100) === 86, "Math.sin(Math.PI/3, 2) = " + tmp);
1509 tmp = Math.sin(true);
1510 ok(Math.floor(tmp*100) === 84, "Math.sin(true) = " + tmp);
1512 tmp = Math.sin(false);
1513 ok(tmp === 0, "Math.sin(false) = " + tmp);
1516 ok(isNaN(tmp), "Math.sin() is not NaN");
1518 tmp = Math.sin(NaN);
1519 ok(isNaN(tmp), "Math.sin(NaN) is not NaN");
1521 tmp = Math.sin(Infinity);
1522 ok(isNaN(tmp), "Math.sin(Infinity) is not NaN");
1524 tmp = Math.sin(-Infinity);
1525 ok(isNaN(tmp), "Math.sin(-Infinity) is not NaN");
1528 ok(tmp === 0, "Math.sqrt(0) = " + tmp);
1531 ok(tmp === 2, "Math.sqrt(4) = " + tmp);
1533 tmp = Math.sqrt(-1);
1534 ok(isNaN(tmp), "Math.sqrt(-1) is not NaN");
1536 tmp = Math.sqrt(2, 2);
1537 ok(Math.floor(tmp*100) === 141, "Math.sqrt(2, 2) = " + tmp);
1539 tmp = Math.sqrt(true);
1540 ok(tmp === 1, "Math.sqrt(true) = " + tmp);
1542 tmp = Math.sqrt(false);
1543 ok(tmp === 0, "Math.sqrt(false) = " + tmp);
1546 ok(isNaN(tmp), "Math.sqrt() is not NaN");
1548 tmp = Math.sqrt(NaN);
1549 ok(isNaN(tmp), "Math.sqrt(NaN) is not NaN");
1551 tmp = Math.sqrt(Infinity);
1552 ok(tmp === Infinity, "Math.sqrt(Infinity) = " + tmp);
1554 tmp = Math.sqrt(-Infinity);
1555 ok(isNaN(tmp), "Math.sqrt(-Infinity) is not NaN");
1558 ok(tmp === 0, "Math.tan(0) = " + tmp);
1560 tmp = Math.tan(Math.PI);
1561 ok(Math.floor(tmp*100) === -1, "Math.tan(Math.PI) = " + tmp);
1563 tmp = Math.tan(2, 2);
1564 ok(Math.floor(tmp*100) === -219, "Math.tan(2, 2) = " + tmp);
1566 tmp = Math.tan(true);
1567 ok(Math.floor(tmp*100) === 155, "Math.tan(true) = " + tmp);
1569 tmp = Math.tan(false);
1570 ok(tmp === 0, "Math.tan(false) = " + tmp);
1573 ok(isNaN(tmp), "Math.tan() is not NaN");
1575 tmp = Math.tan(NaN);
1576 ok(isNaN(tmp), "Math.tan(NaN) is not NaN");
1578 tmp = Math.tan(Infinity);
1579 ok(isNaN(tmp), "Math.tan(Infinity) is not NaN");
1581 tmp = Math.tan(-Infinity);
1582 ok(isNaN(tmp), "Math.tan(-Infinity) is not NaN");
1584 var func = function (a) {
1588 ok(func.toString() === "function (a) {\n var a = 1;\n if(a) return;\n }",
1589 "func.toString() = " + func.toString());
1590 ok("" + func === "function (a) {\n var a = 1;\n if(a) return;\n }",
1591 "'' + func.toString() = " + func);
1593 ok(func.valueOf === Object.prototype.valueOf, "func.valueOf !== Object.prototype.valueOf");
1594 ok(func === func.valueOf(), "func !== func.valueOf()");
1596 function testFuncToString(x,y) {
1599 ok(testFuncToString.toString() === "function testFuncToString(x,y) {\n return x+y;\n}",
1600 "testFuncToString.toString() = " + testFuncToString.toString());
1601 ok("" + testFuncToString === "function testFuncToString(x,y) {\n return x+y;\n}",
1602 "'' + testFuncToString = " + testFuncToString);
1606 function callTest(argc) {
1607 ok(this === tmp, "this !== tmp\n");
1608 ok(arguments.length === argc+1, "arguments.length = " + arguments.length + " expected " + (argc+1));
1609 for(var i=1; i <= argc; i++)
1610 ok(arguments[i] === i, "arguments[i] = " + arguments[i]);
1613 callTest.call(tmp, 1, 1);
1614 callTest.call(tmp, 2, 1, 2);
1616 callTest.apply(tmp, [1, 1]);
1617 callTest.apply(tmp, [2, 1, 2]);
1618 (function () { callTest.apply(tmp, arguments); })(2,1,2);
1620 function callTest2() {
1621 ok(this === tmp, "this !== tmp\n");
1622 ok(arguments.length === 0, "callTest2: arguments.length = " + arguments.length + " expected 0");
1625 callTest2.call(tmp);
1626 callTest2.apply(tmp, []);
1627 callTest2.apply(tmp);
1628 (function () { callTest2.apply(tmp, arguments); })();
1630 function callTest3() {
1632 ok(arguments.length === 0, "arguments.length = " + arguments.length + " expected 0");
1636 callTest3.call(undefined);
1637 callTest3.call(null);
1639 callTest3.apply(undefined);
1640 callTest3.apply(null);
1642 tmp = Number.prototype.toString.call(3);
1643 ok(tmp === "3", "Number.prototype.toString.call(3) = " + tmp);
1645 var func = new Function("return 3;");
1648 ok(tmp === 3, "func() = " + tmp);
1649 ok(func.call() === 3, "func.call() = " + tmp);
1650 ok(func.length === 0, "func.length = " + func.length);
1651 tmp = func.toString();
1652 ok(tmp === "function anonymous() {\nreturn 3;\n}", "func.toString() = " + tmp);
1654 func = new Function("x", "return x+2;");
1656 ok(tmp === 3, "func(1) = " + tmp);
1657 tmp = func.toString();
1658 ok(tmp === "function anonymous(x) {\nreturn x+2;\n}", "func.toString() = " + tmp);
1660 tmp = (new Function("x ", "return x+2;")).toString();
1661 ok(tmp === "function anonymous(x ) {\nreturn x+2;\n}", "func.toString() = " + tmp);
1663 func = new Function("x", "y", "return x+y");
1665 ok(tmp === 4, "func(1,3) = " + tmp);
1666 tmp = func.toString();
1667 ok(tmp === "function anonymous(x, y) {\nreturn x+y\n}", "func.toString() = " + tmp);
1669 func = new Function(" x, \ty", "\tz", "return x+y+z;");
1671 ok(tmp === 6, "func(1,3,2) = " + tmp);
1672 ok(func.length === 3, "func.length = " + func.length);
1673 tmp = func.toString();
1674 ok(tmp === "function anonymous( x, \ty, \tz) {\nreturn x+y+z;\n}", "func.toString() = " + tmp);
1676 func = new Function();
1678 ok(tmp === undefined, "func() = " + tmp);
1679 tmp = func.toString();
1680 ok(tmp == "function anonymous() {\n\n}", "func.toString() = " + tmp);
1682 func = (function() {
1684 return new Function("return tmp;");
1688 ok(tmp === 2, "func() = " + tmp);
1690 var date = new Date();
1692 date = new Date(100);
1693 ok(date.getTime() === 100, "date.getTime() = " + date.getTime());
1694 ok(Date.prototype.getTime() === 0, "date.prototype.getTime() = " + Date.prototype.getTime());
1695 date = new Date(8.64e15);
1696 ok(date.getTime() === 8.64e15, "date.getTime() = " + date.getTime());
1697 date = new Date(8.64e15+1);
1698 ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
1699 date = new Date(Infinity);
1700 ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
1701 date = new Date("3 July 2009 22:28:00 UTC+0100");
1702 ok(date.getTime() === 1246656480000, "date.getTime() = " + date.getTime());
1703 date = new Date(1984, 11, 29, 13, 51, 24, 120);
1704 ok(date.getFullYear() === 1984, "date.getFullYear() = " + date.getFullYear());
1705 ok(date.getMonth() === 11, "date.getMonth() = " + date.getMonth());
1706 ok(date.getDate() === 29, "date.getDate() = " + date.getDate());
1707 ok(date.getHours() === 13, "date.getHours() = " + date.getHours());
1708 ok(date.getMinutes() === 51, "date.getMinutes() = " + date.getMinutes());
1709 ok(date.getSeconds() === 24, "date.getSeconds() = " + date.getSeconds());
1710 ok(date.getMilliseconds() === 120, "date.getMilliseconds() = " + date.getMilliseconds());
1711 date = new Date(731, -32, 40, -1, 70, 65, -13);
1712 ok(date.getFullYear() === 728, "date.getFullYear() = " + date.getFullYear());
1713 ok(date.getMonth() === 5, "date.getMonth() = " + date.getMonth());
1714 ok(date.getDate() === 9, "date.getDate() = " + date.getDate());
1715 ok(date.getHours() === 0, "date.getHours() = " + date.getHours());
1716 ok(date.getMinutes() === 11, "date.getMinutes() = " + date.getMinutes());
1717 ok(date.getSeconds() === 4, "date.getSeconds() = " + date.getSeconds());
1718 ok(date.getMilliseconds() === 987, "date.getMilliseconds() = " + date.getMilliseconds());
1720 ok(date.setTime(123) === 123, "date.setTime(123) !== 123");
1721 ok(date.setTime("123", NaN) === 123, "date.setTime(\"123\") !== 123");
1722 ok(isNaN(date.setTime(NaN)), "date.setTime(NaN) is not NaN");
1724 ok(date.setTime(0) === date.getTime(), "date.setTime(0) !== date.getTime()");
1725 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
1726 ok(date.getUTCMonth() === 0, "date.getUTCMonth() = " + date.getUTCMonth());
1727 ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
1728 ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
1729 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
1730 ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
1731 ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
1732 ok(date.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1734 date.setTime(60*24*60*60*1000);
1735 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
1736 ok(date.getUTCMonth() === 2, "date.getUTCMonth() = " + date.getUTCMonth());
1737 ok(date.getUTCDate() === 2, "date.getUTCDate() = " + date.getUTCDate());
1738 ok(date.getUTCDay() === 1, "date.getUTCDay() = " + date.getUTCDay());
1739 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
1740 ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
1741 ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
1742 ok(date.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1744 date.setTime(59*24*60*60*1000 + 4*365*24*60*60*1000 + 60*60*1000 + 2*60*1000 + 2*1000 + 640);
1745 ok(date.getUTCFullYear() === 1974, "date.getUTCFullYear() = " + date.getUTCFullYear());
1746 ok(date.getUTCMonth() === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1747 ok(date.getUTCMonth(123) === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1748 ok(date.getUTCDate() === 28, "date.getUTCDate() = " + date.getUTCDate());
1749 ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
1750 ok(date.getUTCHours() === 1, "date.getUTCHours() = " + date.getUTCHours());
1751 ok(date.getUTCMinutes() === 2, "date.getUTCMinutes() = " + date.getUTCMinutes());
1752 ok(date.getUTCSeconds() === 2, "date.getUTCSeconds() = " + date.getUTCSeconds());
1753 ok(date.getUTCMilliseconds() === 640, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1755 tmp = date.setYear(96);
1756 ok(date.getYear() === 96, "date.getYear() = " + date.getYear());
1757 ok(date.getFullYear() === 1996, "date.getFullYear() = " + date.getYear());
1758 ok(date.getUTCMonth() === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1759 ok(date.getUTCMonth(123) === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1760 ok(date.getUTCMilliseconds() === 640, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1762 tmp = date.setYear(2010);
1763 ok(tmp === date.getTime(), "date.setYear(2010) = " + tmp);
1764 ok(date.getYear() === 2010, "date.getYear() = " + date.getYear());
1765 ok(date.getFullYear() === 2010, "date.getFullYear() = " + date.getYear());
1766 ok(date.getUTCMonth() === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1767 ok(date.getUTCMonth(123) === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1768 ok(date.getUTCMilliseconds() === 640, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1770 date.setTime(Infinity);
1771 ok(isNaN(date.getUTCFullYear()), "date.getUTCFullYear() is not NaN");
1772 ok(isNaN(date.getUTCMonth()), "date.getUTCMonth() is not NaN");
1773 ok(isNaN(date.getUTCDate()), "date.getUTCDate() is not NaN");
1774 ok(isNaN(date.getUTCDay()), "date.getUTCDay() is not NaN");
1775 ok(isNaN(date.getUTCHours()), "date.getUTCHours() is not NaN");
1776 ok(isNaN(date.getUTCMinutes()), "date.getUTCMinutes() is not NaN");
1777 ok(isNaN(date.getUTCSeconds()), "date.getUTCSeconds() is not NaN");
1778 ok(isNaN(date.getUTCMilliseconds()), "date.getUTCMilliseconds() is not NaN");
1779 ok(isNaN(date.setMilliseconds(0)), "date.setMilliseconds() is not NaN");
1782 tmp = date.setYear(NaN);
1783 ok(isNaN(tmp), "date.setYear(NaN) = " + tmp);
1784 ok(isNaN(date.getUTCFullYear()), "date.getUTCFullYear() is not NaN");
1785 ok(isNaN(date.getUTCMonth()), "date.getUTCMonth() is not NaN");
1788 date.setUTCMilliseconds(-10, 2);
1789 ok(date.getUTCMilliseconds() === 990, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1790 date.setUTCMilliseconds(10);
1791 ok(date.getUTCMilliseconds() === 10, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1792 date.setUTCSeconds(-10);
1793 ok(date.getUTCSeconds() === 50, "date.getUTCSeconds() = " + date.getUTCSeconds());
1794 date.setUTCMinutes(-10);
1795 ok(date.getUTCMinutes() === 50, "date.getUTCMinutes() = " + date.getUTCMinutes());
1796 date.setUTCHours(-10);
1797 ok(date.getUTCHours() === 14, "date.getUTCHours() = " + date.getUTCHours());
1798 date.setUTCHours(-123);
1799 ok(date.getTime() === -612549990, "date.getTime() = " + date.getTime());
1800 date.setUTCHours(20);
1801 ok(date.getUTCHours() === 20, "date.getUTCHours() = " + date.getUTCHours());
1802 date.setUTCDate(32);
1803 ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
1804 date.setUTCMonth(22, 37);
1805 ok(date.getTime() === 60987050010, "date.getTime() = " + date.getTime());
1806 date.setUTCFullYear(83, 21, 321);
1807 ok(date.getTime() === -59464984149990, "date.getTime() = " + date.getTime());
1808 ok(Math.abs(date) === 59464984149990, "Math.abs(date) = " + Math.abs(date));
1809 ok(getVT(date+1) === "VT_BSTR", "getVT(date+1) = " + getVT(date+1));
1811 ok(isNaN(Date.parse()), "Date.parse() is not NaN");
1812 ok(isNaN(Date.parse("")), "Date.parse(\"\") is not NaN");
1813 ok(isNaN(Date.parse("Jan Jan 20 2009")), "Date.parse(\"Jan Jan 20 2009\") is not NaN");
1814 ok(Date.parse("Jan 20 2009 UTC") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC\") = " + Date.parse("Jan 20 2009 UTC"));
1815 ok(Date.parse("Jan 20 2009 GMT") === 1232409600000, "Date.parse(\"Jan 20 2009 GMT\") = " + Date.parse("Jan 20 2009 GMT"));
1816 ok(Date.parse("Jan 20 2009 UTC-0") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC-0\") = " + Date.parse("Jan 20 2009 UTC-0"));
1817 ok(Date.parse("Jan 20 2009 UTC+0000") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC+0000\") = " + Date.parse("Jan 20 2009 UTC+0000"));
1818 ok(Date.parse("Ju 13 79 UTC") === 300672000000, "Date.parse(\"Ju 13 79 UTC\") = " + Date.parse("Ju 13 79 UTC"));
1819 ok(Date.parse("12Au91 UTC") === 681955200000, "Date.parse(\"12Au91 UTC\") = " + Date.parse("12Au91 UTC"));
1820 ok(Date.parse("7/02/17 UTC") === -1656806400000, "Date.parse(\"7/02/17 UTC\") = " + Date.parse("7/02/17 UTC"));
1821 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"));
1822 ok(Date.parse("February 31 UTC, 2000 12:31:17 PM") === 952000277000,
1823 "Date.parse(\"February 31 UTC, 2000 12:31:17 PM\") = " + Date.parse("February 31 UTC, 2000 12:31:17 PM"));
1824 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 "));
1825 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"));
1827 ok(typeof(Math.PI) === "number", "typeof(Math.PI) = " + typeof(Math.PI));
1828 ok(Math.floor(Math.PI*100) === 314, "Math.PI = " + Math.PI);
1830 ok(Math.floor(Math.PI*100) === 314, "modified Math.PI = " + Math.PI);
1832 ok(typeof(Math.E) === "number", "typeof(Math.E) = " + typeof(Math.E));
1833 ok(Math.floor(Math.E*100) === 271, "Math.E = " + Math.E);
1835 ok(Math.floor(Math.E*100) === 271, "modified Math.E = " + Math.E);
1837 ok(typeof(Math.LOG2E) === "number", "typeof(Math.LOG2E) = " + typeof(Math.LOG2E));
1838 ok(Math.floor(Math.LOG2E*100) === 144, "Math.LOG2E = " + Math.LOG2E);
1839 Math.LOG2E = "test";
1840 ok(Math.floor(Math.LOG2E*100) === 144, "modified Math.LOG2E = " + Math.LOG2E);
1842 ok(typeof(Math.LOG10E) === "number", "typeof(Math.LOG10E) = " + typeof(Math.LOG10E));
1843 ok(Math.floor(Math.LOG10E*100) === 43, "Math.LOG10E = " + Math.LOG10E);
1844 Math.LOG10E = "test";
1845 ok(Math.floor(Math.LOG10E*100) === 43, "modified Math.LOG10E = " + Math.LOG10E);
1847 ok(typeof(Math.LN2) === "number", "typeof(Math.LN2) = " + typeof(Math.LN2));
1848 ok(Math.floor(Math.LN2*100) === 69, "Math.LN2 = " + Math.LN2);
1850 ok(Math.floor(Math.LN2*100) === 69, "modified Math.LN2 = " + Math.LN2);
1852 ok(typeof(Math.LN10) === "number", "typeof(Math.LN10) = " + typeof(Math.LN10));
1853 ok(Math.floor(Math.LN10*100) === 230, "Math.LN10 = " + Math.LN10);
1855 ok(Math.floor(Math.LN10*100) === 230, "modified Math.LN10 = " + Math.LN10);
1857 ok(typeof(Math.SQRT2) === "number", "typeof(Math.SQRT2) = " + typeof(Math.SQRT2));
1858 ok(Math.floor(Math.SQRT2*100) === 141, "Math.SQRT2 = " + Math.SQRT2);
1859 Math.SQRT2 = "test";
1860 ok(Math.floor(Math.SQRT2*100) === 141, "modified Math.SQRT2 = " + Math.SQRT2);
1862 ok(typeof(Math.SQRT1_2) === "number", "typeof(Math.SQRT1_2) = " + typeof(Math.SQRT1_2));
1863 ok(Math.floor(Math.SQRT1_2*100) === 70, "Math.SQRT1_2 = " + Math.SQRT1_2);
1864 Math.SQRT1_2 = "test";
1865 ok(Math.floor(Math.SQRT1_2*100) === 70, "modified Math.SQRT1_2 = " + Math.SQRT1_2);
1867 ok(isNaN.toString() === "\nfunction isNaN() {\n [native code]\n}\n",
1868 "isNaN.toString = '" + isNaN.toString() + "'");
1869 ok(Array.toString() === "\nfunction Array() {\n [native code]\n}\n",
1870 "isNaN.toString = '" + Array.toString() + "'");
1871 ok(Function.toString() === "\nfunction Function() {\n [native code]\n}\n",
1872 "isNaN.toString = '" + Function.toString() + "'");
1873 ok(Function.prototype.toString() === "\nfunction prototype() {\n [native code]\n}\n",
1874 "isNaN.toString = '" + Function.prototype.toString() + "'");
1875 ok("".substr.toString() === "\nfunction substr() {\n [native code]\n}\n",
1876 "''.substr.toString = '" + "".substr.toString() + "'");
1878 var bool = new Boolean();
1879 ok(bool.toString() === "false", "bool.toString() = " + bool.toString());
1880 var bool = new Boolean("false");
1881 ok(bool.toString() === "true", "bool.toString() = " + bool.toString());
1882 ok(bool.valueOf() === Boolean(1), "bool.valueOf() = " + bool.valueOf());
1883 ok(bool.toLocaleString() === bool.toString(), "bool.toLocaleString() = " + bool.toLocaleString());
1885 ok(ActiveXObject instanceof Function, "ActiveXObject is not instance of Function");
1886 ok(ActiveXObject.prototype instanceof Object, "ActiveXObject.prototype is not instance of Object");
1888 ok(Error.prototype !== TypeError.prototype, "Error.prototype === TypeError.prototype");
1889 ok(RangeError.prototype !== TypeError.prototype, "RangeError.prototype === TypeError.prototype");
1890 ok(Error.prototype.toLocaleString === Object.prototype.toLocaleString,
1891 "Error.prototype.toLocaleString !== Object.prototype.toLocaleString");
1893 ok(err.valueOf === Object.prototype.valueOf, "err.valueOf !== Object.prototype.valueOf");
1894 ok(Error.prototype.name === "Error", "Error.prototype.name = " + Error.prototype.name);
1895 ok(err.name === "Error", "err.name = " + err.name);
1896 EvalError.prototype.message = "test";
1897 ok(err.toString !== Object.prototype.toString, "err.toString === Object.prototype.toString");
1898 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "Error"), "err.toString() = " + err.toString());
1899 err = new EvalError();
1900 ok(EvalError.prototype.name === "EvalError", "EvalError.prototype.name = " + EvalError.prototype.name);
1901 ok(err.name === "EvalError", "err.name = " + err.name);
1902 ok(err.toString === Error.prototype.toString, "err.toString !== Error.prototype.toString");
1903 ok(err.message === "", "err.message != ''");
1905 ok(err.message === date, "err.message != date");
1906 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "EvalError: "+err.message),
1907 "err.toString() = " + err.toString());
1908 ok(err.toString !== Object.prototype.toString, "err.toString === Object.prototype.toString");
1909 err = new RangeError();
1910 ok(RangeError.prototype.name === "RangeError", "RangeError.prototype.name = " + RangeError.prototype.name);
1911 ok(err.name === "RangeError", "err.name = " + err.name);
1912 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "RangeError"), "err.toString() = " + err.toString());
1913 err = new ReferenceError();
1914 ok(ReferenceError.prototype.name === "ReferenceError", "ReferenceError.prototype.name = " + ReferenceError.prototype.name);
1915 ok(err.name === "ReferenceError", "err.name = " + err.name);
1916 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "ReferenceError"), "err.toString() = " + err.toString());
1917 err = new SyntaxError();
1918 ok(SyntaxError.prototype.name === "SyntaxError", "SyntaxError.prototype.name = " + SyntaxError.prototype.name);
1919 ok(err.name === "SyntaxError", "err.name = " + err.name);
1920 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "SyntaxError"), "err.toString() = " + err.toString());
1921 err = new TypeError();
1922 ok(TypeError.prototype.name === "TypeError", "TypeError.prototype.name = " + TypeError.prototype.name);
1923 ok(err.name === "TypeError", "err.name = " + err.name);
1924 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "TypeError"), "err.toString() = " + err.toString());
1925 err = new URIError();
1926 ok(URIError.prototype.name === "URIError", "URIError.prototype.name = " + URIError.prototype.name);
1927 ok(err.name === "URIError", "err.name = " + err.name);
1928 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "URIError"), "err.toString() = " + err.toString());
1929 err = new Error("message");
1930 ok(err.message === "message", "err.message !== 'message'");
1931 ok(err.toString() === (invokeVersion < 2 ? "[object Error]" : "Error: message"), "err.toString() = " + err.toString());
1932 err = new Error(123);
1933 ok(err.number === 123, "err.number = " + err.number);
1935 ok(err.number === 254, "err.number = " + err.number);
1936 err = new Error(0, "message");
1937 ok(err.number === 0, "err.number = " + err.number);
1938 ok(err.message === "message", "err.message = " + err.message);
1939 ok(err.description === "message", "err.description = " + err.description);
1941 ok(err.number === 0, "err.number = " + err.number);
1942 ok(err.description === "", "err.description = " + err.description);
1943 err.description = 5;
1944 ok(err.description === 5, "err.description = " + err.description);
1945 ok(err.message === "", "err.message = " + err.message);
1947 ok(err.message === 4, "err.message = " + err.message);
1949 ok(!("number" in Error), "number is in Error");
1952 ok(tmp.hasOwnProperty("toString") === false, "toString property should be inherited");
1953 tmp.toString = function() { return "test"; };
1954 ok(tmp.hasOwnProperty("toString") === true, "toString own property should exist");
1955 ok(tmp.hasOwnProperty("nonExisting") === false, "nonExisting property should not exist");
1957 tmp = Error.prototype.toString.call(tmp);
1958 ok(tmp === "[object Error]", "Error.prototype.toString.call(tmp) = " + tmp);
1960 tmp = function() { return 0; };
1962 ok(tmp.hasOwnProperty("toString") === false, "toString property should be inherited");
1963 ok(tmp.hasOwnProperty("0") === true, "hasOwnProperty(0) returned false");
1964 ok(tmp.hasOwnProperty() === false, "hasOwnProperty() returned true");
1966 ok(Object.prototype.hasOwnProperty.call(testObj) === false, "hasOwnProperty without name returned true");
1968 if(invokeVersion >= 2) {
1971 tmp = Error.prototype.toString.call(obj);
1972 ok(tmp === "test", "Error.prototype.toString.call(obj) = " + tmp);
1976 obj.message = false;
1977 tmp = Error.prototype.toString.call(obj);
1978 ok(tmp === "6: false", "Error.prototype.toString.call(obj) = " + tmp);
1981 obj.message = "test";
1982 tmp = Error.prototype.toString.call(obj);
1983 ok(tmp === "test", "Error.prototype.toString.call(obj) = " + tmp);
1987 obj.message = "test";
1988 tmp = Error.prototype.toString.call(obj);
1989 ok(tmp === "test", "Error.prototype.toString.call(obj) = " + tmp);
1992 tmp = Error.prototype.toString.call(testObj);
1993 ok(tmp === "[object Error]", "Error.prototype.toString.call(testObj) = " + tmp);
1997 ok(err.name === null, "err.name = " + err.name + " expected null");
1998 if(invokeVersion >= 2)
1999 ok(err.toString() === "null", "err.toString() = " + err.toString());
2002 err.message = false;
2003 ok(err.message === false, "err.message = " + err.message + " expected false");
2004 if(invokeVersion >= 2)
2005 ok(err.toString() === "Error: false", "err.toString() = " + err.toString());
2008 err.message = new Object();
2009 err.message.toString = function() { return ""; };
2010 if(invokeVersion >= 2)
2011 ok(err.toString() === "Error", "err.toString() = " + err.toString());
2014 err.message = undefined;
2015 if(invokeVersion >= 2)
2016 ok(err.toString() === "Error", "err.toString() = " + err.toString());
2018 var exception_array = {
2019 E_INVALID_LENGTH: { type: "RangeError", number: -2146823259 },
2021 E_NOT_DATE: { type: "TypeError", number: -2146823282 },
2022 E_NOT_BOOL: { type: "TypeError", number: -2146823278 },
2023 E_ARG_NOT_OPT: { type: "TypeError", number: -2146827839 },
2024 E_NO_PROPERTY: { type: "TypeError", number: -2146827850 },
2025 E_NOT_NUM: { type: "TypeError", number: -2146823287 },
2026 E_INVALID_CALL_ARG: { type: "TypeError", number: -2146828283 },
2027 E_NOT_FUNC: { type: "TypeError", number: -2146823286 },
2028 E_OBJECT_EXPECTED: { type: "TypeError", number: -2146823281 },
2029 E_OBJECT_REQUIRED: { type: "TypeError", number: -2146827864 },
2030 E_UNSUPPORTED_ACTION: { type: "TypeError", number: -2146827843 },
2031 E_NOT_VBARRAY: { type: "TypeError", number: -2146823275 },
2032 E_INVALID_DELETE: { type: "TypeError", number: -2146823276 },
2033 E_UNDEFINED: { type: "TypeError", number: -2146823279 },
2034 E_JSCRIPT_EXPECTED: { type: "TypeError", number: -2146823274 },
2035 E_NOT_ARRAY: { type: "TypeError", number: -2146823257 },
2037 E_SYNTAX_ERROR: { type: "SyntaxError", number: -2146827286 },
2038 E_LBRACKET: { type: "SyntaxError", number: -2146827283 },
2039 E_RBRACKET: { type: "SyntaxError", number: -2146827282 },
2040 E_SEMICOLON: { type: "SyntaxError", number: -2146827284 },
2041 E_UNTERMINATED_STR: { type: "SyntaxError", number: -2146827273 },
2042 E_DISABLED_CC: { type: "SyntaxError", number: -2146827258 },
2043 E_INVALID_BREAK: { type: "SyntaxError", number: -2146827269 },
2044 E_INVALID_CONTINUE: { type: "SyntaxError", number: -2146827268 },
2045 E_LABEL_NOT_FOUND: { type: "SyntaxError", number: -2146827262 },
2046 E_LABEL_REDEFINED: { type: "SyntaxError", number: -2146827263 },
2048 E_ILLEGAL_ASSIGN: { type: "ReferenceError", number: -2146823280 },
2050 E_PRECISION_OUT_OF_RANGE: {type: "RangeError", number: -2146823261 },
2051 E_FRACTION_DIGITS_OUT_OF_RANGE: {type: "RangeError", number: -2146823262 },
2052 E_SUBSCRIPT_OUT_OF_RANGE: {type: "RangeError", number: -2146828279 },
2054 E_REGEXP_SYNTAX_ERROR: { type: "RegExpError", number: -2146823271 },
2056 E_URI_INVALID_CHAR: { type: "URIError", number: -2146823264 },
2057 E_URI_INVALID_CODING: { type: "URIError", number: -2146823263 }
2060 function testException(func, id) {
2061 var ex = exception_array[id];
2062 var ret = "", num = "";
2071 ok(ret === ex.type, "Exception test, ret = " + ret + ", expected " + ex.type +". Executed function: " + func.toString());
2072 ok(num === ex.number, "Exception test, num = " + num + ", expected " + ex.number + ". Executed function: " + func.toString());
2076 testException(function() {Array(-3);}, "E_INVALID_LENGTH");
2077 testException(function() {createArray().lbound("aaa");}, "E_SUBSCRIPT_OUT_OF_RANGE");
2078 testException(function() {createArray().lbound(3);}, "E_SUBSCRIPT_OUT_OF_RANGE");
2079 testException(function() {createArray().getItem(3);}, "E_SUBSCRIPT_OUT_OF_RANGE");
2082 testException(function() {date.setTime();}, "E_ARG_NOT_OPT");
2083 testException(function() {date.setYear();}, "E_ARG_NOT_OPT");
2084 testException(function() {arr.test();}, "E_NO_PROPERTY");
2085 testException(function() {Number.prototype.toString.call(arr);}, "E_NOT_NUM");
2086 testException(function() {Number.prototype.toFixed.call(arr);}, "E_NOT_NUM");
2087 testException(function() {(new Number(3)).toString(1);}, "E_INVALID_CALL_ARG");
2088 testException(function() {(new Number(3)).toFixed(21);}, "E_FRACTION_DIGITS_OUT_OF_RANGE");
2089 testException(function() {(new Number(1)).toPrecision(0);}, "E_PRECISION_OUT_OF_RANGE");
2090 testException(function() {not_existing_variable.something();}, "E_UNDEFINED");
2091 testException(function() {date();}, "E_NOT_FUNC");
2092 testException(function() {arr();}, "E_NOT_FUNC");
2093 testException(function() {(new Object) instanceof (new Object);}, "E_NOT_FUNC");
2094 testException(function() {eval("nonexistingfunc()")}, "E_OBJECT_EXPECTED");
2095 testException(function() {(new Object()) instanceof 3;}, "E_NOT_FUNC");
2096 testException(function() {(new Object()) instanceof null;}, "E_NOT_FUNC");
2097 testException(function() {(new Object()) instanceof nullDisp;}, "E_NOT_FUNC");
2098 testException(function() {"test" in 3;}, "E_OBJECT_EXPECTED");
2099 testException(function() {"test" in null;}, "E_OBJECT_EXPECTED");
2100 testException(function() {"test" in nullDisp;}, "E_OBJECT_EXPECTED");
2101 testException(function() {new 3;}, "E_UNSUPPORTED_ACTION");
2102 testException(function() {new null;}, "E_OBJECT_EXPECTED");
2103 testException(function() {new nullDisp;}, "E_NO_PROPERTY");
2104 testException(function() {new VBArray();}, "E_NOT_VBARRAY");
2105 testException(function() {new VBArray(new VBArray(createArray()));}, "E_NOT_VBARRAY");
2106 testException(function() {VBArray.prototype.lbound.call(new Object());}, "E_NOT_VBARRAY");
2107 testException(function() {+nullDisp.prop;}, "E_OBJECT_REQUIRED");
2108 testException(function() {+nullDisp["prop"];}, "E_OBJECT_REQUIRED");
2109 testException(function() {delete (new Object());}, "E_INVALID_DELETE");
2110 testException(function() {delete false;}, "E_INVALID_DELETE");
2115 testException(function() {delete ((tmp = true) ? obj.prop : obj.prop);}, "E_INVALID_DELETE");
2116 ok(tmp, "delete (..) expression not evaluated");
2118 //FIXME: testException(function() {nonexistent++;}, "E_OBJECT_EXPECTED");
2119 //FIXME: testException(function() {undefined.nonexistent++;}, "E_OBJECT_EXPECTED");
2122 // SyntaxError tests
2123 function testSyntaxError(code, id) {
2124 var ex = exception_array[id];
2125 var ret = "", num = "";
2134 ok(ret === ex.type, "Syntax exception test, ret = " + ret + ", expected " + ex.type +". Executed code: " + code);
2135 ok(num === ex.number, "Syntax exception test, num = " + num + ", expected " + ex.number + ". Executed code: " + code);
2138 testSyntaxError("for(i=0;) {}", "E_SYNTAX_ERROR");
2139 testSyntaxError("function {};", "E_LBRACKET");
2140 testSyntaxError("if", "E_LBRACKET");
2141 testSyntaxError("do i=0; while", "E_LBRACKET");
2142 testSyntaxError("while", "E_LBRACKET");
2143 testSyntaxError("for", "E_LBRACKET");
2144 testSyntaxError("with", "E_LBRACKET");
2145 testSyntaxError("switch", "E_LBRACKET");
2146 testSyntaxError("if(false", "E_RBRACKET");
2147 testSyntaxError("for(i=0; i<10; i++", "E_RBRACKET");
2148 testSyntaxError("while(true", "E_RBRACKET");
2149 testSyntaxError("for(i=0", "E_SEMICOLON");
2150 testSyntaxError("for(i=0;i<10", "E_SEMICOLON");
2151 testSyntaxError("while(", "E_SYNTAX_ERROR");
2152 testSyntaxError("if(", "E_SYNTAX_ERROR");
2153 testSyntaxError("'unterminated", "E_UNTERMINATED_STR");
2154 testSyntaxError("*", "E_SYNTAX_ERROR");
2155 testSyntaxError("@_jscript_version", "E_DISABLED_CC");
2156 testSyntaxError("@a", "E_DISABLED_CC");
2157 testSyntaxError("/* @cc_on @*/ @_jscript_version", "E_DISABLED_CC");
2158 testSyntaxError("ok(false, 'unexpected execution'); break;", "E_INVALID_BREAK");
2159 testSyntaxError("ok(false, 'unexpected execution'); continue;", "E_INVALID_CONTINUE");
2160 testSyntaxError("ok(false, 'unexpected execution'); while(true) break unknown_label;", "E_LABEL_NOT_FOUND");
2161 testSyntaxError("ok(false, 'unexpected execution'); some_label: continue some_label;", "E_INVALID_CONTINUE");
2162 testSyntaxError("ok(false, 'unexpected execution'); while(true) continue some_label;", "E_LABEL_NOT_FOUND");
2163 testSyntaxError("ok(false, 'unexpected execution'); some_label: { while(true) continue some_label; }", "E_INVALID_CONTINUE");
2164 testSyntaxError("ok(false, 'unexpected execution'); some_label: { some_label: while(true); }", "E_LABEL_REDEFINED");
2166 // ReferenceError tests
2167 testException(function() {test = function() {}}, "E_ILLEGAL_ASSIGN");
2170 testException(function() {test = (tmp = true);}, "E_ILLEGAL_ASSIGN");
2171 ok(tmp, "expr value on invalid assign not evaluated");
2174 testException(function() {(tmp = true) = false;}, "E_ILLEGAL_ASSIGN");
2175 ok(tmp, "expr assign not evaluated");
2178 testException(function() {true = (tmp = true);}, "E_ILLEGAL_ASSIGN");
2179 ok(tmp, "expr value assign not evaluated");
2182 testException(function() {(tmp = tmp+"1") = (tmp = tmp+"2");}, "E_ILLEGAL_ASSIGN");
2183 ok(tmp === "12", "assign evaluated in unexpected order");
2186 testException(function() { ((tmp = true) && false)++; }, "E_ILLEGAL_ASSIGN")
2187 ok(tmp, "incremented expression not evaluated");
2189 // RegExpError tests
2190 testException(function() {RegExp(/a/, "g");}, "E_REGEXP_SYNTAX_ERROR");
2193 testException(function() {encodeURI('\udcaa');}, "E_URI_INVALID_CHAR");
2194 testException(function() {encodeURIComponent('\udcaa');}, "E_URI_INVALID_CHAR");
2195 testException(function() {decodeURI('%');}, "E_URI_INVALID_CODING");
2196 testException(function() {decodeURI('%aaaa');}, "E_URI_INVALID_CODING");
2198 function testThisExcept(func, e) {
2199 testException(function() {func.call(new Object())}, e);
2202 function testBoolThis(func) {
2203 testThisExcept(Boolean.prototype[func], "E_NOT_BOOL");
2206 testBoolThis("toString");
2207 testBoolThis("valueOf");
2209 function testDateThis(func) {
2210 testThisExcept(Date.prototype[func], "E_NOT_DATE");
2213 testDateThis("getDate");
2214 testDateThis("getDay");
2215 testDateThis("getFullYear");
2216 testDateThis("getHours");
2217 testDateThis("getMilliseconds");
2218 testDateThis("getMinutes");
2219 testDateThis("getMonth");
2220 testDateThis("getSeconds");
2221 testDateThis("getTime");
2222 testDateThis("getTimezoneOffset");
2223 testDateThis("getUTCDate");
2224 testDateThis("getUTCDay");
2225 testDateThis("getUTCFullYear");
2226 testDateThis("getUTCHours");
2227 testDateThis("getUTCMilliseconds");
2228 testDateThis("getUTCMinutes");
2229 testDateThis("getUTCMonth");
2230 testDateThis("getUTCSeconds");
2231 testDateThis("getYear");
2232 testDateThis("setDate");
2233 testDateThis("setFullYear");
2234 testDateThis("setHours");
2235 testDateThis("setMilliseconds");
2236 testDateThis("setMinutes");
2237 testDateThis("setMonth");
2238 testDateThis("setSeconds");
2239 testDateThis("setTime");
2240 testDateThis("setUTCDate");
2241 testDateThis("setUTCFullYear");
2242 testDateThis("setUTCHours");
2243 testDateThis("setUTCMilliseconds");
2244 testDateThis("setUTCMinutes");
2245 testDateThis("setUTCMonth");
2246 testDateThis("setUTCSeconds");
2247 testDateThis("setYear");
2248 testDateThis("toDateString");
2249 testDateThis("toLocaleDateString");
2250 testDateThis("toLocaleString");
2251 testDateThis("toLocaleTimeString");
2252 testDateThis("toString");
2253 testDateThis("toTimeString");
2254 testDateThis("toUTCString");
2255 testDateThis("valueOf");
2257 function testArrayThis(func) {
2258 testThisExcept(Array.prototype[func], "E_NOT_ARRAY");
2261 testArrayThis("toString");
2263 function testFunctionThis(func) {
2264 testThisExcept(Function.prototype[func], "E_NOT_FUNC");
2267 testFunctionThis("toString");
2268 testFunctionThis("call");
2269 testFunctionThis("apply");
2271 function testArrayHostThis(func) {
2272 testException(function() { Array.prototype[func].call(testObj); }, "E_JSCRIPT_EXPECTED");
2275 testArrayHostThis("push");
2276 testArrayHostThis("shift");
2277 testArrayHostThis("slice");
2278 testArrayHostThis("splice");
2279 testArrayHostThis("unshift");
2280 testArrayHostThis("reverse");
2281 testArrayHostThis("join");
2282 testArrayHostThis("pop");
2283 testArrayHostThis("sort");
2285 function testObjectInherit(obj, constr, ts, tls, vo) {
2286 ok(obj instanceof Object, "obj is not instance of Object");
2287 ok(obj instanceof constr, "obj is not instance of its constructor");
2289 ok(obj.hasOwnProperty === Object.prototype.hasOwnProperty,
2290 "obj.hasOwnProperty !== Object.prototype.hasOwnProprty");
2291 ok(obj.isPrototypeOf === Object.prototype.isPrototypeOf,
2292 "obj.isPrototypeOf !== Object.prototype.isPrototypeOf");
2293 ok(obj.propertyIsEnumerable === Object.prototype.propertyIsEnumerable,
2294 "obj.propertyIsEnumerable !== Object.prototype.propertyIsEnumerable");
2297 ok(obj.toString === Object.prototype.toString,
2298 "obj.toString !== Object.prototype.toString");
2300 ok(obj.toString != Object.prototype.toString,
2301 "obj.toString == Object.prototype.toString");
2304 ok(obj.toLocaleString === Object.prototype.toLocaleString,
2305 "obj.toLocaleString !== Object.prototype.toLocaleString");
2307 ok(obj.toLocaleString != Object.prototype.toLocaleString,
2308 "obj.toLocaleString == Object.prototype.toLocaleString");
2311 ok(obj.valueOf === Object.prototype.valueOf,
2312 "obj.valueOf !== Object.prototype.valueOf");
2314 ok(obj.valueOf != Object.prototype.valueOf,
2315 "obj.valueOf == Object.prototype.valueOf");
2317 ok(obj._test === "test", "obj.test = " + obj._test);
2320 Object.prototype._test = "test";
2321 testObjectInherit(new String("test"), String, false, true, false);
2322 testObjectInherit(/test/g, RegExp, false, true, true);
2323 testObjectInherit(new Number(1), Number, false, false, false);
2324 testObjectInherit(new Date(), Date, false, false, false);
2325 testObjectInherit(new Boolean(true), Boolean, false, true, false);
2326 testObjectInherit(new Array(), Array, false, false, true);
2327 testObjectInherit(new Error(), Error, false, true, true);
2328 testObjectInherit(testObjectInherit, Function, false, true, true);
2329 testObjectInherit(Math, Object, true, true, true);
2331 (function() { testObjectInherit(arguments, Object, true, true, true); })();
2333 function testFunctions(obj, arr) {
2336 for(var i=0; i<arr.length; i++) {
2337 l = obj[arr[i][0]].length;
2338 ok(l === arr[i][1], arr[i][0] + ".length = " + l);
2342 testFunctions(Boolean.prototype, [
2347 testFunctions(Number.prototype, [
2350 ["toExponential", 1],
2351 ["toLocaleString", 0],
2355 testFunctions(String.prototype, [
2372 ["localeCompare", 1],
2384 ["toLocaleLowerCase", 0],
2385 ["toLocaleUpperCase", 0],
2390 testFunctions(RegExp.prototype, [
2396 testFunctions(Date.prototype, [
2401 ["getMilliseconds", 0],
2406 ["getTimezoneOffset", 0],
2409 ["getUTCFullYear", 0],
2411 ["getUTCMilliseconds", 0],
2412 ["getUTCMinutes", 0],
2414 ["getUTCSeconds", 0],
2419 ["setMilliseconds", 1],
2425 ["setUTCFullYear", 3],
2427 ["setUTCMilliseconds", 1],
2428 ["setUTCMinutes", 3],
2430 ["setUTCSeconds", 2],
2432 ["toDateString", 0],
2433 ["toLocaleDateString", 0],
2434 ["toLocaleString", 0],
2435 ["toLocaleTimeString", 0],
2437 ["toTimeString", 0],
2443 testFunctions(Array.prototype, [
2453 ["toLocaleString", 0],
2458 testFunctions(Error.prototype, [
2462 testFunctions(Math, [
2483 testFunctions(Object.prototype, [
2484 ["hasOwnProperty", 1],
2485 ["isPrototypeOf", 1],
2486 ["propertyIsEnumerable", 1],
2487 ["toLocaleString", 0],
2492 testFunctions(Function.prototype, [
2498 testFunctions(VBArray.prototype, [
2506 ok(ActiveXObject.length == 1, "ActiveXObject.length = " + ActiveXObject.length);
2507 ok(Array.length == 1, "Array.length = " + Array.length);
2508 ok(Boolean.length == 1, "Boolean.length = " + Boolean.length);
2509 ok(CollectGarbage.length == 0, "CollectGarbage.length = " + CollectGarbage.length);
2510 ok(Date.length == 7, "Date.length = " + Date.length);
2511 ok(Enumerator.length == 7, "Enumerator.length = " + Enumerator.length);
2512 ok(Error.length == 1, "Error.length = " + Error.length);
2513 ok(EvalError.length == 1, "EvalError.length = " + EvalError.length);
2514 ok(Function.length == 1, "Function.length = " + Function.length);
2515 ok(GetObject.length == 2, "GetObject.length = " + GetObject.length);
2516 ok(Number.length == 1, "Number.length = " + Number.length);
2517 ok(Object.length == 0, "Object.length = " + Object.length);
2518 ok(RangeError.length == 1, "RangeError.length = " + RangeError.length);
2519 ok(ReferenceError.length == 1, "ReferenceError.length = " + ReferenceError.length);
2520 ok(RegExp.length == 2, "RegExp.length = " + RegExp.length);
2521 ok(ScriptEngine.length == 0, "ScriptEngine.length = " + ScriptEngine.length);
2522 ok(ScriptEngineBuildVersion.length == 0,
2523 "ScriptEngineBuildVersion.length = " + ScriptEngineBuildVersion.length);
2524 ok(ScriptEngineMajorVersion.length == 0,
2525 "ScriptEngineMajorVersion.length = " + ScriptEngineMajorVersion.length);
2526 ok(ScriptEngineMinorVersion.length == 0,
2527 "ScriptEngineMinorVersion.length = " + ScriptEngineMinorVersion.length);
2528 ok(String.length == 1, "String.length = " + String.length);
2529 ok(SyntaxError.length == 1, "SyntaxError.length = " + SyntaxError.length);
2530 ok(TypeError.length == 1, "TypeError.length = " + TypeError.length);
2531 ok(URIError.length == 1, "URIError.length = " + URIError.length);
2532 ok(VBArray.length == 1, "VBArray.length = " + VBArray.length);
2533 ok(decodeURI.length == 1, "decodeURI.length = " + decodeURI.length);
2534 ok(decodeURIComponent.length == 1, "decodeURIComponent.length = " + decodeURIComponent.length);
2535 ok(encodeURI.length == 1, "encodeURI.length = " + encodeURI.length);
2536 ok(encodeURIComponent.length == 1, "encodeURIComponent.length = " + encodeURIComponent.length);
2537 ok(escape.length == 1, "escape.length = " + escape.length);
2538 ok(eval.length == 1, "eval.length = " + eval.length);
2539 ok(isFinite.length == 1, "isFinite.length = " + isFinite.length);
2540 ok(isNaN.length == 1, "isNaN.length = " + isNaN.length);
2541 ok(parseFloat.length == 1, "parseFloat.length = " + parseFloat.length);
2542 ok(parseInt.length == 2, "parseInt.length = " + parseInt.length);
2543 ok(unescape.length == 1, "unescape.length = " + unescape.length);
2546 ok(String.length == 1, "String.length = " + String.length);
2548 var tmp = createArray();
2549 ok(getVT(tmp) == "VT_ARRAY|VT_VARIANT", "getVT(createArray()) = " + getVT(tmp));
2550 ok(getVT(VBArray(tmp)) == "VT_ARRAY|VT_VARIANT", "getVT(VBArray(tmp)) = " + getVT(VBArray(tmp)));
2551 tmp = new VBArray(tmp);
2552 tmp = new VBArray(VBArray(createArray()));
2553 ok(tmp.dimensions() == 2, "tmp.dimensions() = " + tmp.dimensions());
2554 ok(tmp.lbound() == 0, "tmp.lbound() = " + tmp.lbound());
2555 ok(tmp.lbound(1) == 0, "tmp.lbound(1) = " + tmp.lbound(1));
2556 ok(tmp.lbound(2, 1) == 2, "tmp.lbound(2, 1) = " + tmp.lbound(2, 1));
2557 ok(tmp.ubound() == 4, "tmp.ubound() = " + tmp.ubound());
2558 ok(tmp.ubound("2") == 3, "tmp.ubound(\"2\") = " + tmp.ubound("2"));
2559 ok(tmp.getItem(1, 2) == 3, "tmp.getItem(1, 2) = " + tmp.getItem(1, 2));
2560 ok(tmp.getItem(2, 3) == 33, "tmp.getItem(2, 3) = " + tmp.getItem(2, 3));
2561 ok(tmp.getItem(3, 2) == 13, "tmp.getItem(3, 2) = " + tmp.getItem(3, 2));
2562 ok(tmp.toArray() == "2,3,12,13,22,23,32,33,42,43", "tmp.toArray() = " + tmp.toArray());
2563 ok(createArray().toArray() == "2,3,12,13,22,23,32,33,42,43",
2564 "createArray.toArray()=" + createArray().toArray());