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
22 ok(i
=== 0, "parseInt('0') = " + i
);
24 ok(i
=== 123, "parseInt('123') = " + i
);
26 ok(i
=== -123, "parseInt('-123') = " + i
);
28 ok(i
=== 0xff, "parseInt('0xff') = " + i
);
29 i
= parseInt("11", 8);
30 ok(i
=== 9, "parseInt('11', 8) = " + i
);
31 i
= parseInt("1j", 22);
32 ok(i
=== 41, "parseInt('1j', 32) = " + i
);
33 i
= parseInt("123", 0);
34 ok(i
=== 123, "parseInt('123', 0) = " + i
);
35 i
= parseInt("123", 10, "test");
36 ok(i
=== 123, "parseInt('123', 10, 'test') = " + i
);
37 i
= parseInt("11", "8");
38 ok(i
=== 9, "parseInt('11', '8') = " + i
);
40 tmp
= encodeURI("abc");
41 ok(tmp
=== "abc", "encodeURI('abc') = " + tmp
);
42 tmp
= encodeURI("{abc}");
43 ok(tmp
=== "%7Babc%7D", "encodeURI('{abc}') = " + tmp
);
45 ok(tmp
=== "", "encodeURI('') = " + tmp
);
46 tmp
= encodeURI("\01\02\03\04");
47 ok(tmp
=== "%01%02%03%04", "encodeURI('\\01\\02\\03\\04') = " + tmp
);
48 tmp
= encodeURI("{#@}");
49 ok(tmp
=== "%7B#@%7D", "encodeURI('{#@}') = " + tmp
);
50 tmp
= encodeURI("\xa1 ");
51 ok(tmp
=== "%C2%A1%20", "encodeURI(\\xa1 ) = " + tmp
);
52 tmp
= encodeURI("\xffff");
53 ok(tmp
.length
=== 8, "encodeURI('\\xffff').length = " + tmp
.length
);
54 tmp
= encodeURI("abcABC123;/?:@&=+$,-_.!~*'()");
55 ok(tmp
=== "abcABC123;/?:@&=+$,-_.!~*'()", "encodeURI('abcABC123;/?:@&=+$,-_.!~*'()') = " + tmp
);
57 ok(tmp
=== "undefined", "encodeURI() = " + tmp
);
58 tmp
= encodeURI("abc", "test");
59 ok(tmp
=== "abc", "encodeURI('abc') = " + tmp
);
61 tmp
= encodeURIComponent("abc");
62 ok(tmp
=== "abc", "encodeURIComponent('abc') = " + tmp
);
63 dec
= decodeURIComponent(tmp
);
64 ok(dec
=== "abc", "decodeURIComponent('" + tmp
+ "') = " + dec
);
65 tmp
= encodeURIComponent("{abc}");
66 ok(tmp
=== "%7Babc%7D", "encodeURIComponent('{abc}') = " + tmp
);
67 dec
= decodeURIComponent(tmp
);
68 ok(dec
=== "{abc}", "decodeURIComponent('" + tmp
+ "') = " + dec
);
69 tmp
= encodeURIComponent("");
70 ok(tmp
=== "", "encodeURIComponent('') = " + tmp
);
71 dec
= decodeURIComponent(tmp
);
72 ok(dec
=== "", "decodeURIComponent('" + tmp
+ "') = " + dec
);
73 tmp
= encodeURIComponent("\01\02\03\04");
74 ok(tmp
=== "%01%02%03%04", "encodeURIComponent('\\01\\02\\03\\04') = " + tmp
);
75 dec
= decodeURIComponent(tmp
);
76 ok(dec
=== "\01\02\03\04", "decodeURIComponent('" + tmp
+ "') = " + dec
);
77 tmp
= encodeURIComponent("{#@}");
78 ok(tmp
=== "%7B%23%40%7D", "encodeURIComponent('{#@}') = " + tmp
);
79 dec
= decodeURIComponent(tmp
);
80 ok(dec
=== "{#@}", "decodeURIComponent('" + tmp
+ "') = " + dec
);
81 tmp
= encodeURIComponent("\xa1 ");
82 ok(tmp
=== "%C2%A1%20", "encodeURIComponent(\\xa1 ) = " + tmp
);
83 dec
= decodeURIComponent(tmp
);
84 ok(dec
=== "\xa1 ", "decodeURIComponent('" + tmp
+ "') = " + dec
);
85 tmp
= encodeURIComponent("\xffff");
86 ok(tmp
.length
=== 8, "encodeURIComponent('\\xffff').length = " + tmp
.length
);
87 dec
= decodeURIComponent(tmp
);
88 ok(dec
=== "\xffff", "decodeURIComponent('" + tmp
+ "') = " + dec
);
89 tmp
= encodeURIComponent("abcABC123;/?:@&=+$,-_.!~*'()");
90 ok(tmp
=== "abcABC123%3B%2F%3F%3A%40%26%3D%2B%24%2C-_.!~*'()", "encodeURIComponent('abcABC123;/?:@&=+$,-_.!~*'()') = " + tmp
);
91 dec
= decodeURIComponent(tmp
);
92 ok(dec
=== "abcABC123;/?:@&=+$,-_.!~*'()", "decodeURIComponent('" + tmp
+ "') = " + dec
);
93 tmp
= encodeURIComponent();
94 ok(tmp
=== "undefined", "encodeURIComponent() = " + tmp
);
95 tmp
= encodeURIComponent("abc", "test");
96 ok(tmp
=== "abc", "encodeURIComponent('abc') = " + tmp
);
97 dec
= decodeURIComponent();
98 ok(dec
=== "undefined", "decodeURIComponent() = " + dec
);
99 dec
= decodeURIComponent("abc", "test");
100 ok(dec
=== "abc", "decodeURIComponent('abc') = " + dec
);
103 ok(tmp
=== "abc", "escape('abc') = " + tmp
);
105 ok(tmp
=== "", "escape('') = " + tmp
);
106 tmp
= escape("a1b c!d+e@*-_+./,");
107 ok(tmp
=== "a1b%20c%21d+e@*-_+./%2C", "escape('a1b c!d+e@*-_+./,') = " + tmp
);
109 ok(tmp
=== "undefined", "escape() = " + tmp
);
110 tmp
= escape('\u1234\123\xf3');
111 ok(tmp
== "%u1234S%F3", "escape('\u1234\123\xf3') = " + tmp
);
113 tmp
= unescape("abc");
114 ok(tmp
=== "abc", "unescape('abc') = " + tmp
);
116 ok(tmp
=== "", "unescape('') = " + tmp
);
117 tmp
= unescape("%%%");
118 ok(tmp
=== "%%%", "unescape('%%%') = " + tmp
);
120 ok(tmp
=== "undefined", "unescape() = " + tmp
);
121 tmp
= unescape("%54%65s%u0074");
122 ok(tmp
=== "Test", "unescape('%54%65s%u0074') = " + tmp
);
124 tmp
= "aA1~`!@#$%^&*()_+=-][{}';:/.,<>?\|";
125 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
));
126 ok(unescape(escape(tmp
)) === tmp
, "unescape(escape('" + tmp
+ "')) = " + unescape(escape(tmp
)));
128 tmp
= "" + new Object();
129 ok(tmp
=== "[object Object]", "'' + new Object() = " + tmp
);
130 (tmp
= new Array
).f
= Object
.prototype.toString
;
131 ok(tmp
.f() === "[object Array]", "tmp.f() = " + tmp
.f());
132 (tmp
= new Boolean
).f
= Object
.prototype.toString
;
133 ok(tmp
.f() === "[object Boolean]", "tmp.f() = " + tmp
.f());
134 (tmp
= new Date
).f
= Object
.prototype.toString
;
135 ok(tmp
.f() === "[object Date]", "tmp.f() = " + tmp
.f());
136 (tmp = function() {}).f
= Object
.prototype.toString
;
137 ok(tmp
.f() === "[object Function]", "tmp.f() = " + tmp
.f());
138 Math
.f
= Object
.prototype.toString
;
139 ok(Math
.f() === "[object Math]", "tmp.f() = " + tmp
.f());
140 (tmp
= new Number
).f
= Object
.prototype.toString
;
141 ok(tmp
.f() === "[object Number]", "tmp.f() = " + tmp
.f());
142 (tmp
= new RegExp("")).f
= Object
.prototype.toString
;
143 ok(tmp
.f() === "[object RegExp]", "tmp.f() = " + tmp
.f());
144 (tmp
= new String
).f
= Object
.prototype.toString
;
145 ok(tmp
.f() === "[object String]", "tmp.f() = " + tmp
.f());
146 tmp
= Object
.prototype.toString
.call(testObj
);
147 ok(tmp
=== "[object Object]", "toString.call(testObj) = " + tmp
);
148 tmp
= Object
.prototype.toString
.call(this);
149 ok(tmp
=== "[object Object]", "toString.call(this) = " + tmp
);
150 (function () { tmp
= Object
.prototype.toString
.call(arguments
); })();
151 ok(tmp
=== "[object Object]", "toString.call(arguments) = " + tmp
);
153 ok(Object(1) instanceof Number
, "Object(1) is not instance of Number");
154 ok(Object("") instanceof String
, "Object('') is not instance of String");
155 ok(Object(false) instanceof Boolean
, "Object(false) is not instance of Boolean");
158 ok(Object(obj
) === obj
, "Object(obj) !== obj");
160 ok(typeof(Object()) === "object", "typeof(Object()) !== 'object'");
161 ok(typeof(Object(undefined)) === "object", "typeof(Object(undefined)) !== 'object'");
162 ok(typeof(Object(null)) === "object", "typeof(Object(null)) !== 'object'");
164 var obj
= new Object();
165 obj
.toString = function (x
) {
166 ok(arguments
.length
=== 0, "arguments.length = " + arguments
.length
);
169 ok((tmp
= obj
.toLocaleString()) === "test", "obj.toLocaleString() = " + tmp
);
170 ok((tmp
= obj
.toLocaleString(1)) === "test", "obj.toLocaleString(1) = " + tmp
);
171 ok(obj
=== obj
.valueOf(), "obj !== obj.valueOf");
173 ok("".length
=== 0, "\"\".length = " + "".length
);
174 ok(getVT("".length
) == "VT_I4", "\"\".length = " + "".length
);
175 ok("abc".length
=== 3, "\"abc\".length = " + "abc".length
);
176 ok(String
.prototype.length
=== 0, "String.prototype.length = " + String
.prototype.length
);
179 ok(tmp
=== "", "''.toString() = " + tmp
);
180 tmp
= "test".toString();
181 ok(tmp
=== "test", "''.toString() = " + tmp
);
182 tmp
= "test".toString(3);
183 ok(tmp
=== "test", "''.toString(3) = " + tmp
);
186 ok(tmp
=== "", "''.valueOf() = " + tmp
);
187 tmp
= "test".valueOf();
188 ok(tmp
=== "test", "''.valueOf() = " + tmp
);
189 tmp
= "test".valueOf(3);
190 ok(tmp
=== "test", "''.valueOf(3) = " + tmp
);
192 var str
= new String("test");
193 ok(str
.toString() === "test", "str.toString() = " + str
.toString());
194 var str
= new String();
195 ok(str
.toString() === "", "str.toString() = " + str
.toString());
196 var str
= new String("test", "abc");
197 ok(str
.toString() === "test", "str.toString() = " + str
.toString());
199 var strObj
= new Object();
200 strObj
.toString = function() { return "abcd" };
201 strObj
.substr
= String
.prototype.substr
;
202 strObj
.lastIndexOf
= String
.prototype.lastIndexOf
;
204 tmp
= "value " + str
;
205 ok(tmp
=== "value test", "'value ' + str = " + tmp
);
208 ok(tmp
=== "", "String() = " + tmp
);
210 ok(tmp
=== "false", "String(false) = " + tmp
);
212 ok(tmp
=== "null", "String(null) = " + tmp
);
213 tmp
= String("test");
214 ok(tmp
=== "test", "String('test') = " + tmp
);
215 tmp
= String("test", "abc");
216 ok(tmp
=== "test", "String('test','abc') = " + tmp
);
218 tmp
= "abc".charAt(0);
219 ok(tmp
=== "a", "'abc',charAt(0) = " + tmp
);
220 tmp
= "abc".charAt(1);
221 ok(tmp
=== "b", "'abc',charAt(1) = " + tmp
);
222 tmp
= "abc".charAt(2);
223 ok(tmp
=== "c", "'abc',charAt(2) = " + tmp
);
224 tmp
= "abc".charAt(3);
225 ok(tmp
=== "", "'abc',charAt(3) = " + tmp
);
226 tmp
= "abc".charAt(4);
227 ok(tmp
=== "", "'abc',charAt(4) = " + tmp
);
228 tmp
= "abc".charAt();
229 ok(tmp
=== "a", "'abc',charAt() = " + tmp
);
230 tmp
= "abc".charAt(-1);
231 ok(tmp
=== "", "'abc',charAt(-1) = " + tmp
);
232 tmp
= "abc".charAt(0,2);
233 ok(tmp
=== "a", "'abc',charAt(0.2) = " + tmp
);
234 tmp
= "abc".charAt(NaN
);
235 ok(tmp
=== "a", "'abc',charAt(NaN) = " + tmp
);
237 tmp
= "abc".charCodeAt(0);
238 ok(tmp
=== 0x61, "'abc'.charCodeAt(0) = " + tmp
);
239 tmp
= "abc".charCodeAt(1);
240 ok(tmp
=== 0x62, "'abc'.charCodeAt(1) = " + tmp
);
241 tmp
= "abc".charCodeAt(2);
242 ok(tmp
=== 0x63, "'abc'.charCodeAt(2) = " + tmp
);
243 tmp
= "abc".charCodeAt();
244 ok(tmp
=== 0x61, "'abc'.charCodeAt() = " + tmp
);
245 tmp
= "abc".charCodeAt(true);
246 ok(tmp
=== 0x62, "'abc'.charCodeAt(true) = " + tmp
);
247 tmp
= "abc".charCodeAt(0,2);
248 ok(tmp
=== 0x61, "'abc'.charCodeAt(0,2) = " + tmp
);
249 tmp
= "\u49F4".charCodeAt(0);
250 ok(tmp
=== 0x49F4, "'\u49F4'.charCodeAt(0) = " + tmp
);
251 tmp
= "\052".charCodeAt(0);
252 ok(tmp
=== 0x2A, "'\052'.charCodeAt(0) = " + tmp
);
253 tmp
= "\xa2".charCodeAt(0);
254 ok(tmp
=== 0xA2, "'\xa2'.charCodeAt(0) = " + tmp
);
256 tmp
= "abcd".substring(1,3);
257 ok(tmp
=== "bc", "'abcd'.substring(1,3) = " + tmp
);
258 tmp
= "abcd".substring(-1,3);
259 ok(tmp
=== "abc", "'abcd'.substring(-1,3) = " + tmp
);
260 tmp
= "abcd".substring(1,6);
261 ok(tmp
=== "bcd", "'abcd'.substring(1,6) = " + tmp
);
262 tmp
= "abcd".substring(3,1);
263 ok(tmp
=== "bc", "'abcd'.substring(3,1) = " + tmp
);
264 tmp
= "abcd".substring(2,2);
265 ok(tmp
=== "", "'abcd'.substring(2,2) = " + tmp
);
266 tmp
= "abcd".substring(true,"3");
267 ok(tmp
=== "bc", "'abcd'.substring(true,'3') = " + tmp
);
268 tmp
= "abcd".substring(1,3,2);
269 ok(tmp
=== "bc", "'abcd'.substring(1,3,2) = " + tmp
);
270 tmp
= "abcd".substring();
271 ok(tmp
=== "abcd", "'abcd'.substring() = " + tmp
);
273 tmp
= "abcd".substr(1,3);
274 ok(tmp
=== "bcd", "'abcd'.substr(1,3) = " + tmp
);
275 tmp
= "abcd".substr(-1,3);
276 ok(tmp
=== "abc", "'abcd'.substr(-1,3) = " + tmp
);
277 tmp
= "abcd".substr(1,6);
278 ok(tmp
=== "bcd", "'abcd'.substr(1,6) = " + tmp
);
279 tmp
= "abcd".substr(2,-1);
280 ok(tmp
=== "", "'abcd'.substr(3,1) = " + tmp
);
281 tmp
= "abcd".substr(2,0);
282 ok(tmp
=== "", "'abcd'.substr(2,2) = " + tmp
);
283 tmp
= "abcd".substr(true,"3");
284 ok(tmp
=== "bcd", "'abcd'.substr(true,'3') = " + tmp
);
285 tmp
= "abcd".substr(1,3,2);
286 ok(tmp
=== "bcd", "'abcd'.substr(1,3,2) = " + tmp
);
287 tmp
= "abcd".substr();
288 ok(tmp
=== "abcd", "'abcd'.substr() = " + tmp
);
289 tmp
= strObj
.substr(1,1);
290 ok(tmp
=== "b", "'abcd'.substr(1,3) = " + tmp
);
292 tmp
= "abcd".slice(1,3);
293 ok(tmp
=== "bc", "'abcd'.slice(1,3) = " + tmp
);
294 tmp
= "abcd".slice(1,-1);
295 ok(tmp
=== "bc", "'abcd'.slice(1,-1) = " + tmp
);
296 tmp
= "abcd".slice(-3,3);
297 ok(tmp
=== "bc", "'abcd'.slice(-3,3) = " + tmp
);
298 tmp
= "abcd".slice(-6,3);
299 ok(tmp
=== "abc", "'abcd'.slice(-6,3) = " + tmp
);
300 tmp
= "abcd".slice(3,1);
301 ok(tmp
=== "", "'abcd'.slice(3,1) = " + tmp
);
302 tmp
= "abcd".slice(true,3);
303 ok(tmp
=== "bc", "'abcd'.slice(true,3) = " + tmp
);
304 tmp
= "abcd".slice();
305 ok(tmp
=== "abcd", "'abcd'.slice() = " + tmp
);
306 tmp
= "abcd".slice(1);
307 ok(tmp
=== "bcd", "'abcd'.slice(1) = " + tmp
);
309 tmp
= "abc".concat(["d",1],2,false);
310 ok(tmp
=== "abcd,12false", "concat returned " + tmp
);
311 var arr
= new Array(2,"a");
312 arr
.concat
= String
.prototype.concat
;
313 tmp
= arr
.concat("d");
314 ok(tmp
=== "2,ad", "arr.concat = " + tmp
);
316 m
= "a+bcabc".match("a+");
317 ok(typeof(m
) === "object", "typeof m is not object");
318 ok(m
.length
=== 1, "m.length is not 1");
319 ok(m
["0"] === "a", "m[0] is not \"ab\"");
321 r
= "- [test] -".replace("[test]", "success");
322 ok(r
=== "- success -", "r = " + r
+ " expected '- success -'");
324 r
= "- [test] -".replace("[test]", "success", "test");
325 ok(r
=== "- success -", "r = " + r
+ " expected '- success -'");
327 r
= "test".replace();
328 ok(r
=== "test", "r = " + r
+ " expected 'test'");
330 function replaceFunc3(m
, off
, str
) {
331 ok(arguments
.length
=== 3, "arguments.length = " + arguments
.length
);
332 ok(m
=== "[test]", "m = " + m
+ " expected [test1]");
333 ok(off
=== 1, "off = " + off
+ " expected 0");
334 ok(str
=== "-[test]-", "str = " + arguments
[3]);
338 r
= "-[test]-".replace("[test]", replaceFunc3
);
339 ok(r
=== "-ret-", "r = " + r
+ " expected '-ret-'");
341 r
= "-[test]-".replace("[test]", replaceFunc3
, "test");
342 ok(r
=== "-ret-", "r = " + r
+ " expected '-ret-'");
344 r
= "1,2,3".split(",");
345 ok(typeof(r
) === "object", "typeof(r) = " + typeof(r
));
346 ok(r
.length
=== 3, "r.length = " + r
.length
);
347 ok(r
[0] === "1", "r[0] = " + r
[0]);
348 ok(r
[1] === "2", "r[1] = " + r
[1]);
349 ok(r
[2] === "3", "r[2] = " + r
[2]);
352 r
= "1,2,3".split(",*");
353 ok(r
.length
=== 1, "r.length = " + r
.length
);
354 ok(r
[0] === "1,2,3", "r[0] = " + r
[0]);
357 ok(r
.length
=== 3, "r.length = " + r
.length
);
358 ok(r
[0] === "1", "r[0] = " + r
[0]);
359 ok(r
[1] === "2", "r[1] = " + r
[1]);
360 ok(r
[2] === "3", "r[2] = " + r
[2]);
363 ok(r
.length
=== 2, "r.length = " + r
.length
);
364 ok(r
[0] === "1", "r[0] = " + r
[0]);
365 ok(r
[1] === "3", "r[1] = " + r
[1]);
367 r
= "1,2,".split(",");
368 ok(typeof(r
) === "object", "typeof(r) = " + typeof(r
));
369 ok(r
.length
=== 3, "r.length = " + r
.length
);
370 ok(r
[0] === "1", "r[0] = " + r
[0]);
371 ok(r
[1] === "2", "r[1] = " + r
[1]);
372 ok(r
[2] === "", "r[2] = " + r
[2]);
374 tmp
= "abcd".indexOf("bc",0);
375 ok(tmp
=== 1, "indexOf = " + tmp
);
376 tmp
= "abcd".indexOf("bc",1);
377 ok(tmp
=== 1, "indexOf = " + tmp
);
378 tmp
= "abcd".indexOf("bc");
379 ok(tmp
=== 1, "indexOf = " + tmp
);
380 tmp
= "abcd".indexOf("ac");
381 ok(tmp
=== -1, "indexOf = " + tmp
);
382 tmp
= "abcd".indexOf("bc",2);
383 ok(tmp
=== -1, "indexOf = " + tmp
);
384 tmp
= "abcd".indexOf("a",0);
385 ok(tmp
=== 0, "indexOf = " + tmp
);
386 tmp
= "abcd".indexOf("bc",0,"test");
387 ok(tmp
=== 1, "indexOf = " + tmp
);
388 tmp
= "abcd".indexOf();
389 ok(tmp
== -1, "indexOf = " + tmp
);
391 tmp
= "abcd".lastIndexOf("bc",1);
392 ok(tmp
=== 1, "lastIndexOf = " + tmp
);
393 tmp
= "abcd".lastIndexOf("bc",2);
394 ok(tmp
=== 1, "lastIndexOf = " + tmp
);
395 tmp
= "abcd".lastIndexOf("bc");
396 ok(tmp
=== 1, "lastIndexOf = " + tmp
);
397 tmp
= "abcd".lastIndexOf("ac");
398 ok(tmp
=== -1, "lastIndexOf = " + tmp
);
399 tmp
= "abcd".lastIndexOf("d",10);
400 ok(tmp
=== 3, "lastIndexOf = " + tmp
);
401 tmp
= "abcd".lastIndexOf("bc",0,"test");
402 ok(tmp
=== -1, "lastIndexOf = " + tmp
);
403 tmp
= "abcd".lastIndexOf();
404 ok(tmp
=== -1, "lastIndexOf = " + tmp
);
405 tmp
= "aaaa".lastIndexOf("a",2);
406 ok(tmp
== 2, "lastIndexOf = " + tmp
);
407 tmp
= strObj
.lastIndexOf("b");
408 ok(tmp
=== 1, "lastIndexOf = " + tmp
);
410 tmp
= "".toLowerCase();
411 ok(tmp
=== "", "''.toLowerCase() = " + tmp
);
412 tmp
= "test".toLowerCase();
413 ok(tmp
=== "test", "''.toLowerCase() = " + tmp
);
414 tmp
= "test".toLowerCase(3);
415 ok(tmp
=== "test", "''.toLowerCase(3) = " + tmp
);
416 tmp
= "tEsT".toLowerCase();
417 ok(tmp
=== "test", "''.toLowerCase() = " + tmp
);
418 tmp
= "tEsT".toLowerCase(3);
419 ok(tmp
=== "test", "''.toLowerCase(3) = " + tmp
);
421 tmp
= "".toUpperCase();
422 ok(tmp
=== "", "''.toUpperCase() = " + tmp
);
423 tmp
= "TEST".toUpperCase();
424 ok(tmp
=== "TEST", "''.toUpperCase() = " + tmp
);
425 tmp
= "TEST".toUpperCase(3);
426 ok(tmp
=== "TEST", "''.toUpperCase(3) = " + tmp
);
427 tmp
= "tEsT".toUpperCase();
428 ok(tmp
=== "TEST", "''.toUpperCase() = " + tmp
);
429 tmp
= "tEsT".toUpperCase(3);
430 ok(tmp
=== "TEST", "''.toUpperCase(3) = " + tmp
);
433 ok(tmp
=== "<A NAME=\"undefined\"></A>", "''.anchor() = " + tmp
);
435 ok(tmp
=== "<A NAME=\"3\"></A>", "''.anchor(3) = " + tmp
);
436 tmp
= "".anchor("red");
437 ok(tmp
=== "<A NAME=\"red\"></A>", "''.anchor('red') = " + tmp
);
438 tmp
= "test".anchor();
439 ok(tmp
=== "<A NAME=\"undefined\">test</A>", "'test'.anchor() = " + tmp
);
440 tmp
= "test".anchor(3);
441 ok(tmp
=== "<A NAME=\"3\">test</A>", "'test'.anchor(3) = " + tmp
);
442 tmp
= "test".anchor("green");
443 ok(tmp
=== "<A NAME=\"green\">test</A>", "'test'.anchor('green') = " + tmp
);
446 ok(tmp
=== "<BIG></BIG>", "''.big() = " + tmp
);
448 ok(tmp
=== "<BIG></BIG>", "''.big(3) = " + tmp
);
450 ok(tmp
=== "<BIG>test</BIG>", "'test'.big() = " + tmp
);
452 ok(tmp
=== "<BIG>test</BIG>", "'test'.big(3) = " + tmp
);
455 ok(tmp
=== "<BLINK></BLINK>", "''.blink() = " + tmp
);
457 ok(tmp
=== "<BLINK></BLINK>", "''.blink(3) = " + tmp
);
458 tmp
= "test".blink();
459 ok(tmp
=== "<BLINK>test</BLINK>", "'test'.blink() = " + tmp
);
460 tmp
= "test".blink(3);
461 ok(tmp
=== "<BLINK>test</BLINK>", "'test'.blink(3) = " + tmp
);
464 ok(tmp
=== "<B></B>", "''.bold() = " + tmp
);
466 ok(tmp
=== "<B></B>", "''.bold(3) = " + tmp
);
468 ok(tmp
=== "<B>test</B>", "'test'.bold() = " + tmp
);
469 tmp
= "test".bold(3);
470 ok(tmp
=== "<B>test</B>", "'test'.bold(3) = " + tmp
);
473 ok(tmp
=== "<TT></TT>", "''.fixed() = " + tmp
);
475 ok(tmp
=== "<TT></TT>", "''.fixed(3) = " + tmp
);
476 tmp
= "test".fixed();
477 ok(tmp
=== "<TT>test</TT>", "'test'.fixed() = " + tmp
);
478 tmp
= "test".fixed(3);
479 ok(tmp
=== "<TT>test</TT>", "'test'.fixed(3) = " + tmp
);
481 tmp
= "".fontcolor();
482 ok(tmp
=== "<FONT COLOR=\"undefined\"></FONT>", "''.fontcolor() = " + tmp
);
483 tmp
= "".fontcolor(3);
484 ok(tmp
=== "<FONT COLOR=\"3\"></FONT>", "''.fontcolor(3) = " + tmp
);
485 tmp
= "".fontcolor("red");
486 ok(tmp
=== "<FONT COLOR=\"red\"></FONT>", "''.fontcolor('red') = " + tmp
);
487 tmp
= "test".fontcolor();
488 ok(tmp
=== "<FONT COLOR=\"undefined\">test</FONT>", "'test'.fontcolor() = " + tmp
);
489 tmp
= "test".fontcolor(3);
490 ok(tmp
=== "<FONT COLOR=\"3\">test</FONT>", "'test'.fontcolor(3) = " + tmp
);
491 tmp
= "test".fontcolor("green");
492 ok(tmp
=== "<FONT COLOR=\"green\">test</FONT>", "'test'.fontcolor('green') = " + tmp
);
495 ok(tmp
=== "<FONT SIZE=\"undefined\"></FONT>", "''.fontsize() = " + tmp
);
496 tmp
= "".fontsize(3);
497 ok(tmp
=== "<FONT SIZE=\"3\"></FONT>", "''.fontsize(3) = " + tmp
);
498 tmp
= "".fontsize("red");
499 ok(tmp
=== "<FONT SIZE=\"red\"></FONT>", "''.fontsize('red') = " + tmp
);
500 tmp
= "test".fontsize();
501 ok(tmp
=== "<FONT SIZE=\"undefined\">test</FONT>", "'test'.fontsize() = " + tmp
);
502 tmp
= "test".fontsize(3);
503 ok(tmp
=== "<FONT SIZE=\"3\">test</FONT>", "'test'.fontsize(3) = " + tmp
);
504 tmp
= "test".fontsize("green");
505 ok(tmp
=== "<FONT SIZE=\"green\">test</FONT>", "'test'.fontsize('green') = " + tmp
);
507 tmp
= ("".fontcolor()).fontsize();
508 ok(tmp
=== "<FONT SIZE=\"undefined\"><FONT COLOR=\"undefined\"></FONT></FONT>", "(''.fontcolor()).fontsize() = " + tmp
);
511 ok(tmp
=== "<I></I>", "''.italics() = " + tmp
);
513 ok(tmp
=== "<I></I>", "''.italics(3) = " + tmp
);
514 tmp
= "test".italics();
515 ok(tmp
=== "<I>test</I>", "'test'.italics() = " + tmp
);
516 tmp
= "test".italics(3);
517 ok(tmp
=== "<I>test</I>", "'test'.italics(3) = " + tmp
);
520 ok(tmp
=== "<A HREF=\"undefined\"></A>", "''.link() = " + tmp
);
522 ok(tmp
=== "<A HREF=\"3\"></A>", "''.link(3) = " + tmp
);
523 tmp
= "".link("red");
524 ok(tmp
=== "<A HREF=\"red\"></A>", "''.link('red') = " + tmp
);
526 ok(tmp
=== "<A HREF=\"undefined\">test</A>", "'test'.link() = " + tmp
);
527 tmp
= "test".link(3);
528 ok(tmp
=== "<A HREF=\"3\">test</A>", "'test'.link(3) = " + tmp
);
529 tmp
= "test".link("green");
530 ok(tmp
=== "<A HREF=\"green\">test</A>", "'test'.link('green') = " + tmp
);
533 ok(tmp
=== "<SMALL></SMALL>", "''.small() = " + tmp
);
535 ok(tmp
=== "<SMALL></SMALL>", "''.small(3) = " + tmp
);
536 tmp
= "test".small();
537 ok(tmp
=== "<SMALL>test</SMALL>", "'test'.small() = " + tmp
);
538 tmp
= "test".small(3);
539 ok(tmp
=== "<SMALL>test</SMALL>", "'test'.small(3) = " + tmp
);
542 ok(tmp
=== "<STRIKE></STRIKE>", "''.strike() = " + tmp
);
544 ok(tmp
=== "<STRIKE></STRIKE>", "''.strike(3) = " + tmp
);
545 tmp
= "test".strike();
546 ok(tmp
=== "<STRIKE>test</STRIKE>", "'test'.strike() = " + tmp
);
547 tmp
= "test".strike(3);
548 ok(tmp
=== "<STRIKE>test</STRIKE>", "'test'.strike(3) = " + tmp
);
551 ok(tmp
=== "<SUB></SUB>", "''.sub() = " + tmp
);
553 ok(tmp
=== "<SUB></SUB>", "''.sub(3) = " + tmp
);
555 ok(tmp
=== "<SUB>test</SUB>", "'test'.sub() = " + tmp
);
557 ok(tmp
=== "<SUB>test</SUB>", "'test'.sub(3) = " + tmp
);
560 ok(tmp
=== "<SUP></SUP>", "''.sup() = " + tmp
);
562 ok(tmp
=== "<SUP></SUP>", "''.sup(3) = " + tmp
);
564 ok(tmp
=== "<SUP>test</SUP>", "'test'.sup() = " + tmp
);
566 ok(tmp
=== "<SUP>test</SUP>", "'test'.sup(3) = " + tmp
);
568 ok(String
.fromCharCode() === "", "String.fromCharCode() = " + String
.fromCharCode());
569 ok(String
.fromCharCode(65,"66",67) === "ABC", "String.fromCharCode(65,'66',67) = " + String
.fromCharCode(65,"66",67));
570 ok(String
.fromCharCode(1024*64+65, -1024*64+65) === "AA",
571 "String.fromCharCode(1024*64+65, -1024*64+65) = " + String
.fromCharCode(1024*64+65, -1024*64+65));
572 ok(String
.fromCharCode(65, NaN
, undefined).length
=== 3,
573 "String.fromCharCode(65, NaN, undefined).length = " + String
.fromCharCode(65, NaN
, undefined).length
);
575 var arr
= new Array();
576 ok(typeof(arr
) === "object", "arr () is not object");
577 ok((arr
.length
=== 0), "arr.length is not 0");
578 ok(arr
["0"] === undefined, "arr[0] is not undefined");
580 var arr
= new Array(1, 2, "test");
581 ok(typeof(arr
) === "object", "arr (1,2,test) is not object");
582 ok((arr
.length
=== 3), "arr.length is not 3");
583 ok(arr
["0"] === 1, "arr[0] is not 1");
584 ok(arr
["1"] === 2, "arr[1] is not 2");
585 ok(arr
["2"] === "test", "arr[2] is not \"test\"");
588 ok((arr
.length
=== 8), "arr.length is not 8");
591 ok(tmp
=== "", "'' + [] = " + tmp
);
593 ok(tmp
=== "1,true", "'' + [1,true] = " + tmp
);
595 var arr
= new Array(6);
596 ok(typeof(arr
) === "object", "arr (6) is not object");
597 ok((arr
.length
=== 6), "arr.length is not 6");
598 ok(arr
["0"] === undefined, "arr[0] is not undefined");
600 ok(arr
.push() === 6, "arr.push() !== 6");
601 ok(arr
.push(1) === 7, "arr.push(1) !== 7");
602 ok(arr
[6] === 1, "arr[6] != 1");
603 ok(arr
.length
=== 7, "arr.length != 10");
604 ok(arr
.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10");
605 ok(arr
[8] === "b", "arr[8] != 'b'");
606 ok(arr
.length
=== 10, "arr.length != 10");
608 var arr
= new Object();
609 arr
.push
= Array
.prototype.push
;
613 ok(arr
.push() === 6, "arr.push() !== 6");
614 ok(arr
.push(1) === 7, "arr.push(1) !== 7");
615 ok(arr
[6] === 1, "arr[6] != 1");
616 ok(arr
.length
=== 7, "arr.length != 10");
617 ok(arr
.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10");
618 ok(arr
[8] === "b", "arr[8] != 'b'");
619 ok(arr
.length
=== 10, "arr.length != 10");
621 arr
.pop
= Array
.prototype.pop
;
622 ok(arr
.pop() === false, "arr.pop() !== false");
623 ok(arr
[8] === "b", "arr[8] !== 'b'");
624 ok(arr
.pop() === 'b', "arr.pop() !== 'b'");
625 ok(arr
[8] === undefined, "arr[8] !== undefined");
629 ok(arr
.length
=== 2, "arr.length = " + arr
.length
);
630 ok(tmp
=== 5, "pop() = " + tmp
);
632 ok(arr
.length
=== 1, "arr.length = " + arr
.length
);
633 ok(tmp
=== 4, "pop() = " + tmp
);
635 ok(arr
.length
=== 0, "arr.length = " + arr
.length
);
636 ok(tmp
=== 3, "pop() = " + tmp
);
638 ok(false, "not deleted " + tmp
);
640 ok(arr
.length
=== 0, "arr.length = " + arr
.length
);
641 ok(tmp
=== undefined, "tmp = " + tmp
);
643 arr
.pop
= Array
.prototype.pop
;
645 ok(arr
.length
=== 0, "arr.length = " + arr
.length
);
646 ok(tmp
=== undefined, "tmp = " + tmp
);
649 ok(arr
.length
=== 5, "arr.length = " + arr
.length
);
650 ok(tmp
=== undefined, "tmp = " + tmp
);
652 arr
= [1,2,null,false,undefined,,"a"];
655 ok(tmp
=== "1,2,,false,,,a", "arr.join() = " + tmp
);
657 ok(tmp
=== "1;2;;false;;;a", "arr.join(';') = " + tmp
);
658 tmp
= arr
.join(";","test");
659 ok(tmp
=== "1;2;;false;;;a", "arr.join(';') = " + tmp
);
661 ok(tmp
=== "12falsea", "arr.join('') = " + tmp
);
663 tmp
= arr
.toString();
664 ok(tmp
=== "1,2,,false,,,a", "arr.toString() = " + tmp
);
665 tmp
= arr
.toString("test");
666 ok(tmp
=== "1,2,,false,,,a", "arr.toString() = " + tmp
);
673 arr
.join
= Array
.prototype.join
;
675 ok(arr
.length
=== 3, "arr.length = " + arr
.length
);
676 ok(tmp
=== "aa,,2", "tmp = " + tmp
);
678 arr
= [5,true,2,-1,3,false,"2.5"];
679 tmp
= arr
.sort(function(x
,y
) { return y
-x
; });
680 ok(tmp
=== arr
, "tmp !== arr");
681 tmp
= [5,3,"2.5",2,true,false,-1];
682 for(var i
=0; i
< arr
.length
; i
++)
683 ok(arr
[i
] === tmp
[i
], "arr[" + i
+ "] = " + arr
[i
] + " expected " + tmp
[i
]);
685 arr
= [5,false,2,0,"abc",3,"a",-1];
687 ok(tmp
=== arr
, "tmp !== arr");
688 tmp
= [-1,0,2,3,5,"a","abc",false];
689 for(var i
=0; i
< arr
.length
; i
++)
690 ok(arr
[i
] === tmp
[i
], "arr[" + i
+ "] = " + arr
[i
] + " expected " + tmp
[i
]);
692 arr
= ["a", "b", "ab"];
693 tmp
= ["a", "ab", "b"];
694 ok(arr
.sort() === arr
, "arr.sort() !== arr");
695 for(var i
=0; i
< arr
.length
; i
++)
696 ok(arr
[i
] === tmp
[i
], "arr[" + i
+ "] = " + arr
[i
] + " expected " + tmp
[i
]);
702 arr
.sort
= Array
.prototype.sort
;
704 ok(arr
=== tmp
, "tmp !== arr");
705 ok(arr
[0]===1 && arr
[1]==="aa" && arr
[2]===undefined, "arr is sorted incorectly");
707 arr
= ["1", "2", "3"];
709 ok(arr
.length
=== 1, "arr.length = " + arr
.length
);
711 ok(arr
.length
=== 3, "arr.length = " + arr
.length
);
712 ok(arr
.toString() === "1,,", "arr.toString() = " + arr
.toString());
714 arr
= Array("a","b","c");
715 ok(arr
.toString() === "a,b,c", "arr.toString() = " + arr
.toString());
717 ok(arr
.valueOf
=== Object
.prototype.valueOf
, "arr.valueOf !== Object.prototype.valueOf");
718 ok(arr
=== arr
.valueOf(), "arr !== arr.valueOf");
722 ok(tmp
=== arr
, "tmp !== arr");
723 ok(arr
.length
=== 3, "arr.length = " + arr
.length
);
724 ok(arr
.toString() === "3,2,1", "arr.toString() = " + arr
.toString());
730 ok(tmp
=== arr
, "tmp !== arr");
731 ok(arr
.length
=== 6, "arr.length = " + arr
.length
);
732 ok(arr
.toString() === "1,,5,,,", "arr.toString() = " + arr
.toString());
739 arr
.reverse
= Array
.prototype.reverse
;
741 ok(tmp
=== arr
, "tmp !== arr");
742 ok(arr
.length
=== 3, "arr.length = " + arr
.length
);
743 ok(arr
[0] === 2 && arr
[1] === undefined && arr
[2] === "aa", "unexpected array");
746 tmp
= arr
.unshift(0);
747 ok(tmp
=== (invokeVersion
< 2 ? undefined : 4), "[1,2,3].unshift(0) returned " +tmp
);
748 ok(arr
.length
=== 4, "arr.length = " + arr
.length
);
749 ok(arr
.toString() === "0,1,2,3", "arr.toString() = " + arr
.toString());
754 tmp
= arr
.unshift(-1,0);
755 ok(tmp
=== (invokeVersion
< 2 ? undefined : 5), "unshift returned " +tmp
);
756 ok(arr
.length
=== 5, "arr.length = " + arr
.length
);
757 ok(arr
.toString() === "-1,0,1,,3", "arr.toString() = " + arr
.toString());
761 ok(tmp
=== (invokeVersion
< 2 ? undefined : 3), "unshift returned " +tmp
);
762 ok(arr
.length
=== 3, "arr.length = " + arr
.length
);
763 ok(arr
.toString() === "1,2,3", "arr.toString() = " + arr
.toString());
769 tmp
= Array
.prototype.unshift
.call(arr
, 0);
770 ok(tmp
=== (invokeVersion
< 2 ? undefined : 3), "unshift returned " +tmp
);
771 ok(arr
.length
=== 3, "arr.length = " + arr
.length
);
772 ok(arr
[0] === 0 && arr
[1] === 1 && arr
[2] === 2, "unexpected array");
776 ok(tmp
=== 1, "[1,2,,4].shift() = " + tmp
);
777 ok(arr
.toString() === "2,,4", "arr = " + arr
.toString());
781 ok(tmp
=== undefined, "[].shift() = " + tmp
);
782 ok(arr
.toString() === "", "arr = " + arr
.toString());
786 ok(tmp
=== 1, "[1,2,,4].shift(2) = " + tmp
);
787 ok(arr
.toString() === "2,,4", "arr = " + arr
.toString());
791 ok(tmp
=== 1, "[1,].shift() = " + tmp
);
792 ok(arr
.toString() === "", "arr = " + arr
.toString());
798 tmp
= Array
.prototype.shift
.call(obj
);
799 ok(tmp
=== "test", "obj.shift() = " + tmp
);
800 ok(obj
.length
== 2, "obj.length = " + obj
.length
);
801 ok(obj
[1] === 3, "obj[1] = " + obj
[1]);
803 var num
= new Number(6);
805 tmp
= arr
.concat(3, [4,5], num
);
806 ok(tmp
!== arr
, "tmp === arr");
807 for(var i
=0; i
<6; i
++)
808 ok(tmp
[i
] === i
, "tmp[" + i
+ "] = " + tmp
[i
]);
809 ok(tmp
[6] === num
, "tmp[6] !== num");
810 ok(tmp
.length
=== 7, "tmp.length = " + tmp
.length
);
813 ok(arr
.length
=== 0, "arr.length = " + arr
.length
);
816 tmp
= arr
.concat([2]);
817 ok(tmp
.length
=== 3, "tmp.length = " + tmp
.length
);
818 ok(tmp
[1] === undefined, "tmp[1] = " + tmp
[1]);
820 arr
= [1,false,'a',null,undefined,'a'];
821 ok(arr
.slice(0,6).toString() === "1,false,a,,,a", "arr.slice(0,6).toString() = " + arr
.slice(0,6));
822 ok(arr
.slice(0,6).length
=== 6, "arr.slice(0,6).length = " + arr
.slice(0,6).length
);
823 ok(arr
.slice().toString() === "1,false,a,,,a", "arr.slice().toString() = " + arr
.slice());
824 ok(arr
.slice("abc").toString() === "1,false,a,,,a", "arr.slice(\"abc\").toString() = " + arr
.slice("abc"));
825 ok(arr
.slice(3,8).toString() === ",,a", "arr.slice(3,8).toString() = " + arr
.slice(3,8));
826 ok(arr
.slice(3,8).length
=== 3, "arr.slice(3,8).length = " + arr
.slice(3,8).length
);
827 ok(arr
.slice(1).toString() === "false,a,,,a", "arr.slice(1).toString() = " + arr
.slice(1));
828 ok(arr
.slice(-2).toString() === ",a", "arr.slice(-2).toString() = " + arr
.slice(-2));
829 ok(arr
.slice(3,1).toString() === "", "arr.slice(3,1).toString() = " + arr
.slice(3,1));
830 tmp
= arr
.slice(0,6);
831 for(var i
=0; i
< arr
.length
; i
++)
832 ok(arr
[i
] === tmp
[i
], "arr[" + i
+ "] = " + arr
[i
] + " expected " + tmp
[i
]);
834 ok(arr
.slice(5).toString() === "a,,,,,,,2", "arr.slice(5).toString() = " + arr
.slice(5).toString());
835 ok(arr
.slice(5).length
=== 8, "arr.slice(5).length = " + arr
.slice(5).length
);
838 tmp
= arr
.splice(2,2);
839 ok(tmp
.toString() == "3,4", "arr.splice(2,2) returned " + tmp
.toString());
840 ok(arr
.toString() == "1,2,5", "arr.splice(2,2) is " + arr
.toString());
843 tmp
= arr
.splice(2,2,"a");
844 ok(tmp
.toString() == "3,4", "arr.splice(2,2,'a') returned " + tmp
.toString());
845 ok(arr
.toString() == "1,2,a,5", "arr.splice(2,2,'a') is " + arr
.toString());
848 tmp
= arr
.splice(2,2,'a','b','c');
849 ok(tmp
.toString() == "3,4", "arr.splice(2,2,'a','b','c') returned " + tmp
.toString());
850 ok(arr
.toString() == "1,2,a,b,c,5", "arr.splice(2,2,'a','b','c') is " + arr
.toString());
853 tmp
= arr
.splice(2,2,'a','b','c');
854 ok(tmp
.toString() == "3,4", "arr.splice(2,2,'a','b','c') returned " + tmp
.toString());
855 ok(arr
.toString() == "1,2,a,b,c,", "arr.splice(2,2,'a','b','c') is " + arr
.toString());
858 arr
.splice(2,2,'a','b','c');
859 ok(arr
.toString() == "1,2,a,b,c,", "arr.splice(2,2,'a','b','c') is " + arr
.toString());
862 tmp
= arr
.splice(2,2,'a','b');
863 ok(tmp
.toString() == "3,4", "arr.splice(2,2,'a','b') returned " + tmp
.toString());
864 ok(arr
.toString() == "1,2,a,b,5", "arr.splice(2,2,'a','b') is " + arr
.toString());
867 tmp
= arr
.splice(-1,2);
868 ok(tmp
.toString() == "5", "arr.splice(-1,2) returned " + tmp
.toString());
869 ok(arr
.toString() == "1,2,3,4", "arr.splice(-1,2) is " + arr
.toString());
872 tmp
= arr
.splice(-10,3);
873 ok(tmp
.toString() == "1,2,3", "arr.splice(-10,3) returned " + tmp
.toString());
874 ok(arr
.toString() == "4,5", "arr.splice(-10,3) is " + arr
.toString());
877 tmp
= arr
.splice(-10,100);
878 ok(tmp
.toString() == "1,2,3,4,5", "arr.splice(-10,100) returned " + tmp
.toString());
879 ok(arr
.toString() == "", "arr.splice(-10,100) is " + arr
.toString());
882 tmp
= arr
.splice(2,-1);
883 ok(tmp
.toString() == "", "arr.splice(2,-1) returned " + tmp
.toString());
884 ok(arr
.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr
.toString());
888 ok(tmp
.toString() == "", "arr.splice(2,-1) returned " + tmp
.toString());
889 ok(arr
.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr
.toString());
893 ok(tmp
.toString() == "", "arr.splice(2,-1) returned " + tmp
.toString());
894 ok(arr
.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr
.toString());
901 tmp
= Array
.prototype.splice
.call(obj
, 1, 1, 'a', 'b');
902 ok(tmp
.toString() === "2", "obj.splice returned " + tmp
);
903 ok(obj
.length
=== 4, "obj.length = " + obj
.length
);
904 ok(obj
[0] === 1, "obj[0] = " + obj
[0]);
905 ok(obj
[1] === 'a', "obj[1] = " + obj
[1]);
906 ok(obj
[2] === 'b', "obj[2] = " + obj
[2]);
907 ok(obj
[3] === 3, "obj[3] = " + obj
[3]);
914 tmp
= Array
.prototype.slice
.call(obj
, 1, 2);
915 ok(tmp
.length
=== 1, "tmp.length = " + tmp
.length
);
916 ok(tmp
[0] === 2, "tmp[0] = " + tmp
[0]);
918 var num
= new Number(2);
919 ok(num
.toString() === "2", "num(2).toString !== 2");
920 var num
= new Number();
921 ok(num
.toString() === "0", "num().toString !== 0");
923 ok(Number() === 0, "Number() = " + Number());
924 ok(Number(false) === 0, "Number(false) = " + Number(false));
925 ok(Number("43") === 43, "Number('43') = " + Number("43"));
927 tmp
= (new Number(1)).valueOf();
928 ok(tmp
=== 1, "(new Number(1)).valueOf = " + tmp
);
929 tmp
= (new Number(1,2)).valueOf();
930 ok(tmp
=== 1, "(new Number(1,2)).valueOf = " + tmp
);
931 tmp
= (new Number()).valueOf();
932 ok(tmp
=== 0, "(new Number()).valueOf = " + tmp
);
933 tmp
= Number
.prototype.valueOf();
934 ok(tmp
=== 0, "Number.prototype.valueOf = " + tmp
);
936 function equals(val
, base
) {
939 var str
= val
.toString(base
);
941 for(i
=0; i
<str
.length
; i
++) {
942 if(str
.substring(i
, i
+1) == '(') break;
943 if(str
.substring(i
, i
+1) == '.') break;
944 num
= num
*base
+ parseInt(str
.substring(i
, i
+1));
947 if(str
.substring(i
, i
+1) == '.') {
949 for(i
++; i
<str
.length
; i
++) {
950 if(str
.substring(i
, i
+1) == '(') break;
951 num
+= parseInt(str
.substring(i
, i
+1))/mult
;
956 if(str
.substring(i
, i
+1) == '(') {
957 exp
= parseInt(str
.substring(i
+2));
958 num
*= Math
.pow(base
, exp
);
961 ok(num
>val
-val
/1000 && num<val+val/1000, "equals: num = " + num
);
964 ok((10).toString(11) === "a", "(10).toString(11) = " + (10).toString(11));
965 ok((213213433).toString(17) === "8e2ddcb", "(213213433).toString(17) = " + (213213433).toString(17));
966 ok((-3254343).toString(33) === "-2oicf", "(-3254343).toString(33) = " + (-3254343).toString(33));
967 ok((NaN
).toString(12) === "NaN", "(NaN).toString(11) = " + (NaN
).toString(11));
968 ok((Infinity
).toString(13) === "Infinity", "(Infinity).toString(11) = " + (Infinity
).toString(11));
969 for(i
=2; i
<10; i
++) {
971 equals(2305843009200000000, i
);
974 equals(1024*1024*1024*1024*1024*1024*1.9999, i
);
977 equals(4.65661287308e-10, i
);
978 ok((0).toString(i
) === "0", "(0).toString("+i
+") = " + (0).toString(i
));
981 ok(parseFloat('123') === 123, "parseFloat('123') = " + parseFloat('123'));
982 ok(parseFloat('-13.7') === -13.7, "parseFloat('-13.7') = " + parseFloat('-13.7'));
983 ok(parseFloat('-0.01e-2') === -0.01e-2, "parseFloat('-0.01e-2') = " + parseFloat('-0.01e-2'));
984 ok(parseFloat('-12e+5') === -12e+5, "parseFloat('-12e+5') = " + parseFloat('-12e+5'));
985 ok(parseFloat('1E5 not parsed') === 1E5
, "parseFloat('1E5 not parsed') = " + parseFloat('1E5 not parsed'));
986 ok(isNaN(parseFloat('not a number')), "parseFloat('not a number') is not NaN");
987 ok(parseFloat('+13.2e-3') === 13.2e-3, "parseFloat('+13.2e-3') = " + parseFloat('+13.2e-3'));
988 ok(parseFloat('.12') === 0.12, "parseFloat('.12') = " + parseFloat('.12'));
989 ok(parseFloat('1e') === 1, "parseFloat('1e') = " + parseFloat('1e'));
992 ok(tmp
=== 1, "Math.min(1) = " + tmp
);
994 tmp
= Math
.min(1, false);
995 ok(tmp
=== 0, "Math.min(1, false) = " + tmp
);
998 ok(tmp
=== Infinity
, "Math.min() = " + tmp
);
1000 tmp
= Math
.min(1, NaN
, -Infinity
, false);
1001 ok(isNaN(tmp
), "Math.min(1, NaN, -Infinity, false) is not NaN");
1003 tmp
= Math
.min(1, false, true, null, -3);
1004 ok(tmp
=== -3, "Math.min(1, false, true, null, -3) = " + tmp
);
1007 ok(tmp
=== 1, "Math.max(1) = " + tmp
);
1009 tmp
= Math
.max(true, 0);
1010 ok(tmp
=== 1, "Math.max(true, 0) = " + tmp
);
1012 tmp
= Math
.max(-2, false, true, null, 1);
1013 ok(tmp
=== 1, "Math.max(-2, false, true, null, 1) = " + tmp
);
1016 ok(tmp
=== -Infinity
, "Math.max() = " + tmp
);
1018 tmp
= Math
.max(true, NaN
, 0);
1019 ok(isNaN(tmp
), "Math.max(true, NaN, 0) is not NaN");
1021 tmp
= Math
.round(0.5);
1022 ok(tmp
=== 1, "Math.round(0.5) = " + tmp
);
1024 tmp
= Math
.round(-0.5);
1025 ok(tmp
=== 0, "Math.round(-0.5) = " + tmp
);
1027 tmp
= Math
.round(1.1);
1028 ok(tmp
=== 1, "Math.round(1.1) = " + tmp
);
1030 tmp
= Math
.round(true);
1031 ok(tmp
=== 1, "Math.round(true) = " + tmp
);
1033 tmp
= Math
.round(1.1, 3, 4);
1034 ok(tmp
=== 1, "Math.round(1.1, 3, 4) = " + tmp
);
1037 ok(isNaN(tmp
), "Math.round() is not NaN");
1039 tmp
= Math
.ceil(0.5);
1040 ok(tmp
=== 1, "Math.ceil(0.5) = " + tmp
);
1042 tmp
= Math
.ceil(-0.5);
1043 ok(tmp
=== 0, "Math.ceil(-0.5) = " + tmp
);
1045 tmp
= Math
.ceil(1.1);
1046 ok(tmp
=== 2, "Math.round(1.1) = " + tmp
);
1048 tmp
= Math
.ceil(true);
1049 ok(tmp
=== 1, "Math.ceil(true) = " + tmp
);
1051 tmp
= Math
.ceil(1.1, 3, 4);
1052 ok(tmp
=== 2, "Math.ceil(1.1, 3, 4) = " + tmp
);
1055 ok(isNaN(tmp
), "ceil() is not NaN");
1057 tmp
= Math
.floor(0.5);
1058 ok(tmp
=== 0, "Math.floor(0.5) = " + tmp
);
1060 tmp
= Math
.floor(-0.5);
1061 ok(tmp
=== -1, "Math.floor(-0.5) = " + tmp
);
1063 tmp
= Math
.floor(1.1);
1064 ok(tmp
=== 1, "Math.floor(1.1) = " + tmp
);
1066 tmp
= Math
.floor(true);
1067 ok(tmp
=== 1, "Math.floor(true) = " + tmp
);
1069 tmp
= Math
.floor(1.1, 3, 4);
1070 ok(tmp
=== 1, "Math.floor(1.1, 3, 4) = " + tmp
);
1073 ok(isNaN(tmp
), "floor is not NaN");
1076 ok(tmp
=== 3, "Math.abs(3) = " + tmp
);
1079 ok(tmp
=== 3, "Math.abs(-3) = " + tmp
);
1081 tmp
= Math
.abs(true);
1082 ok(tmp
=== 1, "Math.abs(true) = " + tmp
);
1085 ok(isNaN(tmp
), "Math.abs() is not NaN");
1087 tmp
= Math
.abs(NaN
);
1088 ok(isNaN(tmp
), "Math.abs() is not NaN");
1090 tmp
= Math
.abs(-Infinity
);
1091 ok(tmp
=== Infinity
, "Math.abs(-Infinite) = " + tmp
);
1093 tmp
= Math
.abs(-3, 2);
1094 ok(tmp
=== 3, "Math.abs(-3, 2) = " + tmp
);
1097 ok(tmp
=== 1, "Math.cos(0) = " + tmp
);
1099 tmp
= Math
.cos(Math
.PI
/2);
1100 ok(Math
.floor(tmp
*100) === 0, "Math.cos(Math.PI/2) = " + tmp
);
1102 tmp
= Math
.cos(-Math
.PI
/2);
1103 ok(Math
.floor(tmp
*100) === 0, "Math.cos(-Math.PI/2) = " + tmp
);
1105 tmp
= Math
.cos(Math
.PI
/3, 2);
1106 ok(Math
.floor(tmp
*100) === 50, "Math.cos(Math.PI/3, 2) = " + tmp
);
1108 tmp
= Math
.cos(true);
1109 ok(Math
.floor(tmp
*100) === 54, "Math.cos(true) = " + tmp
);
1111 tmp
= Math
.cos(false);
1112 ok(tmp
=== 1, "Math.cos(false) = " + tmp
);
1115 ok(isNaN(tmp
), "Math.cos() is not NaN");
1117 tmp
= Math
.cos(NaN
);
1118 ok(isNaN(tmp
), "Math.cos(NaN) is not NaN");
1120 tmp
= Math
.cos(Infinity
);
1121 ok(isNaN(tmp
), "Math.cos(Infinity) is not NaN");
1123 tmp
= Math
.cos(-Infinity
);
1124 ok(isNaN(tmp
), "Math.cos(-Infinity) is not NaN");
1126 tmp
= Math
.pow(2, 2);
1127 ok(tmp
=== 4, "Math.pow(2, 2) = " + tmp
);
1129 tmp
= Math
.pow(4, 0.5);
1130 ok(tmp
=== 2, "Math.pow(2, 2) = " + tmp
);
1132 tmp
= Math
.pow(2, 2, 3);
1133 ok(tmp
=== 4, "Math.pow(2, 2, 3) = " + tmp
);
1136 ok(isNaN(tmp
), "Math.pow(2) is not NaN");
1139 ok(isNaN(tmp
), "Math.pow() is not NaN");
1141 tmp
= Math
.random();
1142 ok(typeof(tmp
) == "number", "typeof(tmp) = " + typeof(tmp
));
1143 ok(0 <= tmp
&& tmp
<= 1, "Math.random() = " + tmp
);
1145 tmp
= Math
.random(100);
1146 ok(typeof(tmp
) == "number", "typeof(tmp) = " + typeof(tmp
));
1147 ok(0 <= tmp
&& tmp
<= 1, "Math.random(100) = " + tmp
);
1150 ok(Math
.floor(tmp
*100) === 157, "Math.acos(0) = " + tmp
);
1153 ok(Math
.floor(tmp
*100) === 0, "Math.acos(1) = " + tmp
);
1155 tmp
= Math
.acos(-1);
1156 ok(Math
.floor(tmp
*100) === 314, "Math.acos(-1) = " + tmp
);
1158 tmp
= Math
.acos(Math
.PI
/4, 2);
1159 ok(Math
.floor(tmp
*100) === 66, "Math.acos(Math.PI/4, 2) = " + tmp
);
1161 tmp
= Math
.acos(true);
1162 ok(Math
.floor(tmp
*100) === 0, "Math.acos(true) = " + tmp
);
1164 tmp
= Math
.acos(false);
1165 ok(Math
.floor(tmp
*100) === 157, "Math.acos(false) = " + tmp
);
1167 tmp
= Math
.acos(1.1);
1168 ok(isNaN(tmp
), "Math.acos(1.1) is not NaN");
1171 ok(isNaN(tmp
), "Math.acos() is not NaN");
1173 tmp
= Math
.acos(NaN
);
1174 ok(isNaN(tmp
), "Math.acos(NaN) is not NaN");
1176 tmp
= Math
.acos(Infinity
);
1177 ok(isNaN(tmp
), "Math.acos(Infinity) is not NaN");
1179 tmp
= Math
.acos(-Infinity
);
1180 ok(isNaN(tmp
), "Math.acos(-Infinity) is not NaN");
1183 ok(Math
.floor(tmp
*100) === 0, "Math.asin(0) = " + tmp
);
1186 ok(Math
.floor(tmp
*100) === 157, "Math.asin(1) = " + tmp
);
1188 tmp
= Math
.asin(-1);
1189 ok(Math
.floor(tmp
*100) === -158, "Math.asin(-1) = " + tmp
);
1191 tmp
= Math
.asin(Math
.PI
/4, 2);
1192 ok(Math
.floor(tmp
*100) === 90, "Math.asin(Math.PI/4, 2) = " + tmp
);
1194 tmp
= Math
.asin(true);
1195 ok(Math
.floor(tmp
*100) === 157, "Math.asin(true) = " + tmp
);
1197 tmp
= Math
.asin(false);
1198 ok(Math
.floor(tmp
*100) === 0, "Math.asin(false) = " + tmp
);
1200 tmp
= Math
.asin(1.1);
1201 ok(isNaN(tmp
), "Math.asin(1.1) is not NaN");
1204 ok(isNaN(tmp
), "Math.asin() is not NaN");
1206 tmp
= Math
.asin(NaN
);
1207 ok(isNaN(tmp
), "Math.asin(NaN) is not NaN");
1209 tmp
= Math
.asin(Infinity
);
1210 ok(isNaN(tmp
), "Math.asin(Infinity) is not NaN");
1212 tmp
= Math
.asin(-Infinity
);
1213 ok(isNaN(tmp
), "Math.asin(-Infinity) is not NaN");
1216 ok(Math
.floor(tmp
*100) === 0, "Math.atan(0) = " + tmp
);
1219 ok(Math
.floor(tmp
*100) === 78, "Math.atan(1) = " + tmp
);
1221 tmp
= Math
.atan(-1);
1222 ok(Math
.floor(tmp
*100) === -79, "Math.atan(-1) = " + tmp
);
1224 tmp
= Math
.atan(true);
1225 ok(Math
.floor(tmp
*100) === 78, "Math.atan(true) = " + tmp
);
1227 tmp
= Math
.atan(false);
1228 ok(Math
.floor(tmp
*100) === 0, "Math.atan(false) = " + tmp
);
1231 ok(isNaN(tmp
), "Math.atan() is not NaN");
1233 tmp
= Math
.atan(NaN
);
1234 ok(isNaN(tmp
), "Math.atan(NaN) is not NaN");
1236 tmp
= Math
.atan(Infinity
);
1237 ok(Math
.floor(tmp
*100) === 157, "Math.atan(Infinity) = " + tmp
);
1239 tmp
= Math
.atan(-Infinity
);
1240 ok(Math
.floor(tmp
*100) === -158, "Math.atan(Infinity) = " + tmp
);
1242 tmp
= Math
.atan2(0, 0);
1243 ok(Math
.floor(tmp
*100) === 0, "Math.atan2(0, 0) = " + tmp
);
1245 tmp
= Math
.atan2(0, 1);
1246 ok(Math
.floor(tmp
*100) === 0, "Math.atan2(0, 1) = " + tmp
);
1248 tmp
= Math
.atan2(0, Infinity
);
1249 ok(Math
.floor(tmp
*100) === 0, "Math.atan2(0, Infinity) = " + tmp
);
1251 tmp
= Math
.atan2(0, -1);
1252 ok(Math
.floor(tmp
*100) === 314, "Math.atan2(0, -1) = " + tmp
);
1254 tmp
= Math
.atan2(0, -Infinity
);
1255 ok(Math
.floor(tmp
*100) === 314, "Math.atan2(0, -Infinity) = " + tmp
);
1257 tmp
= Math
.atan2(1, 0);
1258 ok(Math
.floor(tmp
*100) === 157, "Math.atan2(1, 0) = " + tmp
);
1260 tmp
= Math
.atan2(Infinity
, 0);
1261 ok(Math
.floor(tmp
*100) === 157, "Math.atan2(Infinity, 0) = " + tmp
);
1263 tmp
= Math
.atan2(-1, 0);
1264 ok(Math
.floor(tmp
*100) === -158, "Math.atan2(-1, 0) = " + tmp
);
1266 tmp
= Math
.atan2(-Infinity
, 0);
1267 ok(Math
.floor(tmp
*100) === -158, "Math.atan2(-Infinity, 0) = " + tmp
);
1269 tmp
= Math
.atan2(1, 1);
1270 ok(Math
.floor(tmp
*100) === 78, "Math.atan2(1, 1) = " + tmp
);
1272 tmp
= Math
.atan2(-1, -1);
1273 ok(Math
.floor(tmp
*100) === -236, "Math.atan2(-1, -1) = " + tmp
);
1275 tmp
= Math
.atan2(-1, 1);
1276 ok(Math
.floor(tmp
*100) === -79, "Math.atan2(-1, 1) = " + tmp
);
1278 tmp
= Math
.atan2(Infinity
, Infinity
);
1279 ok(Math
.floor(tmp
*100) === 78, "Math.atan2(Infinity, Infinity) = " + tmp
);
1281 tmp
= Math
.atan2(Infinity
, -Infinity
, 1);
1282 ok(Math
.floor(tmp
*100) === 235, "Math.atan2(Infinity, -Infinity, 1) = " + tmp
);
1285 ok(isNaN(tmp
), "Math.atan2() is not NaN");
1287 tmp
= Math
.atan2(1);
1288 ok(isNaN(tmp
), "Math.atan2(1) is not NaN");
1291 ok(tmp
=== 1, "Math.exp(0) = " + tmp
);
1294 ok(Math
.floor(tmp
*100) === 271, "Math.exp(1) = " + tmp
);
1297 ok(Math
.floor(tmp
*100) === 36, "Math.exp(-1) = " + tmp
);
1299 tmp
= Math
.exp(true);
1300 ok(Math
.floor(tmp
*100) === 271, "Math.exp(true) = " + tmp
);
1302 tmp
= Math
.exp(1, 1);
1303 ok(Math
.floor(tmp
*100) === 271, "Math.exp(1, 1) = " + tmp
);
1306 ok(isNaN(tmp
), "Math.exp() is not NaN");
1308 tmp
= Math
.exp(NaN
);
1309 ok(isNaN(tmp
), "Math.exp(NaN) is not NaN");
1311 tmp
= Math
.exp(Infinity
);
1312 ok(tmp
=== Infinity
, "Math.exp(Infinity) = " + tmp
);
1314 tmp
= Math
.exp(-Infinity
);
1315 ok(tmp
=== 0, "Math.exp(-Infinity) = " + tmp
);
1318 ok(Math
.floor(tmp
*100) === 0, "Math.log(1) = " + tmp
);
1321 ok(isNaN(tmp
), "Math.log(-1) is not NaN");
1323 tmp
= Math
.log(true);
1324 ok(Math
.floor(tmp
*100) === 0, "Math.log(true) = " + tmp
);
1326 tmp
= Math
.log(1, 1);
1327 ok(Math
.floor(tmp
*100) === 0, "Math.log(1, 1) = " + tmp
);
1330 ok(isNaN(tmp
), "Math.log() is not NaN");
1332 tmp
= Math
.log(NaN
);
1333 ok(isNaN(tmp
), "Math.log(NaN) is not NaN");
1335 tmp
= Math
.log(Infinity
);
1336 ok(tmp
=== Infinity
, "Math.log(Infinity) = " + tmp
);
1338 tmp
= Math
.log(-Infinity
);
1339 ok(isNaN(tmp
), "Math.log(-Infinity) is not NaN");
1342 ok(tmp
=== 0, "Math.sin(0) = " + tmp
);
1344 tmp
= Math
.sin(Math
.PI
/2);
1345 ok(tmp
=== 1, "Math.sin(Math.PI/2) = " + tmp
);
1347 tmp
= Math
.sin(-Math
.PI
/2);
1348 ok(tmp
=== -1, "Math.sin(-Math.PI/2) = " + tmp
);
1350 tmp
= Math
.sin(Math
.PI
/3, 2);
1351 ok(Math
.floor(tmp
*100) === 86, "Math.sin(Math.PI/3, 2) = " + tmp
);
1353 tmp
= Math
.sin(true);
1354 ok(Math
.floor(tmp
*100) === 84, "Math.sin(true) = " + tmp
);
1356 tmp
= Math
.sin(false);
1357 ok(tmp
=== 0, "Math.sin(false) = " + tmp
);
1360 ok(isNaN(tmp
), "Math.sin() is not NaN");
1362 tmp
= Math
.sin(NaN
);
1363 ok(isNaN(tmp
), "Math.sin(NaN) is not NaN");
1365 tmp
= Math
.sin(Infinity
);
1366 ok(isNaN(tmp
), "Math.sin(Infinity) is not NaN");
1368 tmp
= Math
.sin(-Infinity
);
1369 ok(isNaN(tmp
), "Math.sin(-Infinity) is not NaN");
1372 ok(tmp
=== 0, "Math.sqrt(0) = " + tmp
);
1375 ok(tmp
=== 2, "Math.sqrt(4) = " + tmp
);
1377 tmp
= Math
.sqrt(-1);
1378 ok(isNaN(tmp
), "Math.sqrt(-1) is not NaN");
1380 tmp
= Math
.sqrt(2, 2);
1381 ok(Math
.floor(tmp
*100) === 141, "Math.sqrt(2, 2) = " + tmp
);
1383 tmp
= Math
.sqrt(true);
1384 ok(tmp
=== 1, "Math.sqrt(true) = " + tmp
);
1386 tmp
= Math
.sqrt(false);
1387 ok(tmp
=== 0, "Math.sqrt(false) = " + tmp
);
1390 ok(isNaN(tmp
), "Math.sqrt() is not NaN");
1392 tmp
= Math
.sqrt(NaN
);
1393 ok(isNaN(tmp
), "Math.sqrt(NaN) is not NaN");
1395 tmp
= Math
.sqrt(Infinity
);
1396 ok(tmp
=== Infinity
, "Math.sqrt(Infinity) = " + tmp
);
1398 tmp
= Math
.sqrt(-Infinity
);
1399 ok(isNaN(tmp
), "Math.sqrt(-Infinity) is not NaN");
1402 ok(tmp
=== 0, "Math.tan(0) = " + tmp
);
1404 tmp
= Math
.tan(Math
.PI
);
1405 ok(Math
.floor(tmp
*100) === -1, "Math.tan(Math.PI) = " + tmp
);
1407 tmp
= Math
.tan(2, 2);
1408 ok(Math
.floor(tmp
*100) === -219, "Math.tan(2, 2) = " + tmp
);
1410 tmp
= Math
.tan(true);
1411 ok(Math
.floor(tmp
*100) === 155, "Math.tan(true) = " + tmp
);
1413 tmp
= Math
.tan(false);
1414 ok(tmp
=== 0, "Math.tan(false) = " + tmp
);
1417 ok(isNaN(tmp
), "Math.tan() is not NaN");
1419 tmp
= Math
.tan(NaN
);
1420 ok(isNaN(tmp
), "Math.tan(NaN) is not NaN");
1422 tmp
= Math
.tan(Infinity
);
1423 ok(isNaN(tmp
), "Math.tan(Infinity) is not NaN");
1425 tmp
= Math
.tan(-Infinity
);
1426 ok(isNaN(tmp
), "Math.tan(-Infinity) is not NaN");
1428 var func = function (a
) {
1432 ok(func
.toString() === "function (a) {\n var a = 1;\n if(a) return;\n }",
1433 "func.toString() = " + func
.toString());
1434 ok("" + func
=== "function (a) {\n var a = 1;\n if(a) return;\n }",
1435 "'' + func.toString() = " + func
);
1437 ok(func
.valueOf
=== Object
.prototype.valueOf
, "func.valueOf !== Object.prototype.valueOf");
1438 ok(func
=== func
.valueOf(), "func !== func.valueOf()");
1440 function testFuncToString(x
,y
) {
1443 ok(testFuncToString
.toString() === "function testFuncToString(x,y) {\n return x+y;\n}",
1444 "testFuncToString.toString() = " + testFuncToString
.toString());
1445 ok("" + testFuncToString
=== "function testFuncToString(x,y) {\n return x+y;\n}",
1446 "'' + testFuncToString = " + testFuncToString
);
1450 function callTest(argc
) {
1451 ok(this === tmp
, "this !== tmp\n");
1452 ok(arguments
.length
=== argc
+1, "arguments.length = " + arguments
.length
+ " expected " + (argc
+1));
1453 for(var i
=1; i
<= argc
; i
++)
1454 ok(arguments
[i
] === i
, "arguments[i] = " + arguments
[i
]);
1457 callTest
.call(tmp
, 1, 1);
1458 callTest
.call(tmp
, 2, 1, 2);
1460 callTest
.apply(tmp
, [1, 1]);
1461 callTest
.apply(tmp
, [2, 1, 2]);
1462 (function () { callTest
.apply(tmp
, arguments
); })(2,1,2);
1464 function callTest2() {
1465 ok(this === tmp
, "this !== tmp\n");
1466 ok(arguments
.length
=== 0, "callTest2: arguments.length = " + arguments
.length
+ " expected 0");
1469 callTest2
.call(tmp
);
1470 callTest2
.apply(tmp
, []);
1471 callTest2
.apply(tmp
);
1472 (function () { callTest2
.apply(tmp
, arguments
); })();
1474 function callTest3() {
1476 ok(arguments
.length
=== 0, "arguments.length = " + arguments
.length
+ " expected 0");
1480 callTest3
.call(undefined);
1481 callTest3
.call(null);
1483 callTest3
.apply(undefined);
1484 callTest3
.apply(null);
1486 tmp
= Number
.prototype.toString
.call(3);
1487 ok(tmp
=== "3", "Number.prototype.toString.call(3) = " + tmp
);
1489 var func
= new Function("return 3;");
1492 ok(tmp
=== 3, "func() = " + tmp
);
1493 ok(func
.call() === 3, "func.call() = " + tmp
);
1494 ok(func
.length
=== 0, "func.length = " + func
.length
);
1495 tmp
= func
.toString();
1496 ok(tmp
=== "function anonymous() {\nreturn 3;\n}", "func.toString() = " + tmp
);
1498 func
= new Function("x", "return x+2;");
1500 ok(tmp
=== 3, "func(1) = " + tmp
);
1501 tmp
= func
.toString();
1502 ok(tmp
=== "function anonymous(x) {\nreturn x+2;\n}", "func.toString() = " + tmp
);
1504 tmp
= (new Function("x ", "return x+2;")).toString();
1505 ok(tmp
=== "function anonymous(x ) {\nreturn x+2;\n}", "func.toString() = " + tmp
);
1507 func
= new Function("x", "y", "return x+y");
1509 ok(tmp
=== 4, "func(1,3) = " + tmp
);
1510 tmp
= func
.toString();
1511 ok(tmp
=== "function anonymous(x, y) {\nreturn x+y\n}", "func.toString() = " + tmp
);
1513 func
= new Function(" x, \ty", "\tz", "return x+y+z;");
1515 ok(tmp
=== 6, "func(1,3,2) = " + tmp
);
1516 ok(func
.length
=== 3, "func.length = " + func
.length
);
1517 tmp
= func
.toString();
1518 ok(tmp
=== "function anonymous( x, \ty, \tz) {\nreturn x+y+z;\n}", "func.toString() = " + tmp
);
1520 func
= new Function();
1522 ok(tmp
=== undefined, "func() = " + tmp
);
1523 tmp
= func
.toString();
1524 ok(tmp
== "function anonymous() {\n\n}", "func.toString() = " + tmp
);
1526 func
= (function() {
1528 return new Function("return tmp;");
1532 ok(tmp
=== 2, "func() = " + tmp
);
1534 var date
= new Date();
1536 date
= new Date(100);
1537 ok(date
.getTime() === 100, "date.getTime() = " + date
.getTime());
1538 ok(Date
.prototype.getTime() === 0, "date.prototype.getTime() = " + Date
.prototype.getTime());
1539 date
= new Date(8.64e15
);
1540 ok(date
.getTime() === 8.64e15
, "date.getTime() = " + date
.getTime());
1541 date
= new Date(8.64e15
+1);
1542 ok(isNaN(0+date
.getTime()), "date.getTime() is not NaN");
1543 date
= new Date(Infinity
);
1544 ok(isNaN(0+date
.getTime()), "date.getTime() is not NaN");
1545 date
= new Date("3 July 2009 22:28:00 UTC+0100");
1546 ok(date
.getTime() === 1246656480000, "date.getTime() = " + date
.getTime());
1547 date
= new Date(1984, 11, 29, 13, 51, 24, 120);
1548 ok(date
.getFullYear() === 1984, "date.getFullYear() = " + date
.getFullYear());
1549 ok(date
.getMonth() === 11, "date.getMonth() = " + date
.getMonth());
1550 ok(date
.getDate() === 29, "date.getDate() = " + date
.getDate());
1551 ok(date
.getHours() === 13, "date.getHours() = " + date
.getHours());
1552 ok(date
.getMinutes() === 51, "date.getMinutes() = " + date
.getMinutes());
1553 ok(date
.getSeconds() === 24, "date.getSeconds() = " + date
.getSeconds());
1554 ok(date
.getMilliseconds() === 120, "date.getMilliseconds() = " + date
.getMilliseconds());
1555 date
= new Date(731, -32, 40, -1, 70, 65, -13);
1556 ok(date
.getFullYear() === 728, "date.getFullYear() = " + date
.getFullYear());
1557 ok(date
.getMonth() === 5, "date.getMonth() = " + date
.getMonth());
1558 ok(date
.getDate() === 9, "date.getDate() = " + date
.getDate());
1559 ok(date
.getHours() === 0, "date.getHours() = " + date
.getHours());
1560 ok(date
.getMinutes() === 11, "date.getMinutes() = " + date
.getMinutes());
1561 ok(date
.getSeconds() === 4, "date.getSeconds() = " + date
.getSeconds());
1562 ok(date
.getMilliseconds() === 987, "date.getMilliseconds() = " + date
.getMilliseconds());
1564 ok(date
.setTime(123) === 123, "date.setTime(123) !== 123");
1565 ok(date
.setTime("123", NaN
) === 123, "date.setTime(\"123\") !== 123");
1566 ok(isNaN(date
.setTime(NaN
)), "date.setTime(NaN) is not NaN");
1568 ok(date
.setTime(0) === date
.getTime(), "date.setTime(0) !== date.getTime()");
1569 ok(date
.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date
.getUTCFullYear());
1570 ok(date
.getUTCMonth() === 0, "date.getUTCMonth() = " + date
.getUTCMonth());
1571 ok(date
.getUTCDate() === 1, "date.getUTCDate() = " + date
.getUTCDate());
1572 ok(date
.getUTCDay() === 4, "date.getUTCDay() = " + date
.getUTCDay());
1573 ok(date
.getUTCHours() === 0, "date.getUTCHours() = " + date
.getUTCHours());
1574 ok(date
.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date
.getUTCMinutes());
1575 ok(date
.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date
.getUTCSeconds());
1576 ok(date
.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date
.getUTCMilliseconds());
1577 date
.setTime(60*24*60*60*1000);
1578 ok(date
.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date
.getUTCFullYear());
1579 ok(date
.getUTCMonth() === 2, "date.getUTCMonth() = " + date
.getUTCMonth());
1580 ok(date
.getUTCDate() === 2, "date.getUTCDate() = " + date
.getUTCDate());
1581 ok(date
.getUTCDay() === 1, "date.getUTCDay() = " + date
.getUTCDay());
1582 ok(date
.getUTCHours() === 0, "date.getUTCHours() = " + date
.getUTCHours());
1583 ok(date
.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date
.getUTCMinutes());
1584 ok(date
.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date
.getUTCSeconds());
1585 ok(date
.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date
.getUTCMilliseconds());
1586 date
.setTime(59*24*60*60*1000 + 4*365*24*60*60*1000 + 60*60*1000 + 2*60*1000 + 2*1000 + 640);
1587 ok(date
.getUTCFullYear() === 1974, "date.getUTCFullYear() = " + date
.getUTCFullYear());
1588 ok(date
.getUTCMonth() === 1, "date.getUTCMonth() = " + date
.getUTCMonth());
1589 ok(date
.getUTCMonth(123) === 1, "date.getUTCMonth() = " + date
.getUTCMonth());
1590 ok(date
.getUTCDate() === 28, "date.getUTCDate() = " + date
.getUTCDate());
1591 ok(date
.getUTCDay() === 4, "date.getUTCDay() = " + date
.getUTCDay());
1592 ok(date
.getUTCHours() === 1, "date.getUTCHours() = " + date
.getUTCHours());
1593 ok(date
.getUTCMinutes() === 2, "date.getUTCMinutes() = " + date
.getUTCMinutes());
1594 ok(date
.getUTCSeconds() === 2, "date.getUTCSeconds() = " + date
.getUTCSeconds());
1595 ok(date
.getUTCMilliseconds() === 640, "date.getUTCMilliseconds() = " + date
.getUTCMilliseconds());
1596 date
.setTime(Infinity
);
1597 ok(isNaN(date
.getUTCFullYear()), "date.getUTCFullYear() is not NaN");
1598 ok(isNaN(date
.getUTCMonth()), "date.getUTCMonth() is not NaN");
1599 ok(isNaN(date
.getUTCDate()), "date.getUTCDate() is not NaN");
1600 ok(isNaN(date
.getUTCDay()), "date.getUTCDay() is not NaN");
1601 ok(isNaN(date
.getUTCHours()), "date.getUTCHours() is not NaN");
1602 ok(isNaN(date
.getUTCMinutes()), "date.getUTCMinutes() is not NaN");
1603 ok(isNaN(date
.getUTCSeconds()), "date.getUTCSeconds() is not NaN");
1604 ok(isNaN(date
.getUTCMilliseconds()), "date.getUTCMilliseconds() is not NaN");
1605 ok(isNaN(date
.setMilliseconds(0)), "date.setMilliseconds() is not NaN");
1608 date
.setUTCMilliseconds(-10, 2);
1609 ok(date
.getUTCMilliseconds() === 990, "date.getUTCMilliseconds() = " + date
.getUTCMilliseconds());
1610 date
.setUTCMilliseconds(10);
1611 ok(date
.getUTCMilliseconds() === 10, "date.getUTCMilliseconds() = " + date
.getUTCMilliseconds());
1612 date
.setUTCSeconds(-10);
1613 ok(date
.getUTCSeconds() === 50, "date.getUTCSeconds() = " + date
.getUTCSeconds());
1614 date
.setUTCMinutes(-10);
1615 ok(date
.getUTCMinutes() === 50, "date.getUTCMinutes() = " + date
.getUTCMinutes());
1616 date
.setUTCHours(-10);
1617 ok(date
.getUTCHours() === 14, "date.getUTCHours() = " + date
.getUTCHours());
1618 date
.setUTCHours(-123);
1619 ok(date
.getTime() === -612549990, "date.getTime() = " + date
.getTime());
1620 date
.setUTCHours(20);
1621 ok(date
.getUTCHours() === 20, "date.getUTCHours() = " + date
.getUTCHours());
1622 date
.setUTCDate(32);
1623 ok(date
.getUTCDate() === 1, "date.getUTCDate() = " + date
.getUTCDate());
1624 date
.setUTCMonth(22, 37);
1625 ok(date
.getTime() === 60987050010, "date.getTime() = " + date
.getTime());
1626 date
.setUTCFullYear(83, 21, 321);
1627 ok(date
.getTime() === -59464984149990, "date.getTime() = " + date
.getTime());
1628 ok(Math
.abs(date
) === 59464984149990, "Math.abs(date) = " + Math
.abs(date
));
1629 ok(getVT(date
+1) === "VT_BSTR", "getVT(date+1) = " + getVT(date
+1));
1631 ok(isNaN(Date
.parse()), "Date.parse() is not NaN");
1632 ok(isNaN(Date
.parse("")), "Date.parse(\"\") is not NaN");
1633 ok(isNaN(Date
.parse("Jan Jan 20 2009")), "Date.parse(\"Jan Jan 20 2009\") is not NaN");
1634 ok(Date
.parse("Jan 20 2009 UTC") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC\") = " + Date
.parse("Jan 20 2009 UTC"));
1635 ok(Date
.parse("Jan 20 2009 GMT") === 1232409600000, "Date.parse(\"Jan 20 2009 GMT\") = " + Date
.parse("Jan 20 2009 GMT"));
1636 ok(Date
.parse("Jan 20 2009 UTC-0") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC-0\") = " + Date
.parse("Jan 20 2009 UTC-0"));
1637 ok(Date
.parse("Jan 20 2009 UTC+0000") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC+0000\") = " + Date
.parse("Jan 20 2009 UTC+0000"));
1638 ok(Date
.parse("Ju 13 79 UTC") === 300672000000, "Date.parse(\"Ju 13 79 UTC\") = " + Date
.parse("Ju 13 79 UTC"));
1639 ok(Date
.parse("12Au91 UTC") === 681955200000, "Date.parse(\"12Au91 UTC\") = " + Date
.parse("12Au91 UTC"));
1640 ok(Date
.parse("7/02/17 UTC") === -1656806400000, "Date.parse(\"7/02/17 UTC\") = " + Date
.parse("7/02/17 UTC"));
1641 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"));
1642 ok(Date
.parse("February 31 UTC, 2000 12:31:17 PM") === 952000277000,
1643 "Date.parse(\"February 31 UTC, 2000 12:31:17 PM\") = " + Date
.parse("February 31 UTC, 2000 12:31:17 PM"));
1644 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 "));
1645 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"));
1647 ok(typeof(Math
.PI
) === "number", "typeof(Math.PI) = " + typeof(Math
.PI
));
1648 ok(Math
.floor(Math
.PI
*100) === 314, "Math.PI = " + Math
.PI
);
1650 ok(Math
.floor(Math
.PI
*100) === 314, "modified Math.PI = " + Math
.PI
);
1652 ok(typeof(Math
.E
) === "number", "typeof(Math.E) = " + typeof(Math
.E
));
1653 ok(Math
.floor(Math
.E
*100) === 271, "Math.E = " + Math
.E
);
1655 ok(Math
.floor(Math
.E
*100) === 271, "modified Math.E = " + Math
.E
);
1657 ok(typeof(Math
.LOG2E
) === "number", "typeof(Math.LOG2E) = " + typeof(Math
.LOG2E
));
1658 ok(Math
.floor(Math
.LOG2E
*100) === 144, "Math.LOG2E = " + Math
.LOG2E
);
1659 Math
.LOG2E
= "test";
1660 ok(Math
.floor(Math
.LOG2E
*100) === 144, "modified Math.LOG2E = " + Math
.LOG2E
);
1662 ok(typeof(Math
.LOG10E
) === "number", "typeof(Math.LOG10E) = " + typeof(Math
.LOG10E
));
1663 ok(Math
.floor(Math
.LOG10E
*100) === 43, "Math.LOG10E = " + Math
.LOG10E
);
1664 Math
.LOG10E
= "test";
1665 ok(Math
.floor(Math
.LOG10E
*100) === 43, "modified Math.LOG10E = " + Math
.LOG10E
);
1667 ok(typeof(Math
.LN2
) === "number", "typeof(Math.LN2) = " + typeof(Math
.LN2
));
1668 ok(Math
.floor(Math
.LN2
*100) === 69, "Math.LN2 = " + Math
.LN2
);
1670 ok(Math
.floor(Math
.LN2
*100) === 69, "modified Math.LN2 = " + Math
.LN2
);
1672 ok(typeof(Math
.LN10
) === "number", "typeof(Math.LN10) = " + typeof(Math
.LN10
));
1673 ok(Math
.floor(Math
.LN10
*100) === 230, "Math.LN10 = " + Math
.LN10
);
1675 ok(Math
.floor(Math
.LN10
*100) === 230, "modified Math.LN10 = " + Math
.LN10
);
1677 ok(typeof(Math
.SQRT2
) === "number", "typeof(Math.SQRT2) = " + typeof(Math
.SQRT2
));
1678 ok(Math
.floor(Math
.SQRT2
*100) === 141, "Math.SQRT2 = " + Math
.SQRT2
);
1679 Math
.SQRT2
= "test";
1680 ok(Math
.floor(Math
.SQRT2
*100) === 141, "modified Math.SQRT2 = " + Math
.SQRT2
);
1682 ok(typeof(Math
.SQRT1_2
) === "number", "typeof(Math.SQRT1_2) = " + typeof(Math
.SQRT1_2
));
1683 ok(Math
.floor(Math
.SQRT1_2
*100) === 70, "Math.SQRT1_2 = " + Math
.SQRT1_2
);
1684 Math
.SQRT1_2
= "test";
1685 ok(Math
.floor(Math
.SQRT1_2
*100) === 70, "modified Math.SQRT1_2 = " + Math
.SQRT1_2
);
1687 ok(isNaN
.toString() === "\nfunction isNaN() {\n [native code]\n}\n",
1688 "isNaN.toString = '" + isNaN
.toString() + "'");
1689 ok(Array
.toString() === "\nfunction Array() {\n [native code]\n}\n",
1690 "isNaN.toString = '" + Array
.toString() + "'");
1691 ok(Function
.toString() === "\nfunction Function() {\n [native code]\n}\n",
1692 "isNaN.toString = '" + Function
.toString() + "'");
1693 ok(Function
.prototype.toString() === "\nfunction prototype() {\n [native code]\n}\n",
1694 "isNaN.toString = '" + Function
.prototype.toString() + "'");
1695 ok("".substr
.toString() === "\nfunction substr() {\n [native code]\n}\n",
1696 "''.substr.toString = '" + "".substr
.toString() + "'");
1698 var bool
= new Boolean();
1699 ok(bool
.toString() === "false", "bool.toString() = " + bool
.toString());
1700 var bool
= new Boolean("false");
1701 ok(bool
.toString() === "true", "bool.toString() = " + bool
.toString());
1702 ok(bool
.valueOf() === Boolean(1), "bool.valueOf() = " + bool
.valueOf());
1703 ok(bool
.toLocaleString() === bool
.toString(), "bool.toLocaleString() = " + bool
.toLocaleString());
1705 ok(ActiveXObject
instanceof Function
, "ActiveXObject is not instance of Function");
1706 ok(ActiveXObject
.prototype instanceof Object
, "ActiveXObject.prototype is not instance of Object");
1708 ok(Error
.prototype !== TypeError
.prototype, "Error.prototype === TypeError.prototype");
1709 ok(RangeError
.prototype !== TypeError
.prototype, "RangeError.prototype === TypeError.prototype");
1710 ok(Error
.prototype.toLocaleString
=== Object
.prototype.toLocaleString
,
1711 "Error.prototype.toLocaleString !== Object.prototype.toLocaleString");
1713 ok(err
.valueOf
=== Object
.prototype.valueOf
, "err.valueOf !== Object.prototype.valueOf");
1714 ok(Error
.prototype.name
=== "Error", "Error.prototype.name = " + Error
.prototype.name
);
1715 ok(err
.name
=== "Error", "err.name = " + err
.name
);
1716 EvalError
.prototype.message
= "test";
1717 ok(err
.toString
!== Object
.prototype.toString
, "err.toString === Object.prototype.toString");
1718 ok(err
.toString() === (invokeVersion
< 2 ? "[object Error]" : "Error"), "err.toString() = " + err
.toString());
1719 err
= new EvalError();
1720 ok(EvalError
.prototype.name
=== "EvalError", "EvalError.prototype.name = " + EvalError
.prototype.name
);
1721 ok(err
.name
=== "EvalError", "err.name = " + err
.name
);
1722 ok(err
.toString
=== Error
.prototype.toString
, "err.toString !== Error.prototype.toString");
1723 ok(err
.message
=== "", "err.message != ''");
1725 ok(err
.message
=== date
, "err.message != date");
1726 ok(err
.toString() === (invokeVersion
< 2 ? "[object Error]" : "EvalError: "+err
.message
),
1727 "err.toString() = " + err
.toString());
1728 ok(err
.toString
!== Object
.prototype.toString
, "err.toString === Object.prototype.toString");
1729 err
= new RangeError();
1730 ok(RangeError
.prototype.name
=== "RangeError", "RangeError.prototype.name = " + RangeError
.prototype.name
);
1731 ok(err
.name
=== "RangeError", "err.name = " + err
.name
);
1732 ok(err
.toString() === (invokeVersion
< 2 ? "[object Error]" : "RangeError"), "err.toString() = " + err
.toString());
1733 err
= new ReferenceError();
1734 ok(ReferenceError
.prototype.name
=== "ReferenceError", "ReferenceError.prototype.name = " + ReferenceError
.prototype.name
);
1735 ok(err
.name
=== "ReferenceError", "err.name = " + err
.name
);
1736 ok(err
.toString() === (invokeVersion
< 2 ? "[object Error]" : "ReferenceError"), "err.toString() = " + err
.toString());
1737 err
= new SyntaxError();
1738 ok(SyntaxError
.prototype.name
=== "SyntaxError", "SyntaxError.prototype.name = " + SyntaxError
.prototype.name
);
1739 ok(err
.name
=== "SyntaxError", "err.name = " + err
.name
);
1740 ok(err
.toString() === (invokeVersion
< 2 ? "[object Error]" : "SyntaxError"), "err.toString() = " + err
.toString());
1741 err
= new TypeError();
1742 ok(TypeError
.prototype.name
=== "TypeError", "TypeError.prototype.name = " + TypeError
.prototype.name
);
1743 ok(err
.name
=== "TypeError", "err.name = " + err
.name
);
1744 ok(err
.toString() === (invokeVersion
< 2 ? "[object Error]" : "TypeError"), "err.toString() = " + err
.toString());
1745 err
= new URIError();
1746 ok(URIError
.prototype.name
=== "URIError", "URIError.prototype.name = " + URIError
.prototype.name
);
1747 ok(err
.name
=== "URIError", "err.name = " + err
.name
);
1748 ok(err
.toString() === (invokeVersion
< 2 ? "[object Error]" : "URIError"), "err.toString() = " + err
.toString());
1749 err
= new Error("message");
1750 ok(err
.message
=== "message", "err.message !== 'message'");
1751 ok(err
.toString() === (invokeVersion
< 2 ? "[object Error]" : "Error: message"), "err.toString() = " + err
.toString());
1752 err
= new Error(123);
1753 ok(err
.number
=== 123, "err.number = " + err
.number
);
1754 err
= new Error(0, "message");
1755 ok(err
.number
=== 0, "err.number = " + err
.number
);
1756 ok(err
.message
=== "message", "err.message = " + err
.message
);
1757 ok(err
.description
=== "message", "err.description = " + err
.description
);
1760 tmp
.toString = function() { return "test"; };
1762 tmp
= Error
.prototype.toString
.call(tmp
);
1763 ok(tmp
=== "[object Error]", "Error.prototype.toString.call(tmp) = " + tmp
);
1767 ok(err
.name
=== null, "err.name = " + err
.name
+ " expected null");
1768 if(invokeVersion
>= 2)
1769 ok(err
.toString() === "null", "err.toString() = " + err
.toString());
1772 err
.message
= false;
1773 ok(err
.message
=== false, "err.message = " + err
.message
+ " expected false");
1774 if(invokeVersion
>= 2)
1775 ok(err
.toString() === "Error: false", "err.toString() = " + err
.toString());
1778 err
.message
= new Object();
1779 err
.message
.toString = function() { return ""; };
1780 if(invokeVersion
>= 2)
1781 ok(err
.toString() === "Error", "err.toString() = " + err
.toString());
1784 err
.message
= undefined;
1785 if(invokeVersion
>= 2)
1786 ok(err
.toString() === "Error", "err.toString() = " + err
.toString());
1788 function exception_test(func
, type
, number
) {
1797 ok(ret
=== type
, "Exception test, ret = " + ret
+ ", expected " + type
+". Executed function: " + func
.toString());
1798 ok(num
=== number
, "Exception test, num = " + num
+ ", expected " + number
+ ". Executed function: " + func
.toString());
1800 exception_test(function() {arr
.toString
= Date
.prototype.toString
; arr
.toString();}, "TypeError", -2146823282);
1801 exception_test(function() {Array(-3);}, "RangeError", -2146823259);
1802 exception_test(function() {arr
.toString
= Boolean
.prototype.toString
; arr
.toString();}, "TypeError", -2146823278);
1803 exception_test(function() {date
.setTime();}, "TypeError", -2146827839);
1804 exception_test(function() {arr
.test();}, "TypeError", -2146827850);
1805 exception_test(function() {arr
.toString
= Number
.prototype.toString
; arr
.toString();}, "TypeError", -2146823287);
1806 exception_test(function() {(new Number(3)).toString(1);}, "TypeError", -2146828283);
1807 exception_test(function() {not_existing_variable
.something();}, "TypeError", -2146823279);
1808 exception_test(function() {arr
.toString
= Function
.prototype.toString
; arr
.toString();}, "TypeError", -2146823286);
1809 exception_test(function() {date();}, "TypeError", -2146823286);
1810 exception_test(function() {arr();}, "TypeError", -2146823286);
1811 exception_test(function() {eval("for(i=0;) {}");}, "SyntaxError", -2146827286);
1812 exception_test(function() {eval("function {};");}, "SyntaxError", -2146827283);
1813 exception_test(function() {eval("if");}, "SyntaxError", -2146827283);
1814 exception_test(function() {eval("do i=0; while");}, "SyntaxError", -2146827283);
1815 exception_test(function() {eval("while");}, "SyntaxError", -2146827283);
1816 exception_test(function() {eval("for");}, "SyntaxError", -2146827283);
1817 exception_test(function() {eval("with");}, "SyntaxError", -2146827283);
1818 exception_test(function() {eval("switch");}, "SyntaxError", -2146827283);
1819 exception_test(function() {eval("if(false");}, "SyntaxError", -2146827282);
1820 exception_test(function() {eval("for(i=0; i<10; i++");}, "SyntaxError", -2146827282);
1821 exception_test(function() {eval("while(true");}, "SyntaxError", -2146827282);
1822 exception_test(function() {test = function() {}}, "ReferenceError", -2146823280);
1823 exception_test(function() {eval("for(i=0")}, "SyntaxError", -2146827284);
1824 exception_test(function() {eval("for(i=0;i<10")}, "SyntaxError", -2146827284);
1825 exception_test(function() {eval("while(")}, "SyntaxError", -2146827286);
1826 exception_test(function() {eval("if(")}, "SyntaxError", -2146827286);
1827 exception_test(function() {eval("'unterminated")}, "SyntaxError", -2146827273);
1828 exception_test(function() {eval("nonexistingfunc()")}, "TypeError", -2146823281);
1829 exception_test(function() {RegExp(/a
/, "g");}, "RegExpError", -2146823271);
1830 exception_test(function() {encodeURI('\udcaa');}, "URIError", -2146823264);
1832 function testThisExcept(func
, number
) {
1833 exception_test(function() {func
.call(new Object())}, "TypeError", number
);
1836 function testBoolThis(func
) {
1837 testThisExcept(Boolean
.prototype[func
], -2146823278);
1840 testBoolThis("toString");
1841 testBoolThis("valueOf");
1843 function testDateThis(func
) {
1844 testThisExcept(Date
.prototype[func
], -2146823282);
1847 testDateThis("getDate");
1848 testDateThis("getDay");
1849 testDateThis("getFullYear");
1850 testDateThis("getHours");
1851 testDateThis("getMilliseconds");
1852 testDateThis("getMinutes");
1853 testDateThis("getMonth");
1854 testDateThis("getSeconds");
1855 testDateThis("getTime");
1856 testDateThis("getTimezoneOffset");
1857 testDateThis("getUTCDate");
1858 testDateThis("getUTCDay");
1859 testDateThis("getUTCFullYear");
1860 testDateThis("getUTCHours");
1861 testDateThis("getUTCMilliseconds");
1862 testDateThis("getUTCMinutes");
1863 testDateThis("getUTCMonth");
1864 testDateThis("getUTCSeconds");
1865 testDateThis("setDate");
1866 testDateThis("setFullYear");
1867 testDateThis("setHours");
1868 testDateThis("setMilliseconds");
1869 testDateThis("setMinutes");
1870 testDateThis("setMonth");
1871 testDateThis("setSeconds");
1872 testDateThis("setTime");
1873 testDateThis("setUTCDate");
1874 testDateThis("setUTCFullYear");
1875 testDateThis("setUTCHours");
1876 testDateThis("setUTCMilliseconds");
1877 testDateThis("setUTCMinutes");
1878 testDateThis("setUTCMonth");
1879 testDateThis("setUTCSeconds");
1880 testDateThis("toDateString");
1881 testDateThis("toLocaleDateString");
1882 testDateThis("toLocaleString");
1883 testDateThis("toLocaleTimeString");
1884 testDateThis("toString");
1885 testDateThis("toTimeString");
1886 testDateThis("toUTCString");
1887 testDateThis("valueOf");
1889 function testArrayThis(func
) {
1890 testThisExcept(Array
.prototype[func
], -2146823257);
1893 testArrayThis("toString");
1895 function testFunctionThis(func
) {
1896 testThisExcept(Function
.prototype[func
], -2146823286);
1899 testFunctionThis("toString");
1900 testFunctionThis("call");
1901 testFunctionThis("apply");
1903 function testArrayHostThis(func
) {
1904 exception_test(function() { Array
.prototype[func
].call(testObj
); }, "TypeError", -2146823274);
1907 testArrayHostThis("push");
1908 testArrayHostThis("shift");
1909 testArrayHostThis("slice");
1910 testArrayHostThis("splice");
1911 testArrayHostThis("unshift");
1912 testArrayHostThis("reverse");
1913 testArrayHostThis("join");
1914 testArrayHostThis("pop");
1915 testArrayHostThis("sort");
1917 function testObjectInherit(obj
, constr
, ts
, tls
, vo
) {
1918 ok(obj
instanceof Object
, "obj is not instance of Object");
1919 ok(obj
instanceof constr
, "obj is not instance of its constructor");
1921 ok(obj
.hasOwnProperty
=== Object
.prototype.hasOwnProperty
,
1922 "obj.hasOwnProperty !== Object.prototype.hasOwnProprty");
1923 ok(obj
.isPrototypeOf
=== Object
.prototype.isPrototypeOf
,
1924 "obj.isPrototypeOf !== Object.prototype.isPrototypeOf");
1925 ok(obj
.propertyIsEnumerable
=== Object
.prototype.propertyIsEnumerable
,
1926 "obj.propertyIsEnumerable !== Object.prototype.propertyIsEnumerable");
1929 ok(obj
.toString
=== Object
.prototype.toString
,
1930 "obj.toString !== Object.prototype.toString");
1932 ok(obj
.toString
!= Object
.prototype.toString
,
1933 "obj.toString == Object.prototype.toString");
1936 ok(obj
.toLocaleString
=== Object
.prototype.toLocaleString
,
1937 "obj.toLocaleString !== Object.prototype.toLocaleString");
1939 ok(obj
.toLocaleString
!= Object
.prototype.toLocaleString
,
1940 "obj.toLocaleString == Object.prototype.toLocaleString");
1943 ok(obj
.valueOf
=== Object
.prototype.valueOf
,
1944 "obj.valueOf !== Object.prototype.valueOf");
1946 ok(obj
.valueOf
!= Object
.prototype.valueOf
,
1947 "obj.valueOf == Object.prototype.valueOf");
1949 ok(obj
._test
=== "test", "obj.test = " + obj
._test
);
1952 Object
.prototype._test
= "test";
1953 testObjectInherit(new String("test"), String
, false, true, false);
1954 testObjectInherit(/test/g, RegExp
, false, true, true);
1955 testObjectInherit(new Number(1), Number
, false, false, false);
1956 testObjectInherit(new Date(), Date
, false, false, false);
1957 testObjectInherit(new Boolean(true), Boolean
, false, true, false);
1958 testObjectInherit(new Array(), Array
, false, false, true);
1959 testObjectInherit(new Error(), Error
, false, true, true);
1960 testObjectInherit(testObjectInherit
, Function
, false, true, true);
1961 testObjectInherit(Math
, Object
, true, true, true);
1963 (function() { testObjectInherit(arguments
, Object
, true, true, true); })();
1965 function testFunctions(obj
, arr
) {
1968 for(var i
=0; i
<arr
.length
; i
++) {
1969 l
= obj
[arr
[i
][0]].length
;
1970 ok(l
=== arr
[i
][1], arr
[i
][0] + ".length = " + l
);
1974 testFunctions(Boolean
.prototype, [
1979 testFunctions(Number
.prototype, [
1982 ["toExponential", 1],
1983 ["toLocaleString", 0],
1987 testFunctions(String
.prototype, [
2004 ["localeCompare", 1],
2016 ["toLocaleLowerCase", 0],
2017 ["toLocaleUpperCase", 0],
2022 testFunctions(RegExp
.prototype, [
2028 testFunctions(Date
.prototype, [
2033 ["getMilliseconds", 0],
2038 ["getTimezoneOffset", 0],
2041 ["getUTCFullYear", 0],
2043 ["getUTCMilliseconds", 0],
2044 ["getUTCMinutes", 0],
2046 ["getUTCSeconds", 0],
2050 ["setMilliseconds", 1],
2056 ["setUTCFullYear", 3],
2058 ["setUTCMilliseconds", 1],
2059 ["setUTCMinutes", 3],
2061 ["setUTCSeconds", 2],
2062 ["toDateString", 0],
2063 ["toLocaleDateString", 0],
2064 ["toLocaleString", 0],
2065 ["toLocaleTimeString", 0],
2067 ["toTimeString", 0],
2073 testFunctions(Array
.prototype, [
2083 ["toLocaleString", 0],
2088 testFunctions(Error
.prototype, [
2092 testFunctions(Math
, [
2113 testFunctions(Object
.prototype, [
2114 ["hasOwnProperty", 1],
2115 ["isPrototypeOf", 1],
2116 ["propertyIsEnumerable", 1],
2117 ["toLocaleString", 0],
2122 testFunctions(Function
.prototype, [
2128 ok(ActiveXObject
.length
== 1, "ActiveXObject.length = " + ActiveXObject
.length
);
2129 ok(Array
.length
== 1, "Array.length = " + Array
.length
);
2130 ok(Boolean
.length
== 1, "Boolean.length = " + Boolean
.length
);
2131 ok(CollectGarbage
.length
== 0, "CollectGarbage.length = " + CollectGarbage
.length
);
2132 ok(Date
.length
== 7, "Date.length = " + Date
.length
);
2133 ok(Enumerator
.length
== 7, "Enumerator.length = " + Enumerator
.length
);
2134 ok(Error
.length
== 1, "Error.length = " + Error
.length
);
2135 ok(EvalError
.length
== 1, "EvalError.length = " + EvalError
.length
);
2136 ok(Function
.length
== 1, "Function.length = " + Function
.length
);
2137 ok(GetObject
.length
== 2, "GetObject.length = " + GetObject
.length
);
2138 ok(Number
.length
== 1, "Number.length = " + Number
.length
);
2139 ok(Object
.length
== 0, "Object.length = " + Object
.length
);
2140 ok(RangeError
.length
== 1, "RangeError.length = " + RangeError
.length
);
2141 ok(ReferenceError
.length
== 1, "ReferenceError.length = " + ReferenceError
.length
);
2142 ok(RegExp
.length
== 2, "RegExp.length = " + RegExp
.length
);
2143 ok(ScriptEngine
.length
== 0, "ScriptEngine.length = " + ScriptEngine
.length
);
2144 ok(ScriptEngineBuildVersion
.length
== 0,
2145 "ScriptEngineBuildVersion.length = " + ScriptEngineBuildVersion
.length
);
2146 ok(ScriptEngineMajorVersion
.length
== 0,
2147 "ScriptEngineMajorVersion.length = " + ScriptEngineMajorVersion
.length
);
2148 ok(ScriptEngineMinorVersion
.length
== 0,
2149 "ScriptEngineMinorVersion.length = " + ScriptEngineMinorVersion
.length
);
2150 ok(String
.length
== 1, "String.length = " + String
.length
);
2151 ok(SyntaxError
.length
== 1, "SyntaxError.length = " + SyntaxError
.length
);
2152 ok(TypeError
.length
== 1, "TypeError.length = " + TypeError
.length
);
2153 ok(URIError
.length
== 1, "URIError.length = " + URIError
.length
);
2154 ok(VBArray
.length
== 1, "VBArray.length = " + VBArray
.length
);
2155 ok(decodeURI
.length
== 1, "decodeURI.length = " + decodeURI
.length
);
2156 ok(decodeURIComponent
.length
== 1, "decodeURIComponent.length = " + decodeURIComponent
.length
);
2157 ok(encodeURI
.length
== 1, "encodeURI.length = " + encodeURI
.length
);
2158 ok(encodeURIComponent
.length
== 1, "encodeURIComponent.length = " + encodeURIComponent
.length
);
2159 ok(escape
.length
== 1, "escape.length = " + escape
.length
);
2160 ok(eval
.length
== 1, "eval.length = " + eval
.length
);
2161 ok(isFinite
.length
== 1, "isFinite.length = " + isFinite
.length
);
2162 ok(isNaN
.length
== 1, "isNaN.length = " + isNaN
.length
);
2163 ok(parseFloat
.length
== 1, "parseFloat.length = " + parseFloat
.length
);
2164 ok(parseInt
.length
== 2, "parseInt.length = " + parseInt
.length
);
2165 ok(unescape
.length
== 1, "unescape.length = " + unescape
.length
);
2168 ok(String
.length
== 1, "String.length = " + String
.length
);