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
= "" + new Object();
62 ok(tmp
=== "[object Object]", "'' + new Object() = " + tmp
);
63 (tmp
= new Array
).f
= Object
.prototype.toString
;
64 ok(tmp
.f() === "[object Array]", "tmp.f() = " + tmp
.f());
65 (tmp
= new Boolean
).f
= Object
.prototype.toString
;
66 ok(tmp
.f() === "[object Boolean]", "tmp.f() = " + tmp
.f());
67 (tmp
= new Date
).f
= Object
.prototype.toString
;
68 ok(tmp
.f() === "[object Date]", "tmp.f() = " + tmp
.f());
69 (tmp = function() {}).f
= Object
.prototype.toString
;
70 ok(tmp
.f() === "[object Function]", "tmp.f() = " + tmp
.f());
71 Math
.f
= Object
.prototype.toString
;
72 ok(Math
.f() === "[object Math]", "tmp.f() = " + tmp
.f());
73 (tmp
= new Number
).f
= Object
.prototype.toString
;
74 ok(tmp
.f() === "[object Number]", "tmp.f() = " + tmp
.f());
75 (tmp
= new RegExp("")).f
= Object
.prototype.toString
;
76 ok(tmp
.f() === "[object RegExp]", "tmp.f() = " + tmp
.f());
77 (tmp
= new String
).f
= Object
.prototype.toString
;
78 ok(tmp
.f() === "[object String]", "tmp.f() = " + tmp
.f());
80 var obj
= new Object();
81 obj
.toString = function (x
) {
82 ok(arguments
.length
=== 0, "arguments.length = " + arguments
.length
);
85 ok((tmp
= obj
.toLocaleString()) === "test", "obj.toLocaleString() = " + tmp
);
86 ok((tmp
= obj
.toLocaleString(1)) === "test", "obj.toLocaleString(1) = " + tmp
);
88 ok("".length
=== 0, "\"\".length = " + "".length
);
89 ok(getVT("".length
) == "VT_I4", "\"\".length = " + "".length
);
90 ok("abc".length
=== 3, "\"abc\".length = " + "abc".length
);
91 ok(String
.prototype.length
=== 0, "String.prototype.length = " + String
.prototype.length
);
94 ok(tmp
=== "", "''.toString() = " + tmp
);
95 tmp
= "test".toString();
96 ok(tmp
=== "test", "''.toString() = " + tmp
);
97 tmp
= "test".toString(3);
98 ok(tmp
=== "test", "''.toString(3) = " + tmp
);
101 ok(tmp
=== "", "''.valueOf() = " + tmp
);
102 tmp
= "test".valueOf();
103 ok(tmp
=== "test", "''.valueOf() = " + tmp
);
104 tmp
= "test".valueOf(3);
105 ok(tmp
=== "test", "''.valueOf(3) = " + tmp
);
107 var str
= new String("test");
108 ok(str
.toString() === "test", "str.toString() = " + str
.toString());
109 var str
= new String();
110 ok(str
.toString() === "", "str.toString() = " + str
.toString());
111 var str
= new String("test", "abc");
112 ok(str
.toString() === "test", "str.toString() = " + str
.toString());
114 var strObj
= new Object();
115 strObj
.toString = function() { return "abcd" };
116 strObj
.substr
= String
.prototype.substr
;
118 tmp
= "value " + str
;
119 ok(tmp
=== "value test", "'value ' + str = " + tmp
);
122 ok(tmp
=== "", "String() = " + tmp
);
124 ok(tmp
=== "false", "String(false) = " + tmp
);
126 ok(tmp
=== "null", "String(null) = " + tmp
);
127 tmp
= String("test");
128 ok(tmp
=== "test", "String('test') = " + tmp
);
129 tmp
= String("test", "abc");
130 ok(tmp
=== "test", "String('test','abc') = " + tmp
);
132 tmp
= "abc".charAt(0);
133 ok(tmp
=== "a", "'abc',charAt(0) = " + tmp
);
134 tmp
= "abc".charAt(1);
135 ok(tmp
=== "b", "'abc',charAt(1) = " + tmp
);
136 tmp
= "abc".charAt(2);
137 ok(tmp
=== "c", "'abc',charAt(2) = " + tmp
);
138 tmp
= "abc".charAt(3);
139 ok(tmp
=== "", "'abc',charAt(3) = " + tmp
);
140 tmp
= "abc".charAt(4);
141 ok(tmp
=== "", "'abc',charAt(4) = " + tmp
);
142 tmp
= "abc".charAt();
143 ok(tmp
=== "a", "'abc',charAt() = " + tmp
);
144 tmp
= "abc".charAt(-1);
145 ok(tmp
=== "", "'abc',charAt(-1) = " + tmp
);
146 tmp
= "abc".charAt(0,2);
147 ok(tmp
=== "a", "'abc',charAt(0.2) = " + tmp
);
149 tmp
= "abc".charCodeAt(0);
150 ok(tmp
=== 0x61, "'abc'.charCodeAt(0) = " + tmp
);
151 tmp
= "abc".charCodeAt(1);
152 ok(tmp
=== 0x62, "'abc'.charCodeAt(1) = " + tmp
);
153 tmp
= "abc".charCodeAt(2);
154 ok(tmp
=== 0x63, "'abc'.charCodeAt(2) = " + tmp
);
155 tmp
= "abc".charCodeAt();
156 ok(tmp
=== 0x61, "'abc'.charCodeAt() = " + tmp
);
157 tmp
= "abc".charCodeAt(true);
158 ok(tmp
=== 0x62, "'abc'.charCodeAt(true) = " + tmp
);
159 tmp
= "abc".charCodeAt(0,2);
160 ok(tmp
=== 0x61, "'abc'.charCodeAt(0,2) = " + tmp
);
162 tmp
= "abcd".substring(1,3);
163 ok(tmp
=== "bc", "'abcd'.substring(1,3) = " + tmp
);
164 tmp
= "abcd".substring(-1,3);
165 ok(tmp
=== "abc", "'abcd'.substring(-1,3) = " + tmp
);
166 tmp
= "abcd".substring(1,6);
167 ok(tmp
=== "bcd", "'abcd'.substring(1,6) = " + tmp
);
168 tmp
= "abcd".substring(3,1);
169 ok(tmp
=== "bc", "'abcd'.substring(3,1) = " + tmp
);
170 tmp
= "abcd".substring(2,2);
171 ok(tmp
=== "", "'abcd'.substring(2,2) = " + tmp
);
172 tmp
= "abcd".substring(true,"3");
173 ok(tmp
=== "bc", "'abcd'.substring(true,'3') = " + tmp
);
174 tmp
= "abcd".substring(1,3,2);
175 ok(tmp
=== "bc", "'abcd'.substring(1,3,2) = " + tmp
);
176 tmp
= "abcd".substring();
177 ok(tmp
=== "abcd", "'abcd'.substring() = " + tmp
);
179 tmp
= "abcd".substr(1,3);
180 ok(tmp
=== "bcd", "'abcd'.substr(1,3) = " + tmp
);
181 tmp
= "abcd".substr(-1,3);
182 ok(tmp
=== "abc", "'abcd'.substr(-1,3) = " + tmp
);
183 tmp
= "abcd".substr(1,6);
184 ok(tmp
=== "bcd", "'abcd'.substr(1,6) = " + tmp
);
185 tmp
= "abcd".substr(2,-1);
186 ok(tmp
=== "", "'abcd'.substr(3,1) = " + tmp
);
187 tmp
= "abcd".substr(2,0);
188 ok(tmp
=== "", "'abcd'.substr(2,2) = " + tmp
);
189 tmp
= "abcd".substr(true,"3");
190 ok(tmp
=== "bcd", "'abcd'.substr(true,'3') = " + tmp
);
191 tmp
= "abcd".substr(1,3,2);
192 ok(tmp
=== "bcd", "'abcd'.substr(1,3,2) = " + tmp
);
193 tmp
= "abcd".substr();
194 ok(tmp
=== "abcd", "'abcd'.substr() = " + tmp
);
195 tmp
= strObj
.substr(1,1);
196 ok(tmp
=== "b", "'abcd'.substr(1,3) = " + tmp
);
198 tmp
= "abcd".slice(1,3);
199 ok(tmp
=== "bc", "'abcd'.slice(1,3) = " + tmp
);
200 tmp
= "abcd".slice(1,-1);
201 ok(tmp
=== "bc", "'abcd'.slice(1,-1) = " + tmp
);
202 tmp
= "abcd".slice(-3,3);
203 ok(tmp
=== "bc", "'abcd'.slice(-3,3) = " + tmp
);
204 tmp
= "abcd".slice(-6,3);
205 ok(tmp
=== "abc", "'abcd'.slice(-6,3) = " + tmp
);
206 tmp
= "abcd".slice(3,1);
207 ok(tmp
=== "", "'abcd'.slice(3,1) = " + tmp
);
208 tmp
= "abcd".slice(true,3);
209 ok(tmp
=== "bc", "'abcd'.slice(true,3) = " + tmp
);
210 tmp
= "abcd".slice();
211 ok(tmp
=== "abcd", "'abcd'.slice() = " + tmp
);
212 tmp
= "abcd".slice(1);
213 ok(tmp
=== "bcd", "'abcd'.slice(1) = " + tmp
);
215 tmp
= "abc".concat(["d",1],2,false);
216 ok(tmp
=== "abcd,12false", "concat returned " + tmp
);
217 var arr
= new Array(2,"a");
218 arr
.concat
= String
.prototype.concat
;
219 tmp
= arr
.concat("d");
220 ok(tmp
=== "2,ad", "arr.concat = " + tmp
);
222 m
= "a+bcabc".match("a+");
223 ok(typeof(m
) === "object", "typeof m is not object");
224 ok(m
.length
=== 1, "m.length is not 1");
225 ok(m
["0"] === "a", "m[0] is not \"ab\"");
227 r
= "- [test] -".replace("[test]", "success");
228 ok(r
=== "- success -", "r = " + r
+ " expected '- success -'");
230 r
= "- [test] -".replace("[test]", "success", "test");
231 ok(r
=== "- success -", "r = " + r
+ " expected '- success -'");
233 r
= "test".replace();
234 ok(r
=== "test", "r = " + r
+ " expected 'test'");
236 function replaceFunc3(m
, off
, str
) {
237 ok(arguments
.length
=== 3, "arguments.length = " + arguments
.length
);
238 ok(m
=== "[test]", "m = " + m
+ " expected [test1]");
239 ok(off
=== 1, "off = " + off
+ " expected 0");
240 ok(str
=== "-[test]-", "str = " + arguments
[3]);
244 r
= "-[test]-".replace("[test]", replaceFunc3
);
245 ok(r
=== "-ret-", "r = " + r
+ " expected '-ret-'");
247 r
= "-[test]-".replace("[test]", replaceFunc3
, "test");
248 ok(r
=== "-ret-", "r = " + r
+ " expected '-ret-'");
250 r
= "1,2,3".split(",");
251 ok(typeof(r
) === "object", "typeof(r) = " + typeof(r
));
252 ok(r
.length
=== 3, "r.length = " + r
.length
);
253 ok(r
[0] === "1", "r[0] = " + r
[0]);
254 ok(r
[1] === "2", "r[1] = " + r
[1]);
255 ok(r
[2] === "3", "r[2] = " + r
[2]);
258 r
= "1,2,3".split(",*");
259 ok(r
.length
=== 1, "r.length = " + r
.length
);
260 ok(r
[0] === "1,2,3", "r[0] = " + r
[0]);
263 ok(r
.length
=== 3, "r.length = " + r
.length
);
264 ok(r
[0] === "1", "r[0] = " + r
[0]);
265 ok(r
[1] === "2", "r[1] = " + r
[1]);
266 ok(r
[2] === "3", "r[2] = " + r
[2]);
269 ok(r
.length
=== 2, "r.length = " + r
.length
);
270 ok(r
[0] === "1", "r[0] = " + r
[0]);
271 ok(r
[1] === "3", "r[1] = " + r
[1]);
273 r
= "1,2,".split(",");
274 ok(typeof(r
) === "object", "typeof(r) = " + typeof(r
));
275 ok(r
.length
=== 3, "r.length = " + r
.length
);
276 ok(r
[0] === "1", "r[0] = " + r
[0]);
277 ok(r
[1] === "2", "r[1] = " + r
[1]);
278 ok(r
[2] === "", "r[2] = " + r
[2]);
280 tmp
= "abcd".indexOf("bc",0);
281 ok(tmp
=== 1, "indexOf = " + tmp
);
282 tmp
= "abcd".indexOf("bc",1);
283 ok(tmp
=== 1, "indexOf = " + tmp
);
284 tmp
= "abcd".indexOf("bc");
285 ok(tmp
=== 1, "indexOf = " + tmp
);
286 tmp
= "abcd".indexOf("ac");
287 ok(tmp
=== -1, "indexOf = " + tmp
);
288 tmp
= "abcd".indexOf("bc",2);
289 ok(tmp
=== -1, "indexOf = " + tmp
);
290 tmp
= "abcd".indexOf("a",0);
291 ok(tmp
=== 0, "indexOf = " + tmp
);
292 tmp
= "abcd".indexOf("bc",0,"test");
293 ok(tmp
=== 1, "indexOf = " + tmp
);
294 tmp
= "abcd".indexOf();
295 ok(tmp
== -1, "indexOf = " + tmp
);
297 tmp
= "".toLowerCase();
298 ok(tmp
=== "", "''.toLowerCase() = " + tmp
);
299 tmp
= "test".toLowerCase();
300 ok(tmp
=== "test", "''.toLowerCase() = " + tmp
);
301 tmp
= "test".toLowerCase(3);
302 ok(tmp
=== "test", "''.toLowerCase(3) = " + tmp
);
303 tmp
= "tEsT".toLowerCase();
304 ok(tmp
=== "test", "''.toLowerCase() = " + tmp
);
305 tmp
= "tEsT".toLowerCase(3);
306 ok(tmp
=== "test", "''.toLowerCase(3) = " + tmp
);
308 tmp
= "".toUpperCase();
309 ok(tmp
=== "", "''.toUpperCase() = " + tmp
);
310 tmp
= "TEST".toUpperCase();
311 ok(tmp
=== "TEST", "''.toUpperCase() = " + tmp
);
312 tmp
= "TEST".toUpperCase(3);
313 ok(tmp
=== "TEST", "''.toUpperCase(3) = " + tmp
);
314 tmp
= "tEsT".toUpperCase();
315 ok(tmp
=== "TEST", "''.toUpperCase() = " + tmp
);
316 tmp
= "tEsT".toUpperCase(3);
317 ok(tmp
=== "TEST", "''.toUpperCase(3) = " + tmp
);
320 ok(tmp
=== "<A NAME=\"undefined\"></A>", "''.anchor() = " + tmp
);
322 ok(tmp
=== "<A NAME=\"3\"></A>", "''.anchor(3) = " + tmp
);
323 tmp
= "".anchor("red");
324 ok(tmp
=== "<A NAME=\"red\"></A>", "''.anchor('red') = " + tmp
);
325 tmp
= "test".anchor();
326 ok(tmp
=== "<A NAME=\"undefined\">test</A>", "'test'.anchor() = " + tmp
);
327 tmp
= "test".anchor(3);
328 ok(tmp
=== "<A NAME=\"3\">test</A>", "'test'.anchor(3) = " + tmp
);
329 tmp
= "test".anchor("green");
330 ok(tmp
=== "<A NAME=\"green\">test</A>", "'test'.anchor('green') = " + tmp
);
333 ok(tmp
=== "<BIG></BIG>", "''.big() = " + tmp
);
335 ok(tmp
=== "<BIG></BIG>", "''.big(3) = " + tmp
);
337 ok(tmp
=== "<BIG>test</BIG>", "'test'.big() = " + tmp
);
339 ok(tmp
=== "<BIG>test</BIG>", "'test'.big(3) = " + tmp
);
342 ok(tmp
=== "<BLINK></BLINK>", "''.blink() = " + tmp
);
344 ok(tmp
=== "<BLINK></BLINK>", "''.blink(3) = " + tmp
);
345 tmp
= "test".blink();
346 ok(tmp
=== "<BLINK>test</BLINK>", "'test'.blink() = " + tmp
);
347 tmp
= "test".blink(3);
348 ok(tmp
=== "<BLINK>test</BLINK>", "'test'.blink(3) = " + tmp
);
351 ok(tmp
=== "<B></B>", "''.bold() = " + tmp
);
353 ok(tmp
=== "<B></B>", "''.bold(3) = " + tmp
);
355 ok(tmp
=== "<B>test</B>", "'test'.bold() = " + tmp
);
356 tmp
= "test".bold(3);
357 ok(tmp
=== "<B>test</B>", "'test'.bold(3) = " + tmp
);
360 ok(tmp
=== "<TT></TT>", "''.fixed() = " + tmp
);
362 ok(tmp
=== "<TT></TT>", "''.fixed(3) = " + tmp
);
363 tmp
= "test".fixed();
364 ok(tmp
=== "<TT>test</TT>", "'test'.fixed() = " + tmp
);
365 tmp
= "test".fixed(3);
366 ok(tmp
=== "<TT>test</TT>", "'test'.fixed(3) = " + tmp
);
368 tmp
= "".fontcolor();
369 ok(tmp
=== "<FONT COLOR=\"undefined\"></FONT>", "''.fontcolor() = " + tmp
);
370 tmp
= "".fontcolor(3);
371 ok(tmp
=== "<FONT COLOR=\"3\"></FONT>", "''.fontcolor(3) = " + tmp
);
372 tmp
= "".fontcolor("red");
373 ok(tmp
=== "<FONT COLOR=\"red\"></FONT>", "''.fontcolor('red') = " + tmp
);
374 tmp
= "test".fontcolor();
375 ok(tmp
=== "<FONT COLOR=\"undefined\">test</FONT>", "'test'.fontcolor() = " + tmp
);
376 tmp
= "test".fontcolor(3);
377 ok(tmp
=== "<FONT COLOR=\"3\">test</FONT>", "'test'.fontcolor(3) = " + tmp
);
378 tmp
= "test".fontcolor("green");
379 ok(tmp
=== "<FONT COLOR=\"green\">test</FONT>", "'test'.fontcolor('green') = " + tmp
);
382 ok(tmp
=== "<FONT SIZE=\"undefined\"></FONT>", "''.fontsize() = " + tmp
);
383 tmp
= "".fontsize(3);
384 ok(tmp
=== "<FONT SIZE=\"3\"></FONT>", "''.fontsize(3) = " + tmp
);
385 tmp
= "".fontsize("red");
386 ok(tmp
=== "<FONT SIZE=\"red\"></FONT>", "''.fontsize('red') = " + tmp
);
387 tmp
= "test".fontsize();
388 ok(tmp
=== "<FONT SIZE=\"undefined\">test</FONT>", "'test'.fontsize() = " + tmp
);
389 tmp
= "test".fontsize(3);
390 ok(tmp
=== "<FONT SIZE=\"3\">test</FONT>", "'test'.fontsize(3) = " + tmp
);
391 tmp
= "test".fontsize("green");
392 ok(tmp
=== "<FONT SIZE=\"green\">test</FONT>", "'test'.fontsize('green') = " + tmp
);
394 tmp
= ("".fontcolor()).fontsize();
395 ok(tmp
=== "<FONT SIZE=\"undefined\"><FONT COLOR=\"undefined\"></FONT></FONT>", "(''.fontcolor()).fontsize() = " + tmp
);
398 ok(tmp
=== "<I></I>", "''.italics() = " + tmp
);
400 ok(tmp
=== "<I></I>", "''.italics(3) = " + tmp
);
401 tmp
= "test".italics();
402 ok(tmp
=== "<I>test</I>", "'test'.italics() = " + tmp
);
403 tmp
= "test".italics(3);
404 ok(tmp
=== "<I>test</I>", "'test'.italics(3) = " + tmp
);
407 ok(tmp
=== "<A HREF=\"undefined\"></A>", "''.link() = " + tmp
);
409 ok(tmp
=== "<A HREF=\"3\"></A>", "''.link(3) = " + tmp
);
410 tmp
= "".link("red");
411 ok(tmp
=== "<A HREF=\"red\"></A>", "''.link('red') = " + tmp
);
413 ok(tmp
=== "<A HREF=\"undefined\">test</A>", "'test'.link() = " + tmp
);
414 tmp
= "test".link(3);
415 ok(tmp
=== "<A HREF=\"3\">test</A>", "'test'.link(3) = " + tmp
);
416 tmp
= "test".link("green");
417 ok(tmp
=== "<A HREF=\"green\">test</A>", "'test'.link('green') = " + tmp
);
420 ok(tmp
=== "<SMALL></SMALL>", "''.small() = " + tmp
);
422 ok(tmp
=== "<SMALL></SMALL>", "''.small(3) = " + tmp
);
423 tmp
= "test".small();
424 ok(tmp
=== "<SMALL>test</SMALL>", "'test'.small() = " + tmp
);
425 tmp
= "test".small(3);
426 ok(tmp
=== "<SMALL>test</SMALL>", "'test'.small(3) = " + tmp
);
429 ok(tmp
=== "<STRIKE></STRIKE>", "''.strike() = " + tmp
);
431 ok(tmp
=== "<STRIKE></STRIKE>", "''.strike(3) = " + tmp
);
432 tmp
= "test".strike();
433 ok(tmp
=== "<STRIKE>test</STRIKE>", "'test'.strike() = " + tmp
);
434 tmp
= "test".strike(3);
435 ok(tmp
=== "<STRIKE>test</STRIKE>", "'test'.strike(3) = " + tmp
);
438 ok(tmp
=== "<SUB></SUB>", "''.sub() = " + tmp
);
440 ok(tmp
=== "<SUB></SUB>", "''.sub(3) = " + tmp
);
442 ok(tmp
=== "<SUB>test</SUB>", "'test'.sub() = " + tmp
);
444 ok(tmp
=== "<SUB>test</SUB>", "'test'.sub(3) = " + tmp
);
447 ok(tmp
=== "<SUP></SUP>", "''.sup() = " + tmp
);
449 ok(tmp
=== "<SUP></SUP>", "''.sup(3) = " + tmp
);
451 ok(tmp
=== "<SUP>test</SUP>", "'test'.sup() = " + tmp
);
453 ok(tmp
=== "<SUP>test</SUP>", "'test'.sup(3) = " + tmp
);
455 ok(String
.fromCharCode() === "", "String.fromCharCode() = " + String
.fromCharCode());
456 ok(String
.fromCharCode(65,"66",67) === "ABC", "String.fromCharCode(65,'66',67) = " + String
.fromCharCode(65,"66",67));
457 ok(String
.fromCharCode(1024*64+65, -1024*64+65) === "AA",
458 "String.fromCharCode(1024*64+65, -1024*64+65) = " + String
.fromCharCode(1024*64+65, -1024*64+65));
459 ok(String
.fromCharCode(65, NaN
, undefined).length
=== 3,
460 "String.fromCharCode(65, NaN, undefined).length = " + String
.fromCharCode(65, NaN
, undefined).length
);
462 var arr
= new Array();
463 ok(typeof(arr
) === "object", "arr () is not object");
464 ok((arr
.length
=== 0), "arr.length is not 0");
465 ok(arr
["0"] === undefined, "arr[0] is not undefined");
467 var arr
= new Array(1, 2, "test");
468 ok(typeof(arr
) === "object", "arr (1,2,test) is not object");
469 ok((arr
.length
=== 3), "arr.length is not 3");
470 ok(arr
["0"] === 1, "arr[0] is not 1");
471 ok(arr
["1"] === 2, "arr[1] is not 2");
472 ok(arr
["2"] === "test", "arr[2] is not \"test\"");
475 ok((arr
.length
=== 8), "arr.length is not 8");
478 ok(tmp
=== "", "'' + [] = " + tmp
);
480 ok(tmp
=== "1,true", "'' + [1,true] = " + tmp
);
482 var arr
= new Array(6);
483 ok(typeof(arr
) === "object", "arr (6) is not object");
484 ok((arr
.length
=== 6), "arr.length is not 6");
485 ok(arr
["0"] === undefined, "arr[0] is not undefined");
487 ok(arr
.push() === 6, "arr.push() !== 6");
488 ok(arr
.push(1) === 7, "arr.push(1) !== 7");
489 ok(arr
[6] === 1, "arr[6] != 1");
490 ok(arr
.length
=== 7, "arr.length != 10");
491 ok(arr
.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10");
492 ok(arr
[8] === "b", "arr[8] != 'b'");
493 ok(arr
.length
=== 10, "arr.length != 10");
495 var arr
= new Object();
496 arr
.push
= Array
.prototype.push
;
500 ok(arr
.push() === 6, "arr.push() !== 6");
501 ok(arr
.push(1) === 7, "arr.push(1) !== 7");
502 ok(arr
[6] === 1, "arr[6] != 1");
503 ok(arr
.length
=== 7, "arr.length != 10");
504 ok(arr
.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10");
505 ok(arr
[8] === "b", "arr[8] != 'b'");
506 ok(arr
.length
=== 10, "arr.length != 10");
510 ok(arr
.length
=== 2, "arr.length = " + arr
.length
);
511 ok(tmp
=== 5, "pop() = " + tmp
);
513 ok(arr
.length
=== 1, "arr.length = " + arr
.length
);
514 ok(tmp
=== 4, "pop() = " + tmp
);
516 ok(arr
.length
=== 0, "arr.length = " + arr
.length
);
517 ok(tmp
=== 3, "pop() = " + tmp
);
519 ok(false, "not deleted " + tmp
);
521 ok(arr
.length
=== 0, "arr.length = " + arr
.length
);
522 ok(tmp
=== undefined, "tmp = " + tmp
);
525 ok(arr
.length
=== 5, "arr.length = " + arr
.length
);
526 ok(tmp
=== undefined, "tmp = " + tmp
);
528 arr
= [1,2,null,false,undefined,,"a"];
531 ok(tmp
=== "1,2,,false,,,a", "arr.join() = " + tmp
);
533 ok(tmp
=== "1;2;;false;;;a", "arr.join(';') = " + tmp
);
534 tmp
= arr
.join(";","test");
535 ok(tmp
=== "1;2;;false;;;a", "arr.join(';') = " + tmp
);
537 ok(tmp
=== "12falsea", "arr.join('') = " + tmp
);
539 tmp
= arr
.toString();
540 ok(tmp
=== "1,2,,false,,,a", "arr.toString() = " + tmp
);
541 tmp
= arr
.toString("test");
542 ok(tmp
=== "1,2,,false,,,a", "arr.toString() = " + tmp
);
544 arr
= [5,true,2,-1,3,false,"2.5"];
545 tmp
= arr
.sort(function(x
,y
) { return y
-x
; });
546 ok(tmp
=== arr
, "tmp !== arr");
547 tmp
= [5,3,"2.5",2,true,false,-1];
548 for(var i
=0; i
< arr
.length
; i
++)
549 ok(arr
[i
] === tmp
[i
], "arr[" + i
+ "] = " + arr
[i
] + " expected " + tmp
[i
]);
551 arr
= [5,false,2,0,"abc",3,"a",-1];
553 ok(tmp
=== arr
, "tmp !== arr");
554 tmp
= [-1,0,2,3,5,"a","abc",false];
555 for(var i
=0; i
< arr
.length
; i
++)
556 ok(arr
[i
] === tmp
[i
], "arr[" + i
+ "] = " + arr
[i
] + " expected " + tmp
[i
]);
558 arr
= ["a", "b", "ab"];
559 tmp
= ["a", "ab", "b"];
560 ok(arr
.sort() === arr
, "arr.sort() !== arr");
561 for(var i
=0; i
< arr
.length
; i
++)
562 ok(arr
[i
] === tmp
[i
], "arr[" + i
+ "] = " + arr
[i
] + " expected " + tmp
[i
]);
564 arr
= ["1", "2", "3"];
566 ok(arr
.length
=== 1, "arr.length = " + arr
.length
);
568 ok(arr
.length
=== 3, "arr.length = " + arr
.length
);
569 ok(arr
.toString() === "1,,", "arr.toString() = " + arr
.toString());
571 arr
= Array("a","b","c");
572 ok(arr
.toString() === "a,b,c", "arr.toString() = " + arr
.toString());
574 ok(arr
.valueOf
=== Object
.prototype.valueOf
, "arr.valueOf !== Object.prototype.valueOf");
575 ok(arr
=== arr
.valueOf(), "arr !== arr.valueOf");
577 var num
= new Number(6);
579 tmp
= arr
.concat(3, [4,5], num
);
580 ok(tmp
!== arr
, "tmp === arr");
581 for(var i
=0; i
<6; i
++)
582 ok(tmp
[i
] === i
, "tmp[" + i
+ "] = " + tmp
[i
]);
583 ok(tmp
[6] === num
, "tmp[6] !== num");
584 ok(tmp
.length
=== 7, "tmp.length = " + tmp
.length
);
587 ok(arr
.length
=== 0, "arr.length = " + arr
.length
);
590 tmp
= arr
.concat([2]);
591 ok(tmp
.length
=== 3, "tmp.length = " + tmp
.length
);
592 ok(tmp
[1] === undefined, "tmp[1] = " + tmp
[1]);
594 arr
= [1,false,'a',null,undefined,'a'];
595 ok(arr
.slice(0,6).toString() === "1,false,a,,,a", "arr.slice(0,6).toString() = " + arr
.slice(0,6));
596 ok(arr
.slice(0,6).length
=== 6, "arr.slice(0,6).length = " + arr
.slice(0,6).length
);
597 ok(arr
.slice().toString() === "1,false,a,,,a", "arr.slice().toString() = " + arr
.slice());
598 ok(arr
.slice("abc").toString() === "1,false,a,,,a", "arr.slice(\"abc\").toString() = " + arr
.slice("abc"));
599 ok(arr
.slice(3,8).toString() === ",,a", "arr.slice(3,8).toString() = " + arr
.slice(3,8));
600 ok(arr
.slice(3,8).length
=== 3, "arr.slice(3,8).length = " + arr
.slice(3,8).length
);
601 ok(arr
.slice(1).toString() === "false,a,,,a", "arr.slice(1).toString() = " + arr
.slice(1));
602 ok(arr
.slice(-2).toString() === ",a", "arr.slice(-2).toString() = " + arr
.slice(-2));
603 ok(arr
.slice(3,1).toString() === "", "arr.slice(3,1).toString() = " + arr
.slice(3,1));
604 tmp
= arr
.slice(0,6);
605 for(var i
=0; i
< arr
.length
; i
++)
606 ok(arr
[i
] === tmp
[i
], "arr[" + i
+ "] = " + arr
[i
] + " expected " + tmp
[i
]);
608 ok(arr
.slice(5).toString() === "a,,,,,,,2", "arr.slice(5).toString() = " + arr
.slice(5).toString());
609 ok(arr
.slice(5).length
=== 8, "arr.slice(5).length = " + arr
.slice(5).length
);
611 var num
= new Number(2);
612 ok(num
.toString() === "2", "num(2).toString !== 2");
613 var num
= new Number();
614 ok(num
.toString() === "0", "num().toString !== 0");
616 ok(Number() === 0, "Number() = " + Number());
617 ok(Number(false) === 0, "Number(false) = " + Number(false));
618 ok(Number("43") === 43, "Number('43') = " + Number("43"));
620 tmp
= (new Number(1)).valueOf();
621 ok(tmp
=== 1, "(new Number(1)).valueOf = " + tmp
);
622 tmp
= (new Number(1,2)).valueOf();
623 ok(tmp
=== 1, "(new Number(1,2)).valueOf = " + tmp
);
624 tmp
= (new Number()).valueOf();
625 ok(tmp
=== 0, "(new Number()).valueOf = " + tmp
);
626 tmp
= Number
.prototype.valueOf();
627 ok(tmp
=== 0, "Number.prototype.valueOf = " + tmp
);
629 function equals(val
, base
) {
632 var str
= val
.toString(base
);
634 for(i
=0; i
<str
.length
; i
++) {
635 if(str
.substring(i
, i
+1) == '(') break;
636 if(str
.substring(i
, i
+1) == '.') break;
637 num
= num
*base
+ parseInt(str
.substring(i
, i
+1));
640 if(str
.substring(i
, i
+1) == '.') {
642 for(i
++; i
<str
.length
; i
++) {
643 if(str
.substring(i
, i
+1) == '(') break;
644 num
+= parseInt(str
.substring(i
, i
+1))/mult
;
649 if(str
.substring(i
, i
+1) == '(') {
650 exp
= parseInt(str
.substring(i
+2));
651 num
*= Math
.pow(base
, exp
);
654 ok(num
>val
-val
/1000 && num<val+val/1000, "equals: num = " + num
);
657 ok((10).toString(11) === "a", "(10).toString(11) = " + (10).toString(11));
658 ok((213213433).toString(17) === "8e2ddcb", "(213213433).toString(17) = " + (213213433).toString(17));
659 ok((-3254343).toString(33) === "-2oicf", "(-3254343).toString(33) = " + (-3254343).toString(33));
660 ok((NaN
).toString(12) === "NaN", "(NaN).toString(11) = " + (NaN
).toString(11));
661 ok((Infinity
).toString(13) === "Infinity", "(Infinity).toString(11) = " + (Infinity
).toString(11));
662 for(i
=2; i
<10; i
++) {
664 equals(2305843009200000000, i
);
667 equals(1024*1024*1024*1024*1024*1024*1.9999, i
);
670 equals(4.65661287308e-10, i
);
671 ok((0).toString(i
) === "0", "(0).toString("+i
+") = " + (0).toString(i
));
674 ok(parseFloat('123') === 123, "parseFloat('123') = " + parseFloat('123'));
675 ok(parseFloat('-13.7') === -13.7, "parseFloat('-13.7') = " + parseFloat('-13.7'));
676 ok(parseFloat('-0.01e-2') === -0.01e-2, "parseFloat('-0.01e-2') = " + parseFloat('-0.01e-2'));
677 ok(parseFloat('-12e+5') === -12e+5, "parseFloat('-12e+5') = " + parseFloat('-12e+5'));
678 ok(parseFloat('1E5 not parsed') === 1E5
, "parseFloat('1E5 not parsed') = " + parseFloat('1E5 not parsed'));
679 ok(isNaN(parseFloat('not a number')), "parseFloat('not a number') is not NaN");
680 ok(parseFloat('+13.2e-3') === 13.2e-3, "parseFloat('+13.2e-3') = " + parseFloat('+13.2e-3'));
681 ok(parseFloat('.12') === 0.12, "parseFloat('.12') = " + parseFloat('.12'));
682 ok(parseFloat('1e') === 1, "parseFloat('1e') = " + parseFloat('1e'));
685 ok(tmp
=== 1, "Math.min(1) = " + tmp
);
687 tmp
= Math
.min(1, false);
688 ok(tmp
=== 0, "Math.min(1, false) = " + tmp
);
691 ok(tmp
=== Infinity
, "Math.min() = " + tmp
);
693 tmp
= Math
.min(1, NaN
, -Infinity
, false);
694 ok(isNaN(tmp
), "Math.min(1, NaN, -Infinity, false) is not NaN");
696 tmp
= Math
.min(1, false, true, null, -3);
697 ok(tmp
=== -3, "Math.min(1, false, true, null, -3) = " + tmp
);
700 ok(tmp
=== 1, "Math.max(1) = " + tmp
);
702 tmp
= Math
.max(true, 0);
703 ok(tmp
=== 1, "Math.max(true, 0) = " + tmp
);
705 tmp
= Math
.max(-2, false, true, null, 1);
706 ok(tmp
=== 1, "Math.max(-2, false, true, null, 1) = " + tmp
);
709 ok(tmp
=== -Infinity
, "Math.max() = " + tmp
);
711 tmp
= Math
.max(true, NaN
, 0);
712 ok(isNaN(tmp
), "Math.max(true, NaN, 0) is not NaN");
714 tmp
= Math
.round(0.5);
715 ok(tmp
=== 1, "Math.round(0.5) = " + tmp
);
717 tmp
= Math
.round(-0.5);
718 ok(tmp
=== 0, "Math.round(-0.5) = " + tmp
);
720 tmp
= Math
.round(1.1);
721 ok(tmp
=== 1, "Math.round(1.1) = " + tmp
);
723 tmp
= Math
.round(true);
724 ok(tmp
=== 1, "Math.round(true) = " + tmp
);
726 tmp
= Math
.round(1.1, 3, 4);
727 ok(tmp
=== 1, "Math.round(1.1, 3, 4) = " + tmp
);
730 ok(isNaN(tmp
), "Math.round() is not NaN");
732 tmp
= Math
.ceil(0.5);
733 ok(tmp
=== 1, "Math.ceil(0.5) = " + tmp
);
735 tmp
= Math
.ceil(-0.5);
736 ok(tmp
=== 0, "Math.ceil(-0.5) = " + tmp
);
738 tmp
= Math
.ceil(1.1);
739 ok(tmp
=== 2, "Math.round(1.1) = " + tmp
);
741 tmp
= Math
.ceil(true);
742 ok(tmp
=== 1, "Math.ceil(true) = " + tmp
);
744 tmp
= Math
.ceil(1.1, 3, 4);
745 ok(tmp
=== 2, "Math.ceil(1.1, 3, 4) = " + tmp
);
748 ok(isNaN(tmp
), "ceil() is not NaN");
750 tmp
= Math
.floor(0.5);
751 ok(tmp
=== 0, "Math.floor(0.5) = " + tmp
);
753 tmp
= Math
.floor(-0.5);
754 ok(tmp
=== -1, "Math.floor(-0.5) = " + tmp
);
756 tmp
= Math
.floor(1.1);
757 ok(tmp
=== 1, "Math.floor(1.1) = " + tmp
);
759 tmp
= Math
.floor(true);
760 ok(tmp
=== 1, "Math.floor(true) = " + tmp
);
762 tmp
= Math
.floor(1.1, 3, 4);
763 ok(tmp
=== 1, "Math.floor(1.1, 3, 4) = " + tmp
);
766 ok(isNaN(tmp
), "floor is not NaN");
769 ok(tmp
=== 3, "Math.abs(3) = " + tmp
);
772 ok(tmp
=== 3, "Math.abs(-3) = " + tmp
);
774 tmp
= Math
.abs(true);
775 ok(tmp
=== 1, "Math.abs(true) = " + tmp
);
778 ok(isNaN(tmp
), "Math.abs() is not NaN");
781 ok(isNaN(tmp
), "Math.abs() is not NaN");
783 tmp
= Math
.abs(-Infinity
);
784 ok(tmp
=== Infinity
, "Math.abs(-Infinite) = " + tmp
);
786 tmp
= Math
.abs(-3, 2);
787 ok(tmp
=== 3, "Math.abs(-3, 2) = " + tmp
);
790 ok(tmp
=== 1, "Math.cos(0) = " + tmp
);
792 tmp
= Math
.cos(Math
.PI
/2);
793 ok(Math
.floor(tmp
*100) === 0, "Math.cos(Math.PI/2) = " + tmp
);
795 tmp
= Math
.cos(-Math
.PI
/2);
796 ok(Math
.floor(tmp
*100) === 0, "Math.cos(-Math.PI/2) = " + tmp
);
798 tmp
= Math
.cos(Math
.PI
/3, 2);
799 ok(Math
.floor(tmp
*100) === 50, "Math.cos(Math.PI/3, 2) = " + tmp
);
801 tmp
= Math
.cos(true);
802 ok(Math
.floor(tmp
*100) === 54, "Math.cos(true) = " + tmp
);
804 tmp
= Math
.cos(false);
805 ok(tmp
=== 1, "Math.cos(false) = " + tmp
);
808 ok(isNaN(tmp
), "Math.cos() is not NaN");
811 ok(isNaN(tmp
), "Math.cos(NaN) is not NaN");
813 tmp
= Math
.cos(Infinity
);
814 ok(isNaN(tmp
), "Math.cos(Infinity) is not NaN");
816 tmp
= Math
.cos(-Infinity
);
817 ok(isNaN(tmp
), "Math.cos(-Infinity) is not NaN");
819 tmp
= Math
.pow(2, 2);
820 ok(tmp
=== 4, "Math.pow(2, 2) = " + tmp
);
822 tmp
= Math
.pow(4, 0.5);
823 ok(tmp
=== 2, "Math.pow(2, 2) = " + tmp
);
825 tmp
= Math
.pow(2, 2, 3);
826 ok(tmp
=== 4, "Math.pow(2, 2, 3) = " + tmp
);
829 ok(isNaN(tmp
), "Math.pow(2) is not NaN");
832 ok(isNaN(tmp
), "Math.pow() is not NaN");
835 ok(typeof(tmp
) == "number", "typeof(tmp) = " + typeof(tmp
));
836 ok(0 <= tmp
&& tmp
<= 1, "Math.random() = " + tmp
);
838 tmp
= Math
.random(100);
839 ok(typeof(tmp
) == "number", "typeof(tmp) = " + typeof(tmp
));
840 ok(0 <= tmp
&& tmp
<= 1, "Math.random(100) = " + tmp
);
843 ok(Math
.floor(tmp
*100) === 157, "Math.acos(0) = " + tmp
);
846 ok(Math
.floor(tmp
*100) === 0, "Math.acos(1) = " + tmp
);
849 ok(Math
.floor(tmp
*100) === 314, "Math.acos(-1) = " + tmp
);
851 tmp
= Math
.acos(Math
.PI
/4, 2);
852 ok(Math
.floor(tmp
*100) === 66, "Math.acos(Math.PI/4, 2) = " + tmp
);
854 tmp
= Math
.acos(true);
855 ok(Math
.floor(tmp
*100) === 0, "Math.acos(true) = " + tmp
);
857 tmp
= Math
.acos(false);
858 ok(Math
.floor(tmp
*100) === 157, "Math.acos(false) = " + tmp
);
860 tmp
= Math
.acos(1.1);
861 ok(isNaN(tmp
), "Math.acos(1.1) is not NaN");
864 ok(isNaN(tmp
), "Math.acos() is not NaN");
866 tmp
= Math
.acos(NaN
);
867 ok(isNaN(tmp
), "Math.acos(NaN) is not NaN");
869 tmp
= Math
.acos(Infinity
);
870 ok(isNaN(tmp
), "Math.acos(Infinity) is not NaN");
872 tmp
= Math
.acos(-Infinity
);
873 ok(isNaN(tmp
), "Math.acos(-Infinity) is not NaN");
876 ok(Math
.floor(tmp
*100) === 0, "Math.asin(0) = " + tmp
);
879 ok(Math
.floor(tmp
*100) === 157, "Math.asin(1) = " + tmp
);
882 ok(Math
.floor(tmp
*100) === -158, "Math.asin(-1) = " + tmp
);
884 tmp
= Math
.asin(Math
.PI
/4, 2);
885 ok(Math
.floor(tmp
*100) === 90, "Math.asin(Math.PI/4, 2) = " + tmp
);
887 tmp
= Math
.asin(true);
888 ok(Math
.floor(tmp
*100) === 157, "Math.asin(true) = " + tmp
);
890 tmp
= Math
.asin(false);
891 ok(Math
.floor(tmp
*100) === 0, "Math.asin(false) = " + tmp
);
893 tmp
= Math
.asin(1.1);
894 ok(isNaN(tmp
), "Math.asin(1.1) is not NaN");
897 ok(isNaN(tmp
), "Math.asin() is not NaN");
899 tmp
= Math
.asin(NaN
);
900 ok(isNaN(tmp
), "Math.asin(NaN) is not NaN");
902 tmp
= Math
.asin(Infinity
);
903 ok(isNaN(tmp
), "Math.asin(Infinity) is not NaN");
905 tmp
= Math
.asin(-Infinity
);
906 ok(isNaN(tmp
), "Math.asin(-Infinity) is not NaN");
909 ok(Math
.floor(tmp
*100) === 0, "Math.atan(0) = " + tmp
);
912 ok(Math
.floor(tmp
*100) === 78, "Math.atan(1) = " + tmp
);
915 ok(Math
.floor(tmp
*100) === -79, "Math.atan(-1) = " + tmp
);
917 tmp
= Math
.atan(true);
918 ok(Math
.floor(tmp
*100) === 78, "Math.atan(true) = " + tmp
);
920 tmp
= Math
.atan(false);
921 ok(Math
.floor(tmp
*100) === 0, "Math.atan(false) = " + tmp
);
924 ok(isNaN(tmp
), "Math.atan() is not NaN");
926 tmp
= Math
.atan(NaN
);
927 ok(isNaN(tmp
), "Math.atan(NaN) is not NaN");
929 tmp
= Math
.atan(Infinity
);
930 ok(Math
.floor(tmp
*100) === 157, "Math.atan(Infinity) = " + tmp
);
932 tmp
= Math
.atan(-Infinity
);
933 ok(Math
.floor(tmp
*100) === -158, "Math.atan(Infinity) = " + tmp
);
935 tmp
= Math
.atan2(0, 0);
936 ok(Math
.floor(tmp
*100) === 0, "Math.atan2(0, 0) = " + tmp
);
938 tmp
= Math
.atan2(0, 1);
939 ok(Math
.floor(tmp
*100) === 0, "Math.atan2(0, 1) = " + tmp
);
941 tmp
= Math
.atan2(0, Infinity
);
942 ok(Math
.floor(tmp
*100) === 0, "Math.atan2(0, Infinity) = " + tmp
);
944 tmp
= Math
.atan2(0, -1);
945 ok(Math
.floor(tmp
*100) === 314, "Math.atan2(0, -1) = " + tmp
);
947 tmp
= Math
.atan2(0, -Infinity
);
948 ok(Math
.floor(tmp
*100) === 314, "Math.atan2(0, -Infinity) = " + tmp
);
950 tmp
= Math
.atan2(1, 0);
951 ok(Math
.floor(tmp
*100) === 157, "Math.atan2(1, 0) = " + tmp
);
953 tmp
= Math
.atan2(Infinity
, 0);
954 ok(Math
.floor(tmp
*100) === 157, "Math.atan2(Infinity, 0) = " + tmp
);
956 tmp
= Math
.atan2(-1, 0);
957 ok(Math
.floor(tmp
*100) === -158, "Math.atan2(-1, 0) = " + tmp
);
959 tmp
= Math
.atan2(-Infinity
, 0);
960 ok(Math
.floor(tmp
*100) === -158, "Math.atan2(-Infinity, 0) = " + tmp
);
962 tmp
= Math
.atan2(1, 1);
963 ok(Math
.floor(tmp
*100) === 78, "Math.atan2(1, 1) = " + tmp
);
965 tmp
= Math
.atan2(-1, -1);
966 ok(Math
.floor(tmp
*100) === -236, "Math.atan2(-1, -1) = " + tmp
);
968 tmp
= Math
.atan2(-1, 1);
969 ok(Math
.floor(tmp
*100) === -79, "Math.atan2(-1, 1) = " + tmp
);
971 tmp
= Math
.atan2(Infinity
, Infinity
);
972 ok(Math
.floor(tmp
*100) === 78, "Math.atan2(Infinity, Infinity) = " + tmp
);
974 tmp
= Math
.atan2(Infinity
, -Infinity
, 1);
975 ok(Math
.floor(tmp
*100) === 235, "Math.atan2(Infinity, -Infinity, 1) = " + tmp
);
978 ok(isNaN(tmp
), "Math.atan2() is not NaN");
981 ok(isNaN(tmp
), "Math.atan2(1) is not NaN");
984 ok(tmp
=== 1, "Math.exp(0) = " + tmp
);
987 ok(Math
.floor(tmp
*100) === 271, "Math.exp(1) = " + tmp
);
990 ok(Math
.floor(tmp
*100) === 36, "Math.exp(-1) = " + tmp
);
992 tmp
= Math
.exp(true);
993 ok(Math
.floor(tmp
*100) === 271, "Math.exp(true) = " + tmp
);
995 tmp
= Math
.exp(1, 1);
996 ok(Math
.floor(tmp
*100) === 271, "Math.exp(1, 1) = " + tmp
);
999 ok(isNaN(tmp
), "Math.exp() is not NaN");
1001 tmp
= Math
.exp(NaN
);
1002 ok(isNaN(tmp
), "Math.exp(NaN) is not NaN");
1004 tmp
= Math
.exp(Infinity
);
1005 ok(tmp
=== Infinity
, "Math.exp(Infinity) = " + tmp
);
1007 tmp
= Math
.exp(-Infinity
);
1008 ok(tmp
=== 0, "Math.exp(-Infinity) = " + tmp
);
1011 ok(Math
.floor(tmp
*100) === 0, "Math.log(1) = " + tmp
);
1014 ok(isNaN(tmp
), "Math.log(-1) is not NaN");
1016 tmp
= Math
.log(true);
1017 ok(Math
.floor(tmp
*100) === 0, "Math.log(true) = " + tmp
);
1019 tmp
= Math
.log(1, 1);
1020 ok(Math
.floor(tmp
*100) === 0, "Math.log(1, 1) = " + tmp
);
1023 ok(isNaN(tmp
), "Math.log() is not NaN");
1025 tmp
= Math
.log(NaN
);
1026 ok(isNaN(tmp
), "Math.log(NaN) is not NaN");
1028 tmp
= Math
.log(Infinity
);
1029 ok(tmp
=== Infinity
, "Math.log(Infinity) = " + tmp
);
1031 tmp
= Math
.log(-Infinity
);
1032 ok(isNaN(tmp
), "Math.log(-Infinity) is not NaN");
1035 ok(tmp
=== 0, "Math.sin(0) = " + tmp
);
1037 tmp
= Math
.sin(Math
.PI
/2);
1038 ok(tmp
=== 1, "Math.sin(Math.PI/2) = " + tmp
);
1040 tmp
= Math
.sin(-Math
.PI
/2);
1041 ok(tmp
=== -1, "Math.sin(-Math.PI/2) = " + tmp
);
1043 tmp
= Math
.sin(Math
.PI
/3, 2);
1044 ok(Math
.floor(tmp
*100) === 86, "Math.sin(Math.PI/3, 2) = " + tmp
);
1046 tmp
= Math
.sin(true);
1047 ok(Math
.floor(tmp
*100) === 84, "Math.sin(true) = " + tmp
);
1049 tmp
= Math
.sin(false);
1050 ok(tmp
=== 0, "Math.sin(false) = " + tmp
);
1053 ok(isNaN(tmp
), "Math.sin() is not NaN");
1055 tmp
= Math
.sin(NaN
);
1056 ok(isNaN(tmp
), "Math.sin(NaN) is not NaN");
1058 tmp
= Math
.sin(Infinity
);
1059 ok(isNaN(tmp
), "Math.sin(Infinity) is not NaN");
1061 tmp
= Math
.sin(-Infinity
);
1062 ok(isNaN(tmp
), "Math.sin(-Infinity) is not NaN");
1065 ok(tmp
=== 0, "Math.sqrt(0) = " + tmp
);
1068 ok(tmp
=== 2, "Math.sqrt(4) = " + tmp
);
1070 tmp
= Math
.sqrt(-1);
1071 ok(isNaN(tmp
), "Math.sqrt(-1) is not NaN");
1073 tmp
= Math
.sqrt(2, 2);
1074 ok(Math
.floor(tmp
*100) === 141, "Math.sqrt(2, 2) = " + tmp
);
1076 tmp
= Math
.sqrt(true);
1077 ok(tmp
=== 1, "Math.sqrt(true) = " + tmp
);
1079 tmp
= Math
.sqrt(false);
1080 ok(tmp
=== 0, "Math.sqrt(false) = " + tmp
);
1083 ok(isNaN(tmp
), "Math.sqrt() is not NaN");
1085 tmp
= Math
.sqrt(NaN
);
1086 ok(isNaN(tmp
), "Math.sqrt(NaN) is not NaN");
1088 tmp
= Math
.sqrt(Infinity
);
1089 ok(tmp
=== Infinity
, "Math.sqrt(Infinity) = " + tmp
);
1091 tmp
= Math
.sqrt(-Infinity
);
1092 ok(isNaN(tmp
), "Math.sqrt(-Infinity) is not NaN");
1095 ok(tmp
=== 0, "Math.tan(0) = " + tmp
);
1097 tmp
= Math
.tan(Math
.PI
);
1098 ok(Math
.floor(tmp
*100) === -1, "Math.tan(Math.PI) = " + tmp
);
1100 tmp
= Math
.tan(2, 2);
1101 ok(Math
.floor(tmp
*100) === -219, "Math.tan(2, 2) = " + tmp
);
1103 tmp
= Math
.tan(true);
1104 ok(Math
.floor(tmp
*100) === 155, "Math.tan(true) = " + tmp
);
1106 tmp
= Math
.tan(false);
1107 ok(tmp
=== 0, "Math.tan(false) = " + tmp
);
1110 ok(isNaN(tmp
), "Math.tan() is not NaN");
1112 tmp
= Math
.tan(NaN
);
1113 ok(isNaN(tmp
), "Math.tan(NaN) is not NaN");
1115 tmp
= Math
.tan(Infinity
);
1116 ok(isNaN(tmp
), "Math.tan(Infinity) is not NaN");
1118 tmp
= Math
.tan(-Infinity
);
1119 ok(isNaN(tmp
), "Math.tan(-Infinity) is not NaN");
1121 var func = function (a
) {
1125 ok(func
.toString() === "function (a) {\n var a = 1;\n if(a) return;\n }",
1126 "func.toString() = " + func
.toString());
1127 ok("" + func
=== "function (a) {\n var a = 1;\n if(a) return;\n }",
1128 "'' + func.toString() = " + func
);
1130 ok(func
.valueOf
=== Object
.prototype.valueOf
, "func.valueOf !== Object.prototype.valueOf");
1131 ok(func
=== func
.valueOf(), "func !== func.valueOf()");
1133 function testFuncToString(x
,y
) {
1136 ok(testFuncToString
.toString() === "function testFuncToString(x,y) {\n return x+y;\n}",
1137 "testFuncToString.toString() = " + testFuncToString
.toString());
1138 ok("" + testFuncToString
=== "function testFuncToString(x,y) {\n return x+y;\n}",
1139 "'' + testFuncToString = " + testFuncToString
);
1143 function callTest(argc
) {
1144 ok(this === tmp
, "this !== tmp\n");
1145 ok(arguments
.length
=== argc
+1, "arguments.length = " + arguments
.length
+ " expected " + (argc
+1));
1146 for(var i
=1; i
<= argc
; i
++)
1147 ok(arguments
[i
] === i
, "arguments[i] = " + arguments
[i
]);
1150 callTest
.call(tmp
, 1, 1);
1151 callTest
.call(tmp
, 2, 1, 2);
1153 callTest
.apply(tmp
, [1, 1]);
1154 callTest
.apply(tmp
, [2, 1, 2]);
1155 (function () { callTest
.apply(tmp
, arguments
); })(2,1,2);
1157 function callTest2() {
1158 ok(this === tmp
, "this !== tmp\n");
1159 ok(arguments
.length
=== 0, "callTest2: arguments.length = " + arguments
.length
+ " expected 0");
1162 callTest2
.call(tmp
);
1163 callTest2
.apply(tmp
, []);
1164 callTest2
.apply(tmp
);
1165 (function () { callTest2
.apply(tmp
, arguments
); })();
1167 function callTest3() {
1168 ok(arguments
.length
=== 0, "arguments.length = " + arguments
.length
+ " expected 0");
1173 tmp
= Number
.prototype.toString
.call(3);
1174 ok(tmp
=== "3", "Number.prototype.toString.call(3) = " + tmp
);
1176 var date
= new Date();
1178 date
= new Date(100);
1179 ok(date
.getTime() === 100, "date.getTime() = " + date
.getTime());
1180 ok(Date
.prototype.getTime() === 0, "date.prototype.getTime() = " + Date
.prototype.getTime());
1181 date
= new Date(8.64e15
);
1182 ok(date
.getTime() === 8.64e15
, "date.getTime() = " + date
.getTime());
1183 date
= new Date(8.64e15
+1);
1184 ok(isNaN(0+date
.getTime()), "date.getTime() is not NaN");
1185 date
= new Date(Infinity
);
1186 ok(isNaN(0+date
.getTime()), "date.getTime() is not NaN");
1187 date
= new Date("3 July 2009 22:28:00 UTC+0100");
1188 ok(date
.getTime() === 1246656480000, "date.getTime() = " + date
.getTime());
1189 date
= new Date(1984, 11, 29, 13, 51, 24, 120);
1190 ok(date
.getFullYear() === 1984, "date.getFullYear() = " + date
.getFullYear());
1191 ok(date
.getMonth() === 11, "date.getMonth() = " + date
.getMonth());
1192 ok(date
.getDate() === 29, "date.getDate() = " + date
.getDate());
1193 ok(date
.getHours() === 13, "date.getHours() = " + date
.getHours());
1194 ok(date
.getMinutes() === 51, "date.getMinutes() = " + date
.getMinutes());
1195 ok(date
.getSeconds() === 24, "date.getSeconds() = " + date
.getSeconds());
1196 ok(date
.getMilliseconds() === 120, "date.getMilliseconds() = " + date
.getMilliseconds());
1197 date
= new Date(731, -32, 40, -1, 70, 65, -13);
1198 ok(date
.getFullYear() === 728, "date.getFullYear() = " + date
.getFullYear());
1199 ok(date
.getMonth() === 5, "date.getMonth() = " + date
.getMonth());
1200 ok(date
.getDate() === 9, "date.getDate() = " + date
.getDate());
1201 ok(date
.getHours() === 0, "date.getHours() = " + date
.getHours());
1202 ok(date
.getMinutes() === 11, "date.getMinutes() = " + date
.getMinutes());
1203 ok(date
.getSeconds() === 4, "date.getSeconds() = " + date
.getSeconds());
1204 ok(date
.getMilliseconds() === 987, "date.getMilliseconds() = " + date
.getMilliseconds());
1206 ok(date
.setTime(123) === 123, "date.setTime(123) !== 123");
1207 ok(date
.setTime("123", NaN
) === 123, "date.setTime(\"123\") !== 123");
1208 ok(isNaN(date
.setTime(NaN
)), "date.setTime(NaN) is not NaN");
1210 ok(date
.setTime(0) === date
.getTime(), "date.setTime(0) !== date.getTime()");
1211 ok(date
.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date
.getUTCFullYear());
1212 ok(date
.getUTCMonth() === 0, "date.getUTCMonth() = " + date
.getUTCMonth());
1213 ok(date
.getUTCDate() === 1, "date.getUTCDate() = " + date
.getUTCDate());
1214 ok(date
.getUTCDay() === 4, "date.getUTCDay() = " + date
.getUTCDay());
1215 ok(date
.getUTCHours() === 0, "date.getUTCHours() = " + date
.getUTCHours());
1216 ok(date
.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date
.getUTCMinutes());
1217 ok(date
.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date
.getUTCSeconds());
1218 ok(date
.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date
.getUTCMilliseconds());
1219 date
.setTime(60*24*60*60*1000);
1220 ok(date
.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date
.getUTCFullYear());
1221 ok(date
.getUTCMonth() === 2, "date.getUTCMonth() = " + date
.getUTCMonth());
1222 ok(date
.getUTCDate() === 2, "date.getUTCDate() = " + date
.getUTCDate());
1223 ok(date
.getUTCDay() === 1, "date.getUTCDay() = " + date
.getUTCDay());
1224 ok(date
.getUTCHours() === 0, "date.getUTCHours() = " + date
.getUTCHours());
1225 ok(date
.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date
.getUTCMinutes());
1226 ok(date
.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date
.getUTCSeconds());
1227 ok(date
.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date
.getUTCMilliseconds());
1228 date
.setTime(59*24*60*60*1000 + 4*365*24*60*60*1000 + 60*60*1000 + 2*60*1000 + 2*1000 + 640);
1229 ok(date
.getUTCFullYear() === 1974, "date.getUTCFullYear() = " + date
.getUTCFullYear());
1230 ok(date
.getUTCMonth() === 1, "date.getUTCMonth() = " + date
.getUTCMonth());
1231 ok(date
.getUTCMonth(123) === 1, "date.getUTCMonth() = " + date
.getUTCMonth());
1232 ok(date
.getUTCDate() === 28, "date.getUTCDate() = " + date
.getUTCDate());
1233 ok(date
.getUTCDay() === 4, "date.getUTCDay() = " + date
.getUTCDay());
1234 ok(date
.getUTCHours() === 1, "date.getUTCHours() = " + date
.getUTCHours());
1235 ok(date
.getUTCMinutes() === 2, "date.getUTCMinutes() = " + date
.getUTCMinutes());
1236 ok(date
.getUTCSeconds() === 2, "date.getUTCSeconds() = " + date
.getUTCSeconds());
1237 ok(date
.getUTCMilliseconds() === 640, "date.getUTCMilliseconds() = " + date
.getUTCMilliseconds());
1238 date
.setTime(Infinity
);
1239 ok(isNaN(date
.getUTCFullYear()), "date.getUTCFullYear() is not NaN");
1240 ok(isNaN(date
.getUTCMonth()), "date.getUTCMonth() is not NaN");
1241 ok(isNaN(date
.getUTCDate()), "date.getUTCDate() is not NaN");
1242 ok(isNaN(date
.getUTCDay()), "date.getUTCDay() is not NaN");
1243 ok(isNaN(date
.getUTCHours()), "date.getUTCHours() is not NaN");
1244 ok(isNaN(date
.getUTCMinutes()), "date.getUTCMinutes() is not NaN");
1245 ok(isNaN(date
.getUTCSeconds()), "date.getUTCSeconds() is not NaN");
1246 ok(isNaN(date
.getUTCMilliseconds()), "date.getUTCMilliseconds() is not NaN");
1247 ok(isNaN(date
.setMilliseconds(0)), "date.setMilliseconds() is not NaN");
1250 date
.setUTCMilliseconds(-10, 2);
1251 ok(date
.getUTCMilliseconds() === 990, "date.getUTCMilliseconds() = " + date
.getUTCMilliseconds());
1252 date
.setUTCMilliseconds(10);
1253 ok(date
.getUTCMilliseconds() === 10, "date.getUTCMilliseconds() = " + date
.getUTCMilliseconds());
1254 date
.setUTCSeconds(-10);
1255 ok(date
.getUTCSeconds() === 50, "date.getUTCSeconds() = " + date
.getUTCSeconds());
1256 date
.setUTCMinutes(-10);
1257 ok(date
.getUTCMinutes() === 50, "date.getUTCMinutes() = " + date
.getUTCMinutes());
1258 date
.setUTCHours(-10);
1259 ok(date
.getUTCHours() === 14, "date.getUTCHours() = " + date
.getUTCHours());
1260 date
.setUTCHours(-123);
1261 ok(date
.getTime() === -612549990, "date.getTime() = " + date
.getTime());
1262 date
.setUTCHours(20);
1263 ok(date
.getUTCHours() === 20, "date.getUTCHours() = " + date
.getUTCHours());
1264 date
.setUTCDate(32);
1265 ok(date
.getUTCDate() === 1, "date.getUTCDate() = " + date
.getUTCDate());
1266 date
.setUTCMonth(22, 37);
1267 ok(date
.getTime() === 60987050010, "date.getTime() = " + date
.getTime());
1268 date
.setUTCFullYear(83, 21, 321);
1269 ok(date
.getTime() === -59464984149990, "date.getTime() = " + date
.getTime());
1270 ok(Math
.abs(date
) === 59464984149990, "Math.abs(date) = " + Math
.abs(date
));
1271 ok(getVT(date
+1) === "VT_BSTR", "getVT(date+1) = " + getVT(date
+1));
1273 ok(isNaN(Date
.parse()), "Date.parse() is not NaN");
1274 ok(isNaN(Date
.parse("")), "Date.parse(\"\") is not NaN");
1275 ok(isNaN(Date
.parse("Jan Jan 20 2009")), "Date.parse(\"Jan Jan 20 2009\") is not NaN");
1276 ok(Date
.parse("Jan 20 2009 UTC") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC\") = " + Date
.parse("Jan 20 2009 UTC"));
1277 ok(Date
.parse("Jan 20 2009 GMT") === 1232409600000, "Date.parse(\"Jan 20 2009 GMT\") = " + Date
.parse("Jan 20 2009 GMT"));
1278 ok(Date
.parse("Jan 20 2009 UTC-0") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC-0\") = " + Date
.parse("Jan 20 2009 UTC-0"));
1279 ok(Date
.parse("Jan 20 2009 UTC+0000") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC+0000\") = " + Date
.parse("Jan 20 2009 UTC+0000"));
1280 ok(Date
.parse("Ju 13 79 UTC") === 300672000000, "Date.parse(\"Ju 13 79 UTC\") = " + Date
.parse("Ju 13 79 UTC"));
1281 ok(Date
.parse("12Au91 UTC") === 681955200000, "Date.parse(\"12Au91 UTC\") = " + Date
.parse("12Au91 UTC"));
1282 ok(Date
.parse("7/02/17 UTC") === -1656806400000, "Date.parse(\"7/02/17 UTC\") = " + Date
.parse("7/02/17 UTC"));
1283 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"));
1284 ok(Date
.parse("February 31 UTC, 2000 12:31:17 PM") === 952000277000,
1285 "Date.parse(\"February 31 UTC, 2000 12:31:17 PM\") = " + Date
.parse("February 31 UTC, 2000 12:31:17 PM"));
1286 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 "));
1287 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"));
1289 ok(typeof(Math
.PI
) === "number", "typeof(Math.PI) = " + typeof(Math
.PI
));
1290 ok(Math
.floor(Math
.PI
*100) === 314, "Math.PI = " + Math
.PI
);
1292 ok(Math
.floor(Math
.PI
*100) === 314, "modified Math.PI = " + Math
.PI
);
1294 ok(typeof(Math
.E
) === "number", "typeof(Math.E) = " + typeof(Math
.E
));
1295 ok(Math
.floor(Math
.E
*100) === 271, "Math.E = " + Math
.E
);
1297 ok(Math
.floor(Math
.E
*100) === 271, "modified Math.E = " + Math
.E
);
1299 ok(typeof(Math
.LOG2E
) === "number", "typeof(Math.LOG2E) = " + typeof(Math
.LOG2E
));
1300 ok(Math
.floor(Math
.LOG2E
*100) === 144, "Math.LOG2E = " + Math
.LOG2E
);
1301 Math
.LOG2E
= "test";
1302 ok(Math
.floor(Math
.LOG2E
*100) === 144, "modified Math.LOG2E = " + Math
.LOG2E
);
1304 ok(typeof(Math
.LOG10E
) === "number", "typeof(Math.LOG10E) = " + typeof(Math
.LOG10E
));
1305 ok(Math
.floor(Math
.LOG10E
*100) === 43, "Math.LOG10E = " + Math
.LOG10E
);
1306 Math
.LOG10E
= "test";
1307 ok(Math
.floor(Math
.LOG10E
*100) === 43, "modified Math.LOG10E = " + Math
.LOG10E
);
1309 ok(typeof(Math
.LN2
) === "number", "typeof(Math.LN2) = " + typeof(Math
.LN2
));
1310 ok(Math
.floor(Math
.LN2
*100) === 69, "Math.LN2 = " + Math
.LN2
);
1312 ok(Math
.floor(Math
.LN2
*100) === 69, "modified Math.LN2 = " + Math
.LN2
);
1314 ok(typeof(Math
.LN10
) === "number", "typeof(Math.LN10) = " + typeof(Math
.LN10
));
1315 ok(Math
.floor(Math
.LN10
*100) === 230, "Math.LN10 = " + Math
.LN10
);
1317 ok(Math
.floor(Math
.LN10
*100) === 230, "modified Math.LN10 = " + Math
.LN10
);
1319 ok(typeof(Math
.SQRT2
) === "number", "typeof(Math.SQRT2) = " + typeof(Math
.SQRT2
));
1320 ok(Math
.floor(Math
.SQRT2
*100) === 141, "Math.SQRT2 = " + Math
.SQRT2
);
1321 Math
.SQRT2
= "test";
1322 ok(Math
.floor(Math
.SQRT2
*100) === 141, "modified Math.SQRT2 = " + Math
.SQRT2
);
1324 ok(typeof(Math
.SQRT1_2
) === "number", "typeof(Math.SQRT1_2) = " + typeof(Math
.SQRT1_2
));
1325 ok(Math
.floor(Math
.SQRT1_2
*100) === 70, "Math.SQRT1_2 = " + Math
.SQRT1_2
);
1326 Math
.SQRT1_2
= "test";
1327 ok(Math
.floor(Math
.SQRT1_2
*100) === 70, "modified Math.SQRT1_2 = " + Math
.SQRT1_2
);
1329 var bool
= new Boolean();
1330 ok(bool
.toString() === "false", "bool.toString() = " + bool
.toString());
1331 var bool
= new Boolean("false");
1332 ok(bool
.toString() === "true", "bool.toString() = " + bool
.toString());
1333 ok(bool
.valueOf() === Boolean(1), "bool.valueOf() = " + bool
.valueOf());
1334 ok(bool
.toLocaleString() === bool
.toString(), "bool.toLocaleString() = " + bool
.toLocaleString());
1336 ok(Error
.prototype !== TypeError
.prototype, "Error.prototype === TypeError.prototype");
1337 ok(RangeError
.prototype !== TypeError
.prototype, "RangeError.prototype === TypeError.prototype");
1338 ok(Error
.prototype.toLocaleString
=== Object
.prototype.toLocaleString
,
1339 "Error.prototype.toLocaleString !== Object.prototype.toLocaleString");
1341 ok(err
.valueOf
=== Object
.prototype.valueOf
, "err.valueOf !== Object.prototype.valueOf");
1342 ok(Error
.prototype.name
=== "Error", "Error.prototype.name = " + Error
.prototype.name
);
1343 ok(err
.name
=== "Error", "err.name = " + err
.name
);
1344 EvalError
.prototype.message
= "test";
1345 ok(err
.toString
!== Object
.prototype.toString
, "err.toString === Object.prototype.toString");
1346 ok(err
.toString() === "[object Error]", "err.toString() = " + err
.toString());
1347 err
= new EvalError();
1348 ok(EvalError
.prototype.name
=== "EvalError", "EvalError.prototype.name = " + EvalError
.prototype.name
);
1349 ok(err
.name
=== "EvalError", "err.name = " + err
.name
);
1350 ok(err
.toString
=== Error
.prototype.toString
, "err.toString !== Error.prototype.toString");
1351 ok(err
.message
=== "", "err.message != ''");
1353 ok(err
.message
=== date
, "err.message != date");
1354 ok(err
.toString() === "[object Error]", "err.toString() = " + err
.toString());
1355 ok(err
.toString
!== Object
.prototype.toString
, "err.toString === Object.prototype.toString");
1356 err
= new RangeError();
1357 ok(RangeError
.prototype.name
=== "RangeError", "RangeError.prototype.name = " + RangeError
.prototype.name
);
1358 ok(err
.name
=== "RangeError", "err.name = " + err
.name
);
1359 ok(err
.toString() === "[object Error]", "err.toString() = " + err
.toString());
1360 err
= new ReferenceError();
1361 ok(ReferenceError
.prototype.name
=== "ReferenceError", "ReferenceError.prototype.name = " + ReferenceError
.prototype.name
);
1362 ok(err
.name
=== "ReferenceError", "err.name = " + err
.name
);
1363 ok(err
.toString() === "[object Error]", "err.toString() = " + err
.toString());
1364 err
= new SyntaxError();
1365 ok(SyntaxError
.prototype.name
=== "SyntaxError", "SyntaxError.prototype.name = " + SyntaxError
.prototype.name
);
1366 ok(err
.name
=== "SyntaxError", "err.name = " + err
.name
);
1367 ok(err
.toString() === "[object Error]", "err.toString() = " + err
.toString());
1368 err
= new TypeError();
1369 ok(TypeError
.prototype.name
=== "TypeError", "TypeError.prototype.name = " + TypeError
.prototype.name
);
1370 ok(err
.name
=== "TypeError", "err.name = " + err
.name
);
1371 ok(err
.toString() === "[object Error]", "err.toString() = " + err
.toString());
1372 err
= new URIError();
1373 ok(URIError
.prototype.name
=== "URIError", "URIError.prototype.name = " + URIError
.prototype.name
);
1374 ok(err
.name
=== "URIError", "err.name = " + err
.name
);
1375 ok(err
.toString() === "[object Error]", "err.toString() = " + err
.toString());
1376 err
= new Error("message");
1377 ok(err
.message
=== "message", "err.message !== 'message'");
1378 ok(err
.toString() === "[object Error]", "err.toString() = " + err
.toString());
1379 err
= new Error(123);
1380 ok(err
.number
=== 123, "err.number = " + err
.number
);
1381 err
= new Error(0, "message");
1382 ok(err
.number
=== 0, "err.number = " + err
.number
);
1383 ok(err
.message
=== "message", "err.message = " + err
.message
);
1384 ok(err
.description
=== "message", "err.description = " + err
.description
);
1386 function exception_test(func
, type
, number
) {
1395 ok(ret
=== type
, "Exception test, ret = " + ret
+ ", expected " + type
+". Executed function: " + func
.toString());
1396 ok(num
=== number
, "Exception test, num = " + num
+ ", expected " + number
+ ". Executed function: " + func
.toString());
1398 exception_test(function() {arr
.toString
= Date
.prototype.toString
; arr
.toString();}, "TypeError", -2146823282);
1399 exception_test(function() {Array(-3);}, "RangeError", -2146823259);
1400 exception_test(function() {arr
.toString
= Boolean
.prototype.toString
; arr
.toString();}, "TypeError", -2146823278);
1401 exception_test(function() {date
.setTime();}, "TypeError", -2146827839);
1402 exception_test(function() {arr
.test();}, "TypeError", -2146827850);
1403 exception_test(function() {arr
.toString
= Number
.prototype.toString
; arr
.toString();}, "TypeError", -2146823287);
1404 exception_test(function() {(new Number(3)).toString(1);}, "TypeError", -2146828283);
1405 exception_test(function() {not_existing_variable
.something();}, "TypeError", -2146823279);
1406 exception_test(function() {arr
.toString
= Function
.prototype.toString
; arr
.toString();}, "TypeError", -2146823286);
1407 exception_test(function() {date();}, "TypeError", -2146823286);
1408 exception_test(function() {arr();}, "TypeError", -2146823286);
1409 exception_test(function() {eval("for(i=0;) {}");}, "SyntaxError", -2146827286);
1410 exception_test(function() {eval("function {};");}, "SyntaxError", -2146827283);
1411 exception_test(function() {eval("if");}, "SyntaxError", -2146827283);
1412 exception_test(function() {eval("do i=0; while");}, "SyntaxError", -2146827283);
1413 exception_test(function() {eval("while");}, "SyntaxError", -2146827283);
1414 exception_test(function() {eval("for");}, "SyntaxError", -2146827283);
1415 exception_test(function() {eval("with");}, "SyntaxError", -2146827283);
1416 exception_test(function() {eval("switch");}, "SyntaxError", -2146827283);
1417 exception_test(function() {eval("if(false");}, "SyntaxError", -2146827282);
1418 exception_test(function() {eval("for(i=0; i<10; i++");}, "SyntaxError", -2146827282);
1419 exception_test(function() {eval("while(true");}, "SyntaxError", -2146827282);
1420 exception_test(function() {test = function() {}}, "ReferenceError", -2146823280);
1421 exception_test(function() {eval("for(i=0")}, "SyntaxError", -2146827284);
1422 exception_test(function() {eval("for(i=0;i<10")}, "SyntaxError", -2146827284);
1423 exception_test(function() {eval("while(")}, "SyntaxError", -2146827286);
1424 exception_test(function() {eval("if(")}, "SyntaxError", -2146827286);
1425 exception_test(function() {eval("'unterminated")}, "SyntaxError", -2146827273);
1427 function testObjectInherit(obj
, constr
, ts
, tls
, vo
) {
1428 ok(obj
instanceof Object
, "obj is not instance of Object");
1429 ok(obj
instanceof constr
, "obj is not instance of its constructor");
1431 ok(obj
.hasOwnProperty
=== Object
.prototype.hasOwnProperty
,
1432 "obj.hasOwnProperty !== Object.prototype.hasOwnProprty");
1433 ok(obj
.isPrototypeOf
=== Object
.prototype.isPrototypeOf
,
1434 "obj.isPrototypeOf !== Object.prototype.isPrototypeOf");
1435 ok(obj
.propertyIsEnumerable
=== Object
.prototype.propertyIsEnumerable
,
1436 "obj.propertyIsEnumerable !== Object.prototype.propertyIsEnumerable");
1439 ok(obj
.toString
=== Object
.prototype.toString
,
1440 "obj.toString !== Object.prototype.toString");
1442 ok(obj
.toString
!= Object
.prototype.toString
,
1443 "obj.toString == Object.prototype.toString");
1446 ok(obj
.toLocaleString
=== Object
.prototype.toLocaleString
,
1447 "obj.toLocaleString !== Object.prototype.toLocaleString");
1449 ok(obj
.toLocaleString
!= Object
.prototype.toLocaleString
,
1450 "obj.toLocaleString == Object.prototype.toLocaleString");
1453 ok(obj
.valueOf
=== Object
.prototype.valueOf
,
1454 "obj.valueOf !== Object.prototype.valueOf");
1456 ok(obj
.valueOf
!= Object
.prototype.valueOf
,
1457 "obj.valueOf == Object.prototype.valueOf");
1459 ok(obj
._test
=== "test", "obj.test = " + obj
._test
);
1462 Object
.prototype._test
= "test";
1463 testObjectInherit(new String("test"), String
, false, true, false);
1464 testObjectInherit(/test/g, RegExp
, false, true, true);
1465 testObjectInherit(new Number(1), Number
, false, false, false);
1466 testObjectInherit(new Date(), Date
, false, false, false);
1467 testObjectInherit(new Boolean(true), Boolean
, false, true, false);
1468 testObjectInherit(new Array(), Array
, false, false, true);
1469 testObjectInherit(new Error(), Error
, false, true, true);
1470 testObjectInherit(testObjectInherit
, Function
, false, true, true);
1471 testObjectInherit(Math
, Object
, true, true, true);
1473 (function() { testObjectInherit(arguments
, Object
, true, true, true); })();
1475 function testFunctions(obj
, arr
) {
1478 for(var i
=0; i
<arr
.length
; i
++) {
1479 l
= obj
[arr
[i
][0]].length
;
1480 ok(l
=== arr
[i
][1], arr
[i
][0] + ".length = " + l
);
1484 testFunctions(Boolean
.prototype, [
1489 testFunctions(Number
.prototype, [
1492 ["toExponential", 1],
1493 ["toLocaleString", 0],
1497 testFunctions(String
.prototype, [
1514 ["localeCompare", 1],
1526 ["toLocaleLowerCase", 0],
1527 ["toLocaleUpperCase", 0],
1532 testFunctions(RegExp
.prototype, [
1538 testFunctions(Date
.prototype, [
1543 ["getMilliseconds", 0],
1548 ["getTimezoneOffset", 0],
1551 ["getUTCFullYear", 0],
1553 ["getUTCMilliseconds", 0],
1554 ["getUTCMinutes", 0],
1556 ["getUTCSeconds", 0],
1560 ["setMilliseconds", 1],
1566 ["setUTCFullYear", 3],
1568 ["setUTCMilliseconds", 1],
1569 ["setUTCMinutes", 3],
1571 ["setUTCSeconds", 2],
1572 ["toDateString", 0],
1573 ["toLocaleDateString", 0],
1574 ["toLocaleString", 0],
1575 ["toLocaleTimeString", 0],
1577 ["toTimeString", 0],
1582 testFunctions(Array
.prototype, [
1592 ["toLocaleString", 0],
1597 testFunctions(Error
.prototype, [
1601 testFunctions(Math
, [
1622 testFunctions(Object
.prototype, [
1623 ["hasOwnProperty", 1],
1624 ["isPrototypeOf", 1],
1625 ["propertyIsEnumerable", 1],
1626 ["toLocaleString", 0],
1631 testFunctions(Function
.prototype, [