2 * Copyright 2008 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 ok(true, "true is not true?");
22 ok(!false, "!false is not true");
23 ok(!undefined, "!undefined is not true");
24 ok(!null, "!null is not true");
25 ok(!0, "!0 is not true");
26 ok(!0.0, "!0.0 is not true");
28 ok(1 === 1, "1 === 1 is false");
29 ok(!(1 === 2), "!(1 === 2) is false");
30 ok(1.0 === 1, "1.0 === 1 is false");
31 ok("abc" === "abc", "\"abc\" === \"abc\" is false");
32 ok(true === true, "true === true is false");
33 ok(null === null, "null === null is false");
34 ok(undefined === undefined, "undefined === undefined is false");
35 ok(!(undefined === null), "!(undefined === null) is false");
36 ok(1E0
=== 1, "1E0 === 1 is false");
37 ok(1000000*1000000 === 1000000000000, "1000000*1000000 === 1000000000000 is false");
38 ok(8.64e15
=== 8640000000000000, "8.64e15 !== 8640000000000000");
39 ok(1e2147483648
=== Infinity
, "1e2147483648 !== Infinity");
41 ok(00 === 0, "00 != 0");
42 ok(010 === 8, "010 != 8");
43 ok(077 === 63, "077 != 63");
44 ok(080 === 80, "080 != 80");
45 ok(090 === 90, "090 != 90");
46 ok(018 === 18, "018 != 18");
47 tmp
= 07777777777777777777777;
48 ok(typeof(tmp
) === "number" && tmp
> 0xffffffff, "tmp = " + tmp
);
49 tmp
= 07777777779777777777777;
50 ok(typeof(tmp
) === "number" && tmp
> 0xffffffff, "tmp = " + tmp
);
51 ok(0xffffffff === 4294967295, "0xffffffff = " + 0xffffffff);
52 tmp
= 0x10000000000000000000000000000000000000000000000000000000000000000;
53 ok(tmp
=== Math
.pow(2, 256), "0x1000...00 != 2^256");
55 ok(1 !== 2, "1 !== 2 is false");
56 ok(null !== undefined, "null !== undefined is false");
58 ok(1 == 1, "1 == 1 is false");
59 ok(!(1 == 2), "!(1 == 2) is false");
60 ok(1.0 == 1, "1.0 == 1 is false");
61 ok("abc" == "abc", "\"abc\" == \"abc\" is false");
62 ok(true == true, "true == true is false");
63 ok(null == null, "null == null is false");
64 ok(undefined == undefined, "undefined == undefined is false");
65 ok(undefined == null, "undefined == null is false");
66 ok(true == 1, "true == 1 is false");
67 ok(!(true == 2), "true == 2");
68 ok(0 == false, "0 == false is false");
70 ok(1 != 2, "1 != 2 is false");
71 ok(false != 1, "false != 1 is false");
73 ok(this === test
, "this !== test");
74 eval('ok(this === test, "this !== test");');
77 ok(trueVar
, "trueVar is not true");
79 ok(ScriptEngine
.length
=== 0, "ScriptEngine.length is not 0");
81 function testFunc1(x
, y
) {
82 ok(this !== undefined, "this is undefined");
83 ok(x
=== true, "x is not true");
84 ok(y
=== "test", "y is not \"test\"");
85 ok(arguments
.length
=== 2, "arguments.length is not 2");
86 ok(arguments
["0"] === true, "arguments[0] is not true");
87 ok(arguments
["1"] === "test", "arguments[1] is not \"test\"");
88 ok(arguments
.callee
=== testFunc1
, "arguments.calee !== testFunc1");
89 ok(testFunc1
.arguments
=== arguments
, "testFunc1.arguments = " + testFunc1
.arguments
);
92 ok(arguments
[0] === false, "arguments[0] is not false");
94 ok(y
=== "x", "y = " + y
);
95 ok(arguments
[1] === "x", "arguments[1] = " + arguments
[1]);
97 ok(arguments
["0x0"] === undefined, "arguments['0x0'] = " + arguments
["0x0"]);
98 ok(arguments
["x"] === undefined, "arguments['x'] = " + arguments
["x"]);
100 ok(this === test
, "this !== test");
101 eval('ok(this === test, "this !== test");');
103 tmp
= delete arguments
;
104 ok(tmp
=== false, "arguments deleted");
105 ok(typeof(arguments
) === "object", "typeof(arguments) = " + typeof(arguments
));
108 ok(x
=== 2, "x = " + x
);
109 ok(arguments
[0] === 2, "arguments[0] = " + arguments
[0]);
114 ok(testFunc1
.length
=== 2, "testFunc1.length is not 2");
115 ok(testFunc1
.arguments
=== null, "testFunc1.arguments = " + testFunc1
.arguments
);
117 ok(Object
.prototype !== undefined, "Object.prototype is undefined");
118 ok(Object
.prototype.prototype === undefined, "Object.prototype is not undefined");
119 ok(String
.prototype !== undefined, "String.prototype is undefined");
120 ok(Array
.prototype !== undefined, "Array.prototype is undefined");
121 ok(Boolean
.prototype !== undefined, "Boolean.prototype is undefined");
122 ok(Number
.prototype !== undefined, "Number.prototype is undefined");
123 ok(RegExp
.prototype !== undefined, "RegExp.prototype is undefined");
124 ok(Math
!== undefined, "Math is undefined");
125 ok(Math
.prototype === undefined, "Math.prototype is not undefined");
126 ok(Function
.prototype !== undefined, "Function.prototype is undefined");
127 ok(Function
.prototype.prototype === undefined, "Function.prototype.prototype is not undefined");
128 ok(Date
.prototype !== undefined, "Date.prototype is undefined");
129 ok(Date
.prototype.prototype === undefined, "Date.prototype is not undefined");
131 function testConstructor(constr
, name
, inst
) {
132 ok(constr
.prototype.constructor === constr
, name
+ ".prototype.constructor !== " + name
);
133 ok(constr
.prototype.hasOwnProperty("constructor"), name
+ ".prototype.hasOwnProperty('constructor')");
138 ok(inst
.constructor === constr
, "(new " + name
+ "()).constructor !== " + name
);
139 ok(!inst
.hasOwnProperty("constructor"), "(new " + name
+ "()).hasOwnProperty('constructor')");
142 testConstructor(Object
, "Object");
143 testConstructor(String
, "String");
144 testConstructor(Array
, "Array");
145 testConstructor(Boolean
, "Boolean");
146 testConstructor(Number
, "Number");
147 testConstructor(RegExp
, "RegExp", /x
/);
148 testConstructor(Function
, "Function");
149 testConstructor(Date
, "Date");
150 testConstructor(VBArray
, "VBArray", new VBArray(createArray()));
151 testConstructor(Error
, "Error");
152 testConstructor(EvalError
, "EvalError");
153 testConstructor(RangeError
, "RangeError");
154 testConstructor(ReferenceError
, "ReferenceError");
155 testConstructor(RegExpError
, "RegExpError");
156 testConstructor(SyntaxError
, "SyntaxError");
157 testConstructor(TypeError
, "TypeError");
158 testConstructor(URIError
, "URIError");
160 Function
.prototype.test
= true;
161 ok(testFunc1
.test
=== true, "testFunc1.test !== true");
162 ok(Function
.test
=== true, "Function.test !== true");
164 ok(typeof(0) === "number", "typeof(0) is not number");
165 ok(typeof(1.5) === "number", "typeof(1.5) is not number");
166 ok(typeof("abc") === "string", "typeof(\"abc\") is not string");
167 ok(typeof("") === "string", "typeof(\"\") is not string");
168 ok(typeof(true) === "boolean", "typeof(true) is not boolean");
169 ok(typeof(null) === "object", "typeof(null) is not object");
170 ok(typeof(undefined) === "undefined", "typeof(undefined) is not undefined");
171 ok(typeof(Math
) === "object", "typeof(Math) is not object");
172 ok(typeof(String
.prototype) === "object", "typeof(String.prototype) is not object");
173 ok(typeof(testFunc1
) === "function", "typeof(testFunc1) is not function");
174 ok(typeof(String
) === "function", "typeof(String) is not function");
175 ok(typeof(ScriptEngine
) === "function", "typeof(ScriptEngine) is not function");
176 ok(typeof(this) === "object", "typeof(this) is not object");
177 ok(typeof(doesnotexist
) === "undefined", "typeof(doesnotexist) = " + typeof(doesnotexist
));
178 tmp
= typeof((new Object()).doesnotexist
);
179 ok(tmp
=== "undefined", "typeof((new Object).doesnotexist = " + tmp
);
180 tmp
= typeof(testObj
.onlyDispID
);
181 ok(tmp
=== "unknown", "typeof(testObj.onlyDispID) = " + tmp
);
183 ok(testFunc1(true, "test") === true, "testFunc1 not returned true");
185 ok(testFunc1
.arguments
=== null, "testFunc1.arguments = " + testFunc1
.arguments
);
188 ok(tmp
=== 3, "tmp = " + tmp
);
190 function testRecFunc(x
) {
191 ok(testRecFunc
.arguments
=== arguments
, "testRecFunc.arguments = " + testRecFunc
.arguments
);
194 ok(testRecFunc
.arguments
=== arguments
, "testRecFunc.arguments = " + testRecFunc
.arguments
);
195 ok(testRecFunc
.arguments
[0] === true, "testRecFunc.arguments.x = " + testRecFunc
.arguments
[0]);
199 testRecFunc
.arguments
= 5;
200 ok(testRecFunc
.arguments
=== null, "testRecFunc.arguments = " + testRecFunc
.arguments
);
202 ok(testRecFunc
.arguments
=== null, "testRecFunc.arguments = " + testRecFunc
.arguments
);
204 function argumentsTest() {
205 var save
= arguments
;
206 with({arguments
: 1}) {
207 ok(arguments
=== 1, "arguments = " + arguments
);
209 ok(argumentsTest
.arguments
=== save
, "unexpected argumentsTest.arguments");
212 eval('ok(arguments === save, "unexpected arguments");');
213 [1,2].sort(function() {
214 ok(argumentsTest
.arguments
=== save
, "unexpected argumentsTest.arguments");
221 // arguments object detached from its execution context
223 var args
, get_x
, set_x
;
225 function test_args(detached
) {
226 ok(args
[0] === 1, "args[0] = " + args
[0]);
228 ok(args
[0] === (detached
? 1 : 2), "args[0] = " + args
[0] + " expected " + (detached
? 1 : 2));
230 ok(get_x() === (detached
? 2 : 3), "get_x() = " + get_x());
231 ok(args
[0] === 3, "args[0] = " + args
[0]);
236 get_x = function() { return x
; };
237 set_x = function(v
) { x
= v
; };
246 // arguments is a regular variable, it may be overwritten
248 ok(typeof(arguments
) === "object", "typeof(arguments) = " + typeof(arguments
));
250 ok(arguments
=== 1, "arguments = " + arguments
);
253 (function callAsExprTest() {
254 ok(callAsExprTest
.arguments
=== null, "callAsExprTest.arguments = " + callAsExprTest
.arguments
);
257 tmp
= (function() {1;})();
258 ok(tmp
=== undefined, "tmp = " + tmp
);
260 ok(tmp
=== 1, "tmp = " + tmp
);
262 ok(tmp
=== 2, "tmp = " + tmp
);
263 tmp
= eval("testNoRes(),2;");
264 ok(tmp
=== 2, "tmp = " + tmp
);
265 tmp
= eval("if(true) {3}");
266 ok(tmp
=== 3, "tmp = " + tmp
);
267 eval("testRes(); testRes()");
268 tmp
= eval("3; if(false) {4;} else {};;;")
269 ok(tmp
=== 3, "tmp = " + tmp
);
270 tmp
= eval("try { 1; } finally { 2; }")
271 ok(tmp
=== 2, "tmp = " + tmp
);
274 testRes() && testRes();
275 testNoRes(), testNoRes();
279 ok(x
=== 1, "x = " + x
);
285 ok(r
=== 1, "r = " + r
);
286 (function(x
, a
) { x(a
); })(eval
, "2");
291 ok(r
=== 1, "r = " + r
);
292 (function(x
, a
) { x(a
); })(eval
, "2");
295 tmp
= (function(){ return testNoRes(), testRes();})();
299 ok(funcexpr() == 2, "funcexpr() = " + funcexpr());
301 f1
= function funcexpr() { return 1; }
302 ok(f1
!= funcexpr
, "f1 == funcexpr");
303 ok(f1() === 1, "f1() = " + f1());
305 f2
= function funcexpr() { return 2; }
306 ok(f2
!= funcexpr
, "f2 != funcexpr");
307 ok(f2() === 2, "f2() = " + f2());
310 for(i
= 0; i
< 3; i
++) {
311 f2
= function funcexpr2() {};
312 ok(f1
!= f2
, "f1 == f2");
317 for(i
= 0; i
< 3; i
++) {
319 ok(f1
!= f2
, "f1 == f2");
324 ok(infuncexpr() == 2, "infuncexpr() = " + infuncexpr());
326 f1
= function infuncexpr() { return 1; }
327 ok(f1
!= funcexpr
, "f1 == funcexpr");
328 ok(f1() === 1, "f1() = " + f1());
330 f2
= function infuncexpr() { return 2; }
331 ok(f2
!= funcexpr
, "f2 != funcexpr");
332 ok(f2() === 2, "f2() = " + f2());
335 for(i
= 0; i
< 3; i
++) {
336 f2
= function infuncexpr2() {};
337 ok(f1
!= f2
, "f1 == f2");
342 for(i
= 0; i
< 3; i
++) {
344 ok(f1
!= f2
, "f1 == f2");
349 var obj1
= new Object();
350 ok(typeof(obj1
) === "object", "typeof(obj1) is not object");
351 ok(obj1
.constructor === Object
, "unexpected obj1.constructor");
353 obj1
.func = function () {
354 ok(this === obj1
, "this is not obj1");
355 ok(this.test
=== true, "this.test is not true");
356 ok(arguments
.length
=== 1, "arguments.length is not 1");
357 ok(arguments
["0"] === true, "arguments[0] is not true");
358 ok(typeof(arguments
.callee
) === "function", "typeof(arguments.calee) = " + typeof(arguments
.calee
));
363 ok(obj1
.func(true) === "test", "obj1.func(true) is not \"test\"");
365 function testConstr1() {
368 ok(this !== undefined, "this is undefined");
369 ok(arguments
.length
=== 1, "arguments.length is not 1");
370 ok(arguments
["0"] === true, "arguments[0] is not 1");
371 ok(arguments
.callee
=== testConstr1
, "arguments.calee !== testConstr1");
376 testConstr1
.prototype.pvar
= 1;
377 ok(testConstr1
.prototype.constructor === testConstr1
, "testConstr1.prototype.constructor !== testConstr1");
379 var obj2
= new testConstr1(true);
380 ok(typeof(obj2
) === "object", "typeof(obj2) is not object");
381 ok(obj2
.constructor === testConstr1
, "unexpected obj2.constructor");
382 ok(obj2
.pvar
=== 1, "obj2.pvar is not 1");
383 ok(!obj2
.hasOwnProperty('constructor'), "obj2.hasOwnProperty('constructor')");
385 testConstr1
.prototype.pvar
= 2;
386 ok(obj2
.pvar
=== 2, "obj2.pvar is not 2");
389 testConstr1
.prototype.pvar
= 1;
390 ok(obj2
.pvar
=== 3, "obj2.pvar is not 3");
393 function testConstr3() {
397 obj2
= new testConstr3();
398 ok(obj1
=== obj2
, "obj1 != obj2");
400 function testConstr4() {
404 obj2
= new testConstr3();
405 ok(typeof(obj2
) === "object", "typeof(obj2) = " + typeof(obj2
));
407 var obj3
= new Object
;
408 ok(typeof(obj3
) === "object", "typeof(obj3) is not object");
411 ok(typeof(func
) === "function", "typeof(func) = " + typeof(func
));
413 ok(typeof(func
) === "function", "typeof(func) = " + typeof(func
));
415 ok(typeof(func
) === "number", "typeof(func) = " + typeof(func
));
419 ok(typeof(f
) === "function", "typeof(f) = " + typeof(f
));
421 ok(typeof(f
) === "function", "typeof(f) = " + typeof(f
));
424 for(var iter
in "test")
425 ok(false, "unexpected forin call, test = " + iter
);
427 for(var iter
in null)
428 ok(false, "unexpected forin call, test = " + iter
);
430 for(var iter
in false)
431 ok(false, "unexpected forin call, test = " + iter
);
433 for(var iter
in pureDisp
)
434 ok(false, "unexpected forin call in pureDisp object");
437 ok(!tmp
.nonexistent
, "!tmp.nonexistent = " + !tmp
.nonexistent
);
438 ok(!("nonexistent" in tmp
), "nonexistent is in tmp after '!' expression")
441 ok((~tmp
.nonexistent
) === -1, "!tmp.nonexistent = " + ~tmp
.nonexistent
);
442 ok(!("nonexistent" in tmp
), "nonexistent is in tmp after '~' expression")
445 ok(isNaN(+tmp
.nonexistent
), "!tmp.nonexistent = " + (+tmp
.nonexistent
));
446 ok(!("nonexistent" in tmp
), "nonexistent is in tmp after '+' expression")
449 tmp
[tmp
.nonexistent
];
450 ok(!("nonexistent" in tmp
), "nonexistent is in tmp after array expression")
456 ok(false, "else evaluated");
457 ok(tmp
=== 1, "tmp !== 1, if not evaluated?");
461 ok(false, "if evaluated");
464 ok(tmp
=== 1, "tmp !== 1, if not evaluated?");
467 ok(false, "if(false) evaluated");
472 ok(tmp
=== 1, "tmp !== 1, if(true) not evaluated?");
478 var obj3
= { prop1
: 1, prop2
: typeof(false) };
479 ok(obj3
.prop1
=== 1, "obj3.prop1 is not 1");
480 ok(obj3
.prop2
=== "boolean", "obj3.prop2 is not \"boolean\"");
481 ok(obj3
.constructor === Object
, "unexpected obj3.constructor");
483 if(invokeVersion
>= 2) {
484 eval("tmp = {prop: 'value',}");
485 ok(tmp
.prop
=== "value", "tmp.prop = " + tmp
.prop
);
486 eval("tmp = {prop: 'value',second:2,}");
487 ok(tmp
.prop
=== "value", "tmp.prop = " + tmp
.prop
);
490 eval("tmp = {prop: 'value',}");
494 ok(tmp
=== true, "exception not fired");
501 ok(blockVar
=== 2, "blockVar !== 2");
503 ok((true ? 1 : 2) === 1, "conditional expression true is not 1");
504 ok((0 === 2 ? 1 : 2) === 2, "conditional expression true is not 2");
506 ok(getVT(undefined) === "VT_EMPTY", "getVT(undefined) is not VT_EMPTY");
507 ok(getVT(null) === "VT_NULL", "getVT(null) is not VT_NULL");
508 ok(getVT(0) === "VT_I4", "getVT(0) is not VT_I4");
509 ok(getVT(0.5) === "VT_R8", "getVT(0.5) is not VT_R8");
510 ok(getVT("test") === "VT_BSTR", "getVT(\"test\") is not VT_BSTR");
511 ok(getVT(Math
) === "VT_DISPATCH", "getVT(Math) is not VT_DISPATCH");
512 ok(getVT(false) === "VT_BOOL", "getVT(false) is not VT_BOOL");
515 ok(tmp
=== 4, "2+2 !== 4");
516 ok(getVT(tmp
) === "VT_I4", "getVT(2+2) !== VT_I4");
519 ok(tmp
=== 4.5, "2+2.5 !== 4.5");
520 ok(getVT(tmp
) === "VT_R8", "getVT(2+2.5) !== VT_R8");
523 ok(tmp
=== 4, "1.4+2.5 !== 4");
524 ok(getVT(tmp
) === "VT_I4", "getVT(1.5+2.5) !== VT_I4");
527 ok(tmp
=== 2, "4-2 !== 2");
528 ok(getVT(tmp
) === "VT_I4", "getVT(4-2) !== VT_I4");
531 ok(tmp
=== 2.5, "4.5-2 !== 2.5");
532 ok(getVT(tmp
) === "VT_R8", "getVT(4.5-2) !== VT_R8");
535 ok(tmp
=== 0-2, "-2 !== 0-2");
536 ok(getVT(tmp
) === "VT_I4", "getVT(-2) !== VT_I4");
539 ok(tmp
=== 6, "2*3 !== 6");
540 ok(getVT(tmp
) === "VT_I4", "getVT(2*3) !== VT_I4");
543 ok(tmp
=== 7, "2*3.5 !== 7");
544 ok(getVT(tmp
) === "VT_I4", "getVT(2*3.5) !== VT_I4");
547 /* FIXME: the parser loses precision */
548 /* ok(tmp === 8.75, "2.5*3.5 !== 8.75"); */
549 ok(tmp
> 8.749999 && tmp
< 8.750001, "2.5*3.5 !== 8.75");
550 ok(getVT(tmp
) === "VT_R8", "getVT(2.5*3.5) !== VT_R8");
553 ok(tmp
=== 1, "2*.5 !== 1");
554 ok(getVT(tmp
) == "VT_I4", "getVT(2*.5) !== VT_I4");
557 ok(tmp
=== 2, "4/2 !== 2");
558 ok(getVT(tmp
) === "VT_I4", "getVT(4/2) !== VT_I4");
561 ok(tmp
=== 3, "4.5/1.5 !== 3");
562 ok(getVT(tmp
) === "VT_I4", "getVT(4.5/1.5) !== VT_I4");
565 ok(tmp
=== 1.5, "3/2 !== 1.5");
566 ok(getVT(tmp
) === "VT_R8", "getVT(3/2) !== VT_R8");
569 ok(tmp
=== 1, "3%2 = " + tmp
);
572 ok(tmp
===0, "4%2 = " + tmp
);
575 ok(tmp
=== 0.5, "3.5%1.5 = " + tmp
);
578 ok(tmp
=== 0, "3%true = " + tmp
);
581 ok(tmp
=== "abcd", "\"ab\" + \"cd\" !== \"abcd\"");
584 ok((tmp
+= 1) === 2, "tmp += 1 !== 2");
585 ok(tmp
=== 2, "tmp !== 2");
588 ok((tmp
-= 1) === 1, "tmp -= 1 !== 1");
589 ok(tmp
=== 1, "tmp !=== 1");
592 ok((tmp
*= 1.5) === 3, "tmp *= 1.5 !== 3");
593 ok(tmp
=== 3, "tmp !=== 3");
596 ok((tmp
/= 2) === 2.5, "tmp /= 2 !== 2.5");
597 ok(tmp === 2.5, "tmp
!=== 2.5");
600 ok((tmp %= 2) === 1, "tmp
%= 2 !== 1");
601 ok(tmp === 1, "tmp
!== 1");
604 ok((tmp <<= 1) === 16, "tmp
<<= 1 !== 16");
607 ok((tmp >>= 1) === 4, "tmp
>>= 1 !== 4");
610 ok((tmp >>>= 1) === 4, "tmp
>>>= 1 !== 4");
612 tmp = 3 || ok(false, "second or expression called
");
613 ok(tmp === 3, "3 || (...) is not
3");
616 ok(tmp === 2, "false || 2 is not
2");
618 tmp = 0 && ok(false, "second and expression called
");
619 ok(tmp === 0, "0 && (...) is not
0");
621 tmp = true && "test
";
622 ok(tmp === "test
", "true && \"test
\" is not
\"test
\"");
625 ok(tmp === 0, "true && 0 is not
0");
628 ok(tmp === 7, "3 | 4 !== 7");
629 ok(getVT(tmp) === "VT_I4
", "getVT(3|4) = " + getVT(tmp));
632 ok(tmp === 3, "3.5 | 0 !== 3");
633 ok(getVT(tmp) === "VT_I4
", "getVT(3.5|0) = " + getVT(tmp));
636 ok(tmp === -3, "-3.5 | 0 !== -3");
637 ok(getVT(tmp) === "VT_I4
", "getVT(3.5|0) = " + getVT(tmp));
640 ok(tmp === 0, "0 | NaN
= " + tmp);
643 ok(tmp === 0, "0 | NaN
= " + tmp);
645 tmp = 0 | (-Infinity);
646 ok(tmp === 0, "0 | NaN
= " + tmp);
649 ok((tmp |= 0x10) === 26, "tmp(10) |= 0x10 !== 26");
650 ok(getVT(tmp) === "VT_I4
", "getVT(tmp
|= 10) = " + getVT(tmp));
652 tmp = (123 * Math.pow(2,32) + 2) | 0;
653 ok(tmp === 2, "123*2^32+2 | 0 = " + tmp);
655 tmp = (-123 * Math.pow(2,32) + 2) | 0;
656 ok(tmp === 2, "123*2^32+2 | 0 = " + tmp);
659 ok(tmp === 1, "3 & 5 !== 1");
660 ok(getVT(tmp) === "VT_I4
", "getVT(3|5) = " + getVT(tmp));
663 ok(tmp === 3, "3.5 & 0xffff !== 3 ");
664 ok(getVT(tmp) === "VT_I4
", "getVT(3.5&0xffff) = " + getVT(tmp));
666 tmp = (-3.5) & 0xffffffff;
667 ok(tmp === -3, "-3.5 & 0xffff !== -3");
668 ok(getVT(tmp) === "VT_I4
", "getVT(3.5&0xffff) = " + getVT(tmp));
671 ok(tmp === 16, "2 << 3 = " + tmp);
674 ok(tmp === 16, "2 << 35 = " + tmp);
677 ok(tmp === 2, "8 >> 2 = " + tmp);
680 ok(tmp === -4, "-64 >> 4 = " + tmp);
683 ok(tmp === 2, "8 >> 2 = " + tmp);
686 ok(tmp === 0x0ffffffc, "-64 >>> 4 = " + tmp);
689 ok(tmp === 4, "4 >>> NaN
= " + tmp);
692 ok((tmp &= 8) === 8, "tmp(10) &= 8 !== 8");
693 ok(getVT(tmp) === "VT_I4
", "getVT(tmp
&= 8) = " + getVT(tmp));
696 ok(tmp === 0x0ff0, "0xf0f0^0xff00 !== 0x0ff0");
697 ok(getVT(tmp) === "VT_I4
", "getVT(0xf0f0^0xff00) = " + getVT(tmp));
700 ok((tmp ^= 3) === 6, "tmp(5) ^= 3 !== 6");
701 ok(getVT(tmp) === "VT_I4
", "getVT(tmp
^= 3) = " + getVT(tmp));
704 ok(tmp === -2, "~1 !== -2");
705 ok(getVT(tmp) === "VT_I4
", "getVT(~1) = " + getVT(tmp));
707 ok((3,4) === 4, "(3,4) !== 4");
709 ok(+3 === 3, "+3 !== 3");
710 ok(+true === 1, "+true !== 1");
711 ok(+false === 0, "+false !== 0");
712 ok(+null === 0, "+null !== 0");
713 ok(+"0" === 0, "+'0' !== 0");
714 ok(+"3" === 3, "+'3' !== 3");
715 ok(+"-3" === -3, "+'-3' !== -3");
716 ok(+"0xff" === 255, "+'0xff' !== 255");
717 ok(+"3e3
" === 3000, "+'3e3' !== 3000");
720 ok(+tmp === 1, "+(new Number(1)) = " + (+tmp));
721 ok(tmp.constructor === Number, "unexpected tmp
.constructor");
722 tmp = new String("1");
723 ok(+tmp === 1, "+(new String('1')) = " + (+tmp));
724 ok(tmp.constructor === String, "unexpected tmp
.constructor");
726 ok("" + 0 === "0", "\"\" + 0 !== \"0\"");
727 ok("" + 123 === "123", "\"\" + 123 !== \"123\"");
728 ok("" + (-5) === "-5", "\"\" + (-5) !== \"-5\"");
729 ok("" + null === "null", "\"\" + null !== \"null\"");
730 ok("" + undefined === "undefined", "\"\" + undefined !== \"undefined\"");
731 ok("" + true === "true", "\"\" + true !== \"true\"");
732 ok("" + false === "false", "\"\" + false !== \"false\"");
733 ok("" + 0.5 === "0.5", "'' + 0.5 = " + 0.5);
734 ok("" + (-0.5432) === "-0.5432", "'' + (-0.5432) = " + (-0.5432));
736 ok(1 < 3.4, "1 < 3.4 failed
");
737 ok(!(3.4 < 1), "3.4 < 1");
738 ok("abc
" < "abcd
", "abc
< abcd failed
");
739 ok("abcd
" < "abce
", "abce
< abce failed
");
740 ok("" < "x
", "\"\" < \"x
\" failed
");
741 ok(!(0 < 0), "0 < 0");
743 ok(1 <= 3.4, "1 <= 3.4 failed
");
744 ok(!(3.4 <= 1), "3.4 <= 1");
745 ok("abc
" <= "abcd
", "abc
<= abcd failed
");
746 ok("abcd
" <= "abce
", "abce
<= abce failed
");
747 ok("" <= "x
", "\"\" <= \"x
\" failed
");
748 ok(0 <= 0, "0 <= 0 failed
");
750 ok(3.4 > 1, "3.4 > 1 failed
");
751 ok(!(1 > 3.4), "1 > 3.4");
752 ok("abcd
" > "abc
", "abc
> abcd failed
");
753 ok("abce
" > "abcd
", "abce
> abce failed
");
754 ok("x
" > "", "\"x
\" > \"\" failed
");
755 ok(!(0 > 0), "0 > 0");
757 ok(3.4 >= 1, "3.4 >= 1 failed
");
758 ok(!(1 >= 3.4), "1 >= 3.4");
759 ok("abcd
" >= "abc
", "abc
>= abcd failed
");
760 ok("abce
" >= "abcd
", "abce
>= abce failed
");
761 ok("x
" >= "", "\"x
\" >= \"\" failed
");
762 ok(0 >= 0, "0 >= 0");
765 ok(++tmp === 2, "++tmp (1) is not
2");
766 ok(tmp === 2, "incremented tmp is not
2");
767 ok(--tmp === 1, "--tmp (2) is not
1");
768 ok(tmp === 1, "decremented tmp is not
1");
769 ok(tmp++ === 1, "tmp
++ (1) is not
1");
770 ok(tmp === 2, "incremented
tmp(1) is not
2");
771 ok(tmp-- === 2, "tmp
-- (2) is not
2");
772 ok(tmp === 1, "decremented tmp is not
1");
776 ok(isNaN(tmp.iii), "tmp
.iii
= " + tmp.iii);
778 String.prototype.test = true;
779 ok("".test === true, "\"\".test is not
true");
781 Boolean.prototype.test = true;
782 ok(true.test === true, "true.test is not
true");
784 Number.prototype.test = true;
785 ok((0).test === true, "(0).test is not
true");
786 ok((0.5).test === true, "(0.5).test is not
true");
790 ok(state === "", "try: state
= " + state);
793 ok(false, "unexpected
catch");
795 ok(state === "try", "state
= " + state + " expected
try");
799 ok(state === "", "try: state
= " + state);
802 ok(state === "try", "finally: state
= " + state);
805 ok(state === "finally", "state
= " + state + " expected
finally");
815 ok(state === "finally", "state
= " + state + " expected
finally");
818 ok(state === "catch", "state
= " + state + " expected
catch");
827 ok(e === 1, "e
= " + e);
832 ok(state === "", "try: state
= " + state);
835 ok(false, "unexpected
catch");
837 ok(state === "try", "finally: state
= " + state);
840 ok(state === "finally", "state
= " + state + " expected
finally");
844 ok(state === "", "try: state
= " + state);
848 ok(state === "try", "catch: state
= " + state);
849 ok(ex === "except
", "ex is not
\"except
\"");
852 ok(state === "catch", "state
= " + state + " expected
catch");
856 ok(state === "", "try: state
= " + state);
860 ok(state === "try", "catch: state
= " + state);
861 ok(ex === true, "ex is not
true");
864 ok(state === "catch", "finally: state
= " + state);
867 ok(state === "finally", "state
= " + state + " expected
finally");
871 ok(state === "", "try: state
= " + state);
873 try { throw true; } finally {}
875 ok(state === "try", "catch: state
= " + state);
876 ok(ex === true, "ex is not
true");
879 ok(state === "catch", "finally: state
= " + state);
882 ok(state === "finally", "state
= " + state + " expected
finally");
886 ok(state === "", "try: state
= " + state);
888 try { throw "except
"; } catch(ex) { throw true; }
890 ok(state === "try", "catch: state
= " + state);
891 ok(ex === true, "ex is not
true");
894 ok(state === "catch", "finally: state
= " + state);
897 ok(state === "finally", "state
= " + state + " expected
finally");
899 function throwFunc(x) {
905 ok(state === "", "try: state
= " + state);
909 ok(state === "try", "catch: state
= " + state);
910 ok(ex === true, "ex is not
true");
913 ok(state === "catch", "finally: state
= " + state);
916 ok(state === "finally", "state
= " + state + " expected
finally");
921 ok(false, "unexpected
case \"1\"");
923 ok(state === "", "case 1: state
= " + state);
926 ok(state === "1", "default: state
= " + state);
929 ok(state === "default", "case false: state
= " + state);
932 ok(state === "false", "state
= " + state);
938 ok(false, "unexpected
case 1");
940 ok(state === "", "default: state
= " + state);
943 ok(state === "default", "case false: state
= " + state);
946 ok(state === "false", "state
= " + state);
951 ok(false, "unexpected
case \"1\"");
953 ok(state === "", "case 1: state
= " + state);
956 ok(state === "1", "default: state
= " + state);
960 ok(false, "unexpected
case false");
962 ok(state === "default", "state
= " + state);
966 ok(false, "unexpected
case 2");
968 ok(false, "unexpected
case 3");
973 ok(false, "unexpected
case 2");
981 ok(false, "unexpected
default");
989 ok(false, "unexpected
default");
1010 function unreachable() {
1011 ok(false, "unreachable
");
1014 function expect(value, expect_value) {
1015 ok(value === expect_value, "got
" + value + " expected
" + expect_value);
1030 expect(ret, "finally");
1045 expect(ret, "try,");
1046 expect(x, "try,finally,");
1065 expect(ret, "finally");
1066 expect(x, "try,catch,finally,");
1083 expect(ret, "catch");
1084 expect(x, "try,catch,finally,");
1106 expect(ret, "try2
");
1107 expect(x, "try,try2
,finally2
,finally,");
1134 expect(x, "try,try2
,finally2
,finally,ret
");
1162 expect(x, "try,try2
,finally2
,finally,ret
");
1172 var tmp = (function() {
1173 var s = new String();
1187 ok(tmp === 1, "eval(\"1\") !== 1");
1188 eval("{ ok(tmp
=== 1, 'eval: tmp !== 1'); } tmp
= 2;");
1189 ok(tmp === 2, "tmp
!== 2");
1191 ok(eval(false) === false, "eval(false) !== false");
1192 ok(eval() === undefined, "eval() !== undefined");
1194 tmp = eval("1", "2");
1195 ok(tmp === 1, "eval(\"1\", \"2\") !== 1");
1199 ok(state === "", "try: state
= " + state);
1201 eval("throwFunc(true);");
1203 ok(state === "try", "catch: state
= " + state);
1204 ok(ex === true, "ex is not
true");
1207 ok(state === "catch", "finally: state
= " + state);
1210 ok(state === "finally", "state
= " + state + " expected
finally");
1212 tmp = [,,1,2,,,true];
1213 ok(tmp.length === 7, "tmp
.length
!== 7");
1214 ok(tmp["0"] === undefined, "tmp
[0] is not
undefined");
1215 ok(tmp["3"] === 2, "tmp
[3] !== 2");
1216 ok(tmp["6"] === true, "tmp
[6] !== true");
1217 ok(tmp[2] === 1, "tmp
[2] !== 1");
1218 ok(!("0" in tmp), "0 found
in array
");
1219 ok(!("1" in tmp), "1 found
in array
");
1220 ok("2" in tmp, "2 not found
in array
");
1221 ok(!("2" in [1,,,,]), "2 found
in [1,,,,]");
1223 ok([1,].length === 2, "[1,].length
!== 2");
1224 ok([,,].length === 3, "[,,].length
!== 3");
1225 ok([,].length === 2, "[].length
!= 2");
1226 ok([].length === 0, "[].length
!= 0");
1230 ok(tmp < 4, "tmp
>= 4");
1233 ok(tmp === 4, "tmp
!== 4");
1237 ok(tmp < 4, "tmp
>= 4");
1241 ok(false, "break did not
break");
1244 ok(tmp === 4, "tmp
!== 4");
1248 ok(tmp < 4, "tmp
>= 4");
1251 ok(tmp === 4, "tmp
!== 4");
1255 ok(tmp === 0, "tmp
!=== 0");
1258 ok(tmp === 1, "tmp
!== 1");
1262 ok(tmp < 4, "tmp
>= 4");
1265 ok(tmp === 4, "tmp
!== 4")
1272 ok(false, "break did not
break");
1274 ok(tmp <= 4 && tmp != 2, "tmp
= " + tmp);
1276 ok(tmp === 4, "tmp
!== 4");
1278 for(tmp=0; tmp < 4; tmp++)
1279 ok(tmp < 4, "tmp
= " + tmp);
1280 ok(tmp === 4, "tmp
!== 4");
1282 for(tmp=0; tmp < 4; tmp++) {
1285 ok(tmp < 2, "tmp
= " + tmp);
1287 ok(tmp === 2, "tmp
!== 2");
1289 for(tmp=0; tmp < 4; tmp++) {
1292 ok(tmp < 4 && tmp != 2, "tmp
= " + tmp);
1294 ok(tmp === 4, "tmp
!== 4");
1296 for(var fi=0; fi < 4; fi++)
1297 ok(fi < 4, "fi
= " + fi);
1298 ok(fi === 4, "fi
!== 4");
1301 obj1 = new Object();
1302 for(obj1.nonexistent; tmp; tmp = false)
1303 ok(!("nonexistent
" in obj1), "nonexistent added to obj1
");
1305 obj1 = new Object();
1306 for(tmp in obj1.nonexistent)
1307 ok(false, "for(tmp
in obj1
.nonexistent
) called
with tmp
= " + tmp);
1308 ok(!("nonexistent
" in obj1), "nonexistent added to obj1 by
for..in loop
");
1313 /* Previous versions have broken finally block implementation */
1314 if(ScriptEngineMinorVersion() >= 8) {
1319 for(i = 1; i < 3; i++) {
1333 ok(false, "unexpected state
");
1342 ok(tmp === "123456", "tmp
= " + tmp);
1360 ok(false, "unexpected state
");
1368 ok(tmp === "1234", "tmp
= " + tmp);
1371 for(var iter in [1,2,3]) {
1375 ok(tmp === 3, "tmp
= " + tmp);
1378 for(var iter in [1,2,3]) {
1389 ok(tmp, "tmp
= " + tmp);
1403 ok(false, "unexpected evaluation
1");
1408 ok(false, "unexpected evaluation
2");
1411 just_label: tmp = 1;
1412 ok(tmp === 1, "tmp
!= 1");
1414 some_label: break some_label;
1418 ok(false, "unexpected evaluation
3");
1424 continue loop_label;
1428 for(i = 0; i < 3; i++) {
1430 continue loop_label;
1435 for(i = 0; i < 3; i++) {
1437 continue loop_label;
1441 for(tmp in {prop: false}) {
1443 continue loop_label;
1446 ok((void 1) === undefined, "(void 1) !== undefined");
1448 var inobj = new Object();
1450 for(var iter in inobj)
1451 ok(false, "unexpected iter
= " + iter);
1455 for(iter in inobj) {
1456 ok(iter == "test
", "unexpected iter
= " + iter);
1459 ok(tmp === 1, "for..in tmp
= " + tmp);
1461 function forinTestObj() {}
1463 forinTestObj.prototype.test3 = true;
1465 var arr = new Array();
1466 inobj = new forinTestObj();
1471 for(iter in inobj) {
1476 ok(tmp === 3, "for..in tmp
= " + tmp);
1477 ok(arr["test1
"] === true, "arr
[test1
] !== true");
1478 ok(arr["test2
"] === true, "arr
[test2
] !== true");
1479 ok(arr["test3
"] === true, "arr
[test3
] !== true");
1483 ok((delete tmp.test) === true, "delete returned
false");
1484 ok(typeof(tmp.test) === "undefined", "tmp
.test type
= " + typeof(tmp.test));
1485 ok(!("test
" in tmp), "test is still
in tmp after
delete?");
1487 ok(false, "tmp has prop
" + iter);
1488 ok((delete tmp.test) === true, "deleting test didn
't return true");
1489 ok((delete tmp.nonexistent) === true, "deleting nonexistent didn't
return true");
1490 ok((delete nonexistent) === true, "deleting nonexistent didn
't return true");
1494 ok((delete tmp["test"]) === true, "delete returned false");
1495 ok(typeof(tmp.test) === "undefined", "tmp.test type = " + typeof(tmp.test));
1496 ok(!("test" in tmp), "test is still in tmp after delete?");
1498 tmp.testWith = true;
1500 ok(testWith === true, "testWith !== true");
1503 var varTest1 = true;
1506 ok(varTest1 === undefined, "varTest1 = " + varTest1);
1507 ok(varTest2 === undefined, "varTest2 = " + varTest1);
1511 function varTestFunc(varTest3) {
1514 ok(varTest3 === 3, "varTest3 = " + varTest3);
1515 ok(varTest4 === undefined, "varTest4 = " + varTest4);
1526 ok(false, "deleteTest not throwed exception?");
1531 var r = delete to_delete;
1532 ok(r === false, "delete 1 returned " + r);
1535 ok(to_delete === 2, "to_delete = " + to_delete);
1537 to_delete = new Object();
1538 r = delete to_delete;
1539 ok(r === false, "delete 2 returned " + r);
1540 ok(typeof(to_delete) === "object", "typeof(to_delete) = " + typeof(to_delete));
1543 (function(to_delete) {
1544 var r = delete to_delete;
1545 ok(r === false, "delete 3 returned " + r);
1546 ok(to_delete === 2, "to_delete = " + to_delete);
1548 to_delete = new Object();
1549 r = delete to_delete;
1550 ok(r === false, "delete 4 returned " + r);
1551 ok(typeof(to_delete) === "object", "typeof(to_delete) = " + typeof(to_delete));
1555 with({to_delete: new Object()}) {
1556 var r = delete to_delete;
1557 ok(r === true, "delete returned " + r);
1563 ok(false, "if evaluated");
1565 ok(false, "else should be associated with nearest if statement");
1569 ok(false, "if evaluated");
1571 ok(true, "else should be associated with nearest if statement");
1573 function instanceOfTest() {}
1574 tmp = new instanceOfTest();
1576 ok((tmp instanceof instanceOfTest) === true, "tmp is not instance of instanceOfTest");
1577 ok((tmp instanceof Object) === true, "tmp is not instance of Object");
1578 ok((tmp instanceof String) === false, "tmp is instance of String");
1580 instanceOfTest.prototype = new Object();
1581 ok((tmp instanceof instanceOfTest) === false, "tmp is instance of instanceOfTest");
1582 ok((tmp instanceof Object) === true, "tmp is not instance of Object");
1584 ok((1 instanceof Object) === false, "1 is instance of Object");
1585 ok((false instanceof Boolean) === false, "false is instance of Boolean");
1586 ok(("" instanceof Object) === false, "'' is instance of Object");
1589 ok((arguments instanceof Object) === true, "argument is not instance of Object");
1590 ok((arguments instanceof Array) === false, "argument is not instance of Array");
1591 ok(arguments.toString() === "[object Object]", "arguments.toString() = " + arguments.toString());
1595 ok(("length" in obj) === true, "length is not in obj");
1596 ok(("isPrototypeOf" in obj) === true, "isPrototypeOf is not in obj");
1597 ok(("abc" in obj) === false, "test is in obj");
1599 ok(("abc" in obj) === true, "test is not in obj");
1600 ok(("1" in obj) === false, "1 is in obj");
1603 ok((1 in obj) === true, "1 is not in obj");
1608 ok(false, "expected exception");
1610 ok(!("prop" in obj), "prop in obj");
1612 if(invokeVersion >= 2) {
1613 ok("test"[0] === "t", '"test"[0] = ' + test[0]);
1614 ok("test"[5] === undefined, '"test"[0] = ' + test[0]);
1617 ok(tmp[1] === "e", "tmp[1] = " + tmp[1]);
1619 ok(tmp[1] === "e", "tmp[1] = " + tmp[1]);
1620 ok(tmp["1"] === "e", "tmp['1'] = " + tmp["1"]);
1621 ok(tmp["0x1"] === undefined, "tmp['0x1'] = " + tmp["0x1"]);
1623 ok("test"[0] === undefined, '"test"[0] = ' + test[0]);
1626 ok(isNaN(NaN) === true, "isNaN(NaN) !== true");
1627 ok(isNaN(0.5) === false, "isNaN(0.5) !== false");
1628 ok(isNaN(Infinity) === false, "isNaN(Infinity) !== false");
1629 ok(isNaN() === true, "isNaN() !== true");
1630 ok(isNaN(NaN, 0) === true, "isNaN(NaN, 0) !== true");
1631 ok(isNaN(0.5, NaN) === false, "isNaN(0.5, NaN) !== false");
1632 ok(isNaN(+undefined) === true, "isNaN(+undefined) !== true");
1634 ok(isFinite(0.5) === true, "isFinite(0.5) !== true");
1635 ok(isFinite(Infinity) === false, "isFinite(Infinity) !== false");
1636 ok(isFinite(-Infinity) === false, "isFinite(Infinity) !== false");
1637 ok(isFinite(NaN) === false, "isFinite(NaN) !== false");
1638 ok(isFinite(0.5, NaN) === true, "isFinite(0.5, NaN) !== true");
1639 ok(isFinite(NaN, 0.5) === false, "isFinite(NaN, 0.5) !== false");
1640 ok(isFinite() === false, "isFinite() !== false");
1642 ok((1 < NaN) === false, "(1 < NaN) !== false");
1643 ok((1 > NaN) === false, "(1 > NaN) !== false");
1644 ok((1 <= NaN) === false, "(1 <= NaN) !== false");
1645 ok((1 >= NaN) === false, "(1 >= NaN) !== false");
1646 ok((NaN < 1) === false, "(NaN < 1) !== false");
1647 ok((NaN > 1) === false, "(NaN > 1) !== false");
1648 ok((NaN <= 1) === false, "(NaN <= 1) !== false");
1649 ok((NaN >= 1) === false, "(NaN >= 1) !== false");
1650 ok((Infinity < 2) === false, "(Infinity < 2) !== false");
1651 ok((Infinity > 2) === true, "(Infinity > 2) !== true");
1652 ok((-Infinity < 2) === true, "(-Infinity < 2) !== true");
1654 ok(isNaN(+"test") === true, "isNaN(+'test
') !== true");
1655 ok(isNaN(+"123t") === true, "isNaN(+'123t
') !== true");
1656 ok(isNaN(+"Infinity x") === true, "isNaN(+'Infinity x
') !== true");
1657 ok(+"Infinity" === Infinity, "+'Infinity
' !== Infinity");
1658 ok(+" Infinity " === Infinity, "+' Infinity
' !== Infinity");
1659 ok(+"-Infinity" === -Infinity, "+'-Infinity
' !== -Infinity");
1661 ok((NaN !== NaN) === true, "(NaN !== NaN) !== true");
1662 ok((NaN === NaN) === false, "(NaN === NaN) !== false");
1663 ok((Infinity !== NaN) === true, "(Infinity !== NaN) !== true");
1664 ok((Infinity !== NaN) === true, "(Infinity !== NaN) !== true");
1665 ok((0 === NaN) === false, "(0 === NaN) !== false");
1667 ok((NaN != NaN) === true, "(NaN !== NaN) != true");
1668 ok((NaN == NaN) === false, "(NaN === NaN) != false");
1669 ok((Infinity != NaN) === true, "(Infinity != NaN) !== true");
1670 ok((Infinity != NaN) === true, "(Infinity != NaN) !== true");
1671 ok((0 == NaN) === false, "(0 === NaN) != false");
1684 ["\xf3", "\\xf3
", 0xf3],
1685 ["\u1234", "\\u1234
", 0x1234],
1690 for(i=0; i<escapeTests.length; i++) {
1691 tmp = escapeTests[i][0].charCodeAt(0);
1692 ok(tmp === escapeTests[i][2], "escaped
'" + escapeTests[i][1] + "' = " + tmp + " expected
" + escapeTests[i][2]);
1696 ok(tmp === true, '!+"\v1" = ' + tmp);
1698 ok(typeof(testFunc2) === "function", "typeof(testFunc2
) = " + typeof(testFunc2));
1700 ok(tmp === 2, "testFunc2(1) = " + tmp);
1701 function testFunc2(x) { return x+1; }
1703 ok(typeof(testFunc3) === "function", "typeof(testFunc3
) = " + typeof(testFunc3));
1705 ok(tmp === 3, "testFunc3(1) = " + tmp);
1706 tmp = function testFunc3(x) { return x+2; };
1709 ok(tmp === 5, "testFunc4(1) = " + tmp);
1710 tmp = function testFunc4(x) { return x+3; };
1713 ok(testFunc4 === 1, "testFunc4
= " + testFunc4);
1714 ok(tmp === 5, "testFunc4(1) = " + tmp);
1715 tmp = function testFunc4(x) { return x+4; };
1716 ok(testFunc4 === 1, "testFunc4
= " + testFunc4);
1718 function testEmbeddedFunctions() {
1719 ok(typeof(testFunc5) === "function", "typeof(testFunc5
) = " + typeof(testFunc5));
1721 ok(tmp === 3, "testFunc5(1) = " + tmp);
1722 tmp = function testFunc5(x) { return x+2; };
1725 ok(tmp === 5, "testFunc6(1) = " + tmp);
1726 tmp = function testFunc6(x) { return x+3; };
1728 ok(tmp === 5, "testFunc6(1) = " + tmp);
1729 tmp = function testFunc6(x) { return x+4; };
1731 ok(testFunc6 === 1, "testFunc4
= " + testFunc6);
1734 testEmbeddedFunctions();
1737 date.toString = function() { return "toString
"; }
1738 ok(""+date === "toString
", "''+date
= " + date);
1739 date.toString = function() { return this; }
1740 ok(""+date === ""+date.valueOf(), "''+date
= " + date);
1742 str = new String("test
");
1743 str.valueOf = function() { return "valueOf
"; }
1744 ok(""+str === "valueOf
", "''+str
= " + str);
1745 str.valueOf = function() { return new Date(); }
1746 ok(""+str === "test
", "''+str
= " + str);
1748 ok((function (){return 1;})() === 1, "(function (){return 1;})() = " + (function (){return 1;})());
1750 var re = /=(\?|%3F)/g;
1751 ok(re.source === "=(\\?|%3F
)", "re
.source
= " + re.source);
1754 for(var i=0; i<2; i++)
1756 ok(tmp[0] != tmp[1], "tmp
[0] == tmp
[1]");
1758 ok(isNullBSTR(getNullBSTR()), "isNullBSTR(getNullBSTR()) failed
\n");
1759 ok(getNullBSTR() === '', "getNullBSTR() !== ''");
1760 ok(+getNullBSTR() === 0 , "+getNullBTR() !=== 0");
1762 ok(getVT(nullDisp) === "VT_DISPATCH
", "getVT(nullDisp
) = " + getVT(nullDisp));
1763 ok(typeof(nullDisp) === "object
", "typeof(nullDisp
) = " + typeof(nullDisp));
1764 ok(nullDisp === nullDisp, "nullDisp
!== nullDisp
");
1765 ok(nullDisp !== re, "nullDisp
=== re
");
1766 ok(nullDisp === null, "nullDisp
=== null");
1767 ok(nullDisp == null, "nullDisp
== null");
1768 ok(getVT(true && nullDisp) === "VT_DISPATCH
",
1769 "getVT(0 && nullDisp
) = " + getVT(true && nullDisp));
1770 ok(!nullDisp === true, "!nullDisp
= " + !nullDisp);
1771 ok(String(nullDisp) === "null", "String(nullDisp
) = " + String(nullDisp));
1772 ok(nullDisp != new Object(), "nullDisp
== new Object()");
1773 ok(new Object() != nullDisp, "new Object() == nullDisp
");
1774 ok((typeof Object(nullDisp)) === "object
", "typeof Object(nullDisp
) !== 'object'");
1775 tmp = getVT(Object(nullDisp));
1776 ok(tmp === "VT_DISPATCH
", "getVT(Object(nullDisp
) = " + tmp);
1777 tmp = Object(nullDisp).toString();
1778 ok(tmp === "[object Object
]", "Object(nullDisp
).toString() = " + tmp);
1780 function do_test() {}
1781 function nosemicolon() {} nosemicolon();
1782 function () {} nosemicolon();
1785 function in_if_false() { return true; } ok(false, "!?");
1788 ok(in_if_false(), "in_if_false failed
");
1790 (function() { newValue = 1; })();
1791 ok(newValue === 1, "newValue
= " + newValue);
1793 obj = {undefined: 3};
1795 ok(typeof(name_override_func) === "function", "typeof(name_override_func
) = " + typeof(name_override_func));
1796 name_override_func = 3;
1797 ok(name_override_func === 3, "name_override_func
= " + name_override_func);
1798 function name_override_func() {};
1799 ok(name_override_func === 3, "name_override_func
= " + name_override_func);
1806 ok(tmp, "tmp
= " + tmp);
1809 for(var iter in [1,2,3,4]) {
1815 ok(tmp, "tmp
= " + tmp);
1818 ok(typeof(func) === "function", "typeof(func
) = " + typeof(func));
1819 with(new Object()) {
1820 var x = false && function func() {};
1822 ok(typeof(func) === "function", "typeof(func
) = " + typeof(func));
1826 ok(x === undefined, "x
= " + x); // x is declared, but never initialized
1828 ok(x === 1, "x
= " + x);
1830 ok(x === 2, "x
= " + x);
1832 ok(x === undefined, "x
= " + x);
1837 /* NoNewline rule parser tests */
1845 * no semicolon, but comment present */
1850 if(true) break // no semicolon, but comment present
1860 function returnTest() {
1865 ok(returnTest() === undefined, "returnTest
= " + returnTest());
1868 ok(ActiveXObject === 1, "ActiveXObject
= " + ActiveXObject);
1871 ok(Boolean === 1, "Boolean
= " + Boolean);
1874 ok(Object === 1, "Object
= " + Object);
1877 ok(Array === 1, "Array
= " + Array);
1880 ok(Date === 1, "Date
= " + Date);
1883 ok(Error === 1, "Error
= " + Error);
1885 /* Keep this test in the end of file */
1887 ok(undefined === 6, "undefined = " + undefined);
1890 ok(NaN === 6, "NaN
!== 6");
1893 ok(Infinity === 6, "Infinity
!== 6");
1896 ok(Math === 6, "NaN
!== 6");