jscript: Make compare2_values working with NULL BSTR's.
[wine] / dlls / jscript / tests / api.js
1 /*
2  * Copyright 2008 Jacek Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 var tmp, i;
20
21 i = parseInt("0");
22 ok(i === 0, "parseInt('0') = " + i);
23 i = parseInt("123");
24 ok(i === 123, "parseInt('123') = " + i);
25 i = parseInt("-123");
26 ok(i === -123, "parseInt('-123') = " + i);
27 i = parseInt("0xff");
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);
39
40 tmp = encodeURI("abc");
41 ok(tmp === "abc", "encodeURI('abc') = " + tmp);
42 tmp = encodeURI("{abc}");
43 ok(tmp === "%7Babc%7D", "encodeURI('{abc}') = " + tmp);
44 tmp = encodeURI("");
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);
56 tmp = encodeURI();
57 ok(tmp === "undefined", "encodeURI() = " + tmp);
58 tmp = encodeURI("abc", "test");
59 ok(tmp === "abc", "encodeURI('abc') = " + tmp);
60
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());
79
80 ok("".length === 0, "\"\".length = " + "".length);
81 ok(getVT("".length) == "VT_I4", "\"\".length = " + "".length);
82 ok("abc".length === 3, "\"abc\".length = " + "abc".length);
83 ok(String.prototype.length === 0, "String.prototype.length = " + String.prototype.length);
84
85 tmp = "".toString();
86 ok(tmp === "", "''.toString() = " + tmp);
87 tmp = "test".toString();
88 ok(tmp === "test", "''.toString() = " + tmp);
89 tmp = "test".toString(3);
90 ok(tmp === "test", "''.toString(3) = " + tmp);
91
92 tmp = "".valueOf();
93 ok(tmp === "", "''.valueOf() = " + tmp);
94 tmp = "test".valueOf();
95 ok(tmp === "test", "''.valueOf() = " + tmp);
96 tmp = "test".valueOf(3);
97 ok(tmp === "test", "''.valueOf(3) = " + tmp);
98
99 var str = new String("test");
100 ok(str.toString() === "test", "str.toString() = " + str.toString());
101 var str = new String();
102 ok(str.toString() === "", "str.toString() = " + str.toString());
103 var str = new String("test", "abc");
104 ok(str.toString() === "test", "str.toString() = " + str.toString());
105
106 tmp = "value " + str;
107 ok(tmp === "value test", "'value ' + str = " + tmp);
108
109 tmp = String();
110 ok(tmp === "", "String() = " + tmp);
111 tmp = String(false);
112 ok(tmp === "false", "String(false) = " + tmp);
113 tmp = String(null);
114 ok(tmp === "null", "String(null) = " + tmp);
115 tmp = String("test");
116 ok(tmp === "test", "String('test') = " + tmp);
117 tmp = String("test", "abc");
118 ok(tmp === "test", "String('test','abc') = " + tmp);
119
120 tmp = "abc".charAt(0);
121 ok(tmp === "a", "'abc',charAt(0) = " + tmp);
122 tmp = "abc".charAt(1);
123 ok(tmp === "b", "'abc',charAt(1) = " + tmp);
124 tmp = "abc".charAt(2);
125 ok(tmp === "c", "'abc',charAt(2) = " + tmp);
126 tmp = "abc".charAt(3);
127 ok(tmp === "", "'abc',charAt(3) = " + tmp);
128 tmp = "abc".charAt(4);
129 ok(tmp === "", "'abc',charAt(4) = " + tmp);
130 tmp = "abc".charAt();
131 ok(tmp === "a", "'abc',charAt() = " + tmp);
132 tmp = "abc".charAt(-1);
133 ok(tmp === "", "'abc',charAt(-1) = " + tmp);
134 tmp = "abc".charAt(0,2);
135 ok(tmp === "a", "'abc',charAt(0.2) = " + tmp);
136
137 tmp = "abc".charCodeAt(0);
138 ok(tmp === 0x61, "'abc'.charCodeAt(0) = " + tmp);
139 tmp = "abc".charCodeAt(1);
140 ok(tmp === 0x62, "'abc'.charCodeAt(1) = " + tmp);
141 tmp = "abc".charCodeAt(2);
142 ok(tmp === 0x63, "'abc'.charCodeAt(2) = " + tmp);
143 tmp = "abc".charCodeAt();
144 ok(tmp === 0x61, "'abc'.charCodeAt() = " + tmp);
145 tmp = "abc".charCodeAt(true);
146 ok(tmp === 0x62, "'abc'.charCodeAt(true) = " + tmp);
147 tmp = "abc".charCodeAt(0,2);
148 ok(tmp === 0x61, "'abc'.charCodeAt(0,2) = " + tmp);
149
150 tmp = "abcd".substring(1,3);
151 ok(tmp === "bc", "'abcd'.substring(1,3) = " + tmp);
152 tmp = "abcd".substring(-1,3);
153 ok(tmp === "abc", "'abcd'.substring(-1,3) = " + tmp);
154 tmp = "abcd".substring(1,6);
155 ok(tmp === "bcd", "'abcd'.substring(1,6) = " + tmp);
156 tmp = "abcd".substring(3,1);
157 ok(tmp === "bc", "'abcd'.substring(3,1) = " + tmp);
158 tmp = "abcd".substring(2,2);
159 ok(tmp === "", "'abcd'.substring(2,2) = " + tmp);
160 tmp = "abcd".substring(true,"3");
161 ok(tmp === "bc", "'abcd'.substring(true,'3') = " + tmp);
162 tmp = "abcd".substring(1,3,2);
163 ok(tmp === "bc", "'abcd'.substring(1,3,2) = " + tmp);
164 tmp = "abcd".substring();
165 ok(tmp === "abcd", "'abcd'.substring() = " + tmp);
166
167 tmp = "abcd".slice(1,3);
168 ok(tmp === "bc", "'abcd'.slice(1,3) = " + tmp);
169 tmp = "abcd".slice(1,-1);
170 ok(tmp === "bc", "'abcd'.slice(1,-1) = " + tmp);
171 tmp = "abcd".slice(-3,3);
172 ok(tmp === "bc", "'abcd'.slice(-3,3) = " + tmp);
173 tmp = "abcd".slice(-6,3);
174 ok(tmp === "abc", "'abcd'.slice(-6,3) = " + tmp);
175 tmp = "abcd".slice(3,1);
176 ok(tmp === "", "'abcd'.slice(3,1) = " + tmp);
177 tmp = "abcd".slice(true,3);
178 ok(tmp === "bc", "'abcd'.slice(true,3) = " + tmp);
179 tmp = "abcd".slice();
180 ok(tmp === "abcd", "'abcd'.slice() = " + tmp);
181 tmp = "abcd".slice(1);
182 ok(tmp === "bcd", "'abcd'.slice(1) = " + tmp);
183
184 tmp = "abc".concat(["d",1],2,false);
185 ok(tmp === "abcd,12false", "concat returned " + tmp);
186 var arr = new Array(2,"a");
187 arr.concat = String.prototype.concat;
188 tmp = arr.concat("d");
189 ok(tmp === "2,ad", "arr.concat = " + tmp);
190
191 m = "a+bcabc".match("a+");
192 ok(typeof(m) === "object", "typeof m is not object");
193 ok(m.length === 1, "m.length is not 1");
194 ok(m["0"] === "a", "m[0] is not \"ab\"");
195
196 r = "- [test] -".replace("[test]", "success");
197 ok(r === "- success -", "r = " + r + " expected '- success -'");
198
199 r = "- [test] -".replace("[test]", "success", "test");
200 ok(r === "- success -", "r = " + r + " expected '- success -'");
201
202 r = "test".replace();
203 ok(r === "test", "r = " + r + " expected 'test'");
204
205 function replaceFunc3(m, off, str) {
206     ok(arguments.length === 3, "arguments.length = " + arguments.length);
207     ok(m === "[test]", "m = " + m + " expected [test1]");
208     ok(off === 1, "off = " + off + " expected 0");
209     ok(str === "-[test]-", "str = " + arguments[3]);
210     return "ret";
211 }
212
213 r = "-[test]-".replace("[test]", replaceFunc3);
214 ok(r === "-ret-", "r = " + r + " expected '-ret-'");
215
216 r = "-[test]-".replace("[test]", replaceFunc3, "test");
217 ok(r === "-ret-", "r = " + r + " expected '-ret-'");
218
219 r = "1,2,3".split(",");
220 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
221 ok(r.length === 3, "r.length = " + r.length);
222 ok(r[0] === "1", "r[0] = " + r[0]);
223 ok(r[1] === "2", "r[1] = " + r[1]);
224 ok(r[2] === "3", "r[2] = " + r[2]);
225
226
227 r = "1,2,3".split(",*");
228 ok(r.length === 1, "r.length = " + r.length);
229 ok(r[0] === "1,2,3", "r[0] = " + r[0]);
230
231 r = "123".split("");
232 ok(r.length === 3, "r.length = " + r.length);
233 ok(r[0] === "1", "r[0] = " + r[0]);
234 ok(r[1] === "2", "r[1] = " + r[1]);
235 ok(r[2] === "3", "r[2] = " + r[2]);
236
237 r = "123".split(2);
238 ok(r.length === 2, "r.length = " + r.length);
239 ok(r[0] === "1", "r[0] = " + r[0]);
240 ok(r[1] === "3", "r[1] = " + r[1]);
241
242 r = "1,2,".split(",");
243 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
244 ok(r.length === 3, "r.length = " + r.length);
245 ok(r[0] === "1", "r[0] = " + r[0]);
246 ok(r[1] === "2", "r[1] = " + r[1]);
247 ok(r[2] === "", "r[2] = " + r[2]);
248
249 tmp = "abcd".indexOf("bc",0);
250 ok(tmp === 1, "indexOf = " + tmp);
251 tmp = "abcd".indexOf("bc",1);
252 ok(tmp === 1, "indexOf = " + tmp);
253 tmp = "abcd".indexOf("bc");
254 ok(tmp === 1, "indexOf = " + tmp);
255 tmp = "abcd".indexOf("ac");
256 ok(tmp === -1, "indexOf = " + tmp);
257 tmp = "abcd".indexOf("bc",2);
258 ok(tmp === -1, "indexOf = " + tmp);
259 tmp = "abcd".indexOf("a",0);
260 ok(tmp === 0, "indexOf = " + tmp);
261 tmp = "abcd".indexOf("bc",0,"test");
262 ok(tmp === 1, "indexOf = " + tmp);
263 tmp = "abcd".indexOf();
264 ok(tmp == -1, "indexOf = " + tmp);
265
266 tmp = "".toLowerCase();
267 ok(tmp === "", "''.toLowerCase() = " + tmp);
268 tmp = "test".toLowerCase();
269 ok(tmp === "test", "''.toLowerCase() = " + tmp);
270 tmp = "test".toLowerCase(3);
271 ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
272 tmp = "tEsT".toLowerCase();
273 ok(tmp === "test", "''.toLowerCase() = " + tmp);
274 tmp = "tEsT".toLowerCase(3);
275 ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
276
277 tmp = "".toUpperCase();
278 ok(tmp === "", "''.toUpperCase() = " + tmp);
279 tmp = "TEST".toUpperCase();
280 ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
281 tmp = "TEST".toUpperCase(3);
282 ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
283 tmp = "tEsT".toUpperCase();
284 ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
285 tmp = "tEsT".toUpperCase(3);
286 ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
287
288 tmp = "".anchor();
289 ok(tmp === "<A NAME=\"undefined\"></A>", "''.anchor() = " + tmp);
290 tmp = "".anchor(3);
291 ok(tmp === "<A NAME=\"3\"></A>", "''.anchor(3) = " + tmp);
292 tmp = "".anchor("red");
293 ok(tmp === "<A NAME=\"red\"></A>", "''.anchor('red') = " + tmp);
294 tmp = "test".anchor();
295 ok(tmp === "<A NAME=\"undefined\">test</A>", "'test'.anchor() = " + tmp);
296 tmp = "test".anchor(3);
297 ok(tmp === "<A NAME=\"3\">test</A>", "'test'.anchor(3) = " + tmp);
298 tmp = "test".anchor("green");
299 ok(tmp === "<A NAME=\"green\">test</A>", "'test'.anchor('green') = " + tmp);
300
301 tmp = "".big();
302 ok(tmp === "<BIG></BIG>", "''.big() = " + tmp);
303 tmp = "".big(3);
304 ok(tmp === "<BIG></BIG>", "''.big(3) = " + tmp);
305 tmp = "test".big();
306 ok(tmp === "<BIG>test</BIG>", "'test'.big() = " + tmp);
307 tmp = "test".big(3);
308 ok(tmp === "<BIG>test</BIG>", "'test'.big(3) = " + tmp);
309
310 tmp = "".blink();
311 ok(tmp === "<BLINK></BLINK>", "''.blink() = " + tmp);
312 tmp = "".blink(3);
313 ok(tmp === "<BLINK></BLINK>", "''.blink(3) = " + tmp);
314 tmp = "test".blink();
315 ok(tmp === "<BLINK>test</BLINK>", "'test'.blink() = " + tmp);
316 tmp = "test".blink(3);
317 ok(tmp === "<BLINK>test</BLINK>", "'test'.blink(3) = " + tmp);
318
319 tmp = "".bold();
320 ok(tmp === "<B></B>", "''.bold() = " + tmp);
321 tmp = "".bold(3);
322 ok(tmp === "<B></B>", "''.bold(3) = " + tmp);
323 tmp = "test".bold();
324 ok(tmp === "<B>test</B>", "'test'.bold() = " + tmp);
325 tmp = "test".bold(3);
326 ok(tmp === "<B>test</B>", "'test'.bold(3) = " + tmp);
327
328 tmp = "".fixed();
329 ok(tmp === "<TT></TT>", "''.fixed() = " + tmp);
330 tmp = "".fixed(3);
331 ok(tmp === "<TT></TT>", "''.fixed(3) = " + tmp);
332 tmp = "test".fixed();
333 ok(tmp === "<TT>test</TT>", "'test'.fixed() = " + tmp);
334 tmp = "test".fixed(3);
335 ok(tmp === "<TT>test</TT>", "'test'.fixed(3) = " + tmp);
336
337 tmp = "".fontcolor();
338 ok(tmp === "<FONT COLOR=\"undefined\"></FONT>", "''.fontcolor() = " + tmp);
339 tmp = "".fontcolor(3);
340 ok(tmp === "<FONT COLOR=\"3\"></FONT>", "''.fontcolor(3) = " + tmp);
341 tmp = "".fontcolor("red");
342 ok(tmp === "<FONT COLOR=\"red\"></FONT>", "''.fontcolor('red') = " + tmp);
343 tmp = "test".fontcolor();
344 ok(tmp === "<FONT COLOR=\"undefined\">test</FONT>", "'test'.fontcolor() = " + tmp);
345 tmp = "test".fontcolor(3);
346 ok(tmp === "<FONT COLOR=\"3\">test</FONT>", "'test'.fontcolor(3) = " + tmp);
347 tmp = "test".fontcolor("green");
348 ok(tmp === "<FONT COLOR=\"green\">test</FONT>", "'test'.fontcolor('green') = " + tmp);
349
350 tmp = "".fontsize();
351 ok(tmp === "<FONT SIZE=\"undefined\"></FONT>", "''.fontsize() = " + tmp);
352 tmp = "".fontsize(3);
353 ok(tmp === "<FONT SIZE=\"3\"></FONT>", "''.fontsize(3) = " + tmp);
354 tmp = "".fontsize("red");
355 ok(tmp === "<FONT SIZE=\"red\"></FONT>", "''.fontsize('red') = " + tmp);
356 tmp = "test".fontsize();
357 ok(tmp === "<FONT SIZE=\"undefined\">test</FONT>", "'test'.fontsize() = " + tmp);
358 tmp = "test".fontsize(3);
359 ok(tmp === "<FONT SIZE=\"3\">test</FONT>", "'test'.fontsize(3) = " + tmp);
360 tmp = "test".fontsize("green");
361 ok(tmp === "<FONT SIZE=\"green\">test</FONT>", "'test'.fontsize('green') = " + tmp);
362
363 tmp = ("".fontcolor()).fontsize();
364 ok(tmp === "<FONT SIZE=\"undefined\"><FONT COLOR=\"undefined\"></FONT></FONT>", "(''.fontcolor()).fontsize() = " + tmp);
365
366 tmp = "".italics();
367 ok(tmp === "<I></I>", "''.italics() = " + tmp);
368 tmp = "".italics(3);
369 ok(tmp === "<I></I>", "''.italics(3) = " + tmp);
370 tmp = "test".italics();
371 ok(tmp === "<I>test</I>", "'test'.italics() = " + tmp);
372 tmp = "test".italics(3);
373 ok(tmp === "<I>test</I>", "'test'.italics(3) = " + tmp);
374
375 tmp = "".link();
376 ok(tmp === "<A HREF=\"undefined\"></A>", "''.link() = " + tmp);
377 tmp = "".link(3);
378 ok(tmp === "<A HREF=\"3\"></A>", "''.link(3) = " + tmp);
379 tmp = "".link("red");
380 ok(tmp === "<A HREF=\"red\"></A>", "''.link('red') = " + tmp);
381 tmp = "test".link();
382 ok(tmp === "<A HREF=\"undefined\">test</A>", "'test'.link() = " + tmp);
383 tmp = "test".link(3);
384 ok(tmp === "<A HREF=\"3\">test</A>", "'test'.link(3) = " + tmp);
385 tmp = "test".link("green");
386 ok(tmp === "<A HREF=\"green\">test</A>", "'test'.link('green') = " + tmp);
387
388 tmp = "".small();
389 ok(tmp === "<SMALL></SMALL>", "''.small() = " + tmp);
390 tmp = "".small(3);
391 ok(tmp === "<SMALL></SMALL>", "''.small(3) = " + tmp);
392 tmp = "test".small();
393 ok(tmp === "<SMALL>test</SMALL>", "'test'.small() = " + tmp);
394 tmp = "test".small(3);
395 ok(tmp === "<SMALL>test</SMALL>", "'test'.small(3) = " + tmp);
396
397 tmp = "".strike();
398 ok(tmp === "<STRIKE></STRIKE>", "''.strike() = " + tmp);
399 tmp = "".strike(3);
400 ok(tmp === "<STRIKE></STRIKE>", "''.strike(3) = " + tmp);
401 tmp = "test".strike();
402 ok(tmp === "<STRIKE>test</STRIKE>", "'test'.strike() = " + tmp);
403 tmp = "test".strike(3);
404 ok(tmp === "<STRIKE>test</STRIKE>", "'test'.strike(3) = " + tmp);
405
406 tmp = "".sub();
407 ok(tmp === "<SUB></SUB>", "''.sub() = " + tmp);
408 tmp = "".sub(3);
409 ok(tmp === "<SUB></SUB>", "''.sub(3) = " + tmp);
410 tmp = "test".sub();
411 ok(tmp === "<SUB>test</SUB>", "'test'.sub() = " + tmp);
412 tmp = "test".sub(3);
413 ok(tmp === "<SUB>test</SUB>", "'test'.sub(3) = " + tmp);
414
415 tmp = "".sup();
416 ok(tmp === "<SUP></SUP>", "''.sup() = " + tmp);
417 tmp = "".sup(3);
418 ok(tmp === "<SUP></SUP>", "''.sup(3) = " + tmp);
419 tmp = "test".sup();
420 ok(tmp === "<SUP>test</SUP>", "'test'.sup() = " + tmp);
421 tmp = "test".sup(3);
422 ok(tmp === "<SUP>test</SUP>", "'test'.sup(3) = " + tmp);
423
424 ok(String.fromCharCode() === "", "String.fromCharCode() = " + String.fromCharCode());
425 ok(String.fromCharCode(65,"66",67) === "ABC", "String.fromCharCode(65,'66',67) = " + String.fromCharCode(65,"66",67));
426 ok(String.fromCharCode(1024*64+65, -1024*64+65) === "AA",
427         "String.fromCharCode(1024*64+65, -1024*64+65) = " + String.fromCharCode(1024*64+65, -1024*64+65));
428 ok(String.fromCharCode(65, NaN, undefined).length === 3,
429         "String.fromCharCode(65, NaN, undefined).length = " + String.fromCharCode(65, NaN, undefined).length);
430
431 var arr = new Array();
432 ok(typeof(arr) === "object", "arr () is not object");
433 ok((arr.length === 0), "arr.length is not 0");
434 ok(arr["0"] === undefined, "arr[0] is not undefined");
435
436 var arr = new Array(1, 2, "test");
437 ok(typeof(arr) === "object", "arr (1,2,test) is not object");
438 ok((arr.length === 3), "arr.length is not 3");
439 ok(arr["0"] === 1, "arr[0] is not 1");
440 ok(arr["1"] === 2, "arr[1] is not 2");
441 ok(arr["2"] === "test", "arr[2] is not \"test\"");
442
443 arr["7"] = true;
444 ok((arr.length === 8), "arr.length is not 8");
445
446 tmp = "" + [];
447 ok(tmp === "", "'' + [] = " + tmp);
448 tmp = "" + [1,true];
449 ok(tmp === "1,true", "'' + [1,true] = " + tmp);
450
451 var arr = new Array(6);
452 ok(typeof(arr) === "object", "arr (6) is not object");
453 ok((arr.length === 6), "arr.length is not 6");
454 ok(arr["0"] === undefined, "arr[0] is not undefined");
455
456 ok(arr.push() === 6, "arr.push() !== 6");
457 ok(arr.push(1) === 7, "arr.push(1) !== 7");
458 ok(arr[6] === 1, "arr[6] != 1");
459 ok(arr.length === 7, "arr.length != 10");
460 ok(arr.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10");
461 ok(arr[8] === "b", "arr[8] != 'b'");
462 ok(arr.length === 10, "arr.length != 10");
463
464 arr = [3,4,5];
465 tmp = arr.pop();
466 ok(arr.length === 2, "arr.length = " + arr.length);
467 ok(tmp === 5, "pop() = " + tmp);
468 tmp = arr.pop(2);
469 ok(arr.length === 1, "arr.length = " + arr.length);
470 ok(tmp === 4, "pop() = " + tmp);
471 tmp = arr.pop();
472 ok(arr.length === 0, "arr.length = " + arr.length);
473 ok(tmp === 3, "pop() = " + tmp);
474 for(tmp in arr)
475     ok(false, "not deleted " + tmp);
476 tmp = arr.pop();
477 ok(arr.length === 0, "arr.length = " + arr.length);
478 ok(tmp === undefined, "tmp = " + tmp);
479 arr = [,,,,,];
480 tmp = arr.pop();
481 ok(arr.length === 5, "arr.length = " + arr.length);
482 ok(tmp === undefined, "tmp = " + tmp);
483
484 arr = [1,2,null,false,undefined,,"a"];
485
486 tmp = arr.join();
487 ok(tmp === "1,2,,false,,,a", "arr.join() = " + tmp);
488 tmp = arr.join(";");
489 ok(tmp === "1;2;;false;;;a", "arr.join(';') = " + tmp);
490 tmp = arr.join(";","test");
491 ok(tmp === "1;2;;false;;;a", "arr.join(';') = " + tmp);
492 tmp = arr.join("");
493 ok(tmp === "12falsea", "arr.join('') = " + tmp);
494
495 tmp = arr.toString();
496 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
497 tmp = arr.toString("test");
498 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
499
500 arr = [5,true,2,-1,3,false,"2.5"];
501 tmp = arr.sort(function(x,y) { return y-x; });
502 ok(tmp === arr, "tmp !== arr");
503 tmp = [5,3,"2.5",2,true,false,-1];
504 for(var i=0; i < arr.length; i++)
505     ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
506
507 arr = [5,false,2,0,"abc",3,"a",-1];
508 tmp = arr.sort();
509 ok(tmp === arr, "tmp !== arr");
510 tmp = [-1,0,2,3,5,"a","abc",false];
511 for(var i=0; i < arr.length; i++)
512     ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
513
514 arr = ["a", "b", "ab"];
515 tmp = ["a", "ab", "b"];
516 ok(arr.sort() === arr, "arr.sort() !== arr");
517 for(var i=0; i < arr.length; i++)
518     ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
519
520 arr = ["1", "2", "3"];
521 arr.length = 1;
522 ok(arr.length === 1, "arr.length = " + arr.length);
523 arr.length = 3;
524 ok(arr.length === 3, "arr.length = " + arr.length);
525 ok(arr.toString() === "1,,", "arr.toString() = " + arr.toString());
526
527 arr = Array("a","b","c");
528 ok(arr.toString() === "a,b,c", "arr.toString() = " + arr.toString());
529
530 ok(arr.valueOf === Object.prototype.valueOf, "arr.valueOf !== Object.prototype.valueOf");
531 ok(arr === arr.valueOf(), "arr !== arr.valueOf");
532
533 var num = new Number(6);
534 arr = [0,1,2];
535 tmp = arr.concat(3, [4,5], num);
536 ok(tmp !== arr, "tmp === arr");
537 for(var i=0; i<6; i++)
538     ok(tmp[i] === i, "tmp[" + i + "] = " + tmp[i]);
539 ok(tmp[6] === num, "tmp[6] !== num");
540 ok(tmp.length === 7, "tmp.length = " + tmp.length);
541
542 arr = [].concat();
543 ok(arr.length === 0, "arr.length = " + arr.length);
544
545 arr = [1,];
546 tmp = arr.concat([2]);
547 ok(tmp.length === 3, "tmp.length = " + tmp.length);
548 ok(tmp[1] === undefined, "tmp[1] = " + tmp[1]);
549
550 arr = [1,false,'a',null,undefined,'a'];
551 ok(arr.slice(0,6).toString() === "1,false,a,,,a", "arr.slice(0,6).toString() = " + arr.slice(0,6));
552 ok(arr.slice(0,6).length === 6, "arr.slice(0,6).length = " + arr.slice(0,6).length);
553 ok(arr.slice().toString() === "1,false,a,,,a", "arr.slice().toString() = " + arr.slice());
554 ok(arr.slice("abc").toString() === "1,false,a,,,a", "arr.slice(\"abc\").toString() = " + arr.slice("abc"));
555 ok(arr.slice(3,8).toString() === ",,a", "arr.slice(3,8).toString() = " + arr.slice(3,8));
556 ok(arr.slice(3,8).length === 3, "arr.slice(3,8).length = " + arr.slice(3,8).length);
557 ok(arr.slice(1).toString() === "false,a,,,a", "arr.slice(1).toString() = " + arr.slice(1));
558 ok(arr.slice(-2).toString() === ",a", "arr.slice(-2).toString() = " + arr.slice(-2));
559 ok(arr.slice(3,1).toString() === "", "arr.slice(3,1).toString() = " + arr.slice(3,1));
560 tmp = arr.slice(0,6);
561 for(var i=0; i < arr.length; i++)
562     ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
563 arr[12] = 2;
564 ok(arr.slice(5).toString() === "a,,,,,,,2", "arr.slice(5).toString() = " + arr.slice(5).toString());
565 ok(arr.slice(5).length === 8, "arr.slice(5).length = " + arr.slice(5).length);
566
567 var num = new Number(2);
568 ok(num.toString() === "2", "num(2).toString !== 2");
569 var num = new Number();
570 ok(num.toString() === "0", "num().toString !== 0");
571
572 ok(Number() === 0, "Number() = " + Number());
573 ok(Number(false) === 0, "Number(false) = " + Number(false));
574 ok(Number("43") === 43, "Number('43') = " + Number("43"));
575
576 tmp = (new Number(1)).valueOf();
577 ok(tmp === 1, "(new Number(1)).valueOf = " + tmp);
578 tmp = (new Number(1,2)).valueOf();
579 ok(tmp === 1, "(new Number(1,2)).valueOf = " + tmp);
580 tmp = (new Number()).valueOf();
581 ok(tmp === 0, "(new Number()).valueOf = " + tmp);
582 tmp = Number.prototype.valueOf();
583 ok(tmp === 0, "Number.prototype.valueOf = " + tmp);
584
585 function equals(val, base) {
586     var i;
587     var num = 0;
588     var str = val.toString(base);
589
590     for(i=0; i<str.length; i++) {
591         if(str.substring(i, i+1) == '(') break;
592         if(str.substring(i, i+1) == '.') break;
593         num = num*base + parseInt(str.substring(i, i+1));
594     }
595
596     if(str.substring(i, i+1) == '.') {
597         var mult = base;
598         for(i++; i<str.length; i++) {
599             if(str.substring(i, i+1) == '(') break;
600             num += parseInt(str.substring(i, i+1))/mult;
601             mult *= base;
602         }
603     }
604
605     if(str.substring(i, i+1) == '(') {
606         exp = parseInt(str.substring(i+2));
607         num *= Math.pow(base, exp);
608     }
609
610     ok(num>val-val/1000 && num<val+val/1000, "equals: num = " + num);
611 }
612
613 ok((10).toString(11) === "a", "(10).toString(11) = " + (10).toString(11));
614 ok((213213433).toString(17) === "8e2ddcb", "(213213433).toString(17) = " + (213213433).toString(17));
615 ok((-3254343).toString(33) === "-2oicf", "(-3254343).toString(33) = " + (-3254343).toString(33));
616 ok((NaN).toString(12) === "NaN", "(NaN).toString(11) = " + (NaN).toString(11));
617 ok((Infinity).toString(13) === "Infinity", "(Infinity).toString(11) = " + (Infinity).toString(11));
618 for(i=2; i<10; i++) {
619     equals(1.123, i);
620     equals(2305843009200000000, i);
621     equals(5.123, i);
622     equals(21711, i);
623     equals(1024*1024*1024*1024*1024*1024*1.9999, i);
624     equals(748382, i);
625     equals(0.6, i);
626     equals(4.65661287308e-10, i);
627     ok((0).toString(i) === "0", "(0).toString("+i+") = " + (0).toString(i));
628 }
629
630 tmp = Math.min(1);
631 ok(tmp === 1, "Math.min(1) = " + tmp);
632
633 tmp = Math.min(1, false);
634 ok(tmp === 0, "Math.min(1, false) = " + tmp);
635
636 tmp = Math.min();
637 ok(tmp === Infinity, "Math.min() = " + tmp);
638
639 tmp = Math.min(1, NaN, -Infinity, false);
640 ok(isNaN(tmp), "Math.min(1, NaN, -Infinity, false) is not NaN");
641
642 tmp = Math.min(1, false, true, null, -3);
643 ok(tmp === -3, "Math.min(1, false, true, null, -3) = " + tmp);
644
645 tmp = Math.max(1);
646 ok(tmp === 1, "Math.max(1) = " + tmp);
647
648 tmp = Math.max(true, 0);
649 ok(tmp === 1, "Math.max(true, 0) = " + tmp);
650
651 tmp = Math.max(-2, false, true, null, 1);
652 ok(tmp === 1, "Math.max(-2, false, true, null, 1) = " + tmp);
653
654 tmp = Math.max();
655 ok(tmp === -Infinity, "Math.max() = " + tmp);
656
657 tmp = Math.max(true, NaN, 0);
658 ok(isNaN(tmp), "Math.max(true, NaN, 0) is not NaN");
659
660 tmp = Math.round(0.5);
661 ok(tmp === 1, "Math.round(0.5) = " + tmp);
662
663 tmp = Math.round(-0.5);
664 ok(tmp === 0, "Math.round(-0.5) = " + tmp);
665
666 tmp = Math.round(1.1);
667 ok(tmp === 1, "Math.round(1.1) = " + tmp);
668
669 tmp = Math.round(true);
670 ok(tmp === 1, "Math.round(true) = " + tmp);
671
672 tmp = Math.round(1.1, 3, 4);
673 ok(tmp === 1, "Math.round(1.1, 3, 4) = " + tmp);
674
675 tmp = Math.round();
676 ok(isNaN(tmp), "Math.round() is not NaN");
677
678 tmp = Math.ceil(0.5);
679 ok(tmp === 1, "Math.ceil(0.5) = " + tmp);
680
681 tmp = Math.ceil(-0.5);
682 ok(tmp === 0, "Math.ceil(-0.5) = " + tmp);
683
684 tmp = Math.ceil(1.1);
685 ok(tmp === 2, "Math.round(1.1) = " + tmp);
686
687 tmp = Math.ceil(true);
688 ok(tmp === 1, "Math.ceil(true) = " + tmp);
689
690 tmp = Math.ceil(1.1, 3, 4);
691 ok(tmp === 2, "Math.ceil(1.1, 3, 4) = " + tmp);
692
693 tmp = Math.ceil();
694 ok(isNaN(tmp), "ceil() is not NaN");
695
696 tmp = Math.floor(0.5);
697 ok(tmp === 0, "Math.floor(0.5) = " + tmp);
698
699 tmp = Math.floor(-0.5);
700 ok(tmp === -1, "Math.floor(-0.5) = " + tmp);
701
702 tmp = Math.floor(1.1);
703 ok(tmp === 1, "Math.floor(1.1) = " + tmp);
704
705 tmp = Math.floor(true);
706 ok(tmp === 1, "Math.floor(true) = " + tmp);
707
708 tmp = Math.floor(1.1, 3, 4);
709 ok(tmp === 1, "Math.floor(1.1, 3, 4) = " + tmp);
710
711 tmp = Math.floor();
712 ok(isNaN(tmp), "floor is not NaN");
713
714 tmp = Math.abs(3);
715 ok(tmp === 3, "Math.abs(3) = " + tmp);
716
717 tmp = Math.abs(-3);
718 ok(tmp === 3, "Math.abs(-3) = " + tmp);
719
720 tmp = Math.abs(true);
721 ok(tmp === 1, "Math.abs(true) = " + tmp);
722
723 tmp = Math.abs();
724 ok(isNaN(tmp), "Math.abs() is not NaN");
725
726 tmp = Math.abs(NaN);
727 ok(isNaN(tmp), "Math.abs() is not NaN");
728
729 tmp = Math.abs(-Infinity);
730 ok(tmp === Infinity, "Math.abs(-Infinite) = " + tmp);
731
732 tmp = Math.abs(-3, 2);
733 ok(tmp === 3, "Math.abs(-3, 2) = " + tmp);
734
735 tmp = Math.cos(0);
736 ok(tmp === 1, "Math.cos(0) = " + tmp);
737
738 tmp = Math.cos(Math.PI/2);
739 ok(Math.floor(tmp*100) === 0, "Math.cos(Math.PI/2) = " + tmp);
740
741 tmp = Math.cos(-Math.PI/2);
742 ok(Math.floor(tmp*100) === 0, "Math.cos(-Math.PI/2) = " + tmp);
743
744 tmp = Math.cos(Math.PI/3, 2);
745 ok(Math.floor(tmp*100) === 50, "Math.cos(Math.PI/3, 2) = " + tmp);
746
747 tmp = Math.cos(true);
748 ok(Math.floor(tmp*100) === 54, "Math.cos(true) = " + tmp);
749
750 tmp = Math.cos(false);
751 ok(tmp === 1, "Math.cos(false) = " + tmp);
752
753 tmp = Math.cos();
754 ok(isNaN(tmp), "Math.cos() is not NaN");
755
756 tmp = Math.cos(NaN);
757 ok(isNaN(tmp), "Math.cos(NaN) is not NaN");
758
759 tmp = Math.cos(Infinity);
760 ok(isNaN(tmp), "Math.cos(Infinity) is not NaN");
761
762 tmp = Math.cos(-Infinity);
763 ok(isNaN(tmp), "Math.cos(-Infinity) is not NaN");
764
765 tmp = Math.pow(2, 2);
766 ok(tmp === 4, "Math.pow(2, 2) = " + tmp);
767
768 tmp = Math.pow(4, 0.5);
769 ok(tmp === 2, "Math.pow(2, 2) = " + tmp);
770
771 tmp = Math.pow(2, 2, 3);
772 ok(tmp === 4, "Math.pow(2, 2, 3) = " + tmp);
773
774 tmp = Math.pow(2);
775 ok(isNaN(tmp), "Math.pow(2) is not NaN");
776
777 tmp = Math.pow();
778 ok(isNaN(tmp), "Math.pow() is not NaN");
779
780 tmp = Math.random();
781 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
782 ok(0 <= tmp && tmp <= 1, "Math.random() = " + tmp);
783
784 tmp = Math.random(100);
785 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
786 ok(0 <= tmp && tmp <= 1, "Math.random(100) = " + tmp);
787
788 tmp = Math.acos(0);
789 ok(Math.floor(tmp*100) === 157, "Math.acos(0) = " + tmp);
790
791 tmp = Math.acos(1);
792 ok(Math.floor(tmp*100) === 0, "Math.acos(1) = " + tmp);
793
794 tmp = Math.acos(-1);
795 ok(Math.floor(tmp*100) === 314, "Math.acos(-1) = " + tmp);
796
797 tmp = Math.acos(Math.PI/4, 2);
798 ok(Math.floor(tmp*100) === 66, "Math.acos(Math.PI/4, 2) = " + tmp);
799
800 tmp = Math.acos(true);
801 ok(Math.floor(tmp*100) === 0, "Math.acos(true) = " + tmp);
802
803 tmp = Math.acos(false);
804 ok(Math.floor(tmp*100) === 157, "Math.acos(false) = " + tmp);
805
806 tmp = Math.acos(1.1);
807 ok(isNaN(tmp), "Math.acos(1.1) is not NaN");
808
809 tmp = Math.acos();
810 ok(isNaN(tmp), "Math.acos() is not NaN");
811
812 tmp = Math.acos(NaN);
813 ok(isNaN(tmp), "Math.acos(NaN) is not NaN");
814
815 tmp = Math.acos(Infinity);
816 ok(isNaN(tmp), "Math.acos(Infinity) is not NaN");
817
818 tmp = Math.acos(-Infinity);
819 ok(isNaN(tmp), "Math.acos(-Infinity) is not NaN");
820
821 tmp = Math.asin(0);
822 ok(Math.floor(tmp*100) === 0, "Math.asin(0) = " + tmp);
823
824 tmp = Math.asin(1);
825 ok(Math.floor(tmp*100) === 157, "Math.asin(1) = " + tmp);
826
827 tmp = Math.asin(-1);
828 ok(Math.floor(tmp*100) === -158, "Math.asin(-1) = " + tmp);
829
830 tmp = Math.asin(Math.PI/4, 2);
831 ok(Math.floor(tmp*100) === 90, "Math.asin(Math.PI/4, 2) = " + tmp);
832
833 tmp = Math.asin(true);
834 ok(Math.floor(tmp*100) === 157, "Math.asin(true) = " + tmp);
835
836 tmp = Math.asin(false);
837 ok(Math.floor(tmp*100) === 0, "Math.asin(false) = " + tmp);
838
839 tmp = Math.asin(1.1);
840 ok(isNaN(tmp), "Math.asin(1.1) is not NaN");
841
842 tmp = Math.asin();
843 ok(isNaN(tmp), "Math.asin() is not NaN");
844
845 tmp = Math.asin(NaN);
846 ok(isNaN(tmp), "Math.asin(NaN) is not NaN");
847
848 tmp = Math.asin(Infinity);
849 ok(isNaN(tmp), "Math.asin(Infinity) is not NaN");
850
851 tmp = Math.asin(-Infinity);
852 ok(isNaN(tmp), "Math.asin(-Infinity) is not NaN");
853
854 tmp = Math.atan(0);
855 ok(Math.floor(tmp*100) === 0, "Math.atan(0) = " + tmp);
856
857 tmp = Math.atan(1);
858 ok(Math.floor(tmp*100) === 78, "Math.atan(1) = " + tmp);
859
860 tmp = Math.atan(-1);
861 ok(Math.floor(tmp*100) === -79, "Math.atan(-1) = " + tmp);
862
863 tmp = Math.atan(true);
864 ok(Math.floor(tmp*100) === 78, "Math.atan(true) = " + tmp);
865
866 tmp = Math.atan(false);
867 ok(Math.floor(tmp*100) === 0, "Math.atan(false) = " + tmp);
868
869 tmp = Math.atan();
870 ok(isNaN(tmp), "Math.atan() is not NaN");
871
872 tmp = Math.atan(NaN);
873 ok(isNaN(tmp), "Math.atan(NaN) is not NaN");
874
875 tmp = Math.atan(Infinity);
876 ok(Math.floor(tmp*100) === 157, "Math.atan(Infinity) = " + tmp);
877
878 tmp = Math.atan(-Infinity);
879 ok(Math.floor(tmp*100) === -158, "Math.atan(Infinity) = " + tmp);
880
881 tmp = Math.atan2(0, 0);
882 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 0) = " + tmp);
883
884 tmp = Math.atan2(0, 1);
885 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 1) = " + tmp);
886
887 tmp = Math.atan2(0, Infinity);
888 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, Infinity) = " + tmp);
889
890 tmp = Math.atan2(0, -1);
891 ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -1) = " + tmp);
892
893 tmp = Math.atan2(0, -Infinity);
894 ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -Infinity) = " + tmp);
895
896 tmp = Math.atan2(1, 0);
897 ok(Math.floor(tmp*100) === 157, "Math.atan2(1, 0) = " + tmp);
898
899 tmp = Math.atan2(Infinity, 0);
900 ok(Math.floor(tmp*100) === 157, "Math.atan2(Infinity, 0) = " + tmp);
901
902 tmp = Math.atan2(-1, 0);
903 ok(Math.floor(tmp*100) === -158, "Math.atan2(-1, 0) = " + tmp);
904
905 tmp = Math.atan2(-Infinity, 0);
906 ok(Math.floor(tmp*100) === -158, "Math.atan2(-Infinity, 0) = " + tmp);
907
908 tmp = Math.atan2(1, 1);
909 ok(Math.floor(tmp*100) === 78, "Math.atan2(1, 1) = " + tmp);
910
911 tmp = Math.atan2(-1, -1);
912 ok(Math.floor(tmp*100) === -236, "Math.atan2(-1, -1) = " + tmp);
913
914 tmp = Math.atan2(-1, 1);
915 ok(Math.floor(tmp*100) === -79, "Math.atan2(-1, 1) = " + tmp);
916
917 tmp = Math.atan2(Infinity, Infinity);
918 ok(Math.floor(tmp*100) === 78, "Math.atan2(Infinity, Infinity) = " + tmp);
919
920 tmp = Math.atan2(Infinity, -Infinity, 1);
921 ok(Math.floor(tmp*100) === 235, "Math.atan2(Infinity, -Infinity, 1) = " + tmp);
922
923 tmp = Math.atan2();
924 ok(isNaN(tmp), "Math.atan2() is not NaN");
925
926 tmp = Math.atan2(1);
927 ok(isNaN(tmp), "Math.atan2(1) is not NaN");
928
929 tmp = Math.exp(0);
930 ok(tmp === 1, "Math.exp(0) = " + tmp);
931
932 tmp = Math.exp(1);
933 ok(Math.floor(tmp*100) === 271, "Math.exp(1) = " + tmp);
934
935 tmp = Math.exp(-1);
936 ok(Math.floor(tmp*100) === 36, "Math.exp(-1) = " + tmp);
937
938 tmp = Math.exp(true);
939 ok(Math.floor(tmp*100) === 271, "Math.exp(true) = " + tmp);
940
941 tmp = Math.exp(1, 1);
942 ok(Math.floor(tmp*100) === 271, "Math.exp(1, 1) = " + tmp);
943
944 tmp = Math.exp();
945 ok(isNaN(tmp), "Math.exp() is not NaN");
946
947 tmp = Math.exp(NaN);
948 ok(isNaN(tmp), "Math.exp(NaN) is not NaN");
949
950 tmp = Math.exp(Infinity);
951 ok(tmp === Infinity, "Math.exp(Infinity) = " + tmp);
952
953 tmp = Math.exp(-Infinity);
954 ok(tmp === 0, "Math.exp(-Infinity) = " + tmp);
955
956 tmp = Math.log(1);
957 ok(Math.floor(tmp*100) === 0, "Math.log(1) = " + tmp);
958
959 tmp = Math.log(-1);
960 ok(isNaN(tmp), "Math.log(-1) is not NaN");
961
962 tmp = Math.log(true);
963 ok(Math.floor(tmp*100) === 0, "Math.log(true) = " + tmp);
964
965 tmp = Math.log(1, 1);
966 ok(Math.floor(tmp*100) === 0, "Math.log(1, 1) = " + tmp);
967
968 tmp = Math.log();
969 ok(isNaN(tmp), "Math.log() is not NaN");
970
971 tmp = Math.log(NaN);
972 ok(isNaN(tmp), "Math.log(NaN) is not NaN");
973
974 tmp = Math.log(Infinity);
975 ok(tmp === Infinity, "Math.log(Infinity) = " + tmp);
976
977 tmp = Math.log(-Infinity);
978 ok(isNaN(tmp), "Math.log(-Infinity) is not NaN");
979
980 tmp = Math.sin(0);
981 ok(tmp === 0, "Math.sin(0) = " + tmp);
982
983 tmp = Math.sin(Math.PI/2);
984 ok(tmp === 1, "Math.sin(Math.PI/2) = " + tmp);
985
986 tmp = Math.sin(-Math.PI/2);
987 ok(tmp === -1, "Math.sin(-Math.PI/2) = " + tmp);
988
989 tmp = Math.sin(Math.PI/3, 2);
990 ok(Math.floor(tmp*100) === 86, "Math.sin(Math.PI/3, 2) = " + tmp);
991
992 tmp = Math.sin(true);
993 ok(Math.floor(tmp*100) === 84, "Math.sin(true) = " + tmp);
994
995 tmp = Math.sin(false);
996 ok(tmp === 0, "Math.sin(false) = " + tmp);
997
998 tmp = Math.sin();
999 ok(isNaN(tmp), "Math.sin() is not NaN");
1000
1001 tmp = Math.sin(NaN);
1002 ok(isNaN(tmp), "Math.sin(NaN) is not NaN");
1003
1004 tmp = Math.sin(Infinity);
1005 ok(isNaN(tmp), "Math.sin(Infinity) is not NaN");
1006
1007 tmp = Math.sin(-Infinity);
1008 ok(isNaN(tmp), "Math.sin(-Infinity) is not NaN");
1009
1010 tmp = Math.sqrt(0);
1011 ok(tmp === 0, "Math.sqrt(0) = " + tmp);
1012
1013 tmp = Math.sqrt(4);
1014 ok(tmp === 2, "Math.sqrt(4) = " + tmp);
1015
1016 tmp = Math.sqrt(-1);
1017 ok(isNaN(tmp), "Math.sqrt(-1) is not NaN");
1018
1019 tmp = Math.sqrt(2, 2);
1020 ok(Math.floor(tmp*100) === 141, "Math.sqrt(2, 2) = " + tmp);
1021
1022 tmp = Math.sqrt(true);
1023 ok(tmp === 1, "Math.sqrt(true) = " + tmp);
1024
1025 tmp = Math.sqrt(false);
1026 ok(tmp === 0, "Math.sqrt(false) = " + tmp);
1027
1028 tmp = Math.sqrt();
1029 ok(isNaN(tmp), "Math.sqrt() is not NaN");
1030
1031 tmp = Math.sqrt(NaN);
1032 ok(isNaN(tmp), "Math.sqrt(NaN) is not NaN");
1033
1034 tmp = Math.sqrt(Infinity);
1035 ok(tmp === Infinity, "Math.sqrt(Infinity) = " + tmp);
1036
1037 tmp = Math.sqrt(-Infinity);
1038 ok(isNaN(tmp), "Math.sqrt(-Infinity) is not NaN");
1039
1040 tmp = Math.tan(0);
1041 ok(tmp === 0, "Math.tan(0) = " + tmp);
1042
1043 tmp = Math.tan(Math.PI);
1044 ok(Math.floor(tmp*100) === -1, "Math.tan(Math.PI) = " + tmp);
1045
1046 tmp = Math.tan(2, 2);
1047 ok(Math.floor(tmp*100) === -219, "Math.tan(2, 2) = " + tmp);
1048
1049 tmp = Math.tan(true);
1050 ok(Math.floor(tmp*100) === 155, "Math.tan(true) = " + tmp);
1051
1052 tmp = Math.tan(false);
1053 ok(tmp === 0, "Math.tan(false) = " + tmp);
1054
1055 tmp = Math.tan();
1056 ok(isNaN(tmp), "Math.tan() is not NaN");
1057
1058 tmp = Math.tan(NaN);
1059 ok(isNaN(tmp), "Math.tan(NaN) is not NaN");
1060
1061 tmp = Math.tan(Infinity);
1062 ok(isNaN(tmp), "Math.tan(Infinity) is not NaN");
1063
1064 tmp = Math.tan(-Infinity);
1065 ok(isNaN(tmp), "Math.tan(-Infinity) is not NaN");
1066
1067 var func = function  (a) {
1068         var a = 1;
1069         if(a) return;
1070     };
1071 ok(func.toString() === "function  (a) {\n        var a = 1;\n        if(a) return;\n    }",
1072    "func.toString() = " + func.toString());
1073 ok("" + func === "function  (a) {\n        var a = 1;\n        if(a) return;\n    }",
1074    "'' + func.toString() = " + func);
1075
1076 ok(func.valueOf === Object.prototype.valueOf, "func.valueOf !== Object.prototype.valueOf");
1077 ok(func === func.valueOf(), "func !== func.valueOf()");
1078
1079 function testFuncToString(x,y) {
1080     return x+y;
1081 }
1082 ok(testFuncToString.toString() === "function testFuncToString(x,y) {\n    return x+y;\n}",
1083    "testFuncToString.toString() = " + testFuncToString.toString());
1084 ok("" + testFuncToString === "function testFuncToString(x,y) {\n    return x+y;\n}",
1085    "'' + testFuncToString = " + testFuncToString);
1086
1087 var date = new Date();
1088
1089 date = new Date(100);
1090 ok(date.getTime() === 100, "date.getTime() = " + date.getTime());
1091 ok(Date.prototype.getTime() === 0, "date.prototype.getTime() = " + Date.prototype.getTime());
1092 date = new Date(8.64e15);
1093 ok(date.getTime() === 8.64e15, "date.getTime() = " + date.getTime());
1094 date = new Date(8.64e15+1);
1095 ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
1096 date = new Date(Infinity);
1097 ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
1098 date = new Date("3 July 2009 22:28:00 UTC+0100");
1099 ok(date.getTime() === 1246656480000, "date.getTime() = " + date.getTime());
1100 date = new Date(1984, 11, 29, 13, 51, 24, 120);
1101 ok(date.getFullYear() === 1984, "date.getFullYear() = " + date.getFullYear());
1102 ok(date.getMonth() === 11, "date.getMonth() = " + date.getMonth());
1103 ok(date.getDate() === 29, "date.getDate() = " + date.getDate());
1104 ok(date.getHours() === 13, "date.getHours() = " + date.getHours());
1105 ok(date.getMinutes() === 51, "date.getMinutes() = " + date.getMinutes());
1106 ok(date.getSeconds() === 24, "date.getSeconds() = " + date.getSeconds());
1107 ok(date.getMilliseconds() === 120, "date.getMilliseconds() = " + date.getMilliseconds());
1108 date = new Date(731, -32, 40, -1, 70, 65, -13);
1109 ok(date.getFullYear() === 728, "date.getFullYear() = " + date.getFullYear());
1110 ok(date.getMonth() === 5, "date.getMonth() = " + date.getMonth());
1111 ok(date.getDate() === 9, "date.getDate() = " + date.getDate());
1112 ok(date.getHours() === 0, "date.getHours() = " + date.getHours());
1113 ok(date.getMinutes() === 11, "date.getMinutes() = " + date.getMinutes());
1114 ok(date.getSeconds() === 4, "date.getSeconds() = " + date.getSeconds());
1115 ok(date.getMilliseconds() === 987, "date.getMilliseconds() = " + date.getMilliseconds());
1116
1117 ok(date.setTime(123) === 123, "date.setTime(123) !== 123");
1118 ok(date.setTime("123", NaN) === 123, "date.setTime(\"123\") !== 123");
1119 ok(isNaN(date.setTime(NaN)), "date.setTime(NaN) is not NaN");
1120
1121 ok(date.setTime(0) === date.getTime(), "date.setTime(0) !== date.getTime()");
1122 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
1123 ok(date.getUTCMonth() === 0, "date.getUTCMonth() = " + date.getUTCMonth());
1124 ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
1125 ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
1126 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
1127 ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
1128 ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
1129 ok(date.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1130 date.setTime(60*24*60*60*1000);
1131 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
1132 ok(date.getUTCMonth() === 2, "date.getUTCMonth() = " + date.getUTCMonth());
1133 ok(date.getUTCDate() === 2, "date.getUTCDate() = " + date.getUTCDate());
1134 ok(date.getUTCDay() === 1, "date.getUTCDay() = " + date.getUTCDay());
1135 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
1136 ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
1137 ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
1138 ok(date.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1139 date.setTime(59*24*60*60*1000 + 4*365*24*60*60*1000 + 60*60*1000 + 2*60*1000 + 2*1000 + 640);
1140 ok(date.getUTCFullYear() === 1974, "date.getUTCFullYear() = " + date.getUTCFullYear());
1141 ok(date.getUTCMonth() === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1142 ok(date.getUTCMonth(123) === 1, "date.getUTCMonth() = " + date.getUTCMonth());
1143 ok(date.getUTCDate() === 28, "date.getUTCDate() = " + date.getUTCDate());
1144 ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
1145 ok(date.getUTCHours() === 1, "date.getUTCHours() = " + date.getUTCHours());
1146 ok(date.getUTCMinutes() === 2, "date.getUTCMinutes() = " + date.getUTCMinutes());
1147 ok(date.getUTCSeconds() === 2, "date.getUTCSeconds() = " + date.getUTCSeconds());
1148 ok(date.getUTCMilliseconds() === 640, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1149 date.setTime(Infinity);
1150 ok(isNaN(date.getUTCFullYear()), "date.getUTCFullYear() is not NaN");
1151 ok(isNaN(date.getUTCMonth()), "date.getUTCMonth() is not NaN");
1152 ok(isNaN(date.getUTCDate()), "date.getUTCDate() is not NaN");
1153 ok(isNaN(date.getUTCDay()), "date.getUTCDay() is not NaN");
1154 ok(isNaN(date.getUTCHours()), "date.getUTCHours() is not NaN");
1155 ok(isNaN(date.getUTCMinutes()), "date.getUTCMinutes() is not NaN");
1156 ok(isNaN(date.getUTCSeconds()), "date.getUTCSeconds() is not NaN");
1157 ok(isNaN(date.getUTCMilliseconds()), "date.getUTCMilliseconds() is not NaN");
1158 ok(isNaN(date.setMilliseconds(0)), "date.setMilliseconds() is not NaN");
1159
1160 date.setTime(0);
1161 date.setUTCMilliseconds(-10, 2);
1162 ok(date.getUTCMilliseconds() === 990, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1163 date.setUTCMilliseconds(10);
1164 ok(date.getUTCMilliseconds() === 10, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
1165 date.setUTCSeconds(-10);
1166 ok(date.getUTCSeconds() === 50, "date.getUTCSeconds() = " + date.getUTCSeconds());
1167 date.setUTCMinutes(-10);
1168 ok(date.getUTCMinutes() === 50, "date.getUTCMinutes() = " + date.getUTCMinutes());
1169 date.setUTCHours(-10);
1170 ok(date.getUTCHours() === 14, "date.getUTCHours() = " + date.getUTCHours());
1171 date.setUTCHours(-123);
1172 ok(date.getTime() === -612549990, "date.getTime() = " + date.getTime());
1173 date.setUTCHours(20);
1174 ok(date.getUTCHours() === 20, "date.getUTCHours() = " + date.getUTCHours());
1175 date.setUTCDate(32);
1176 ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
1177 date.setUTCMonth(22, 37);
1178 ok(date.getTime() === 60987050010, "date.getTime() = " + date.getTime());
1179 date.setUTCFullYear(83, 21, 321);
1180 ok(date.getTime() === -59464984149990, "date.getTime() = " + date.getTime());
1181 ok(Math.abs(date) === 59464984149990, "Math.abs(date) = " + Math.abs(date));
1182 ok(getVT(date+1) === "VT_BSTR", "getVT(date+1) = " + getVT(date+1));
1183
1184 ok(isNaN(Date.parse()), "Date.parse() is not NaN");
1185 ok(isNaN(Date.parse("")), "Date.parse(\"\") is not NaN");
1186 ok(isNaN(Date.parse("Jan Jan 20 2009")), "Date.parse(\"Jan Jan 20 2009\") is not NaN");
1187 ok(Date.parse("Jan 20 2009 UTC") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC\") = " + Date.parse("Jan 20 2009 UTC"));
1188 ok(Date.parse("Jan 20 2009 GMT") === 1232409600000, "Date.parse(\"Jan 20 2009 GMT\") = " + Date.parse("Jan 20 2009 GMT"));
1189 ok(Date.parse("Jan 20 2009 UTC-0") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC-0\") = " + Date.parse("Jan 20 2009 UTC-0"));
1190 ok(Date.parse("Jan 20 2009 UTC+0000") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC+0000\") = " + Date.parse("Jan 20 2009 UTC+0000"));
1191 ok(Date.parse("Ju 13 79 UTC") === 300672000000, "Date.parse(\"Ju 13 79 UTC\") = " + Date.parse("Ju 13 79 UTC"));
1192 ok(Date.parse("12Au91 UTC") === 681955200000, "Date.parse(\"12Au91 UTC\") = " + Date.parse("12Au91 UTC"));
1193 ok(Date.parse("7/02/17 UTC") === -1656806400000, "Date.parse(\"7/02/17 UTC\") = " + Date.parse("7/02/17 UTC"));
1194 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"));
1195 ok(Date.parse("February 31   UTC, 2000 12:31:17 PM") === 952000277000,
1196         "Date.parse(\"February 31   UTC, 2000 12:31:17 PM\") = " + Date.parse("February 31   UTC, 2000 12:31:17 PM"));
1197 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 "));
1198 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"));
1199
1200 ok(typeof(Math.PI) === "number", "typeof(Math.PI) = " + typeof(Math.PI));
1201 ok(Math.floor(Math.PI*100) === 314, "Math.PI = " + Math.PI);
1202 Math.PI = "test";
1203 ok(Math.floor(Math.PI*100) === 314, "modified Math.PI = " + Math.PI);
1204
1205 ok(typeof(Math.E) === "number", "typeof(Math.E) = " + typeof(Math.E));
1206 ok(Math.floor(Math.E*100) === 271, "Math.E = " + Math.E);
1207 Math.E = "test";
1208 ok(Math.floor(Math.E*100) === 271, "modified Math.E = " + Math.E);
1209
1210 ok(typeof(Math.LOG2E) === "number", "typeof(Math.LOG2E) = " + typeof(Math.LOG2E));
1211 ok(Math.floor(Math.LOG2E*100) === 144, "Math.LOG2E = " + Math.LOG2E);
1212 Math.LOG2E = "test";
1213 ok(Math.floor(Math.LOG2E*100) === 144, "modified Math.LOG2E = " + Math.LOG2E);
1214
1215 ok(typeof(Math.LOG10E) === "number", "typeof(Math.LOG10E) = " + typeof(Math.LOG10E));
1216 ok(Math.floor(Math.LOG10E*100) === 43, "Math.LOG10E = " + Math.LOG10E);
1217 Math.LOG10E = "test";
1218 ok(Math.floor(Math.LOG10E*100) === 43, "modified Math.LOG10E = " + Math.LOG10E);
1219
1220 ok(typeof(Math.LN2) === "number", "typeof(Math.LN2) = " + typeof(Math.LN2));
1221 ok(Math.floor(Math.LN2*100) === 69, "Math.LN2 = " + Math.LN2);
1222 Math.LN2 = "test";
1223 ok(Math.floor(Math.LN2*100) === 69, "modified Math.LN2 = " + Math.LN2);
1224
1225 ok(typeof(Math.LN10) === "number", "typeof(Math.LN10) = " + typeof(Math.LN10));
1226 ok(Math.floor(Math.LN10*100) === 230, "Math.LN10 = " + Math.LN10);
1227 Math.LN10 = "test";
1228 ok(Math.floor(Math.LN10*100) === 230, "modified Math.LN10 = " + Math.LN10);
1229
1230 ok(typeof(Math.SQRT2) === "number", "typeof(Math.SQRT2) = " + typeof(Math.SQRT2));
1231 ok(Math.floor(Math.SQRT2*100) === 141, "Math.SQRT2 = " + Math.SQRT2);
1232 Math.SQRT2 = "test";
1233 ok(Math.floor(Math.SQRT2*100) === 141, "modified Math.SQRT2 = " + Math.SQRT2);
1234
1235 ok(typeof(Math.SQRT1_2) === "number", "typeof(Math.SQRT1_2) = " + typeof(Math.SQRT1_2));
1236 ok(Math.floor(Math.SQRT1_2*100) === 70, "Math.SQRT1_2 = " + Math.SQRT1_2);
1237 Math.SQRT1_2 = "test";
1238 ok(Math.floor(Math.SQRT1_2*100) === 70, "modified Math.SQRT1_2 = " + Math.SQRT1_2);
1239
1240 var bool = new Boolean();
1241 ok(bool.toString() === "false", "bool.toString() = " + bool.toString());
1242 var bool = new Boolean("false");
1243 ok(bool.toString() === "true", "bool.toString() = " + bool.toString());
1244 ok(bool.valueOf() === Boolean(1), "bool.valueOf() = " + bool.valueOf());
1245 ok(bool.toLocaleString() === bool.toString(), "bool.toLocaleString() = " + bool.toLocaleString());
1246
1247 ok(Error.prototype !== TypeError.prototype, "Error.prototype === TypeError.prototype");
1248 ok(RangeError.prototype !== TypeError.prototype, "RangeError.prototype === TypeError.prototype");
1249 ok(Error.prototype.toLocaleString === Object.prototype.toLocaleString,
1250         "Error.prototype.toLocaleString !== Object.prototype.toLocaleString");
1251 err = new Error();
1252 ok(err.valueOf === Object.prototype.valueOf, "err.valueOf !== Object.prototype.valueOf");
1253 ok(Error.prototype.name === "Error", "Error.prototype.name = " + Error.prototype.name);
1254 ok(err.name === "Error", "err.name = " + err.name);
1255 EvalError.prototype.message = "test";
1256 ok(err.toString !== Object.prototype.toString, "err.toString === Object.prototype.toString");
1257 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1258 err = new EvalError();
1259 ok(EvalError.prototype.name === "EvalError", "EvalError.prototype.name = " + EvalError.prototype.name);
1260 ok(err.name === "EvalError", "err.name = " + err.name);
1261 ok(err.toString === Error.prototype.toString, "err.toString !== Error.prototype.toString");
1262 ok(err.message === "", "err.message != ''");
1263 err.message = date;
1264 ok(err.message === date, "err.message != date");
1265 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1266 ok(err.toString !== Object.prototype.toString, "err.toString === Object.prototype.toString");
1267 err = new RangeError();
1268 ok(RangeError.prototype.name === "RangeError", "RangeError.prototype.name = " + RangeError.prototype.name);
1269 ok(err.name === "RangeError", "err.name = " + err.name);
1270 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1271 err = new ReferenceError();
1272 ok(ReferenceError.prototype.name === "ReferenceError", "ReferenceError.prototype.name = " + ReferenceError.prototype.name);
1273 ok(err.name === "ReferenceError", "err.name = " + err.name);
1274 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1275 err = new SyntaxError();
1276 ok(SyntaxError.prototype.name === "SyntaxError", "SyntaxError.prototype.name = " + SyntaxError.prototype.name);
1277 ok(err.name === "SyntaxError", "err.name = " + err.name);
1278 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1279 err = new TypeError();
1280 ok(TypeError.prototype.name === "TypeError", "TypeError.prototype.name = " + TypeError.prototype.name);
1281 ok(err.name === "TypeError", "err.name = " + err.name);
1282 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1283 err = new URIError();
1284 ok(URIError.prototype.name === "URIError", "URIError.prototype.name = " + URIError.prototype.name);
1285 ok(err.name === "URIError", "err.name = " + err.name);
1286 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1287 err = new Error("message");
1288 ok(err.message === "message", "err.message !== 'message'");
1289 ok(err.toString() === "[object Error]", "err.toString() = " + err.toString());
1290 err = new Error(123);
1291 ok(err.number === 123, "err.number = " + err.number);
1292 err = new Error(0, "message");
1293 ok(err.number === 0, "err.number = " + err.number);
1294 ok(err.message === "message", "err.message = " + err.message);
1295 ok(err.description === "message", "err.description = " + err.description);
1296
1297 function exception_test(func, type, number) {
1298     ret = "";
1299     num = "";
1300     try {
1301         func();
1302     } catch(e) {
1303         ret = e.name;
1304         num = e.number;
1305     }
1306     ok(ret === type, "Exception test, ret = " + ret + ", expected " + type +". Executed function: " + func.toString());
1307     ok(num === number, "Exception test, num = " + num + ", expected " + number + ". Executed function: " + func.toString());
1308 }
1309 exception_test(function() {arr.toString = Date.prototype.toString; arr.toString();}, "TypeError", -2146823282);
1310 exception_test(function() {Array(-3);}, "RangeError", -2146823259);
1311 exception_test(function() {arr.toString = Boolean.prototype.toString; arr.toString();}, "TypeError", -2146823278);
1312 exception_test(function() {date.setTime();}, "TypeError", -2146827839);
1313 exception_test(function() {arr.test();}, "TypeError", -2146827850);
1314 exception_test(function() {arr.toString = Number.prototype.toString; arr.toString();}, "TypeError", -2146823287);
1315 exception_test(function() {(new Number(3)).toString(1);}, "TypeError", -2146828283);
1316 exception_test(function() {not_existing_variable.something();}, "TypeError", -2146823279);
1317 exception_test(function() {arr.toString = Function.prototype.toString; arr.toString();}, "TypeError", -2146823286);
1318 exception_test(function() {date();}, "TypeError", -2146823286);
1319 exception_test(function() {arr();}, "TypeError", -2146823286);
1320 exception_test(function() {eval("for(i=0;) {}");}, "SyntaxError", -2146827286);
1321 exception_test(function() {eval("function {};");}, "SyntaxError", -2146827283);
1322 exception_test(function() {eval("if");}, "SyntaxError", -2146827283);
1323 exception_test(function() {eval("do i=0; while");}, "SyntaxError", -2146827283);
1324 exception_test(function() {eval("while");}, "SyntaxError", -2146827283);
1325 exception_test(function() {eval("for");}, "SyntaxError", -2146827283);
1326 exception_test(function() {eval("with");}, "SyntaxError", -2146827283);
1327 exception_test(function() {eval("switch");}, "SyntaxError", -2146827283);
1328 exception_test(function() {eval("if(false");}, "SyntaxError", -2146827282);
1329 exception_test(function() {eval("for(i=0; i<10; i++");}, "SyntaxError", -2146827282);
1330 exception_test(function() {eval("while(true");}, "SyntaxError", -2146827282);
1331 exception_test(function() {test = function() {}}, "ReferenceError", -2146823280);
1332 exception_test(function() {eval("for(i=0")}, "SyntaxError", -2146827284);
1333 exception_test(function() {eval("for(i=0;i<10")}, "SyntaxError", -2146827284);
1334 exception_test(function() {eval("while(")}, "SyntaxError", -2146827286);
1335 exception_test(function() {eval("if(")}, "SyntaxError", -2146827286);
1336 exception_test(function() {eval("'unterminated")}, "SyntaxError", -2146827273);
1337
1338 reportSuccess();