[JSCRIPT_WINETEST] Sync with Wine Staging 3.9. CORE-14656
[reactos.git] / modules / rostests / winetests / jscript / 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 var bigInt = Math.pow(2,40);
22
23 ok(ScriptEngine() === "JScript", "ScriptEngine() = " + ScriptEngine());
24 ok(ScriptEngine(3) === "JScript", "ScriptEngine(3) = " + ScriptEngine(3));
25 ok(ScriptEngineMajorVersion() === ScriptEngineMajorVersion(2), "ScriptEngineMajorVersion() !== ScriptEngineMajorVersion(2)");
26 ok(ScriptEngineMinorVersion() === ScriptEngineMinorVersion(2), "ScriptEngineMinorVersion() !== ScriptEngineMinorVersion(2)");
27 ok(ScriptEngineBuildVersion() === ScriptEngineBuildVersion(2), "ScriptEngineBuildVersion() !== ScriptEngineBuildVersion(2)");
28
29 function testNoEnumerables(expr) {
30 for(var iter in obj)
31 ok(false, expr + " has property " + iter);
32 }
33
34 testNoEnumerables("Object");
35 testNoEnumerables("Object.prototype");
36 testNoEnumerables("new Object()");
37 testNoEnumerables("Math");
38 testNoEnumerables("String");
39 testNoEnumerables("String.prototype");
40 testNoEnumerables("new String()");
41 testNoEnumerables("Number");
42 testNoEnumerables("Number.prototype");
43 testNoEnumerables("new Number(1)");
44 testNoEnumerables("ActiveXObject");
45 testNoEnumerables("Array");
46 testNoEnumerables("Array.prototype");
47 testNoEnumerables("new Array()");
48 testNoEnumerables("Boolean");
49 testNoEnumerables("Boolean.prototype");
50 testNoEnumerables("new Boolean()");
51 testNoEnumerables("Date");
52 testNoEnumerables("Date.prototype");
53 testNoEnumerables("new Date()");
54 testNoEnumerables("TypeError");
55 testNoEnumerables("TypeError.prototype");
56 testNoEnumerables("new TypeError()");
57 testNoEnumerables("Function");
58 testNoEnumerables("Function.prototype");
59 testNoEnumerables("testNoEnumerates");
60 testNoEnumerables("VBArray");
61
62 ok(Object.propertyIsEnumerable("prototype") === false, "Object.prototype is enumerable");
63 ok(Math.propertyIsEnumerable("E") === false, "Math.E is enumerable");
64 ok(Math.propertyIsEnumerable("SQRT2") === false, "Math.SQRT2 is enumerable");
65 ok(Math.propertyIsEnumerable("PI") === false, "Math.PI is enumerable");
66 ok("test".propertyIsEnumerable("length") === false, "'test'.length is enumerable");
67 ok([1].propertyIsEnumerable("length") === false, "[1].length is enumerable");
68 ok((new TypeError()).propertyIsEnumerable("message") === true, "(new TypeError()).message is not enumerable");
69 ok((new TypeError()).propertyIsEnumerable("description") === false, "(new TypeError()).description is enumerable");
70 ok((new TypeError()).propertyIsEnumerable("name") === false, "(new TypeError()).name is enumerable");
71 ok((new TypeError()).propertyIsEnumerable("number") === false, "(new TypeError()).number is enumerable");
72 ok(Object.propertyIsEnumerable.propertyIsEnumerable("length") === false, "Object.propertyIsEnumerable.length is enumerable");
73
74 tmp = new Object();
75 tmp.test = "1";
76 ok(tmp.propertyIsEnumerable("test"), "tmp.test is not enumerable");
77
78 tmp = { test: 1 };
79 ok(tmp.propertyIsEnumerable("test"), "tmp.test is not enumerable");
80
81 ok([1].concat([2]).propertyIsEnumerable("1"), "[1].concat([2]).1 is not enumerable");
82 ok("t.e.s.t".split(".").propertyIsEnumerable("0"), "'test'.split().0 is not enumerable");
83
84 (function() {
85 ok(arguments.propertyIsEnumerable("0") === false, "arguments.0 is enumerable");
86 ok(arguments.propertyIsEnumerable("length") === false, "arguments.length is enumerable");
87 ok(arguments.propertyIsEnumerable("calee") === false, "arguments.calee is enumerable");
88 })();
89
90 tmp = [1];
91 tmp.push("");
92 ok(tmp.propertyIsEnumerable("1"), "[1].push() ... 1 is not enumerable");
93
94 ok([1,2].reverse().propertyIsEnumerable("1"), "[1,2].rverse().1 is not enumerable");
95 ok([1,2].propertyIsEnumerable("0"), "[1,2].0 is not enumerable");
96
97 i = parseInt("0");
98 ok(i === 0, "parseInt('0') = " + i);
99 i = parseInt("123");
100 ok(i === 123, "parseInt('123') = " + i);
101 i = parseInt("-123");
102 ok(i === -123, "parseInt('-123') = " + i);
103 i = parseInt("0xff");
104 ok(i === 0xff, "parseInt('0xff') = " + i);
105 i = parseInt("11", 8);
106 ok(i === 9, "parseInt('11', 8) = " + i);
107 i = parseInt("1j", 22);
108 ok(i === 41, "parseInt('1j', 32) = " + i);
109 i = parseInt("123", 0);
110 ok(i === 123, "parseInt('123', 0) = " + i);
111 i = parseInt("123", 10, "test");
112 ok(i === 123, "parseInt('123', 10, 'test') = " + i);
113 i = parseInt("11", "8");
114 ok(i === 9, "parseInt('11', '8') = " + i);
115 i = parseInt("010");
116 ok(i === 8, "parseInt('010') = " + i);
117 i = parseInt("");
118 ok(isNaN(i), "parseInt('') = " + i);
119 i = parseInt("0x");
120 ok(isNaN(i), "parseInt('0x') = " + i);
121 i = parseInt("+");
122 ok(isNaN(i), "parseInt('+') = " + i);
123 i = parseInt("-");
124 ok(isNaN(i), "parseInt('-') = " + i);
125 i = parseInt("0x10", 11);
126 ok(i === 0, "parseInt('0x10', 11) = " + i);
127 i = parseInt("010", 7);
128 ok(i === 7, "parseInt('010', 7) = " + i);
129 i = parseInt("123abc");
130 ok(i === 123, "parseInt('123abc') = " + i);
131 i = parseInt(" \t123abc");
132 ok(i === 123, "parseInt(' \\t123abc') = " + i);
133 i = parseInt("abc");
134 ok(isNaN(i), "parseInt('123abc') = " + i);
135 i = parseInt("-12", 11);
136 ok(i === -13, "parseInt('-12') = " + i);
137 i = parseInt("-0x10");
138 ok(i === -16, "parseInt('-0x10') = " + i);
139 i = parseInt("-010");
140 ok(i === -8, "parseInt('-010') = " + i);
141 i = parseInt("123", 0);
142 ok(i === 123, "parseInt('123', 0) = " + i);
143 i = parseInt("0x10", 0);
144 ok(i === 16, "parseInt('123', 0) = " + i);
145 i = parseInt("0x10", 10);
146 ok(i === 0, "parseInt('0x10', 10) = " + i);
147 i = parseInt("0xz");
148 ok(isNaN(i), "parseInt('0xz') = " + i);
149 i = parseInt("1", 1);
150 ok(isNaN(i), "parseInt('1', 1) = " + i);
151 i = parseInt("1", -1);
152 ok(isNaN(i), "parseInt('1', -1) = " + i);
153 i = parseInt("1", 37);
154 ok(isNaN(i), "parseInt('1', 37) = " + i);
155 i = parseInt("1", 36);
156 ok(i === 1, "parseInt('1', 36) = " + i);
157
158 tmp = encodeURI("abc");
159 ok(tmp === "abc", "encodeURI('abc') = " + tmp);
160 tmp = encodeURI("{abc}");
161 ok(tmp === "%7Babc%7D", "encodeURI('{abc}') = " + tmp);
162 tmp = encodeURI("");
163 ok(tmp === "", "encodeURI('') = " + tmp);
164 tmp = encodeURI("\01\02\03\04");
165 ok(tmp === "%01%02%03%04", "encodeURI('\\01\\02\\03\\04') = " + tmp);
166 tmp = encodeURI("{#@}");
167 ok(tmp === "%7B#@%7D", "encodeURI('{#@}') = " + tmp);
168 tmp = encodeURI("\xa1 ");
169 ok(tmp === "%C2%A1%20", "encodeURI(\\xa1 ) = " + tmp);
170 tmp = encodeURI("\xffff");
171 ok(tmp.length === 8, "encodeURI('\\xffff').length = " + tmp.length);
172 tmp = encodeURI("abcABC123;/?:@&=+$,-_.!~*'()");
173 ok(tmp === "abcABC123;/?:@&=+$,-_.!~*'()", "encodeURI('abcABC123;/?:@&=+$,-_.!~*'()') = " + tmp);
174 tmp = encodeURI("%");
175 ok(tmp === "%25", "encodeURI('%') = " + tmp);
176 tmp = encodeURI();
177 ok(tmp === "undefined", "encodeURI() = " + tmp);
178 tmp = encodeURI("abc", "test");
179 ok(tmp === "abc", "encodeURI('abc') = " + tmp);
180
181 tmp = decodeURI("abc");
182 ok(tmp === "abc", "decodeURI('abc') = " + tmp);
183 tmp = decodeURI("{abc}");
184 ok(tmp === "{abc}", "decodeURI('{abc}') = " + tmp);
185 tmp = decodeURI("");
186 ok(tmp === "", "decodeURI('') = " + tmp);
187 tmp = decodeURI("\01\02\03\04");
188 ok(tmp === "\01\02\03\04", "decodeURI('\\01\\02\\03\\04') = " + tmp);
189 tmp = decodeURI();
190 ok(tmp === "undefined", "decodeURI() = " + tmp);
191 tmp = decodeURI("abc", "test");
192 ok(tmp === "abc", "decodeURI('abc') = " + tmp);
193 tmp = decodeURI("%7babc%7d");
194 ok(tmp === "{abc}", "decodeURI('%7Babc%7D') = " + tmp);
195 tmp = decodeURI("%01%02%03%04");
196 ok(tmp === "\01\02\03\04", "decodeURI('%01%02%03%04') = " + tmp);
197 tmp = decodeURI("%C2%A1%20");
198 ok(tmp === "\xa1 ", "decodeURI('%C2%A1%20') = " + tmp);
199 tmp = decodeURI("%C3%BFff");
200 ok(tmp.length === 3, "decodeURI('%C3%BFff').length = " + tmp.length);
201
202 tmp = encodeURIComponent("abc");
203 ok(tmp === "abc", "encodeURIComponent('abc') = " + tmp);
204 dec = decodeURIComponent(tmp);
205 ok(dec === "abc", "decodeURIComponent('" + tmp + "') = " + dec);
206 tmp = encodeURIComponent("{abc}");
207 ok(tmp === "%7Babc%7D", "encodeURIComponent('{abc}') = " + tmp);
208 dec = decodeURIComponent(tmp);
209 ok(dec === "{abc}", "decodeURIComponent('" + tmp + "') = " + dec);
210 tmp = encodeURIComponent("");
211 ok(tmp === "", "encodeURIComponent('') = " + tmp);
212 dec = decodeURIComponent(tmp);
213 ok(dec === "", "decodeURIComponent('" + tmp + "') = " + dec);
214 tmp = encodeURIComponent("\01\02\03\04");
215 ok(tmp === "%01%02%03%04", "encodeURIComponent('\\01\\02\\03\\04') = " + tmp);
216 dec = decodeURIComponent(tmp);
217 ok(dec === "\01\02\03\04", "decodeURIComponent('" + tmp + "') = " + dec);
218 tmp = encodeURIComponent("{#@}");
219 ok(tmp === "%7B%23%40%7D", "encodeURIComponent('{#@}') = " + tmp);
220 dec = decodeURIComponent(tmp);
221 ok(dec === "{#@}", "decodeURIComponent('" + tmp + "') = " + dec);
222 tmp = encodeURIComponent("\xa1 ");
223 ok(tmp === "%C2%A1%20", "encodeURIComponent(\\xa1 ) = " + tmp);
224 dec = decodeURIComponent(tmp);
225 ok(dec === "\xa1 ", "decodeURIComponent('" + tmp + "') = " + dec);
226 tmp = encodeURIComponent("\xffff");
227 ok(tmp.length === 8, "encodeURIComponent('\\xffff').length = " + tmp.length);
228 dec = decodeURIComponent(tmp);
229 ok(dec === "\xffff", "decodeURIComponent('" + tmp + "') = " + dec);
230 tmp = encodeURIComponent("abcABC123;/?:@&=+$,-_.!~*'()");
231 ok(tmp === "abcABC123%3B%2F%3F%3A%40%26%3D%2B%24%2C-_.!~*'()", "encodeURIComponent('abcABC123;/?:@&=+$,-_.!~*'()') = " + tmp);
232 dec = decodeURIComponent(tmp);
233 ok(dec === "abcABC123;/?:@&=+$,-_.!~*'()", "decodeURIComponent('" + tmp + "') = " + dec);
234 tmp = encodeURIComponent();
235 ok(tmp === "undefined", "encodeURIComponent() = " + tmp);
236 tmp = encodeURIComponent("abc", "test");
237 ok(tmp === "abc", "encodeURIComponent('abc') = " + tmp);
238 dec = decodeURIComponent();
239 ok(dec === "undefined", "decodeURIComponent() = " + dec);
240 dec = decodeURIComponent("abc", "test");
241 ok(dec === "abc", "decodeURIComponent('abc') = " + dec);
242
243 tmp = escape("abc");
244 ok(tmp === "abc", "escape('abc') = " + tmp);
245 tmp = escape("");
246 ok(tmp === "", "escape('') = " + tmp);
247 tmp = escape("a1b c!d+e@*-_+./,");
248 ok(tmp === "a1b%20c%21d+e@*-_+./%2C", "escape('a1b c!d+e@*-_+./,') = " + tmp);
249 tmp = escape();
250 ok(tmp === "undefined", "escape() = " + tmp);
251 tmp = escape('\u1234\123\xf3');
252 ok(tmp == "%u1234S%F3", "escape('\u1234\123\xf3') = " + tmp);
253
254 tmp = unescape("abc");
255 ok(tmp === "abc", "unescape('abc') = " + tmp);
256 tmp = unescape("");
257 ok(tmp === "", "unescape('') = " + tmp);
258 tmp = unescape("%%%");
259 ok(tmp === "%%%", "unescape('%%%') = " + tmp);
260 tmp = unescape();
261 ok(tmp === "undefined", "unescape() = " + tmp);
262 tmp = unescape("%54%65s%u0074");
263 ok(tmp === "Test", "unescape('%54%65s%u0074') = " + tmp);
264
265 tmp = "aA1~`!@#$%^&*()_+=-][{}';:/.,<>?\|";
266 ok(escape(tmp) === "aA1%7E%60%21@%23%24%25%5E%26*%28%29_+%3D-%5D%5B%7B%7D%27%3B%3A/.%2C%3C%3E%3F%7C", "escape('" + tmp + "') = " + escape(tmp));
267 ok(unescape(escape(tmp)) === tmp, "unescape(escape('" + tmp + "')) = " + unescape(escape(tmp)));
268
269 ok(Object.prototype.hasOwnProperty('toString'), "Object.prototype.hasOwnProperty('toString') is false");
270 ok(Object.prototype.hasOwnProperty('isPrototypeOf'), "Object.prototype.hasOwnProperty('isPrototypeOf') is false");
271 ok(Function.prototype.hasOwnProperty('call'), "Function.prototype.hasOwnProperty('call') is false");
272
273 obj = new Object();
274
275 ok(!obj.hasOwnProperty('toString'), "obj.hasOwnProperty('toString') is true");
276 ok(!obj.hasOwnProperty('isPrototypeOf'), "obj.hasOwnProperty('isPrototypeOf') is true");
277 ok(!Object.hasOwnProperty('toString'), "Object.hasOwnProperty('toString') is true");
278 ok(!Object.hasOwnProperty('isPrototypeOf'), "Object.hasOwnProperty('isPrototypeOf') is true");
279 ok(!parseFloat.hasOwnProperty('call'), "parseFloat.hasOwnProperty('call') is true");
280 ok(!Function.hasOwnProperty('call'), "Function.hasOwnProperty('call') is true");
281
282 obj = new Array();
283 ok(Array.prototype.hasOwnProperty('sort'), "Array.prototype.hasOwnProperty('sort') is false");
284 ok(Array.prototype.hasOwnProperty('length'), "Array.prototype.hasOwnProperty('length') is false");
285 ok(!obj.hasOwnProperty('sort'), "obj.hasOwnProperty('sort') is true");
286 ok(obj.hasOwnProperty('length'), "obj.hasOwnProperty('length') is true");
287
288 obj = new Boolean(false);
289 ok(!obj.hasOwnProperty('toString'), "obj.hasOwnProperty('toString') is true");
290 ok(!Boolean.hasOwnProperty('toString'), "Boolean.hasOwnProperty('toString') is true");
291 ok(Boolean.prototype.hasOwnProperty('toString'), "Boolean.prototype.hasOwnProperty('toString') is false");
292
293 obj = new Date();
294 ok(!obj.hasOwnProperty('getTime'), "obj.hasOwnProperty('getTime') is true");
295 ok(!Date.hasOwnProperty('getTime'), "Date.hasOwnProperty('getTime') is true");
296 ok(Date.prototype.hasOwnProperty('getTime'), "Date.prototype.hasOwnProperty('getTime') is false");
297 ok(!("now" in Date), "now found in Date");
298
299 obj = new Number();
300 ok(!obj.hasOwnProperty('toFixed'), "obj.hasOwnProperty('toFixed') is true");
301 ok(!Number.hasOwnProperty('toFixed'), "Number.hasOwnProperty('toFixed') is true");
302 ok(Number.prototype.hasOwnProperty('toFixed'), "Number.prototype.hasOwnProperty('toFixed') is false");
303
304 obj = /x/;
305 ok(!obj.hasOwnProperty('exec'), "obj.hasOwnProperty('exec') is true");
306 ok(obj.hasOwnProperty('source'), "obj.hasOwnProperty('source') is false");
307 ok(!RegExp.hasOwnProperty('exec'), "RegExp.hasOwnProperty('exec') is true");
308 ok(!RegExp.hasOwnProperty('source'), "RegExp.hasOwnProperty('source') is true");
309 ok(RegExp.prototype.hasOwnProperty('source'), "RegExp.prototype.hasOwnProperty('source') is false");
310
311 obj = new String();
312 ok(!obj.hasOwnProperty('charAt'), "obj.hasOwnProperty('charAt') is true");
313 ok(obj.hasOwnProperty('length'), "obj.hasOwnProperty('length') is false");
314 ok(!String.hasOwnProperty('charAt'), "String.hasOwnProperty('charAt') is true");
315 ok(String.prototype.hasOwnProperty('charAt'), "String.prototype.hasOwnProperty('charAt') is false");
316 ok(String.prototype.hasOwnProperty('length'), "String.prototype.hasOwnProperty('length') is false");
317
318 tmp = "" + new Object();
319 ok(tmp === "[object Object]", "'' + new Object() = " + tmp);
320 (tmp = new Array).f = Object.prototype.toString;
321 ok(tmp.f() === "[object Array]", "tmp.f() = " + tmp.f());
322 (tmp = new Boolean).f = Object.prototype.toString;
323 ok(tmp.f() === "[object Boolean]", "tmp.f() = " + tmp.f());
324 (tmp = new Date).f = Object.prototype.toString;
325 ok(tmp.f() === "[object Date]", "tmp.f() = " + tmp.f());
326 (tmp = function() {}).f = Object.prototype.toString;
327 ok(tmp.f() === "[object Function]", "tmp.f() = " + tmp.f());
328 Math.f = Object.prototype.toString;
329 ok(Math.f() === "[object Math]", "tmp.f() = " + tmp.f());
330 (tmp = new Number).f = Object.prototype.toString;
331 ok(tmp.f() === "[object Number]", "tmp.f() = " + tmp.f());
332 (tmp = new RegExp("")).f = Object.prototype.toString;
333 ok(tmp.f() === "[object RegExp]", "tmp.f() = " + tmp.f());
334 (tmp = new String).f = Object.prototype.toString;
335 ok(tmp.f() === "[object String]", "tmp.f() = " + tmp.f());
336 tmp = Object.prototype.toString.call(testObj);
337 ok(tmp === "[object Object]", "toString.call(testObj) = " + tmp);
338 tmp = Object.prototype.toString.call(this);
339 ok(tmp === "[object Object]", "toString.call(this) = " + tmp);
340 (function () { tmp = Object.prototype.toString.call(arguments); })();
341 ok(tmp === "[object Object]", "toString.call(arguments) = " + tmp);
342 tmp = Object.prototype.toString.call(new VBArray(createArray()));
343 ok(tmp === "[object Object]", "toString.call(new VBArray()) = " + tmp);
344
345 function TSTestConstr() {}
346 TSTestConstr.prototype = { toString: function() { return "test"; } };
347 obj = new TSTestConstr();
348 ok(obj.toString() === "test", "obj.toString() = " + obj.toString());
349
350 ok(Object(1) instanceof Number, "Object(1) is not instance of Number");
351 ok(Object("") instanceof String, "Object('') is not instance of String");
352 ok(Object(false) instanceof Boolean, "Object(false) is not instance of Boolean");
353
354 ok(new Object(1) instanceof Number, "Object(1) is not instance of Number");
355 ok(new Object("") instanceof String, "Object('') is not instance of String");
356 ok(new Object(false) instanceof Boolean, "Object(false) is not instance of Boolean");
357
358 obj = new Object();
359 ok(Object(obj) === obj, "Object(obj) !== obj");
360
361 ok(typeof(Object()) === "object", "typeof(Object()) !== 'object'");
362 ok(typeof(Object(undefined)) === "object", "typeof(Object(undefined)) !== 'object'");
363 ok(typeof(Object(null)) === "object", "typeof(Object(null)) !== 'object'");
364 ok(typeof(Object(nullDisp)) === "object", "typeof(Object(nullDisp)) !== 'object'");
365
366 ok(Object(nullDisp) != nullDisp, "Object(nullDisp) == nullDisp");
367 ok(new Object(nullDisp) != nullDisp, "new Object(nullDisp) == nullDisp");
368
369 ok(Object(testObj) === testObj, "Object(testObj) != testObj\n");
370 ok(new Object(testObj) === testObj, "new Object(testObj) != testObj\n");
371
372 tmp = new Object();
373 ok(Object(tmp) === tmp, "Object(tmp) != tmp");
374 ok(new Object(tmp) === tmp, "new Object(tmp) != tmp");
375
376 var obj = new Object();
377 obj.toString = function (x) {
378 ok(arguments.length === 0, "arguments.length = " + arguments.length);
379 return "test";
380 };
381 ok((tmp = obj.toLocaleString()) === "test", "obj.toLocaleString() = " + tmp);
382 ok((tmp = obj.toLocaleString(1)) === "test", "obj.toLocaleString(1) = " + tmp);
383 ok(obj === obj.valueOf(), "obj !== obj.valueOf");
384
385 ok("".length === 0, "\"\".length = " + "".length);
386 ok(getVT("".length) == "VT_I4", "\"\".length = " + "".length);
387 ok("abc".length === 3, "\"abc\".length = " + "abc".length);
388 ok(String.prototype.length === 0, "String.prototype.length = " + String.prototype.length);
389
390 tmp = "".toString();
391 ok(tmp === "", "''.toString() = " + tmp);
392 tmp = "test".toString();
393 ok(tmp === "test", "''.toString() = " + tmp);
394 tmp = "test".toString(3);
395 ok(tmp === "test", "''.toString(3) = " + tmp);
396
397 tmp = "".valueOf();
398 ok(tmp === "", "''.valueOf() = " + tmp);
399 tmp = "test".valueOf();
400 ok(tmp === "test", "''.valueOf() = " + tmp);
401 tmp = "test".valueOf(3);
402 ok(tmp === "test", "''.valueOf(3) = " + tmp);
403
404 var str = new String("test");
405 ok(str.toString() === "test", "str.toString() = " + str.toString());
406 var str = new String();
407 ok(str.toString() === "", "str.toString() = " + str.toString());
408 var str = new String("test", "abc");
409 ok(str.toString() === "test", "str.toString() = " + str.toString());
410
411 str = new String("test");
412 ok(str.length === 4, "str.length = " + str.length);
413 str.length = 3;
414 str.length = 5;
415 ok(str.length === 4, "str.length = " + str.length);
416
417 var strObj = new Object();
418 strObj.toString = function() { return "abcd" };
419 strObj.substr = String.prototype.substr;
420 strObj.lastIndexOf = String.prototype.lastIndexOf;
421
422 tmp = "value " + str;
423 ok(tmp === "value test", "'value ' + str = " + tmp);
424
425 tmp = String();
426 ok(tmp === "", "String() = " + tmp);
427 tmp = String(false);
428 ok(tmp === "false", "String(false) = " + tmp);
429 tmp = String(null);
430 ok(tmp === "null", "String(null) = " + tmp);
431 tmp = String("test");
432 ok(tmp === "test", "String('test') = " + tmp);
433 tmp = String("test", "abc");
434 ok(tmp === "test", "String('test','abc') = " + tmp);
435
436 tmp = "abc".charAt(0);
437 ok(tmp === "a", "'abc',charAt(0) = " + tmp);
438 tmp = "abc".charAt(1);
439 ok(tmp === "b", "'abc',charAt(1) = " + tmp);
440 tmp = "abc".charAt(2);
441 ok(tmp === "c", "'abc',charAt(2) = " + tmp);
442 tmp = "abc".charAt(3);
443 ok(tmp === "", "'abc',charAt(3) = " + tmp);
444 tmp = "abc".charAt(4);
445 ok(tmp === "", "'abc',charAt(4) = " + tmp);
446 tmp = "abc".charAt();
447 ok(tmp === "a", "'abc',charAt() = " + tmp);
448 tmp = "abc".charAt(-1);
449 ok(tmp === "", "'abc',charAt(-1) = " + tmp);
450 tmp = "abc".charAt(0,2);
451 ok(tmp === "a", "'abc',charAt(0.2) = " + tmp);
452 tmp = "abc".charAt(NaN);
453 ok(tmp === "a", "'abc',charAt(NaN) = " + tmp);
454 tmp = "abc".charAt(bigInt);
455 ok(tmp === "", "'abc',charAt(bigInt) = " + tmp);
456
457 tmp = "abc".charCodeAt(0);
458 ok(tmp === 0x61, "'abc'.charCodeAt(0) = " + tmp);
459 tmp = "abc".charCodeAt(1);
460 ok(tmp === 0x62, "'abc'.charCodeAt(1) = " + tmp);
461 tmp = "abc".charCodeAt(2);
462 ok(tmp === 0x63, "'abc'.charCodeAt(2) = " + tmp);
463 tmp = "abc".charCodeAt();
464 ok(tmp === 0x61, "'abc'.charCodeAt() = " + tmp);
465 tmp = "abc".charCodeAt(true);
466 ok(tmp === 0x62, "'abc'.charCodeAt(true) = " + tmp);
467 tmp = "abc".charCodeAt(0,2);
468 ok(tmp === 0x61, "'abc'.charCodeAt(0,2) = " + tmp);
469 tmp = "\u49F4".charCodeAt(0);
470 ok(tmp === 0x49F4, "'\u49F4'.charCodeAt(0) = " + tmp);
471 tmp = "\052".charCodeAt(0);
472 ok(tmp === 0x2A, "'\052'.charCodeAt(0) = " + tmp);
473 tmp = "\xa2".charCodeAt(0);
474 ok(tmp === 0xA2, "'\xa2'.charCodeAt(0) = " + tmp);
475 tmp = "abc".charCodeAt(bigInt);
476 ok(isNaN(tmp), "'abc'.charCodeAt(bigInt) = " + tmp);
477
478 tmp = "abcd".substring(1,3);
479 ok(tmp === "bc", "'abcd'.substring(1,3) = " + tmp);
480 tmp = "abcd".substring(-1,3);
481 ok(tmp === "abc", "'abcd'.substring(-1,3) = " + tmp);
482 tmp = "abcd".substring(1,6);
483 ok(tmp === "bcd", "'abcd'.substring(1,6) = " + tmp);
484 tmp = "abcd".substring(3,1);
485 ok(tmp === "bc", "'abcd'.substring(3,1) = " + tmp);
486 tmp = "abcd".substring(2,2);
487 ok(tmp === "", "'abcd'.substring(2,2) = " + tmp);
488 tmp = "abcd".substring(true,"3");
489 ok(tmp === "bc", "'abcd'.substring(true,'3') = " + tmp);
490 tmp = "abcd".substring(1,3,2);
491 ok(tmp === "bc", "'abcd'.substring(1,3,2) = " + tmp);
492 tmp = "abcd".substring();
493 ok(tmp === "abcd", "'abcd'.substring() = " + tmp);
494
495 tmp = "abcd".substr(1,3);
496 ok(tmp === "bcd", "'abcd'.substr(1,3) = " + tmp);
497 tmp = "abcd".substr(-1,3);
498 ok(tmp === "abc", "'abcd'.substr(-1,3) = " + tmp);
499 tmp = "abcd".substr(1,6);
500 ok(tmp === "bcd", "'abcd'.substr(1,6) = " + tmp);
501 tmp = "abcd".substr(2,-1);
502 ok(tmp === "", "'abcd'.substr(3,1) = " + tmp);
503 tmp = "abcd".substr(2,0);
504 ok(tmp === "", "'abcd'.substr(2,2) = " + tmp);
505 tmp = "abcd".substr(true,"3");
506 ok(tmp === "bcd", "'abcd'.substr(true,'3') = " + tmp);
507 tmp = "abcd".substr(1,3,2);
508 ok(tmp === "bcd", "'abcd'.substr(1,3,2) = " + tmp);
509 tmp = "abcd".substr();
510 ok(tmp === "abcd", "'abcd'.substr() = " + tmp);
511 tmp = strObj.substr(1,1);
512 ok(tmp === "b", "'abcd'.substr(1,3) = " + tmp);
513
514 tmp = "abcd".slice(1,3);
515 ok(tmp === "bc", "'abcd'.slice(1,3) = " + tmp);
516 tmp = "abcd".slice(1,-1);
517 ok(tmp === "bc", "'abcd'.slice(1,-1) = " + tmp);
518 tmp = "abcd".slice(-3,3);
519 ok(tmp === "bc", "'abcd'.slice(-3,3) = " + tmp);
520 tmp = "abcd".slice(-6,3);
521 ok(tmp === "abc", "'abcd'.slice(-6,3) = " + tmp);
522 tmp = "abcd".slice(3,1);
523 ok(tmp === "", "'abcd'.slice(3,1) = " + tmp);
524 tmp = "abcd".slice(true,3);
525 ok(tmp === "bc", "'abcd'.slice(true,3) = " + tmp);
526 tmp = "abcd".slice();
527 ok(tmp === "abcd", "'abcd'.slice() = " + tmp);
528 tmp = "abcd".slice(1);
529 ok(tmp === "bcd", "'abcd'.slice(1) = " + tmp);
530
531 tmp = "abc".concat(["d",1],2,false);
532 ok(tmp === "abcd,12false", "concat returned " + tmp);
533 var arr = new Array(2,"a");
534 arr.concat = String.prototype.concat;
535 tmp = arr.concat("d");
536 ok(tmp === "2,ad", "arr.concat = " + tmp);
537
538 m = "a+bcabc".match("a+");
539 ok(typeof(m) === "object", "typeof m is not object");
540 ok(m.length === 1, "m.length is not 1");
541 ok(m["0"] === "a", "m[0] is not \"a\"");
542
543 r = "- [test] -".replace("[test]", "success");
544 ok(r === "- success -", "r = " + r + " expected '- success -'");
545
546 r = "- [test] -".replace("[test]", "success", "test");
547 ok(r === "- success -", "r = " + r + " expected '- success -'");
548
549 r = "test".replace();
550 ok(r === "test", "r = " + r + " expected 'test'");
551
552 function replaceFunc3(m, off, str) {
553 ok(arguments.length === 3, "arguments.length = " + arguments.length);
554 ok(m === "[test]", "m = " + m + " expected [test]");
555 ok(off === 1, "off = " + off + " expected 0");
556 ok(str === "-[test]-", "str = " + arguments[3]);
557 return "ret";
558 }
559
560 r = "-[test]-".replace("[test]", replaceFunc3);
561 ok(r === "-ret-", "r = " + r + " expected '-ret-'");
562
563 r = "-[test]-".replace("[test]", replaceFunc3, "test");
564 ok(r === "-ret-", "r = " + r + " expected '-ret-'");
565
566 r = "x,x,x".replace("x", "y");
567 ok(r === "y,x,x", "r = " + r + " expected 'y,x,x'");
568
569 r = "x,x,x".replace("", "y");
570 ok(r === "yx,x,x", "r = " + r + " expected 'yx,x,x'");
571
572 r = "x,x,x".replace("", "");
573 ok(r === "x,x,x", "r = " + r + " expected 'x,x,x'");
574
575 r = "1,2,3".split(",");
576 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
577 ok(r.length === 3, "r.length = " + r.length);
578 ok(r[0] === "1", "r[0] = " + r[0]);
579 ok(r[1] === "2", "r[1] = " + r[1]);
580 ok(r[2] === "3", "r[2] = " + r[2]);
581
582 r = "1,2,3".split(",*");
583 ok(r.length === 1, "r.length = " + r.length);
584 ok(r[0] === "1,2,3", "r[0] = " + r[0]);
585
586 r = "123".split("");
587 ok(r.length === 3, "r.length = " + r.length);
588 ok(r[0] === "1", "r[0] = " + r[0]);
589 ok(r[1] === "2", "r[1] = " + r[1]);
590 ok(r[2] === "3", "r[2] = " + r[2]);
591
592 r = "123".split(2);
593 ok(r.length === 2, "r.length = " + r.length);
594 ok(r[0] === "1", "r[0] = " + r[0]);
595 ok(r[1] === "3", "r[1] = " + r[1]);
596
597 r = "1,2,".split(",");
598 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
599 ok(r.length === 3, "r.length = " + r.length);
600 ok(r[0] === "1", "r[0] = " + r[0]);
601 ok(r[1] === "2", "r[1] = " + r[1]);
602 ok(r[2] === "", "r[2] = " + r[2]);
603
604 r = "1,2,3".split(",", 2);
605 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
606 ok(r.length === 2, "r.length = " + r.length);
607 ok(r[0] === "1", "r[0] = " + r[0]);
608 ok(r[1] === "2", "r[1] = " + r[1]);
609
610 r = "1,2,3".split(",", 0);
611 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
612 ok(r.length === 0, "r.length = " + r.length);
613
614 r = "1,2,3".split(",", -1);
615 ok(typeof(r) === "object", "typeof(r) = " + typeof(r));
616 ok(r.length === 3, "r.length = " + r.length);
617 ok(r[0] === "1", "r[0] = " + r[0]);
618 ok(r[1] === "2", "r[1] = " + r[1]);
619 ok(r[2] === "3", "r[1] = " + r[1]);
620
621 tmp = "abcd".indexOf("bc",0);
622 ok(tmp === 1, "indexOf = " + tmp);
623 tmp = "abcd".indexOf("bc",1);
624 ok(tmp === 1, "indexOf = " + tmp);
625 tmp = "abcd".indexOf("bc");
626 ok(tmp === 1, "indexOf = " + tmp);
627 tmp = "abcd".indexOf("ac");
628 ok(tmp === -1, "indexOf = " + tmp);
629 tmp = "abcd".indexOf("bc",2);
630 ok(tmp === -1, "indexOf = " + tmp);
631 tmp = "abcd".indexOf("a",0);
632 ok(tmp === 0, "indexOf = " + tmp);
633 tmp = "abcd".indexOf("bc",0,"test");
634 ok(tmp === 1, "indexOf = " + tmp);
635 tmp = "abcd".indexOf();
636 ok(tmp == -1, "indexOf = " + tmp);
637 tmp = "abcd".indexOf("b", bigInt);
638 ok(tmp == -1, "indexOf = " + tmp);
639 tmp = "abcd".indexOf("abcd",0);
640 ok(tmp === 0, "indexOf = " + tmp);
641 tmp = "abcd".indexOf("abcd",1);
642 ok(tmp === -1, "indexOf = " + tmp);
643 tmp = ("ab" + String.fromCharCode(0) + "cd").indexOf(String.fromCharCode(0));
644 ok(tmp === 2, "indexOf = " + tmp);
645
646 tmp = "abcd".lastIndexOf("bc",1);
647 ok(tmp === 1, "lastIndexOf = " + tmp);
648 tmp = "abcd".lastIndexOf("bc",2);
649 ok(tmp === 1, "lastIndexOf = " + tmp);
650 tmp = "abcd".lastIndexOf("bc");
651 ok(tmp === 1, "lastIndexOf = " + tmp);
652 tmp = "abcd".lastIndexOf("ac");
653 ok(tmp === -1, "lastIndexOf = " + tmp);
654 tmp = "abcd".lastIndexOf("d",10);
655 ok(tmp === 3, "lastIndexOf = " + tmp);
656 tmp = "abcd".lastIndexOf("bc",0,"test");
657 ok(tmp === -1, "lastIndexOf = " + tmp);
658 tmp = "abcd".lastIndexOf();
659 ok(tmp === -1, "lastIndexOf = " + tmp);
660 tmp = "aaaa".lastIndexOf("a",2);
661 ok(tmp == 2, "lastIndexOf = " + tmp);
662 tmp = strObj.lastIndexOf("b");
663 ok(tmp === 1, "lastIndexOf = " + tmp);
664 tmp = "bbb".lastIndexOf("b", bigInt);
665 ok(tmp === 2, "lastIndexOf = " + tmp);
666 tmp = "abcd".lastIndexOf("abcd",4);
667 ok(tmp === 0, "lastIndexOf = " + tmp);
668 tmp = "abcd".lastIndexOf("abcd",0);
669 ok(tmp === 0, "lastIndexOf = " + tmp);
670 tmp = ("ab" + String.fromCharCode(0) + "cd").lastIndexOf(String.fromCharCode(0));
671 ok(tmp === 2, "lastIndexOf = " + tmp);
672
673 tmp = "".toLowerCase();
674 ok(tmp === "", "''.toLowerCase() = " + tmp);
675 tmp = "test".toLowerCase();
676 ok(tmp === "test", "''.toLowerCase() = " + tmp);
677 tmp = "test".toLowerCase(3);
678 ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
679 tmp = "tEsT".toLowerCase();
680 ok(tmp === "test", "''.toLowerCase() = " + tmp);
681 tmp = "tEsT".toLowerCase(3);
682 ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
683 tmp = ("tE" + String.fromCharCode(0) + "sT").toLowerCase();
684 ok(tmp === "te" + String.fromCharCode(0) + "st", "''.toLowerCase() = " + tmp);
685
686 tmp = "".toUpperCase();
687 ok(tmp === "", "''.toUpperCase() = " + tmp);
688 tmp = "TEST".toUpperCase();
689 ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
690 tmp = "TEST".toUpperCase(3);
691 ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
692 tmp = "tEsT".toUpperCase();
693 ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
694 tmp = "tEsT".toUpperCase(3);
695 ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
696 tmp = ("tE" + String.fromCharCode(0) + "sT").toUpperCase();
697 ok(tmp === "TE" + String.fromCharCode(0) + "ST", "''.toUpperCase() = " + tmp);
698
699 tmp = "".anchor();
700 ok(tmp === "<A NAME=\"undefined\"></A>", "''.anchor() = " + tmp);
701 tmp = "".anchor(3);
702 ok(tmp === "<A NAME=\"3\"></A>", "''.anchor(3) = " + tmp);
703 tmp = "".anchor("red");
704 ok(tmp === "<A NAME=\"red\"></A>", "''.anchor('red') = " + tmp);
705 tmp = "test".anchor();
706 ok(tmp === "<A NAME=\"undefined\">test</A>", "'test'.anchor() = " + tmp);
707 tmp = "test".anchor(3);
708 ok(tmp === "<A NAME=\"3\">test</A>", "'test'.anchor(3) = " + tmp);
709 tmp = "test".anchor("green");
710 ok(tmp === "<A NAME=\"green\">test</A>", "'test'.anchor('green') = " + tmp);
711
712 tmp = "".big();
713 ok(tmp === "<BIG></BIG>", "''.big() = " + tmp);
714 tmp = "".big(3);
715 ok(tmp === "<BIG></BIG>", "''.big(3) = " + tmp);
716 tmp = "test".big();
717 ok(tmp === "<BIG>test</BIG>", "'test'.big() = " + tmp);
718 tmp = "test".big(3);
719 ok(tmp === "<BIG>test</BIG>", "'test'.big(3) = " + tmp);
720
721 tmp = "".blink();
722 ok(tmp === "<BLINK></BLINK>", "''.blink() = " + tmp);
723 tmp = "".blink(3);
724 ok(tmp === "<BLINK></BLINK>", "''.blink(3) = " + tmp);
725 tmp = "test".blink();
726 ok(tmp === "<BLINK>test</BLINK>", "'test'.blink() = " + tmp);
727 tmp = "test".blink(3);
728 ok(tmp === "<BLINK>test</BLINK>", "'test'.blink(3) = " + tmp);
729
730 tmp = "".bold();
731 ok(tmp === "<B></B>", "''.bold() = " + tmp);
732 tmp = "".bold(3);
733 ok(tmp === "<B></B>", "''.bold(3) = " + tmp);
734 tmp = "test".bold();
735 ok(tmp === "<B>test</B>", "'test'.bold() = " + tmp);
736 tmp = "test".bold(3);
737 ok(tmp === "<B>test</B>", "'test'.bold(3) = " + tmp);
738
739 tmp = "".fixed();
740 ok(tmp === "<TT></TT>", "''.fixed() = " + tmp);
741 tmp = "".fixed(3);
742 ok(tmp === "<TT></TT>", "''.fixed(3) = " + tmp);
743 tmp = "test".fixed();
744 ok(tmp === "<TT>test</TT>", "'test'.fixed() = " + tmp);
745 tmp = "test".fixed(3);
746 ok(tmp === "<TT>test</TT>", "'test'.fixed(3) = " + tmp);
747
748 tmp = "".fontcolor();
749 ok(tmp === "<FONT COLOR=\"undefined\"></FONT>", "''.fontcolor() = " + tmp);
750 tmp = "".fontcolor(3);
751 ok(tmp === "<FONT COLOR=\"3\"></FONT>", "''.fontcolor(3) = " + tmp);
752 tmp = "".fontcolor("red");
753 ok(tmp === "<FONT COLOR=\"red\"></FONT>", "''.fontcolor('red') = " + tmp);
754 tmp = "test".fontcolor();
755 ok(tmp === "<FONT COLOR=\"undefined\">test</FONT>", "'test'.fontcolor() = " + tmp);
756 tmp = "test".fontcolor(3);
757 ok(tmp === "<FONT COLOR=\"3\">test</FONT>", "'test'.fontcolor(3) = " + tmp);
758 tmp = "test".fontcolor("green");
759 ok(tmp === "<FONT COLOR=\"green\">test</FONT>", "'test'.fontcolor('green') = " + tmp);
760
761 tmp = "".fontsize();
762 ok(tmp === "<FONT SIZE=\"undefined\"></FONT>", "''.fontsize() = " + tmp);
763 tmp = "".fontsize(3);
764 ok(tmp === "<FONT SIZE=\"3\"></FONT>", "''.fontsize(3) = " + tmp);
765 tmp = "".fontsize("red");
766 ok(tmp === "<FONT SIZE=\"red\"></FONT>", "''.fontsize('red') = " + tmp);
767 tmp = "test".fontsize();
768 ok(tmp === "<FONT SIZE=\"undefined\">test</FONT>", "'test'.fontsize() = " + tmp);
769 tmp = "test".fontsize(3);
770 ok(tmp === "<FONT SIZE=\"3\">test</FONT>", "'test'.fontsize(3) = " + tmp);
771 tmp = "test".fontsize("green");
772 ok(tmp === "<FONT SIZE=\"green\">test</FONT>", "'test'.fontsize('green') = " + tmp);
773
774 tmp = ("".fontcolor()).fontsize();
775 ok(tmp === "<FONT SIZE=\"undefined\"><FONT COLOR=\"undefined\"></FONT></FONT>", "(''.fontcolor()).fontsize() = " + tmp);
776
777 tmp = "".italics();
778 ok(tmp === "<I></I>", "''.italics() = " + tmp);
779 tmp = "".italics(3);
780 ok(tmp === "<I></I>", "''.italics(3) = " + tmp);
781 tmp = "test".italics();
782 ok(tmp === "<I>test</I>", "'test'.italics() = " + tmp);
783 tmp = "test".italics(3);
784 ok(tmp === "<I>test</I>", "'test'.italics(3) = " + tmp);
785
786 tmp = "".link();
787 ok(tmp === "<A HREF=\"undefined\"></A>", "''.link() = " + tmp);
788 tmp = "".link(3);
789 ok(tmp === "<A HREF=\"3\"></A>", "''.link(3) = " + tmp);
790 tmp = "".link("red");
791 ok(tmp === "<A HREF=\"red\"></A>", "''.link('red') = " + tmp);
792 tmp = "test".link();
793 ok(tmp === "<A HREF=\"undefined\">test</A>", "'test'.link() = " + tmp);
794 tmp = "test".link(3);
795 ok(tmp === "<A HREF=\"3\">test</A>", "'test'.link(3) = " + tmp);
796 tmp = "test".link("green");
797 ok(tmp === "<A HREF=\"green\">test</A>", "'test'.link('green') = " + tmp);
798
799 tmp = "".small();
800 ok(tmp === "<SMALL></SMALL>", "''.small() = " + tmp);
801 tmp = "".small(3);
802 ok(tmp === "<SMALL></SMALL>", "''.small(3) = " + tmp);
803 tmp = "test".small();
804 ok(tmp === "<SMALL>test</SMALL>", "'test'.small() = " + tmp);
805 tmp = "test".small(3);
806 ok(tmp === "<SMALL>test</SMALL>", "'test'.small(3) = " + tmp);
807
808 tmp = "".strike();
809 ok(tmp === "<STRIKE></STRIKE>", "''.strike() = " + tmp);
810 tmp = "".strike(3);
811 ok(tmp === "<STRIKE></STRIKE>", "''.strike(3) = " + tmp);
812 tmp = "test".strike();
813 ok(tmp === "<STRIKE>test</STRIKE>", "'test'.strike() = " + tmp);
814 tmp = "test".strike(3);
815 ok(tmp === "<STRIKE>test</STRIKE>", "'test'.strike(3) = " + tmp);
816
817 tmp = "".sub();
818 ok(tmp === "<SUB></SUB>", "''.sub() = " + tmp);
819 tmp = "".sub(3);
820 ok(tmp === "<SUB></SUB>", "''.sub(3) = " + tmp);
821 tmp = "test".sub();
822 ok(tmp === "<SUB>test</SUB>", "'test'.sub() = " + tmp);
823 tmp = "test".sub(3);
824 ok(tmp === "<SUB>test</SUB>", "'test'.sub(3) = " + tmp);
825
826 tmp = "".sup();
827 ok(tmp === "<SUP></SUP>", "''.sup() = " + tmp);
828 tmp = "".sup(3);
829 ok(tmp === "<SUP></SUP>", "''.sup(3) = " + tmp);
830 tmp = "test".sup();
831 ok(tmp === "<SUP>test</SUP>", "'test'.sup() = " + tmp);
832 tmp = "test".sup(3);
833 ok(tmp === "<SUP>test</SUP>", "'test'.sup(3) = " + tmp);
834
835 ok(String.fromCharCode() === "", "String.fromCharCode() = " + String.fromCharCode());
836 ok(String.fromCharCode(65,"66",67) === "ABC", "String.fromCharCode(65,'66',67) = " + String.fromCharCode(65,"66",67));
837 ok(String.fromCharCode(1024*64+65, -1024*64+65) === "AA",
838 "String.fromCharCode(1024*64+65, -1024*64+65) = " + String.fromCharCode(1024*64+65, -1024*64+65));
839 ok(String.fromCharCode(65, NaN, undefined).length === 3,
840 "String.fromCharCode(65, NaN, undefined).length = " + String.fromCharCode(65, NaN, undefined).length);
841
842 var arr = new Array();
843 ok(typeof(arr) === "object", "arr () is not object");
844 ok((arr.length === 0), "arr.length is not 0");
845 ok(arr["0"] === undefined, "arr[0] is not undefined");
846
847 var arr = new Array(1, 2, "test");
848 ok(typeof(arr) === "object", "arr (1,2,test) is not object");
849 ok((arr.length === 3), "arr.length is not 3");
850 ok(arr["0"] === 1, "arr[0] is not 1");
851 ok(arr["1"] === 2, "arr[1] is not 2");
852 ok(arr["2"] === "test", "arr[2] is not \"test\"");
853
854 arr["7"] = true;
855 ok((arr.length === 8), "arr.length is not 8");
856
857 tmp = "" + [];
858 ok(tmp === "", "'' + [] = " + tmp);
859 tmp = "" + [1,true];
860 ok(tmp === "1,true", "'' + [1,true] = " + tmp);
861
862 var arr = new Array(6);
863 ok(typeof(arr) === "object", "arr (6) is not object");
864 ok((arr.length === 6), "arr.length is not 6");
865 ok(arr["0"] === undefined, "arr[0] is not undefined");
866
867 ok(arr.push() === 6, "arr.push() !== 6");
868 ok(arr.push(1) === 7, "arr.push(1) !== 7");
869 ok(arr[6] === 1, "arr[6] != 1");
870 ok(arr.length === 7, "arr.length != 10");
871 ok(arr.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10");
872 ok(arr[8] === "b", "arr[8] != 'b'");
873 ok(arr.length === 10, "arr.length != 10");
874
875 var arr = new Object();
876 arr.push = Array.prototype.push;
877
878 arr.length = 6;
879
880 ok(arr.push() === 6, "arr.push() !== 6");
881 ok(arr.push(1) === 7, "arr.push(1) !== 7");
882 ok(arr[6] === 1, "arr[6] != 1");
883 ok(arr.length === 7, "arr.length != 10");
884 ok(arr.push(true, 'b', false) === 10, "arr.push(true, 'b', false) !== 10");
885 ok(arr[8] === "b", "arr[8] != 'b'");
886 ok(arr.length === 10, "arr.length != 10");
887
888 arr.pop = Array.prototype.pop;
889 ok(arr.pop() === false, "arr.pop() !== false");
890 ok(arr[8] === "b", "arr[8] !== 'b'");
891 ok(arr.pop() === 'b', "arr.pop() !== 'b'");
892 ok(arr[8] === undefined, "arr[8] !== undefined");
893
894 arr = [3,4,5];
895 tmp = arr.pop();
896 ok(arr.length === 2, "arr.length = " + arr.length);
897 ok(tmp === 5, "pop() = " + tmp);
898 tmp = arr.pop(2);
899 ok(arr.length === 1, "arr.length = " + arr.length);
900 ok(tmp === 4, "pop() = " + tmp);
901 tmp = arr.pop();
902 ok(arr.length === 0, "arr.length = " + arr.length);
903 ok(tmp === 3, "pop() = " + tmp);
904 for(tmp in arr)
905 ok(false, "not deleted " + tmp);
906 tmp = arr.pop();
907 ok(arr.length === 0, "arr.length = " + arr.length);
908 ok(tmp === undefined, "tmp = " + tmp);
909 arr = new Object();
910 arr.pop = Array.prototype.pop;
911 tmp = arr.pop();
912 ok(arr.length === 0, "arr.length = " + arr.length);
913 ok(tmp === undefined, "tmp = " + tmp);
914 arr = [,,,,,];
915 tmp = arr.pop();
916 ok(arr.length === 5, "arr.length = " + arr.length);
917 ok(tmp === undefined, "tmp = " + tmp);
918 tmp = [1,2,,,].pop();
919 ok(tmp === undefined, "tmp = " + tmp);
920
921 function PseudoArray() {
922 this[0] = 0;
923 }
924 PseudoArray.prototype = {length: 1};
925 arr = new PseudoArray();
926 Array.prototype.push.call(arr, 2);
927 ok(arr.propertyIsEnumerable("length"), "arr.length is not enumerable");
928
929 arr = [1,2,null,false,undefined,,"a"];
930
931 tmp = arr.join();
932 ok(tmp === "1,2,,false,,,a", "arr.join() = " + tmp);
933 tmp = arr.join(";");
934 ok(tmp === "1;2;;false;;;a", "arr.join(';') = " + tmp);
935 tmp = arr.join(";","test");
936 ok(tmp === "1;2;;false;;;a", "arr.join(';') = " + tmp);
937 tmp = arr.join("");
938 ok(tmp === "12falsea", "arr.join('') = " + tmp);
939
940 tmp = arr.toString();
941 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
942 tmp = arr.toString("test");
943 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
944
945 arr = ["a", "b"];
946
947 tmp = arr.join(String.fromCharCode(0));
948 ok(tmp === "a" + String.fromCharCode(0) + "b", "arr.join(String.fromCharCode(0)) = " + tmp);
949
950 arr = new Object();
951 arr.length = 3;
952 arr[0] = "aa";
953 arr[2] = 2;
954 arr[7] = 3;
955 arr.join = Array.prototype.join;
956 tmp = arr.join(",");
957 ok(arr.length === 3, "arr.length = " + arr.length);
958 ok(tmp === "aa,,2", "tmp = " + tmp);
959
960 arr = [5,true,2,-1,3,false,"2.5"];
961 tmp = arr.sort(function(x,y) { return y-x; });
962 ok(tmp === arr, "tmp !== arr");
963 tmp = [5,3,"2.5",2,true,false,-1];
964 for(var i=0; i < arr.length; i++)
965 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
966
967 arr = [5,false,2,0,"abc",3,"a",-1];
968 tmp = arr.sort();
969 ok(tmp === arr, "tmp !== arr");
970 tmp = [-1,0,2,3,5,"a","abc",false];
971 for(var i=0; i < arr.length; i++)
972 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
973
974 arr = ["a", "b", "ab"];
975 tmp = ["a", "ab", "b"];
976 ok(arr.sort() === arr, "arr.sort() !== arr");
977 for(var i=0; i < arr.length; i++)
978 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
979
980 arr = new Object();
981 arr.length = 3;
982 arr[0] = 1;
983 arr[2] = "aa";
984 arr.sort = Array.prototype.sort;
985 tmp = arr.sort();
986 ok(arr === tmp, "tmp !== arr");
987 ok(arr[0]===1 && arr[1]==="aa" && arr[2]===undefined, "arr is sorted incorrectly");
988
989 tmp = [["bb","aa"],["ab","aa"]].sort().toString();
990 ok(tmp === "ab,aa,bb,aa", "sort() = " + tmp);
991
992 tmp = [["bb","aa"],"ab"].sort().toString();
993 ok(tmp === "ab,bb,aa", "sort() = " + tmp);
994
995 tmp = [["bb","aa"],"cc"].sort().toString();
996 ok(tmp === "bb,aa,cc", "sort() = " + tmp);
997
998 tmp = [2,"1"].sort().toString();
999 ok(tmp === "1,2", "sort() = " + tmp);
1000
1001 tmp = ["2",1].sort().toString();
1002 ok(tmp === "1,2", "sort() = " + tmp);
1003
1004 tmp = [,,0,"z"].sort().toString();
1005 ok(tmp === "0,z,,", "sort() = " + tmp);
1006
1007 tmp = ["a,b",["a","a"],["a","c"]].sort().toString();
1008 ok(tmp === "a,a,a,b,a,c", "sort() = " + tmp);
1009
1010 arr = ["1", "2", "3"];
1011 arr.length = 1;
1012 ok(arr.length === 1, "arr.length = " + arr.length);
1013 arr.length = 3;
1014 ok(arr.length === 3, "arr.length = " + arr.length);
1015 ok(arr.toString() === "1,,", "arr.toString() = " + arr.toString());
1016
1017 arr = Array("a","b","c");
1018 ok(arr.toString() === "a,b,c", "arr.toString() = " + arr.toString());
1019
1020 ok(arr.valueOf === Object.prototype.valueOf, "arr.valueOf !== Object.prototype.valueOf");
1021 ok(arr === arr.valueOf(), "arr !== arr.valueOf");
1022
1023 arr = [1,2,3];
1024 tmp = arr.reverse();
1025 ok(tmp === arr, "tmp !== arr");
1026 ok(arr.length === 3, "arr.length = " + arr.length);
1027 ok(arr.toString() === "3,2,1", "arr.toString() = " + arr.toString());
1028
1029 arr = [];
1030 arr[3] = 5;
1031 arr[5] = 1;
1032 tmp = arr.reverse();
1033 ok(tmp === arr, "tmp !== arr");
1034 ok(arr.length === 6, "arr.length = " + arr.length);
1035 ok(arr.toString() === "1,,5,,,", "arr.toString() = " + arr.toString());
1036
1037 arr = new Object();
1038 arr.length = 3;
1039 arr[0] = "aa";
1040 arr[2] = 2;
1041 arr[7] = 3;
1042 arr.reverse = Array.prototype.reverse;
1043 tmp = arr.reverse();
1044 ok(tmp === arr, "tmp !== arr");
1045 ok(arr.length === 3, "arr.length = " + arr.length);
1046 ok(arr[0] === 2 && arr[1] === undefined && arr[2] === "aa", "unexpected array");
1047
1048 arr = [1,2,3];
1049 tmp = arr.unshift(0);
1050 ok(tmp === (invokeVersion < 2 ? undefined : 4), "[1,2,3].unshift(0) returned " +tmp);
1051 ok(arr.length === 4, "arr.length = " + arr.length);
1052 ok(arr.toString() === "0,1,2,3", "arr.toString() = " + arr.toString());
1053
1054 arr = new Array(3);
1055 arr[0] = 1;
1056 arr[2] = 3;
1057 tmp = arr.unshift(-1,0);
1058 ok(tmp === (invokeVersion < 2 ? undefined : 5), "unshift returned " +tmp);
1059 ok(arr.length === 5, "arr.length = " + arr.length);
1060 ok(arr.toString() === "-1,0,1,,3", "arr.toString() = " + arr.toString());
1061
1062 arr = [1,2,3];
1063 tmp = arr.unshift();
1064 ok(tmp === (invokeVersion < 2 ? undefined : 3), "unshift returned " +tmp);
1065 ok(arr.length === 3, "arr.length = " + arr.length);
1066 ok(arr.toString() === "1,2,3", "arr.toString() = " + arr.toString());
1067
1068 arr = new Object();
1069 arr.length = 2;
1070 arr[0] = 1;
1071 arr[1] = 2;
1072 tmp = Array.prototype.unshift.call(arr, 0);
1073 ok(tmp === (invokeVersion < 2 ? undefined : 3), "unshift returned " +tmp);
1074 ok(arr.length === 3, "arr.length = " + arr.length);
1075 ok(arr[0] === 0 && arr[1] === 1 && arr[2] === 2, "unexpected array");
1076
1077 arr = [1,2,,4];
1078 tmp = arr.shift();
1079 ok(tmp === 1, "[1,2,,4].shift() = " + tmp);
1080 ok(arr.toString() === "2,,4", "arr = " + arr.toString());
1081
1082 arr = [];
1083 tmp = arr.shift();
1084 ok(tmp === undefined, "[].shift() = " + tmp);
1085 ok(arr.toString() === "", "arr = " + arr.toString());
1086
1087 arr = [1,2,,4];
1088 tmp = arr.shift(2);
1089 ok(tmp === 1, "[1,2,,4].shift(2) = " + tmp);
1090 ok(arr.toString() === "2,,4", "arr = " + arr.toString());
1091
1092 arr = [1,];
1093 tmp = arr.shift();
1094 ok(tmp === 1, "[1,].shift() = " + tmp);
1095 ok(arr.toString() === "", "arr = " + arr.toString());
1096
1097 obj = new Object();
1098 obj[0] = "test";
1099 obj[2] = 3;
1100 obj.length = 3;
1101 tmp = Array.prototype.shift.call(obj);
1102 ok(tmp === "test", "obj.shift() = " + tmp);
1103 ok(obj.length == 2, "obj.length = " + obj.length);
1104 ok(obj[1] === 3, "obj[1] = " + obj[1]);
1105
1106 var num = new Number(6);
1107 arr = [0,1,2];
1108 tmp = arr.concat(3, [4,5], num);
1109 ok(tmp !== arr, "tmp === arr");
1110 for(var i=0; i<6; i++)
1111 ok(tmp[i] === i, "tmp[" + i + "] = " + tmp[i]);
1112 ok(tmp[6] === num, "tmp[6] !== num");
1113 ok(tmp.length === 7, "tmp.length = " + tmp.length);
1114
1115 arr = [].concat();
1116 ok(arr.length === 0, "arr.length = " + arr.length);
1117
1118 arr = [1,];
1119 tmp = arr.concat([2]);
1120 ok(tmp.length === 3, "tmp.length = " + tmp.length);
1121 ok(tmp[1] === undefined, "tmp[1] = " + tmp[1]);
1122
1123 arr = [1,false,'a',null,undefined,'a'];
1124 ok(arr.slice(0,6).toString() === "1,false,a,,,a", "arr.slice(0,6).toString() = " + arr.slice(0,6));
1125 ok(arr.slice(0,6).length === 6, "arr.slice(0,6).length = " + arr.slice(0,6).length);
1126 ok(arr.slice().toString() === "1,false,a,,,a", "arr.slice().toString() = " + arr.slice());
1127 ok(arr.slice("abc").toString() === "1,false,a,,,a", "arr.slice(\"abc\").toString() = " + arr.slice("abc"));
1128 ok(arr.slice(3,8).toString() === ",,a", "arr.slice(3,8).toString() = " + arr.slice(3,8));
1129 ok(arr.slice(3,8).length === 3, "arr.slice(3,8).length = " + arr.slice(3,8).length);
1130 ok(arr.slice(1).toString() === "false,a,,,a", "arr.slice(1).toString() = " + arr.slice(1));
1131 ok(arr.slice(-2).toString() === ",a", "arr.slice(-2).toString() = " + arr.slice(-2));
1132 ok(arr.slice(3,1).toString() === "", "arr.slice(3,1).toString() = " + arr.slice(3,1));
1133 tmp = arr.slice(0,6);
1134 for(var i=0; i < arr.length; i++)
1135 ok(arr[i] === tmp[i], "arr[" + i + "] = " + arr[i] + " expected " + tmp[i]);
1136 arr[12] = 2;
1137 ok(arr.slice(5).toString() === "a,,,,,,,2", "arr.slice(5).toString() = " + arr.slice(5).toString());
1138 ok(arr.slice(5).length === 8, "arr.slice(5).length = " + arr.slice(5).length);
1139
1140 arr = [1,2,3,4,5];
1141 tmp = arr.splice(2,2);
1142 ok(tmp.toString() == "3,4", "arr.splice(2,2) returned " + tmp.toString());
1143 ok(arr.toString() == "1,2,5", "arr.splice(2,2) is " + arr.toString());
1144
1145 arr = [1,2,3,4,5];
1146 tmp = arr.splice(2,2,"a");
1147 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a') returned " + tmp.toString());
1148 ok(arr.toString() == "1,2,a,5", "arr.splice(2,2,'a') is " + arr.toString());
1149
1150 arr = [1,2,3,4,5];
1151 tmp = arr.splice(2,2,'a','b','c');
1152 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a','b','c') returned " + tmp.toString());
1153 ok(arr.toString() == "1,2,a,b,c,5", "arr.splice(2,2,'a','b','c') is " + arr.toString());
1154
1155 arr = [1,2,3,4,];
1156 tmp = arr.splice(2,2,'a','b','c');
1157 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a','b','c') returned " + tmp.toString());
1158 ok(arr.toString() == "1,2,a,b,c,", "arr.splice(2,2,'a','b','c') is " + arr.toString());
1159
1160 arr = [1,2,3,4,];
1161 arr.splice(2,2,'a','b','c');
1162 ok(arr.toString() == "1,2,a,b,c,", "arr.splice(2,2,'a','b','c') is " + arr.toString());
1163
1164 arr = [1,2,3,4,5];
1165 tmp = arr.splice(2,2,'a','b');
1166 ok(tmp.toString() == "3,4", "arr.splice(2,2,'a','b') returned " + tmp.toString());
1167 ok(arr.toString() == "1,2,a,b,5", "arr.splice(2,2,'a','b') is " + arr.toString());
1168
1169 arr = [1,2,3,4,5];
1170 tmp = arr.splice(-1,2);
1171 ok(tmp.toString() == "5", "arr.splice(-1,2) returned " + tmp.toString());
1172 ok(arr.toString() == "1,2,3,4", "arr.splice(-1,2) is " + arr.toString());
1173
1174 arr = [1,2,3,4,5];
1175 tmp = arr.splice(-10,3);
1176 ok(tmp.toString() == "1,2,3", "arr.splice(-10,3) returned " + tmp.toString());
1177 ok(arr.toString() == "4,5", "arr.splice(-10,3) is " + arr.toString());
1178
1179 arr = [1,2,3,4,5];
1180 tmp = arr.splice(-10,100);
1181 ok(tmp.toString() == "1,2,3,4,5", "arr.splice(-10,100) returned " + tmp.toString());
1182 ok(arr.toString() == "", "arr.splice(-10,100) is " + arr.toString());
1183
1184 arr = [1,2,3,4,5];
1185 tmp = arr.splice(2,-1);
1186 ok(tmp.toString() == "", "arr.splice(2,-1) returned " + tmp.toString());
1187 ok(arr.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr.toString());
1188
1189 arr = [1,2,3,4,5];
1190 tmp = arr.splice(2);
1191 ok(tmp.toString() == "", "arr.splice(2,-1) returned " + tmp.toString());
1192 ok(arr.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr.toString());
1193
1194 arr = [1,2,3,4,5];
1195 tmp = arr.splice();
1196 ok(tmp.toString() == "", "arr.splice(2,-1) returned " + tmp.toString());
1197 ok(arr.toString() == "1,2,3,4,5", "arr.splice(2,-1) is " + arr.toString());
1198
1199 arr = [1,2,3,4,5];
1200 tmp = arr.splice(bigInt);
1201 ok(tmp.toString() == "", "arr.splice(bigInt) returned " + tmp.toString());
1202 ok(arr.toString() == "1,2,3,4,5", "arr.splice(bigInt) is " + arr.toString());
1203
1204 arr = [1,2,3,4,5];
1205 tmp = arr.splice(-bigInt);
1206 ok(tmp.toString() == "", "arr.splice(-bigInt) returned " + tmp.toString());
1207 ok(arr.toString() == "1,2,3,4,5", "arr.splice(-bigInt) is " + arr.toString());
1208
1209 if(invokeVersion >= 2) {
1210 arr = [1,2,3,4,5];
1211 tmp = arr.splice(2, bigInt);
1212 ok(tmp.toString() == "3,4,5", "arr.splice(2, bigInt) returned " + tmp.toString());
1213 ok(arr.toString() == "1,2", "arr.splice(2, bigInt) is " + arr.toString());
1214 }
1215
1216 arr = [1,2,3,4,5];
1217 tmp = arr.splice(2, -bigInt);
1218 ok(tmp.toString() == "", "arr.splice(2, -bigInt) returned " + tmp.toString());
1219 ok(arr.toString() == "1,2,3,4,5", "arr.splice(2, -bigInt) is " + arr.toString());
1220
1221 obj = new Object();
1222 obj.length = 3;
1223 obj[0] = 1;
1224 obj[1] = 2;
1225 obj[2] = 3;
1226 tmp = Array.prototype.splice.call(obj, 1, 1, 'a', 'b');
1227 ok(tmp.toString() === "2", "obj.splice returned " + tmp);
1228 ok(obj.length === 4, "obj.length = " + obj.length);
1229 ok(obj[0] === 1, "obj[0] = " + obj[0]);
1230 ok(obj[1] === 'a', "obj[1] = " + obj[1]);
1231 ok(obj[2] === 'b', "obj[2] = " + obj[2]);
1232 ok(obj[3] === 3, "obj[3] = " + obj[3]);
1233
1234 obj = new Object();
1235 obj.length = 3;
1236 obj[0] = 1;
1237 obj[1] = 2;
1238 obj[2] = 3;
1239 tmp = Array.prototype.slice.call(obj, 1, 2);
1240 ok(tmp.length === 1, "tmp.length = " + tmp.length);
1241 ok(tmp[0] === 2, "tmp[0] = " + tmp[0]);
1242
1243 tmp = (new Number(2)).toString();
1244 ok(tmp === "2", "num(2).toString = " + tmp);
1245 tmp = (new Number()).toString();
1246 ok(tmp === "0", "num().toString = " + tmp);
1247 tmp = (new Number(5.5)).toString(2);
1248 ok(tmp === "101.1", "num(5.5).toString(2) = " + tmp);
1249
1250 tmp = (new Number(3)).toFixed(3);
1251 ok(tmp === "3.000", "num(3).toFixed(3) = " + tmp);
1252 tmp = (new Number(3)).toFixed();
1253 ok(tmp === "3", "Number(3).toFixed() = " + tmp);
1254 tmp = (new Number(0)).toFixed();
1255 ok(tmp === "0", "Number(0).toFixed() = " + tmp);
1256 tmp = (new Number(0)).toFixed(1);
1257 ok(tmp === "0.0", "Number(0).toFixed(1) = " + tmp);
1258 tmp = (new Number(0)).toFixed(2);
1259 ok(tmp === "0.00", "Number(0).toFixed(2) = " + tmp);
1260 tmp = (new Number(1.76)).toFixed(1);
1261 ok(tmp === "1.8", "num(1.76).toFixed(1) = " + tmp);
1262 tmp = (new Number(7.92)).toFixed(5);
1263 ok(tmp === "7.92000", "num(7.92).toFixed(5) = " + tmp);
1264 tmp = (new Number(2.88)).toFixed();
1265 ok(tmp === "3", "num(2.88).toFixed = " + tmp);
1266 tmp = (new Number(-2.5)).toFixed();
1267 ok(tmp === "-3", "num(-2.5).toFixed = " + tmp);
1268 tmp = (new Number(1000000000000000128)).toFixed(0);
1269 //todo_wine ok(tmp === "1000000000000000100", "num(1000000000000000128) = " + tmp);
1270 tmp = (new Number(3.14).toFixed(NaN));
1271 ok(tmp === "3", "num(3.14).toFixed = " + tmp);
1272 tmp = (new Number(0.95).toFixed(1));
1273 ok(tmp === "1.0", "num(0.95).toFixed(1) = " + tmp);
1274 tmp = (new Number(1e900)).toFixed(0);
1275 ok(tmp === "Infinity", "num(1000000000000000128) = " + tmp);
1276 tmp = (new Number(0.12345678901234567890123)).toFixed(20);
1277 ok(tmp === "0.12345678901234568000", "num(0.12345678901234567890123) = " + tmp);
1278
1279 tmp = (new Number(2)).toExponential(3);
1280 ok(tmp === "2.000e+0", "num(2).toExponential(3) = " + tmp);
1281 tmp = (new Number(1.17e-32)).toExponential(20);
1282 ok(tmp === "1.17000000000000000000e-32", "num(1.17e-32).toExponential(20) = " + tmp);
1283 tmp = (new Number(0)).toExponential(7);
1284 ok(tmp === "0.0000000e+0", "num(0).toExponential(7) = " + tmp);
1285 tmp = (new Number(0)).toExponential(0);
1286 ok(tmp === "0e+0", "num(0).toExponential() = " + tmp);
1287 tmp = (new Number(-13.7567)).toExponential();
1288 ok(tmp === "-1.37567e+1", "num(-13.7567).toExponential() = " + tmp);
1289 tmp = (new Number(-32.1)).toExponential();
1290 ok(tmp === "-3.21e+1", "num(-32.1).toExponential() = " + tmp);
1291 tmp = (new Number(4723.4235)).toExponential();
1292 ok(tmp === "4.7234235e+3", "num(4723.4235).toExponential() = " + tmp);
1293
1294 tmp = (new Number(5)).toPrecision(12);
1295 ok(tmp == "5.00000000000", "num(5).toPrecision(12) = " + tmp);
1296 tmp = (new Number(7.73)).toPrecision(7);
1297 ok(tmp == "7.730000", "num(7.73).toPrecision(7) = " + tmp);
1298 tmp = (new Number(-127547.47472)).toPrecision(17);
1299 ok(tmp == "-127547.47472000000", "num(-127547.47472).toPrecision(17) = " + tmp);
1300 tmp = (new Number(0)).toPrecision(3);
1301 ok(tmp == "0.00", "num(0).toPrecision(3) = " + tmp);
1302 tmp = (new Number(42345.52342465464562334)).toPrecision(15);
1303 ok(tmp == "42345.5234246546", "num(42345.52342465464562334).toPrecision(15) = " + tmp);
1304 tmp = (new Number(1.182e30)).toPrecision(5);
1305 ok(tmp == "1.1820e+30", "num(1.182e30)).toPrecision(5) = " + tmp);
1306 tmp = (new Number(1.123)).toPrecision();
1307 ok(tmp == "1.123", "num(1.123).toPrecision() = " + tmp);
1308
1309 ok(Number() === 0, "Number() = " + Number());
1310 ok(Number(false) === 0, "Number(false) = " + Number(false));
1311 ok(Number("43") === 43, "Number('43') = " + Number("43"));
1312
1313 tmp = (new Number(1)).valueOf();
1314 ok(tmp === 1, "(new Number(1)).valueOf = " + tmp);
1315 tmp = (new Number(1,2)).valueOf();
1316 ok(tmp === 1, "(new Number(1,2)).valueOf = " + tmp);
1317 tmp = (new Number()).valueOf();
1318 ok(tmp === 0, "(new Number()).valueOf = " + tmp);
1319 tmp = Number.prototype.valueOf();
1320 ok(tmp === 0, "Number.prototype.valueOf = " + tmp);
1321
1322 function equals(val, base) {
1323 var i;
1324 var num = 0;
1325 var str = val.toString(base);
1326
1327 for(i=0; i<str.length; i++) {
1328 if(str.substring(i, i+1) == '(') break;
1329 if(str.substring(i, i+1) == '.') break;
1330 num = num*base + parseInt(str.substring(i, i+1));
1331 }
1332
1333 if(str.substring(i, i+1) == '.') {
1334 var mult = base;
1335 for(i++; i<str.length; i++) {
1336 if(str.substring(i, i+1) == '(') break;
1337 num += parseInt(str.substring(i, i+1))/mult;
1338 mult *= base;
1339 }
1340 }
1341
1342 if(str.substring(i, i+1) == '(') {
1343 exp = parseInt(str.substring(i+2));
1344 num *= Math.pow(base, exp);
1345 }
1346
1347 ok(num>val-val/1000 && num<val+val/1000, "equals: num = " + num);
1348 }
1349
1350 ok((10).toString(11) === "a", "(10).toString(11) = " + (10).toString(11));
1351 ok((213213433).toString(17) === "8e2ddcb", "(213213433).toString(17) = " + (213213433).toString(17));
1352 ok((-3254343).toString(33) === "-2oicf", "(-3254343).toString(33) = " + (-3254343).toString(33));
1353 ok((NaN).toString(12) === "NaN", "(NaN).toString(11) = " + (NaN).toString(11));
1354 ok((Infinity).toString(13) === "Infinity", "(Infinity).toString(11) = " + (Infinity).toString(11));
1355 for(i=2; i<10; i++) {
1356 equals(1.123, i);
1357 equals(2305843009200000000, i);
1358 equals(5.123, i);
1359 equals(21711, i);
1360 equals(1024*1024*1024*1024*1024*1024*1.9999, i);
1361 equals(748382, i);
1362 equals(0.6, i);
1363 equals(4.65661287308e-10, i);
1364 ok((0).toString(i) === "0", "(0).toString("+i+") = " + (0).toString(i));
1365 }
1366
1367 ok(parseFloat('123') === 123, "parseFloat('123') = " + parseFloat('123'));
1368 ok(parseFloat('-13.7') === -13.7, "parseFloat('-13.7') = " + parseFloat('-13.7'));
1369 ok(parseFloat('-0.01e-2') === -0.01e-2, "parseFloat('-0.01e-2') = " + parseFloat('-0.01e-2'));
1370 ok(parseFloat('-12e+5') === -12e+5, "parseFloat('-12e+5') = " + parseFloat('-12e+5'));
1371 ok(parseFloat('1E5 not parsed') === 1E5, "parseFloat('1E5 not parsed') = " + parseFloat('1E5 not parsed'));
1372 ok(isNaN(parseFloat('not a number')), "parseFloat('not a number') is not NaN");
1373 ok(parseFloat('+13.2e-3') === 13.2e-3, "parseFloat('+13.2e-3') = " + parseFloat('+13.2e-3'));
1374 ok(parseFloat('.12') === 0.12, "parseFloat('.12') = " + parseFloat('.12'));
1375 ok(parseFloat('1e') === 1, "parseFloat('1e') = " + parseFloat('1e'));
1376
1377 tmp = Math.min(1);
1378 ok(tmp === 1, "Math.min(1) = " + tmp);
1379
1380 tmp = Math.min(1, false);
1381 ok(tmp === 0, "Math.min(1, false) = " + tmp);
1382
1383 tmp = Math.min();
1384 ok(tmp === Infinity, "Math.min() = " + tmp);
1385
1386 tmp = Math.min(1, NaN, -Infinity, false);
1387 ok(isNaN(tmp), "Math.min(1, NaN, -Infinity, false) is not NaN");
1388
1389 tmp = Math.min(1, false, true, null, -3);
1390 ok(tmp === -3, "Math.min(1, false, true, null, -3) = " + tmp);
1391
1392 tmp = Math.max(1);
1393 ok(tmp === 1, "Math.max(1) = " + tmp);
1394
1395 tmp = Math.max(true, 0);
1396 ok(tmp === 1, "Math.max(true, 0) = " + tmp);
1397
1398 tmp = Math.max(-2, false, true, null, 1);
1399 ok(tmp === 1, "Math.max(-2, false, true, null, 1) = " + tmp);
1400
1401 tmp = Math.max();
1402 ok(tmp === -Infinity, "Math.max() = " + tmp);
1403
1404 tmp = Math.max(true, NaN, 0);
1405 ok(isNaN(tmp), "Math.max(true, NaN, 0) is not NaN");
1406
1407 tmp = Math.round(0.5);
1408 ok(tmp === 1, "Math.round(0.5) = " + tmp);
1409
1410 tmp = Math.round(-0.5);
1411 ok(tmp === 0, "Math.round(-0.5) = " + tmp);
1412
1413 tmp = Math.round(1.1);
1414 ok(tmp === 1, "Math.round(1.1) = " + tmp);
1415
1416 tmp = Math.round(true);
1417 ok(tmp === 1, "Math.round(true) = " + tmp);
1418
1419 tmp = Math.round(1.1, 3, 4);
1420 ok(tmp === 1, "Math.round(1.1, 3, 4) = " + tmp);
1421
1422 tmp = Math.round();
1423 ok(isNaN(tmp), "Math.round() is not NaN");
1424
1425 tmp = Math.ceil(0.5);
1426 ok(tmp === 1, "Math.ceil(0.5) = " + tmp);
1427
1428 tmp = Math.ceil(-0.5);
1429 ok(tmp === 0, "Math.ceil(-0.5) = " + tmp);
1430
1431 tmp = Math.ceil(1.1);
1432 ok(tmp === 2, "Math.round(1.1) = " + tmp);
1433
1434 tmp = Math.ceil(true);
1435 ok(tmp === 1, "Math.ceil(true) = " + tmp);
1436
1437 tmp = Math.ceil(1.1, 3, 4);
1438 ok(tmp === 2, "Math.ceil(1.1, 3, 4) = " + tmp);
1439
1440 tmp = Math.ceil();
1441 ok(isNaN(tmp), "ceil() is not NaN");
1442
1443 tmp = Math.floor(0.5);
1444 ok(tmp === 0, "Math.floor(0.5) = " + tmp);
1445
1446 tmp = Math.floor(-0.5);
1447 ok(tmp === -1, "Math.floor(-0.5) = " + tmp);
1448
1449 tmp = Math.floor(1.1);
1450 ok(tmp === 1, "Math.floor(1.1) = " + tmp);
1451
1452 tmp = Math.floor(true);
1453 ok(tmp === 1, "Math.floor(true) = " + tmp);
1454
1455 tmp = Math.floor(1.1, 3, 4);
1456 ok(tmp === 1, "Math.floor(1.1, 3, 4) = " + tmp);
1457
1458 tmp = Math.floor();
1459 ok(isNaN(tmp), "floor is not NaN");
1460
1461 tmp = Math.abs(3);
1462 ok(tmp === 3, "Math.abs(3) = " + tmp);
1463
1464 tmp = Math.abs(-3);
1465 ok(tmp === 3, "Math.abs(-3) = " + tmp);
1466
1467 tmp = Math.abs(true);
1468 ok(tmp === 1, "Math.abs(true) = " + tmp);
1469
1470 tmp = Math.abs();
1471 ok(isNaN(tmp), "Math.abs() is not NaN");
1472
1473 tmp = Math.abs(NaN);
1474 ok(isNaN(tmp), "Math.abs() is not NaN");
1475
1476 tmp = Math.abs(-Infinity);
1477 ok(tmp === Infinity, "Math.abs(-Infinite) = " + tmp);
1478
1479 tmp = Math.abs(-3, 2);
1480 ok(tmp === 3, "Math.abs(-3, 2) = " + tmp);
1481
1482 tmp = Math.cos(0);
1483 ok(tmp === 1, "Math.cos(0) = " + tmp);
1484
1485 tmp = Math.cos(Math.PI/2);
1486 ok(Math.floor(tmp*100) === 0, "Math.cos(Math.PI/2) = " + tmp);
1487
1488 tmp = Math.cos(-Math.PI/2);
1489 ok(Math.floor(tmp*100) === 0, "Math.cos(-Math.PI/2) = " + tmp);
1490
1491 tmp = Math.cos(Math.PI/3, 2);
1492 ok(Math.floor(tmp*100) === 50, "Math.cos(Math.PI/3, 2) = " + tmp);
1493
1494 tmp = Math.cos(true);
1495 ok(Math.floor(tmp*100) === 54, "Math.cos(true) = " + tmp);
1496
1497 tmp = Math.cos(false);
1498 ok(tmp === 1, "Math.cos(false) = " + tmp);
1499
1500 tmp = Math.cos();
1501 ok(isNaN(tmp), "Math.cos() is not NaN");
1502
1503 tmp = Math.cos(NaN);
1504 ok(isNaN(tmp), "Math.cos(NaN) is not NaN");
1505
1506 tmp = Math.cos(Infinity);
1507 ok(isNaN(tmp), "Math.cos(Infinity) is not NaN");
1508
1509 tmp = Math.cos(-Infinity);
1510 ok(isNaN(tmp), "Math.cos(-Infinity) is not NaN");
1511
1512 tmp = Math.pow(2, 2);
1513 ok(tmp === 4, "Math.pow(2, 2) = " + tmp);
1514
1515 tmp = Math.pow(4, 0.5);
1516 ok(tmp === 2, "Math.pow(2, 2) = " + tmp);
1517
1518 tmp = Math.pow(2, 2, 3);
1519 ok(tmp === 4, "Math.pow(2, 2, 3) = " + tmp);
1520
1521 tmp = Math.pow(2);
1522 ok(isNaN(tmp), "Math.pow(2) is not NaN");
1523
1524 tmp = Math.pow();
1525 ok(isNaN(tmp), "Math.pow() is not NaN");
1526
1527 tmp = Math.random();
1528 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
1529 ok(0 <= tmp && tmp <= 1, "Math.random() = " + tmp);
1530
1531 tmp = Math.random(100);
1532 ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp));
1533 ok(0 <= tmp && tmp <= 1, "Math.random(100) = " + tmp);
1534
1535 tmp = Math.acos(0);
1536 ok(Math.floor(tmp*100) === 157, "Math.acos(0) = " + tmp);
1537
1538 tmp = Math.acos(1);
1539 ok(Math.floor(tmp*100) === 0, "Math.acos(1) = " + tmp);
1540
1541 tmp = Math.acos(-1);
1542 ok(Math.floor(tmp*100) === 314, "Math.acos(-1) = " + tmp);
1543
1544 tmp = Math.acos(Math.PI/4, 2);
1545 ok(Math.floor(tmp*100) === 66, "Math.acos(Math.PI/4, 2) = " + tmp);
1546
1547 tmp = Math.acos(true);
1548 ok(Math.floor(tmp*100) === 0, "Math.acos(true) = " + tmp);
1549
1550 tmp = Math.acos(false);
1551 ok(Math.floor(tmp*100) === 157, "Math.acos(false) = " + tmp);
1552
1553 tmp = Math.acos(1.1);
1554 ok(isNaN(tmp), "Math.acos(1.1) is not NaN");
1555
1556 tmp = Math.acos();
1557 ok(isNaN(tmp), "Math.acos() is not NaN");
1558
1559 tmp = Math.acos(NaN);
1560 ok(isNaN(tmp), "Math.acos(NaN) is not NaN");
1561
1562 tmp = Math.acos(Infinity);
1563 ok(isNaN(tmp), "Math.acos(Infinity) is not NaN");
1564
1565 tmp = Math.acos(-Infinity);
1566 ok(isNaN(tmp), "Math.acos(-Infinity) is not NaN");
1567
1568 tmp = Math.asin(0);
1569 ok(Math.floor(tmp*100) === 0, "Math.asin(0) = " + tmp);
1570
1571 tmp = Math.asin(1);
1572 ok(Math.floor(tmp*100) === 157, "Math.asin(1) = " + tmp);
1573
1574 tmp = Math.asin(-1);
1575 ok(Math.floor(tmp*100) === -158, "Math.asin(-1) = " + tmp);
1576
1577 tmp = Math.asin(Math.PI/4, 2);
1578 ok(Math.floor(tmp*100) === 90, "Math.asin(Math.PI/4, 2) = " + tmp);
1579
1580 tmp = Math.asin(true);
1581 ok(Math.floor(tmp*100) === 157, "Math.asin(true) = " + tmp);
1582
1583 tmp = Math.asin(false);
1584 ok(Math.floor(tmp*100) === 0, "Math.asin(false) = " + tmp);
1585
1586 tmp = Math.asin(1.1);
1587 ok(isNaN(tmp), "Math.asin(1.1) is not NaN");
1588
1589 tmp = Math.asin();
1590 ok(isNaN(tmp), "Math.asin() is not NaN");
1591
1592 tmp = Math.asin(NaN);
1593 ok(isNaN(tmp), "Math.asin(NaN) is not NaN");
1594
1595 tmp = Math.asin(Infinity);
1596 ok(isNaN(tmp), "Math.asin(Infinity) is not NaN");
1597
1598 tmp = Math.asin(-Infinity);
1599 ok(isNaN(tmp), "Math.asin(-Infinity) is not NaN");
1600
1601 tmp = Math.atan(0);
1602 ok(Math.floor(tmp*100) === 0, "Math.atan(0) = " + tmp);
1603
1604 tmp = Math.atan(1);
1605 ok(Math.floor(tmp*100) === 78, "Math.atan(1) = " + tmp);
1606
1607 tmp = Math.atan(-1);
1608 ok(Math.floor(tmp*100) === -79, "Math.atan(-1) = " + tmp);
1609
1610 tmp = Math.atan(true);
1611 ok(Math.floor(tmp*100) === 78, "Math.atan(true) = " + tmp);
1612
1613 tmp = Math.atan(false);
1614 ok(Math.floor(tmp*100) === 0, "Math.atan(false) = " + tmp);
1615
1616 tmp = Math.atan();
1617 ok(isNaN(tmp), "Math.atan() is not NaN");
1618
1619 tmp = Math.atan(NaN);
1620 ok(isNaN(tmp), "Math.atan(NaN) is not NaN");
1621
1622 tmp = Math.atan(Infinity);
1623 ok(Math.floor(tmp*100) === 157, "Math.atan(Infinity) = " + tmp);
1624
1625 tmp = Math.atan(-Infinity);
1626 ok(Math.floor(tmp*100) === -158, "Math.atan(Infinity) = " + tmp);
1627
1628 tmp = Math.atan2(0, 0);
1629 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 0) = " + tmp);
1630
1631 tmp = Math.atan2(0, 1);
1632 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 1) = " + tmp);
1633
1634 tmp = Math.atan2(0, Infinity);
1635 ok(Math.floor(tmp*100) === 0, "Math.atan2(0, Infinity) = " + tmp);
1636
1637 tmp = Math.atan2(0, -1);
1638 ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -1) = " + tmp);
1639
1640 tmp = Math.atan2(0, -Infinity);
1641 ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -Infinity) = " + tmp);
1642
1643 tmp = Math.atan2(1, 0);
1644 ok(Math.floor(tmp*100) === 157, "Math.atan2(1, 0) = " + tmp);
1645
1646 tmp = Math.atan2(Infinity, 0);
1647 ok(Math.floor(tmp*100) === 157, "Math.atan2(Infinity, 0) = " + tmp);
1648
1649 tmp = Math.atan2(-1, 0);
1650 ok(Math.floor(tmp*100) === -158, "Math.atan2(-1, 0) = " + tmp);
1651
1652 tmp = Math.atan2(-Infinity, 0);
1653 ok(Math.floor(tmp*100) === -158, "Math.atan2(-Infinity, 0) = " + tmp);
1654
1655 tmp = Math.atan2(1, 1);
1656 ok(Math.floor(tmp*100) === 78, "Math.atan2(1, 1) = " + tmp);
1657
1658 tmp = Math.atan2(-1, -1);
1659 ok(Math.floor(tmp*100) === -236, "Math.atan2(-1, -1) = " + tmp);
1660
1661 tmp = Math.atan2(-1, 1);
1662 ok(Math.floor(tmp*100) === -79, "Math.atan2(-1, 1) = " + tmp);
1663
1664 tmp = Math.atan2(Infinity, Infinity);
1665 ok(Math.floor(tmp*100) === 78, "Math.atan2(Infinity, Infinity) = " + tmp);
1666
1667 tmp = Math.atan2(Infinity, -Infinity, 1);
1668 ok(Math.floor(tmp*100) === 235, "Math.atan2(Infinity, -Infinity, 1) = " + tmp);
1669
1670 tmp = Math.atan2();
1671 ok(isNaN(tmp), "Math.atan2() is not NaN");
1672
1673 tmp = Math.atan2(1);
1674 ok(isNaN(tmp), "Math.atan2(1) is not NaN");
1675
1676 tmp = Math.exp(0);
1677 ok(tmp === 1, "Math.exp(0) = " + tmp);
1678
1679 tmp = Math.exp(1);
1680 ok(Math.floor(tmp*100) === 271, "Math.exp(1) = " + tmp);
1681
1682 tmp = Math.exp(-1);
1683 ok(Math.floor(tmp*100) === 36, "Math.exp(-1) = " + tmp);
1684
1685 tmp = Math.exp(true);
1686 ok(Math.floor(tmp*100) === 271, "Math.exp(true) = " + tmp);
1687
1688 tmp = Math.exp(1, 1);
1689 ok(Math.floor(tmp*100) === 271, "Math.exp(1, 1) = " + tmp);
1690
1691 tmp = Math.exp();
1692 ok(isNaN(tmp), "Math.exp() is not NaN");
1693
1694 tmp = Math.exp(NaN);
1695 ok(isNaN(tmp), "Math.exp(NaN) is not NaN");
1696
1697 tmp = Math.exp(Infinity);
1698 ok(tmp === Infinity, "Math.exp(Infinity) = " + tmp);
1699
1700 tmp = Math.exp(-Infinity);
1701 ok(tmp === 0, "Math.exp(-Infinity) = " + tmp);
1702
1703 tmp = Math.log(1);
1704 ok(Math.floor(tmp*100) === 0, "Math.log(1) = " + tmp);
1705
1706 tmp = Math.log(-1);
1707 ok(isNaN(tmp), "Math.log(-1) is not NaN");
1708
1709 tmp = Math.log(true);
1710 ok(Math.floor(tmp*100) === 0, "Math.log(true) = " + tmp);
1711
1712 tmp = Math.log(1, 1);
1713 ok(Math.floor(tmp*100) === 0, "Math.log(1, 1) = " + tmp);
1714
1715 tmp = Math.log();
1716 ok(isNaN(tmp), "Math.log() is not NaN");
1717
1718 tmp = Math.log(NaN);
1719 ok(isNaN(tmp), "Math.log(NaN) is not NaN");
1720
1721 tmp = Math.log(Infinity);
1722 ok(tmp === Infinity, "Math.log(Infinity) = " + tmp);
1723
1724 tmp = Math.log(-Infinity);
1725 ok(isNaN(tmp), "Math.log(-Infinity) is not NaN");
1726
1727 tmp = Math.sin(0);
1728 ok(tmp === 0, "Math.sin(0) = " + tmp);
1729
1730 tmp = Math.sin(Math.PI/2);
1731 ok(tmp === 1, "Math.sin(Math.PI/2) = " + tmp);
1732
1733 tmp = Math.sin(-Math.PI/2);
1734 ok(tmp === -1, "Math.sin(-Math.PI/2) = " + tmp);
1735
1736 tmp = Math.sin(Math.PI/3, 2);
1737 ok(Math.floor(tmp*100) === 86, "Math.sin(Math.PI/3, 2) = " + tmp);
1738
1739 tmp = Math.sin(true);
1740 ok(Math.floor(tmp*100) === 84, "Math.sin(true) = " + tmp);
1741
1742 tmp = Math.sin(false);
1743 ok(tmp === 0, "Math.sin(false) = " + tmp);
1744
1745 tmp = Math.sin();
1746 ok(isNaN(tmp), "Math.sin() is not NaN");
1747
1748 tmp = Math.sin(NaN);
1749 ok(isNaN(tmp), "Math.sin(NaN) is not NaN");
1750
1751 tmp = Math.sin(Infinity);
1752 ok(isNaN(tmp), "Math.sin(Infinity) is not NaN");
1753
1754 tmp = Math.sin(-Infinity);
1755 ok(isNaN(tmp), "Math.sin(-Infinity) is not NaN");
1756
1757 tmp = Math.sqrt(0);
1758 ok(tmp === 0, "Math.sqrt(0) = " + tmp);
1759
1760 tmp = Math.sqrt(4);
1761 ok(tmp === 2, "Math.sqrt(4) = " + tmp);
1762
1763 tmp = Math.sqrt(-1);
1764 ok(isNaN(tmp), "Math.sqrt(-1) is not NaN");
1765
1766 tmp = Math.sqrt(2, 2);
1767 ok(Math.floor(tmp*100) === 141, "Math.sqrt(2, 2) = " + tmp);
1768
1769 tmp = Math.sqrt(true);
1770 ok(tmp === 1, "Math.sqrt(true) = " + tmp);
1771
1772 tmp = Math.sqrt(false);
1773 ok(tmp === 0, "Math.sqrt(false) = " + tmp);
1774
1775 tmp = Math.sqrt();
1776 ok(isNaN(tmp), "Math.sqrt() is not NaN");
1777
1778 tmp = Math.sqrt(NaN);
1779 ok(isNaN(tmp), "Math.sqrt(NaN) is not NaN");
1780
1781 tmp = Math.sqrt(Infinity);
1782 ok(tmp === Infinity, "Math.sqrt(Infinity) = " + tmp);
1783
1784 tmp = Math.sqrt(-Infinity);
1785 ok(isNaN(tmp), "Math.sqrt(-Infinity) is not NaN");
1786
1787 tmp = Math.tan(0);
1788 ok(tmp === 0, "Math.tan(0) = " + tmp);
1789
1790 tmp = Math.tan(Math.PI);
1791 ok(Math.floor(tmp*100) === -1, "Math.tan(Math.PI) = " + tmp);
1792
1793 tmp = Math.tan(2, 2);
1794 ok(Math.floor(tmp*100) === -219, "Math.tan(2, 2) = " + tmp);
1795
1796 tmp = Math.tan(true);
1797 ok(Math.floor(tmp*100) === 155, "Math.tan(true) = " + tmp);
1798
1799 tmp = Math.tan(false);
1800 ok(tmp === 0, "Math.tan(false) = " + tmp);
1801
1802 tmp = Math.tan();
1803 ok(isNaN(tmp), "Math.tan() is not NaN");
1804
1805 tmp = Math.tan(NaN);
1806 ok(isNaN(tmp), "Math.tan(NaN) is not NaN");
1807
1808 tmp = Math.tan(Infinity);
1809 ok(isNaN(tmp), "Math.tan(Infinity) is not NaN");
1810
1811 tmp = Math.tan(-Infinity);
1812 ok(isNaN(tmp), "Math.tan(-Infinity) is not NaN");
1813
1814 (function() {
1815 if(invokeVersion < 2)
1816 return;
1817
1818 var stringify_tests = [
1819 [[], undefined],
1820 [[true], "true"],
1821 [[false], "false"],
1822 [[null], "null"],
1823 [[1], "1"],
1824 [["test"], "\"test\""],
1825 [["test\"\\\b\f\n\r\t\u0002 !"], "\"test\\\"\\\\\\b\\f\\n\\r\\t\\u0002 !\""],
1826 [[NaN], "null"],
1827 [[Infinity], "null"],
1828 [[-Infinity], "null"],
1829 [[{prop1: true, prop2: "string"}], "{\"prop1\":true,\"prop2\":\"string\"}"],
1830 [[{prop1: true, prop2: testObj, prop3: undefined}], "{\"prop1\":true}"],
1831 [[{prop1: true, prop2: {prop: "string"}},undefined," "],
1832 "{\n \"prop1\": true,\n \"prop2\": {\n \"prop\": \"string\"\n }\n}"],
1833 [[{ },undefined," "], "{}"],
1834 [[[,2,undefined,3,{ },]],"[null,2,null,3,{},null]"],
1835 [[[,2,undefined,3,{prop:0},],undefined," "],"[\n null,\n 2,\n null,\n 3,\n {\n \"prop\": 0\n },\n null\n]"]
1836 ];
1837
1838 var i, s, v;
1839
1840 for(i=0; i < stringify_tests.length; i++) {
1841 s = JSON.stringify.apply(null, stringify_tests[i][0]);
1842 ok(s === stringify_tests[i][1],
1843 "["+i+"] stringify(" + stringify_tests[i][0] + ") returned " + s + " expected " + stringify_tests[i][1]);
1844 }
1845
1846 s = JSON.stringify();
1847 ok(s === undefined, "stringify() returned " + s + " expected undefined");
1848
1849 s = JSON.stringify(testObj);
1850 ok(s === undefined || s === "undefined" /* broken on some old versions */,
1851 "stringify(testObj) returned " + s + " expected undfined");
1852
1853 s = JSON.stringify(undefined);
1854 ok(s === undefined || s === "undefined" /* broken on some old versions */,
1855 "stringify(undefined) returned " + s + " expected undfined");
1856
1857 var parse_tests = [
1858 ["true", true],
1859 [" \nnull ", null],
1860 ["{}", {}],
1861 ["\"\\r\\n test\\u1111\"", "\r\n test\u1111"],
1862 ["{\"x\" :\n true}", {x:true}],
1863 ["{\"x y\": {}, \"z\": {\"x\":null}}", {"x y":{}, z:{x:null}}],
1864 ["[]", []],
1865 ["[false,{},{\"x\": []}]", [false,{},{x:[]}]],
1866 ["0", 0],
1867 ["- 1", -1],
1868 ["1e2147483648", Infinity]
1869 ];
1870
1871 function json_cmp(x, y) {
1872 if(x === y)
1873 return true;
1874
1875 if(!(x instanceof Object) || !(y instanceof Object))
1876 return false;
1877
1878 for(var prop in x) {
1879 if(!x.hasOwnProperty(prop))
1880 continue;
1881 if(!x.hasOwnProperty(prop))
1882 return false;
1883 if(!json_cmp(x[prop], y[prop]))
1884 return false;
1885 }
1886
1887 for(var prop in y) {
1888 if(!x.hasOwnProperty(prop) && y.hasOwnProperty(prop))
1889 return false;
1890 }
1891
1892 return true;
1893 }
1894
1895 for(i=0; i < parse_tests.length; i++) {
1896 v = JSON.parse(parse_tests[i][0]);
1897 ok(json_cmp(v, parse_tests[i][1]), "parse[" + i + "] returned " + v + ", expected " + parse_tests[i][1]);
1898 }
1899 })();
1900
1901 var func = function (a) {
1902 var a = 1;
1903 if(a) return;
1904 };
1905 ok(func.toString() === "function (a) {\n var a = 1;\n if(a) return;\n }",
1906 "func.toString() = " + func.toString());
1907 ok("" + func === "function (a) {\n var a = 1;\n if(a) return;\n }",
1908 "'' + func.toString() = " + func);
1909
1910 ok(func.valueOf === Object.prototype.valueOf, "func.valueOf !== Object.prototype.valueOf");
1911 ok(func === func.valueOf(), "func !== func.valueOf()");
1912
1913 function testFuncToString(x,y) {
1914 return x+y;
1915 }
1916 ok(testFuncToString.toString() === "function testFuncToString(x,y) {\n return x+y;\n}",
1917 "testFuncToString.toString() = " + testFuncToString.toString());
1918 ok("" + testFuncToString === "function testFuncToString(x,y) {\n return x+y;\n}",
1919 "'' + testFuncToString = " + testFuncToString);
1920
1921 tmp = new Object();
1922
1923 function callTest(argc) {
1924 ok(this === tmp, "this !== tmp\n");
1925 ok(arguments.length === argc+1, "arguments.length = " + arguments.length + " expected " + (argc+1));
1926 for(var i=1; i <= argc; i++)
1927 ok(arguments[i] === i, "arguments[i] = " + arguments[i]);
1928 var a = arguments;
1929 for(var i=1; i <= argc; i++)
1930 ok(a[i] === i, "a[i] = " + a[i]);
1931 }
1932
1933 callTest.call(tmp, 1, 1);
1934 callTest.call(tmp, 2, 1, 2);
1935 callTest.call(tmp, 3, 1, 2, 3);
1936
1937 callTest.apply(tmp, [1, 1]);
1938 callTest.apply(tmp, [2, 1, 2]);
1939 callTest.apply(tmp, [3, 1, 2, 3]);
1940 (function () { callTest.apply(tmp, arguments); })(2,1,2);
1941
1942 function callTest2() {
1943 ok(this === tmp, "this !== tmp\n");
1944 ok(arguments.length === 0, "callTest2: arguments.length = " + arguments.length + " expected 0");
1945 }
1946
1947 callTest2.call(tmp);
1948 callTest2.apply(tmp, []);
1949 callTest2.apply(tmp);
1950 (function () { callTest2.apply(tmp, arguments); })();
1951
1952 function callTest3() {
1953 testThis(this);
1954 ok(arguments.length === 0, "arguments.length = " + arguments.length + " expected 0");
1955 }
1956
1957 callTest3.call();
1958 callTest3.call(undefined);
1959 callTest3.call(null);
1960 callTest3.apply();
1961 callTest3.apply(undefined);
1962 callTest3.apply(null);
1963
1964 tmp = Number.prototype.toString.call(3);
1965 ok(tmp === "3", "Number.prototype.toString.call(3) = " + tmp);
1966
1967 var func = new Function("return 3;");
1968
1969 tmp = func();
1970 ok(tmp === 3, "func() = " + tmp);
1971 ok(func.call() === 3, "func.call() = " + tmp);
1972 ok(func.length === 0, "func.length = " + func.length);
1973 tmp = func.toString();
1974 ok(tmp === "function anonymous() {\nreturn 3;\n}", "func.toString() = " + tmp);
1975
1976 func = new Function("x", "return x+2;");
1977 tmp = func(1);
1978 ok(tmp === 3, "func(1) = " + tmp);
1979 tmp = func.toString();
1980 ok(tmp === "function anonymous(x) {\nreturn x+2;\n}", "func.toString() = " + tmp);
1981
1982 tmp = (new Function("x ", "return x+2;")).toString();
1983 ok(tmp === "function anonymous(x ) {\nreturn x+2;\n}", "func.toString() = " + tmp);
1984
1985 func = new Function("x", "y", "return x+y");
1986 tmp = func(1,3);
1987 ok(tmp === 4, "func(1,3) = " + tmp);
1988 tmp = func.toString();
1989 ok(tmp === "function anonymous(x, y) {\nreturn x+y\n}", "func.toString() = " + tmp);
1990
1991 func = new Function(" x, \ty", "\tz", "return x+y+z;");
1992 tmp = func(1,3,2);
1993 ok(tmp === 6, "func(1,3,2) = " + tmp);
1994 ok(func.length === 3, "func.length = " + func.length);
1995 tmp = func.toString();
1996 ok(tmp === "function anonymous( x, \ty, \tz) {\nreturn x+y+z;\n}", "func.toString() = " + tmp);
1997
1998 func = new Function();
1999 tmp = func();
2000 ok(tmp === undefined, "func() = " + tmp);
2001 tmp = func.toString();
2002 ok(tmp == "function anonymous() {\n\n}", "func.toString() = " + tmp);
2003
2004 // Function constructor called as function
2005 func = Function("return 3;");
2006
2007 tmp = func();
2008 ok(tmp === 3, "func() = " + tmp);
2009 ok(func.call() === 3, "func.call() = " + tmp);
2010 ok(func.length === 0, "func.length = " + func.length);
2011 tmp = func.toString();
2012 ok(tmp === "function anonymous() {\nreturn 3;\n}", "func.toString() = " + tmp);
2013
2014 func = (function() {
2015 var tmp = 3;
2016 return new Function("return tmp;");
2017 })();
2018 tmp = 2;
2019 tmp = func();
2020 ok(tmp === 2, "func() = " + tmp);
2021
2022 var date = new Date();
2023
2024 date = new Date(100);
2025 ok(date.getTime() === 100, "date.getTime() = " + date.getTime());
2026 ok(Date.prototype.getTime() === 0, "date.prototype.getTime() = " + Date.prototype.getTime());
2027 date = new Date(8.64e15);
2028 ok(date.getTime() === 8.64e15, "date.getTime() = " + date.getTime());
2029 date = new Date(8.64e15+1);
2030 ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
2031 date = new Date(Infinity);
2032 ok(isNaN(0+date.getTime()), "date.getTime() is not NaN");
2033 date = new Date("3 July 2009 22:28:00 UTC+0100");
2034 ok(date.getTime() === 1246656480000, "date.getTime() = " + date.getTime());
2035 date = new Date(1984, 11, 29, 13, 51, 24, 120);
2036 ok(date.getFullYear() === 1984, "date.getFullYear() = " + date.getFullYear());
2037 ok(date.getMonth() === 11, "date.getMonth() = " + date.getMonth());
2038 ok(date.getDate() === 29, "date.getDate() = " + date.getDate());
2039 ok(date.getHours() === 13, "date.getHours() = " + date.getHours());
2040 ok(date.getMinutes() === 51, "date.getMinutes() = " + date.getMinutes());
2041 ok(date.getSeconds() === 24, "date.getSeconds() = " + date.getSeconds());
2042 ok(date.getMilliseconds() === 120, "date.getMilliseconds() = " + date.getMilliseconds());
2043 date = new Date(731, -32, 40, -1, 70, 65, -13);
2044 ok(date.getFullYear() === 728, "date.getFullYear() = " + date.getFullYear());
2045 ok(date.getMonth() === 5, "date.getMonth() = " + date.getMonth());
2046 ok(date.getDate() === 9, "date.getDate() = " + date.getDate());
2047 ok(date.getHours() === 0, "date.getHours() = " + date.getHours());
2048 ok(date.getMinutes() === 11, "date.getMinutes() = " + date.getMinutes());
2049 ok(date.getSeconds() === 4, "date.getSeconds() = " + date.getSeconds());
2050 ok(date.getMilliseconds() === 987, "date.getMilliseconds() = " + date.getMilliseconds());
2051
2052 ok(date.setTime(123) === 123, "date.setTime(123) !== 123");
2053 ok(date.setTime("123", NaN) === 123, "date.setTime(\"123\") !== 123");
2054 ok(isNaN(date.setTime(NaN)), "date.setTime(NaN) is not NaN");
2055
2056 ok(date.setTime(0) === date.getTime(), "date.setTime(0) !== date.getTime()");
2057 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
2058 ok(date.getUTCMonth() === 0, "date.getUTCMonth() = " + date.getUTCMonth());
2059 ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
2060 ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
2061 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
2062 ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
2063 ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
2064 ok(date.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
2065
2066 date.setTime(60*24*60*60*1000);
2067 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
2068 ok(date.getUTCMonth() === 2, "date.getUTCMonth() = " + date.getUTCMonth());
2069 ok(date.getUTCDate() === 2, "date.getUTCDate() = " + date.getUTCDate());
2070 ok(date.getUTCDay() === 1, "date.getUTCDay() = " + date.getUTCDay());
2071 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
2072 ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
2073 ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
2074 ok(date.getUTCMilliseconds() === 0, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
2075
2076 date.setTime(59*24*60*60*1000 + 4*365*24*60*60*1000 + 60*60*1000 + 2*60*1000 + 2*1000 + 640);
2077 ok(date.getUTCFullYear() === 1974, "date.getUTCFullYear() = " + date.getUTCFullYear());
2078 ok(date.getUTCMonth() === 1, "date.getUTCMonth() = " + date.getUTCMonth());
2079 ok(date.getUTCMonth(123) === 1, "date.getUTCMonth() = " + date.getUTCMonth());
2080 ok(date.getUTCDate() === 28, "date.getUTCDate() = " + date.getUTCDate());
2081 ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
2082 ok(date.getUTCHours() === 1, "date.getUTCHours() = " + date.getUTCHours());
2083 ok(date.getUTCMinutes() === 2, "date.getUTCMinutes() = " + date.getUTCMinutes());
2084 ok(date.getUTCSeconds() === 2, "date.getUTCSeconds() = " + date.getUTCSeconds());
2085 ok(date.getUTCMilliseconds() === 640, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
2086
2087 tmp = date.setYear(96);
2088 ok(date.getYear() === 96, "date.getYear() = " + date.getYear());
2089 ok(date.getFullYear() === 1996, "date.getFullYear() = " + date.getYear());
2090 ok(date.getUTCMonth() === 1, "date.getUTCMonth() = " + date.getUTCMonth());
2091 ok(date.getUTCMonth(123) === 1, "date.getUTCMonth() = " + date.getUTCMonth());
2092 ok(date.getUTCMilliseconds() === 640, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
2093
2094 tmp = date.setYear(2010);
2095 ok(tmp === date.getTime(), "date.setYear(2010) = " + tmp);
2096 ok(date.getYear() === 2010, "date.getYear() = " + date.getYear());
2097 ok(date.getFullYear() === 2010, "date.getFullYear() = " + date.getYear());
2098 ok(date.getUTCMonth() === 1, "date.getUTCMonth() = " + date.getUTCMonth());
2099 ok(date.getUTCMonth(123) === 1, "date.getUTCMonth() = " + date.getUTCMonth());
2100 ok(date.getUTCMilliseconds() === 640, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
2101
2102 date.setTime(Infinity);
2103 ok(isNaN(date.getUTCFullYear()), "date.getUTCFullYear() is not NaN");
2104 ok(isNaN(date.getUTCMonth()), "date.getUTCMonth() is not NaN");
2105 ok(isNaN(date.getUTCDate()), "date.getUTCDate() is not NaN");
2106 ok(isNaN(date.getUTCDay()), "date.getUTCDay() is not NaN");
2107 ok(isNaN(date.getUTCHours()), "date.getUTCHours() is not NaN");
2108 ok(isNaN(date.getUTCMinutes()), "date.getUTCMinutes() is not NaN");
2109 ok(isNaN(date.getUTCSeconds()), "date.getUTCSeconds() is not NaN");
2110 ok(isNaN(date.getUTCMilliseconds()), "date.getUTCMilliseconds() is not NaN");
2111 ok(isNaN(date.setMilliseconds(0)), "date.setMilliseconds() is not NaN");
2112
2113 date.setTime(0);
2114 tmp = date.setYear(NaN);
2115 ok(isNaN(tmp), "date.setYear(NaN) = " + tmp);
2116 ok(isNaN(date.getUTCFullYear()), "date.getUTCFullYear() is not NaN");
2117 ok(isNaN(date.getUTCMonth()), "date.getUTCMonth() is not NaN");
2118
2119 date.setTime(0);
2120 date.setUTCMilliseconds(-10, 2);
2121 ok(date.getUTCMilliseconds() === 990, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
2122 date.setUTCMilliseconds(10);
2123 ok(date.getUTCMilliseconds() === 10, "date.getUTCMilliseconds() = " + date.getUTCMilliseconds());
2124 date.setUTCSeconds(-10);
2125 ok(date.getUTCSeconds() === 50, "date.getUTCSeconds() = " + date.getUTCSeconds());
2126 date.setUTCMinutes(-10);
2127 ok(date.getUTCMinutes() === 50, "date.getUTCMinutes() = " + date.getUTCMinutes());
2128 date.setUTCHours(-10);
2129 ok(date.getUTCHours() === 14, "date.getUTCHours() = " + date.getUTCHours());
2130 date.setUTCHours(-123);
2131 ok(date.getTime() === -612549990, "date.getTime() = " + date.getTime());
2132 date.setUTCHours(20);
2133 ok(date.getUTCHours() === 20, "date.getUTCHours() = " + date.getUTCHours());
2134 date.setUTCDate(32);
2135 ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
2136 date.setUTCMonth(22, 37);
2137 ok(date.getTime() === 60987050010, "date.getTime() = " + date.getTime());
2138 date.setUTCFullYear(83, 21, 321);
2139 ok(date.getTime() === -59464984149990, "date.getTime() = " + date.getTime());
2140 ok(Math.abs(date) === 59464984149990, "Math.abs(date) = " + Math.abs(date));
2141 ok(getVT(date+1) === "VT_BSTR", "getVT(date+1) = " + getVT(date+1));
2142
2143 ok(isNaN(Date.parse()), "Date.parse() is not NaN");
2144 ok(isNaN(Date.parse("")), "Date.parse(\"\") is not NaN");
2145 ok(isNaN(Date.parse("Jan Jan 20 2009")), "Date.parse(\"Jan Jan 20 2009\") is not NaN");
2146 ok(Date.parse("Jan 20 2009 UTC") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC\") = " + Date.parse("Jan 20 2009 UTC"));
2147 ok(Date.parse("Jan 20 2009 GMT") === 1232409600000, "Date.parse(\"Jan 20 2009 GMT\") = " + Date.parse("Jan 20 2009 GMT"));
2148 ok(Date.parse("Jan 20 2009 UTC-0") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC-0\") = " + Date.parse("Jan 20 2009 UTC-0"));
2149 ok(Date.parse("Jan 20 2009 UTC+0000") === 1232409600000, "Date.parse(\"Jan 20 2009 UTC+0000\") = " + Date.parse("Jan 20 2009 UTC+0000"));
2150 ok(Date.parse("Jan 20 2009 UTC-1") === 1232413200000, "Date.parse(\"Jan 20 2009 UTC-1\") = " + Date.parse("Jan 20 2009 UTC-1"));
2151 ok(Date.parse("Jan 20 2009 UTC+1") === 1232406000000, "Date.parse(\"Jan 20 2009 UTC+1\") = " + Date.parse("Jan 20 2009 UTC+1"));
2152 ok(Date.parse("Ju 13 79 UTC") === 300672000000, "Date.parse(\"Ju 13 79 UTC\") = " + Date.parse("Ju 13 79 UTC"));
2153 ok(Date.parse("12Au91 UTC") === 681955200000, "Date.parse(\"12Au91 UTC\") = " + Date.parse("12Au91 UTC"));
2154 ok(Date.parse("7/02/17 UTC") === -1656806400000, "Date.parse(\"7/02/17 UTC\") = " + Date.parse("7/02/17 UTC"));
2155 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"));
2156 ok(Date.parse("February 31 UTC, 2000 12:31:17 PM") === 952000277000,
2157 "Date.parse(\"February 31 UTC, 2000 12:31:17 PM\") = " + Date.parse("February 31 UTC, 2000 12:31:17 PM"));
2158 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 "));
2159 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"));
2160 ok(Date.parse("1970/01/01") === Date.parse("01/01/1970"), "Date.parse(\"1970/01/01\") = " + Date.parse("1970/01/01"));
2161 ok(Date.parse("71/12/14") === Date.parse("12/14/1971"), "Date.parse(\"71/12/14\") = " + Date.parse("71/12/14"));
2162 ok(Date.parse("Tue, 22 Mar 2016 09:57:55 -0300") === Date.parse("Tue, 22 Mar 2016 09:57:55 GMT-0300"),
2163 "Date.parse(\"Tue, 22 Mar 2016 09:57:55 -0300\") = " + Date.parse("Tue, 22 Mar 2016 09:57:55 -0300"));
2164 ok(Date.parse("Tue, 22 Mar 2016 09:57:55 +0400") === Date.parse("Tue, 22 Mar 2016 09:57:55 UTC+0400"),
2165 "Date.parse(\"Tue, 22 Mar 2016 09:57:55 +0400\") = " + Date.parse("Tue, 22 Mar 2016 09:57:55 +0400"));
2166
2167 tmp = (new Date()).toGMTString();
2168 ok(tmp.indexOf(String.fromCharCode(0)) == -1, "invalid null byte");
2169 tmp = (new Date()).toLocaleDateString();
2170 ok(tmp.indexOf(String.fromCharCode(0)) == -1, "invalid null byte");
2171 tmp = (new Date(1600, 1, 1, 0, 0, 0, 0)).toLocaleDateString();
2172 ok(tmp.indexOf(String.fromCharCode(0)) == -1, "invalid null byte");
2173 tmp = (new Date(1600, 1, 1, 0, 0, 0, 0)).toLocaleString();
2174 ok(tmp.indexOf(String.fromCharCode(0)) == -1, "invalid null byte");
2175 tmp = (new Date()).toLocaleTimeString();
2176 ok(tmp.indexOf(String.fromCharCode(0)) == -1, "invalid null byte");
2177 tmp = (new Date()).toString();
2178 ok(tmp.indexOf(String.fromCharCode(0)) == -1, "invalid null byte");
2179 tmp = (new Date()).toTimeString();
2180 ok(tmp.indexOf(String.fromCharCode(0)) == -1, "invalid null byte");
2181 tmp = (new Date()).toUTCString();
2182 ok(tmp.indexOf(String.fromCharCode(0)) == -1, "invalid null byte");
2183
2184 ok(typeof(Math.PI) === "number", "typeof(Math.PI) = " + typeof(Math.PI));
2185 ok(Math.floor(Math.PI*100) === 314, "Math.PI = " + Math.PI);
2186 Math.PI = "test";
2187 ok(Math.floor(Math.PI*100) === 314, "modified Math.PI = " + Math.PI);
2188
2189 ok(typeof(Math.E) === "number", "typeof(Math.E) = " + typeof(Math.E));
2190 ok(Math.floor(Math.E*100) === 271, "Math.E = " + Math.E);
2191 Math.E = "test";
2192 ok(Math.floor(Math.E*100) === 271, "modified Math.E = " + Math.E);
2193
2194 ok(typeof(Math.LOG2E) === "number", "typeof(Math.LOG2E) = " + typeof(Math.LOG2E));
2195 ok(Math.floor(Math.LOG2E*100) === 144, "Math.LOG2E = " + Math.LOG2E);
2196 Math.LOG2E = "test";
2197 ok(Math.floor(Math.LOG2E*100) === 144, "modified Math.LOG2E = " + Math.LOG2E);
2198
2199 ok(typeof(Math.LOG10E) === "number", "typeof(Math.LOG10E) = " + typeof(Math.LOG10E));
2200 ok(Math.floor(Math.LOG10E*100) === 43, "Math.LOG10E = " + Math.LOG10E);
2201 Math.LOG10E = "test";
2202 ok(Math.floor(Math.LOG10E*100) === 43, "modified Math.LOG10E = " + Math.LOG10E);
2203
2204 ok(typeof(Math.LN2) === "number", "typeof(Math.LN2) = " + typeof(Math.LN2));
2205 ok(Math.floor(Math.LN2*100) === 69, "Math.LN2 = " + Math.LN2);
2206 Math.LN2 = "test";
2207 ok