2008-09-09 01:25:23 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2008 Jacek Caban for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2008-09-10 21:10:06 +02:00
|
|
|
var tmp;
|
|
|
|
|
2008-09-09 01:25:23 +02:00
|
|
|
ok(true, "true is not true?");
|
2008-09-09 01:25:40 +02:00
|
|
|
ok(!false, "!false is not true");
|
|
|
|
ok(!undefined, "!undefined is not true");
|
|
|
|
ok(!null, "!null is not true");
|
|
|
|
ok(!0, "!0 is not true");
|
|
|
|
ok(!0.0, "!0.0 is not true");
|
2008-09-09 01:25:23 +02:00
|
|
|
|
2008-09-09 01:26:20 +02:00
|
|
|
ok(1 === 1, "1 === 1 is false");
|
|
|
|
ok(!(1 === 2), "!(1 === 2) is false");
|
|
|
|
ok(1.0 === 1, "1.0 === 1 is false");
|
|
|
|
ok("abc" === "abc", "\"abc\" === \"abc\" is false");
|
|
|
|
ok(true === true, "true === true is false");
|
|
|
|
ok(null === null, "null === null is false");
|
|
|
|
ok(undefined === undefined, "undefined === undefined is false");
|
|
|
|
ok(!(undefined === null), "!(undefined === null) is false");
|
2009-05-27 01:10:49 +02:00
|
|
|
ok(1E0 === 1, "1E0 === 1 is false");
|
|
|
|
ok(1000000*1000000 === 1000000000000, "1000000*1000000 === 1000000000000 is false");
|
2009-09-08 23:57:26 +02:00
|
|
|
ok(8.64e15 === 8640000000000000, "8.64e15 !== 8640000000000000");
|
2009-06-03 23:17:47 +02:00
|
|
|
ok(1e2147483648 === Infinity, "1e2147483648 !== Infinity");
|
2008-09-09 01:26:20 +02:00
|
|
|
|
2013-11-06 17:18:28 +01:00
|
|
|
ok(00 === 0, "00 != 0");
|
|
|
|
ok(010 === 8, "010 != 8");
|
|
|
|
ok(077 === 63, "077 != 63");
|
|
|
|
ok(080 === 80, "080 != 80");
|
|
|
|
ok(090 === 90, "090 != 90");
|
|
|
|
ok(018 === 18, "018 != 18");
|
|
|
|
tmp = 07777777777777777777777;
|
|
|
|
ok(typeof(tmp) === "number" && tmp > 0xffffffff, "tmp = " + tmp);
|
|
|
|
tmp = 07777777779777777777777;
|
|
|
|
ok(typeof(tmp) === "number" && tmp > 0xffffffff, "tmp = " + tmp);
|
2018-04-11 19:36:11 +02:00
|
|
|
ok(0xffffffff === 4294967295, "0xffffffff = " + 0xffffffff);
|
|
|
|
tmp = 0x10000000000000000000000000000000000000000000000000000000000000000;
|
|
|
|
ok(tmp === Math.pow(2, 256), "0x1000...00 != 2^256");
|
2013-11-06 17:18:28 +01:00
|
|
|
|
2008-09-09 01:26:37 +02:00
|
|
|
ok(1 !== 2, "1 !== 2 is false");
|
|
|
|
ok(null !== undefined, "null !== undefined is false");
|
|
|
|
|
2008-09-17 23:29:16 +02:00
|
|
|
ok(1 == 1, "1 == 1 is false");
|
|
|
|
ok(!(1 == 2), "!(1 == 2) is false");
|
|
|
|
ok(1.0 == 1, "1.0 == 1 is false");
|
|
|
|
ok("abc" == "abc", "\"abc\" == \"abc\" is false");
|
|
|
|
ok(true == true, "true == true is false");
|
|
|
|
ok(null == null, "null == null is false");
|
|
|
|
ok(undefined == undefined, "undefined == undefined is false");
|
|
|
|
ok(undefined == null, "undefined == null is false");
|
|
|
|
ok(true == 1, "true == 1 is false");
|
|
|
|
ok(!(true == 2), "true == 2");
|
|
|
|
ok(0 == false, "0 == false is false");
|
|
|
|
|
2008-09-17 23:29:34 +02:00
|
|
|
ok(1 != 2, "1 != 2 is false");
|
|
|
|
ok(false != 1, "false != 1 is false");
|
|
|
|
|
2012-11-14 15:49:46 +01:00
|
|
|
ok(this === test, "this !== test");
|
|
|
|
eval('ok(this === test, "this !== test");');
|
|
|
|
|
2008-09-09 01:25:59 +02:00
|
|
|
var trueVar = true;
|
|
|
|
ok(trueVar, "trueVar is not true");
|
|
|
|
|
2008-09-09 01:27:38 +02:00
|
|
|
ok(ScriptEngine.length === 0, "ScriptEngine.length is not 0");
|
|
|
|
|
2008-09-09 01:27:57 +02:00
|
|
|
function testFunc1(x, y) {
|
2008-09-10 21:06:25 +02:00
|
|
|
ok(this !== undefined, "this is undefined");
|
2009-09-08 23:57:26 +02:00
|
|
|
ok(x === true, "x is not true");
|
2008-09-10 21:06:25 +02:00
|
|
|
ok(y === "test", "y is not \"test\"");
|
2008-09-10 21:06:43 +02:00
|
|
|
ok(arguments.length === 2, "arguments.length is not 2");
|
2008-09-10 21:07:06 +02:00
|
|
|
ok(arguments["0"] === true, "arguments[0] is not true");
|
|
|
|
ok(arguments["1"] === "test", "arguments[1] is not \"test\"");
|
2009-09-20 20:58:27 +02:00
|
|
|
ok(arguments.callee === testFunc1, "arguments.calee !== testFunc1");
|
2010-07-27 11:31:01 +02:00
|
|
|
ok(testFunc1.arguments === arguments, "testFunc1.arguments = " + testFunc1.arguments);
|
2008-09-10 21:06:25 +02:00
|
|
|
|
2012-11-30 13:01:51 +01:00
|
|
|
x = false;
|
|
|
|
ok(arguments[0] === false, "arguments[0] is not false");
|
|
|
|
arguments[1] = "x";
|
|
|
|
ok(y === "x", "y = " + y);
|
|
|
|
ok(arguments[1] === "x", "arguments[1] = " + arguments[1]);
|
|
|
|
|
|
|
|
ok(arguments["0x0"] === undefined, "arguments['0x0'] = " + arguments["0x0"]);
|
|
|
|
ok(arguments["x"] === undefined, "arguments['x'] = " + arguments["x"]);
|
|
|
|
|
2012-11-14 15:49:46 +01:00
|
|
|
ok(this === test, "this !== test");
|
|
|
|
eval('ok(this === test, "this !== test");');
|
|
|
|
|
2012-11-30 13:02:32 +01:00
|
|
|
tmp = delete arguments;
|
|
|
|
ok(tmp === false, "arguments deleted");
|
|
|
|
ok(typeof(arguments) === "object", "typeof(arguments) = " + typeof(arguments));
|
|
|
|
|
2016-08-03 16:28:32 +02:00
|
|
|
x = 2;
|
|
|
|
ok(x === 2, "x = " + x);
|
|
|
|
ok(arguments[0] === 2, "arguments[0] = " + arguments[0]);
|
|
|
|
|
2008-09-09 01:27:57 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(testFunc1.length === 2, "testFunc1.length is not 2");
|
2010-07-27 11:31:01 +02:00
|
|
|
ok(testFunc1.arguments === null, "testFunc1.arguments = " + testFunc1.arguments);
|
2008-09-09 01:27:57 +02:00
|
|
|
|
2008-09-10 02:33:15 +02:00
|
|
|
ok(Object.prototype !== undefined, "Object.prototype is undefined");
|
|
|
|
ok(Object.prototype.prototype === undefined, "Object.prototype is not undefined");
|
2008-09-10 02:33:37 +02:00
|
|
|
ok(String.prototype !== undefined, "String.prototype is undefined");
|
2008-09-10 02:33:57 +02:00
|
|
|
ok(Array.prototype !== undefined, "Array.prototype is undefined");
|
2008-09-10 02:34:16 +02:00
|
|
|
ok(Boolean.prototype !== undefined, "Boolean.prototype is undefined");
|
2008-09-10 02:34:33 +02:00
|
|
|
ok(Number.prototype !== undefined, "Number.prototype is undefined");
|
2008-09-10 02:34:54 +02:00
|
|
|
ok(RegExp.prototype !== undefined, "RegExp.prototype is undefined");
|
2008-09-10 02:35:43 +02:00
|
|
|
ok(Math !== undefined, "Math is undefined");
|
|
|
|
ok(Math.prototype === undefined, "Math.prototype is not undefined");
|
2008-09-19 00:46:26 +02:00
|
|
|
ok(Function.prototype !== undefined, "Function.prototype is undefined");
|
2009-07-12 19:52:31 +02:00
|
|
|
ok(Function.prototype.prototype === undefined, "Function.prototype.prototype is not undefined");
|
2008-09-30 17:48:18 +02:00
|
|
|
ok(Date.prototype !== undefined, "Date.prototype is undefined");
|
|
|
|
ok(Date.prototype.prototype === undefined, "Date.prototype is not undefined");
|
2008-09-19 00:46:26 +02:00
|
|
|
|
2012-07-16 15:32:15 +02:00
|
|
|
function testConstructor(constr, name, inst) {
|
2012-07-16 15:31:10 +02:00
|
|
|
ok(constr.prototype.constructor === constr, name + ".prototype.constructor !== " + name);
|
2012-07-16 15:32:15 +02:00
|
|
|
ok(constr.prototype.hasOwnProperty("constructor"), name + ".prototype.hasOwnProperty('constructor')");
|
|
|
|
|
|
|
|
if(!inst)
|
|
|
|
inst = new constr();
|
|
|
|
|
|
|
|
ok(inst.constructor === constr, "(new " + name + "()).constructor !== " + name);
|
|
|
|
ok(!inst.hasOwnProperty("constructor"), "(new " + name + "()).hasOwnProperty('constructor')");
|
2012-07-16 15:31:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
testConstructor(Object, "Object");
|
|
|
|
testConstructor(String, "String");
|
|
|
|
testConstructor(Array, "Array");
|
|
|
|
testConstructor(Boolean, "Boolean");
|
|
|
|
testConstructor(Number, "Number");
|
2012-07-16 15:32:15 +02:00
|
|
|
testConstructor(RegExp, "RegExp", /x/);
|
2012-07-16 15:31:24 +02:00
|
|
|
testConstructor(Function, "Function");
|
2012-07-16 15:31:10 +02:00
|
|
|
testConstructor(Date, "Date");
|
2012-07-16 15:32:15 +02:00
|
|
|
testConstructor(VBArray, "VBArray", new VBArray(createArray()));
|
2012-07-16 15:31:37 +02:00
|
|
|
testConstructor(Error, "Error");
|
|
|
|
testConstructor(EvalError, "EvalError");
|
|
|
|
testConstructor(RangeError, "RangeError");
|
|
|
|
testConstructor(ReferenceError, "ReferenceError");
|
2012-07-16 15:31:58 +02:00
|
|
|
testConstructor(RegExpError, "RegExpError");
|
2012-07-16 15:31:37 +02:00
|
|
|
testConstructor(SyntaxError, "SyntaxError");
|
|
|
|
testConstructor(TypeError, "TypeError");
|
|
|
|
testConstructor(URIError, "URIError");
|
2012-07-16 15:30:54 +02:00
|
|
|
|
2008-09-19 00:46:26 +02:00
|
|
|
Function.prototype.test = true;
|
|
|
|
ok(testFunc1.test === true, "testFunc1.test !== true");
|
|
|
|
ok(Function.test === true, "Function.test !== true");
|
2008-09-10 02:33:15 +02:00
|
|
|
|
2008-09-10 02:36:03 +02:00
|
|
|
ok(typeof(0) === "number", "typeof(0) is not number");
|
|
|
|
ok(typeof(1.5) === "number", "typeof(1.5) is not number");
|
|
|
|
ok(typeof("abc") === "string", "typeof(\"abc\") is not string");
|
|
|
|
ok(typeof("") === "string", "typeof(\"\") is not string");
|
|
|
|
ok(typeof(true) === "boolean", "typeof(true) is not boolean");
|
|
|
|
ok(typeof(null) === "object", "typeof(null) is not object");
|
|
|
|
ok(typeof(undefined) === "undefined", "typeof(undefined) is not undefined");
|
|
|
|
ok(typeof(Math) === "object", "typeof(Math) is not object");
|
|
|
|
ok(typeof(String.prototype) === "object", "typeof(String.prototype) is not object");
|
|
|
|
ok(typeof(testFunc1) === "function", "typeof(testFunc1) is not function");
|
|
|
|
ok(typeof(String) === "function", "typeof(String) is not function");
|
|
|
|
ok(typeof(ScriptEngine) === "function", "typeof(ScriptEngine) is not function");
|
2008-09-10 21:05:14 +02:00
|
|
|
ok(typeof(this) === "object", "typeof(this) is not object");
|
2010-12-29 16:02:25 +01:00
|
|
|
ok(typeof(doesnotexist) === "undefined", "typeof(doesnotexist) = " + typeof(doesnotexist));
|
|
|
|
tmp = typeof((new Object()).doesnotexist);
|
|
|
|
ok(tmp === "undefined", "typeof((new Object).doesnotexist = " + tmp);
|
|
|
|
tmp = typeof(testObj.onlyDispID);
|
|
|
|
ok(tmp === "unknown", "typeof(testObj.onlyDispID) = " + tmp);
|
2008-09-10 02:36:03 +02:00
|
|
|
|
2008-09-10 21:06:09 +02:00
|
|
|
ok(testFunc1(true, "test") === true, "testFunc1 not returned true");
|
|
|
|
|
2010-07-27 11:31:01 +02:00
|
|
|
ok(testFunc1.arguments === null, "testFunc1.arguments = " + testFunc1.arguments);
|
|
|
|
|
2011-12-05 11:11:29 +01:00
|
|
|
(tmp) = 3;
|
|
|
|
ok(tmp === 3, "tmp = " + tmp);
|
|
|
|
|
2010-07-27 11:31:01 +02:00
|
|
|
function testRecFunc(x) {
|
|
|
|
ok(testRecFunc.arguments === arguments, "testRecFunc.arguments = " + testRecFunc.arguments);
|
|
|
|
if(x) {
|
|
|
|
testRecFunc(false);
|
|
|
|
ok(testRecFunc.arguments === arguments, "testRecFunc.arguments = " + testRecFunc.arguments);
|
|
|
|
ok(testRecFunc.arguments[0] === true, "testRecFunc.arguments.x = " + testRecFunc.arguments[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
testRecFunc.arguments = 5;
|
|
|
|
ok(testRecFunc.arguments === null, "testRecFunc.arguments = " + testRecFunc.arguments);
|
|
|
|
testRecFunc(true);
|
|
|
|
ok(testRecFunc.arguments === null, "testRecFunc.arguments = " + testRecFunc.arguments);
|
|
|
|
|
2016-03-24 16:39:23 +01:00
|
|
|
function argumentsTest() {
|
|
|
|
var save = arguments;
|
|
|
|
with({arguments: 1}) {
|
|
|
|
ok(arguments === 1, "arguments = " + arguments);
|
|
|
|
(function() {
|
|
|
|
ok(argumentsTest.arguments === save, "unexpected argumentsTest.arguments");
|
|
|
|
})();
|
|
|
|
}
|
|
|
|
eval('ok(arguments === save, "unexpected arguments");');
|
|
|
|
[1,2].sort(function() {
|
|
|
|
ok(argumentsTest.arguments === save, "unexpected argumentsTest.arguments");
|
2016-03-28 17:51:28 +02:00
|
|
|
return 1;
|
2016-03-24 16:39:23 +01:00
|
|
|
});
|
|
|
|
}
|
2016-05-25 14:08:15 +02:00
|
|
|
|
2016-03-28 17:51:28 +02:00
|
|
|
argumentsTest();
|
2016-03-24 16:39:23 +01:00
|
|
|
|
2016-08-03 16:28:32 +02:00
|
|
|
// arguments object detached from its execution context
|
|
|
|
(function() {
|
|
|
|
var args, get_x, set_x;
|
|
|
|
|
|
|
|
function test_args(detached) {
|
|
|
|
ok(args[0] === 1, "args[0] = " + args[0]);
|
|
|
|
set_x(2);
|
|
|
|
ok(args[0] === (detached ? 1 : 2), "args[0] = " + args[0] + " expected " + (detached ? 1 : 2));
|
|
|
|
args[0] = 3;
|
|
|
|
ok(get_x() === (detached ? 2 : 3), "get_x() = " + get_x());
|
|
|
|
ok(args[0] === 3, "args[0] = " + args[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
(function(x) {
|
|
|
|
args = arguments;
|
|
|
|
get_x = function() { return x; };
|
|
|
|
set_x = function(v) { x = v; };
|
|
|
|
|
|
|
|
test_args(false);
|
|
|
|
x = 1;
|
|
|
|
})(1);
|
|
|
|
|
|
|
|
test_args(true);
|
|
|
|
})();
|
|
|
|
|
|
|
|
// arguments is a regular variable, it may be overwritten
|
|
|
|
(function() {
|
|
|
|
ok(typeof(arguments) === "object", "typeof(arguments) = " + typeof(arguments));
|
|
|
|
arguments = 1;
|
|
|
|
ok(arguments === 1, "arguments = " + arguments);
|
|
|
|
})();
|
|
|
|
|
2016-05-25 14:08:15 +02:00
|
|
|
(function callAsExprTest() {
|
|
|
|
ok(callAsExprTest.arguments === null, "callAsExprTest.arguments = " + callAsExprTest.arguments);
|
|
|
|
})(1,2);
|
|
|
|
|
2009-11-04 23:19:11 +01:00
|
|
|
tmp = (function() {1;})();
|
|
|
|
ok(tmp === undefined, "tmp = " + tmp);
|
|
|
|
tmp = eval("1;");
|
|
|
|
ok(tmp === 1, "tmp = " + tmp);
|
2011-12-19 14:58:42 +01:00
|
|
|
tmp = eval("1,2;");
|
|
|
|
ok(tmp === 2, "tmp = " + tmp);
|
2012-12-14 11:06:28 +01:00
|
|
|
tmp = eval("testNoRes(),2;");
|
|
|
|
ok(tmp === 2, "tmp = " + tmp);
|
2011-12-19 14:58:42 +01:00
|
|
|
tmp = eval("if(true) {3}");
|
|
|
|
ok(tmp === 3, "tmp = " + tmp);
|
2012-12-13 12:08:34 +01:00
|
|
|
eval("testRes(); testRes()");
|
|
|
|
tmp = eval("3; if(false) {4;} else {};;;")
|
|
|
|
ok(tmp === 3, "tmp = " + tmp);
|
2017-05-01 18:29:53 +02:00
|
|
|
tmp = eval("try { 1; } finally { 2; }")
|
|
|
|
ok(tmp === 2, "tmp = " + tmp);
|
2012-12-13 12:08:34 +01:00
|
|
|
|
2012-12-14 11:06:28 +01:00
|
|
|
testNoRes();
|
|
|
|
testRes() && testRes();
|
|
|
|
testNoRes(), testNoRes();
|
|
|
|
|
2016-08-05 17:15:20 +02:00
|
|
|
(function() {
|
|
|
|
eval("var x=1;");
|
|
|
|
ok(x === 1, "x = " + x);
|
|
|
|
})();
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
var e = eval;
|
|
|
|
var r = e(1);
|
|
|
|
ok(r === 1, "r = " + r);
|
|
|
|
(function(x, a) { x(a); })(eval, "2");
|
|
|
|
})();
|
|
|
|
|
|
|
|
(function(r) {
|
|
|
|
r = eval("1");
|
|
|
|
ok(r === 1, "r = " + r);
|
|
|
|
(function(x, a) { x(a); })(eval, "2");
|
|
|
|
})();
|
|
|
|
|
2012-12-14 11:06:28 +01:00
|
|
|
tmp = (function(){ return testNoRes(), testRes();})();
|
2009-11-04 23:19:11 +01:00
|
|
|
|
2016-05-06 12:56:35 +02:00
|
|
|
var f1, f2;
|
|
|
|
|
|
|
|
ok(funcexpr() == 2, "funcexpr() = " + funcexpr());
|
|
|
|
|
|
|
|
f1 = function funcexpr() { return 1; }
|
|
|
|
ok(f1 != funcexpr, "f1 == funcexpr");
|
|
|
|
ok(f1() === 1, "f1() = " + f1());
|
|
|
|
|
|
|
|
f2 = function funcexpr() { return 2; }
|
|
|
|
ok(f2 != funcexpr, "f2 != funcexpr");
|
|
|
|
ok(f2() === 2, "f2() = " + f2());
|
|
|
|
|
|
|
|
f1 = null;
|
|
|
|
for(i = 0; i < 3; i++) {
|
|
|
|
f2 = function funcexpr2() {};
|
|
|
|
ok(f1 != f2, "f1 == f2");
|
|
|
|
f1 = f2;
|
|
|
|
}
|
|
|
|
|
|
|
|
f1 = null;
|
|
|
|
for(i = 0; i < 3; i++) {
|
|
|
|
f2 = function() {};
|
|
|
|
ok(f1 != f2, "f1 == f2");
|
|
|
|
f1 = f2;
|
|
|
|
}
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
ok(infuncexpr() == 2, "infuncexpr() = " + infuncexpr());
|
|
|
|
|
|
|
|
f1 = function infuncexpr() { return 1; }
|
|
|
|
ok(f1 != funcexpr, "f1 == funcexpr");
|
|
|
|
ok(f1() === 1, "f1() = " + f1());
|
|
|
|
|
|
|
|
f2 = function infuncexpr() { return 2; }
|
|
|
|
ok(f2 != funcexpr, "f2 != funcexpr");
|
|
|
|
ok(f2() === 2, "f2() = " + f2());
|
|
|
|
|
|
|
|
f1 = null;
|
|
|
|
for(i = 0; i < 3; i++) {
|
|
|
|
f2 = function infuncexpr2() {};
|
|
|
|
ok(f1 != f2, "f1 == f2");
|
|
|
|
f1 = f2;
|
|
|
|
}
|
|
|
|
|
|
|
|
f1 = null;
|
|
|
|
for(i = 0; i < 3; i++) {
|
|
|
|
f2 = function() {};
|
|
|
|
ok(f1 != f2, "f1 == f2");
|
|
|
|
f1 = f2;
|
|
|
|
}
|
|
|
|
})();
|
|
|
|
|
2008-09-10 21:08:26 +02:00
|
|
|
var obj1 = new Object();
|
|
|
|
ok(typeof(obj1) === "object", "typeof(obj1) is not object");
|
2010-02-05 23:17:35 +01:00
|
|
|
ok(obj1.constructor === Object, "unexpected obj1.constructor");
|
2008-09-10 21:08:46 +02:00
|
|
|
obj1.test = true;
|
|
|
|
obj1.func = function () {
|
|
|
|
ok(this === obj1, "this is not obj1");
|
|
|
|
ok(this.test === true, "this.test is not true");
|
|
|
|
ok(arguments.length === 1, "arguments.length is not 1");
|
|
|
|
ok(arguments["0"] === true, "arguments[0] is not true");
|
2009-09-20 20:58:27 +02:00
|
|
|
ok(typeof(arguments.callee) === "function", "typeof(arguments.calee) = " + typeof(arguments.calee));
|
2008-09-10 21:08:46 +02:00
|
|
|
|
|
|
|
return "test";
|
|
|
|
};
|
|
|
|
|
|
|
|
ok(obj1.func(true) === "test", "obj1.func(true) is not \"test\"");
|
2008-09-10 21:08:26 +02:00
|
|
|
|
2008-09-10 21:09:04 +02:00
|
|
|
function testConstr1() {
|
|
|
|
this.var1 = 1;
|
|
|
|
|
|
|
|
ok(this !== undefined, "this is undefined");
|
|
|
|
ok(arguments.length === 1, "arguments.length is not 1");
|
|
|
|
ok(arguments["0"] === true, "arguments[0] is not 1");
|
2009-09-20 20:58:27 +02:00
|
|
|
ok(arguments.callee === testConstr1, "arguments.calee !== testConstr1");
|
2008-09-10 21:09:04 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
testConstr1.prototype.pvar = 1;
|
2012-07-16 15:32:15 +02:00
|
|
|
ok(testConstr1.prototype.constructor === testConstr1, "testConstr1.prototype.constructor !== testConstr1");
|
2008-09-10 21:09:04 +02:00
|
|
|
|
|
|
|
var obj2 = new testConstr1(true);
|
|
|
|
ok(typeof(obj2) === "object", "typeof(obj2) is not object");
|
2010-02-05 23:17:35 +01:00
|
|
|
ok(obj2.constructor === testConstr1, "unexpected obj2.constructor");
|
2008-09-10 21:09:04 +02:00
|
|
|
ok(obj2.pvar === 1, "obj2.pvar is not 1");
|
2012-07-16 15:32:15 +02:00
|
|
|
ok(!obj2.hasOwnProperty('constructor'), "obj2.hasOwnProperty('constructor')");
|
2008-09-10 21:09:04 +02:00
|
|
|
|
|
|
|
testConstr1.prototype.pvar = 2;
|
|
|
|
ok(obj2.pvar === 2, "obj2.pvar is not 2");
|
|
|
|
|
|
|
|
obj2.pvar = 3;
|
|
|
|
testConstr1.prototype.pvar = 1;
|
|
|
|
ok(obj2.pvar === 3, "obj2.pvar is not 3");
|
|
|
|
|
2009-10-19 20:42:03 +02:00
|
|
|
obj1 = new Object();
|
|
|
|
function testConstr3() {
|
|
|
|
return obj1;
|
|
|
|
}
|
|
|
|
|
|
|
|
obj2 = new testConstr3();
|
|
|
|
ok(obj1 === obj2, "obj1 != obj2");
|
|
|
|
|
|
|
|
function testConstr4() {
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
obj2 = new testConstr3();
|
|
|
|
ok(typeof(obj2) === "object", "typeof(obj2) = " + typeof(obj2));
|
|
|
|
|
2008-09-17 23:29:58 +02:00
|
|
|
var obj3 = new Object;
|
|
|
|
ok(typeof(obj3) === "object", "typeof(obj3) is not object");
|
|
|
|
|
2016-08-05 17:15:20 +02:00
|
|
|
(function() {
|
|
|
|
ok(typeof(func) === "function", "typeof(func) = " + typeof(func));
|
|
|
|
function func() {}
|
|
|
|
ok(typeof(func) === "function", "typeof(func) = " + typeof(func));
|
|
|
|
func = 0;
|
|
|
|
ok(typeof(func) === "number", "typeof(func) = " + typeof(func));
|
|
|
|
})();
|
|
|
|
|
|
|
|
(function(f) {
|
|
|
|
ok(typeof(f) === "function", "typeof(f) = " + typeof(f));
|
|
|
|
function f() {};
|
|
|
|
ok(typeof(f) === "function", "typeof(f) = " + typeof(f));
|
|
|
|
})(1);
|
|
|
|
|
2008-09-21 15:40:04 +02:00
|
|
|
for(var iter in "test")
|
|
|
|
ok(false, "unexpected forin call, test = " + iter);
|
|
|
|
|
|
|
|
for(var iter in null)
|
|
|
|
ok(false, "unexpected forin call, test = " + iter);
|
|
|
|
|
|
|
|
for(var iter in false)
|
|
|
|
ok(false, "unexpected forin call, test = " + iter);
|
|
|
|
|
2011-06-21 17:45:50 +02:00
|
|
|
for(var iter in pureDisp)
|
|
|
|
ok(false, "unexpected forin call in pureDisp object");
|
|
|
|
|
2011-11-18 14:10:40 +01:00
|
|
|
tmp = new Object();
|
|
|
|
ok(!tmp.nonexistent, "!tmp.nonexistent = " + !tmp.nonexistent);
|
2011-11-21 15:35:15 +01:00
|
|
|
ok(!("nonexistent" in tmp), "nonexistent is in tmp after '!' expression")
|
|
|
|
|
|
|
|
tmp = new Object();
|
|
|
|
ok((~tmp.nonexistent) === -1, "!tmp.nonexistent = " + ~tmp.nonexistent);
|
|
|
|
ok(!("nonexistent" in tmp), "nonexistent is in tmp after '~' expression")
|
2011-11-18 14:10:40 +01:00
|
|
|
|
2011-11-22 16:31:29 +01:00
|
|
|
tmp = new Object();
|
2011-12-15 15:43:43 +01:00
|
|
|
ok(isNaN(+tmp.nonexistent), "!tmp.nonexistent = " + (+tmp.nonexistent));
|
2011-11-22 16:31:29 +01:00
|
|
|
ok(!("nonexistent" in tmp), "nonexistent is in tmp after '+' expression")
|
|
|
|
|
2011-12-15 15:43:43 +01:00
|
|
|
tmp = new Object();
|
|
|
|
tmp[tmp.nonexistent];
|
|
|
|
ok(!("nonexistent" in tmp), "nonexistent is in tmp after array expression")
|
|
|
|
|
2008-09-10 21:10:06 +02:00
|
|
|
tmp = 0;
|
|
|
|
if(true)
|
|
|
|
tmp = 1;
|
|
|
|
else
|
|
|
|
ok(false, "else evaluated");
|
|
|
|
ok(tmp === 1, "tmp !== 1, if not evaluated?");
|
|
|
|
|
|
|
|
tmp = 0;
|
|
|
|
if(1 === 0)
|
|
|
|
ok(false, "if evaluated");
|
|
|
|
else
|
|
|
|
tmp = 1;
|
|
|
|
ok(tmp === 1, "tmp !== 1, if not evaluated?");
|
|
|
|
|
|
|
|
if(false)
|
|
|
|
ok(false, "if(false) evaluated");
|
|
|
|
|
|
|
|
tmp = 0;
|
|
|
|
if(true)
|
|
|
|
tmp = 1;
|
|
|
|
ok(tmp === 1, "tmp !== 1, if(true) not evaluated?");
|
|
|
|
|
2008-10-02 16:22:45 +02:00
|
|
|
if(false) {
|
|
|
|
}else {
|
|
|
|
}
|
|
|
|
|
2008-09-10 21:10:23 +02:00
|
|
|
var obj3 = { prop1: 1, prop2: typeof(false) };
|
|
|
|
ok(obj3.prop1 === 1, "obj3.prop1 is not 1");
|
|
|
|
ok(obj3.prop2 === "boolean", "obj3.prop2 is not \"boolean\"");
|
2010-02-05 23:17:35 +01:00
|
|
|
ok(obj3.constructor === Object, "unexpected obj3.constructor");
|
2008-09-10 21:10:23 +02:00
|
|
|
|
2008-09-10 21:10:41 +02:00
|
|
|
{
|
|
|
|
var blockVar = 1;
|
|
|
|
blockVar = 2;
|
|
|
|
}
|
|
|
|
ok(blockVar === 2, "blockVar !== 2");
|
|
|
|
|
2008-09-10 21:11:15 +02:00
|
|
|
ok((true ? 1 : 2) === 1, "conditional expression true is not 1");
|
|
|
|
ok((0 === 2 ? 1 : 2) === 2, "conditional expression true is not 2");
|
|
|
|
|
2008-09-10 21:12:19 +02:00
|
|
|
ok(getVT(undefined) === "VT_EMPTY", "getVT(undefined) is not VT_EMPTY");
|
|
|
|
ok(getVT(null) === "VT_NULL", "getVT(null) is not VT_NULL");
|
|
|
|
ok(getVT(0) === "VT_I4", "getVT(0) is not VT_I4");
|
2011-06-26 18:28:28 +02:00
|
|
|
ok(getVT(0.5) === "VT_R8", "getVT(0.5) is not VT_R8");
|
2008-09-10 21:12:19 +02:00
|
|
|
ok(getVT("test") === "VT_BSTR", "getVT(\"test\") is not VT_BSTR");
|
|
|
|
ok(getVT(Math) === "VT_DISPATCH", "getVT(Math) is not VT_DISPATCH");
|
|
|
|
ok(getVT(false) === "VT_BOOL", "getVT(false) is not VT_BOOL");
|
|
|
|
|
2008-09-10 21:12:45 +02:00
|
|
|
tmp = 2+2;
|
|
|
|
ok(tmp === 4, "2+2 !== 4");
|
|
|
|
ok(getVT(tmp) === "VT_I4", "getVT(2+2) !== VT_I4");
|
|
|
|
|
|
|
|
tmp = 2+2.5;
|
|
|
|
ok(tmp === 4.5, "2+2.5 !== 4.5");
|
|
|
|
ok(getVT(tmp) === "VT_R8", "getVT(2+2.5) !== VT_R8");
|
|
|
|
|
|
|
|
tmp = 1.5+2.5;
|
|
|
|
ok(tmp === 4, "1.4+2.5 !== 4");
|
|
|
|
ok(getVT(tmp) === "VT_I4", "getVT(1.5+2.5) !== VT_I4");
|
|
|
|
|
2008-09-16 20:46:01 +02:00
|
|
|
tmp = 4-2;
|
|
|
|
ok(tmp === 2, "4-2 !== 2");
|
|
|
|
ok(getVT(tmp) === "VT_I4", "getVT(4-2) !== VT_I4");
|
|
|
|
|
|
|
|
tmp = 4.5-2;
|
|
|
|
ok(tmp === 2.5, "4.5-2 !== 2.5");
|
2011-06-26 18:28:28 +02:00
|
|
|
ok(getVT(tmp) === "VT_R8", "getVT(4.5-2) !== VT_R8");
|
2008-09-16 20:46:01 +02:00
|
|
|
|
2008-09-16 20:47:43 +02:00
|
|
|
tmp = -2;
|
|
|
|
ok(tmp === 0-2, "-2 !== 0-2");
|
|
|
|
ok(getVT(tmp) === "VT_I4", "getVT(-2) !== VT_I4");
|
|
|
|
|
2008-09-16 20:46:33 +02:00
|
|
|
tmp = 2*3;
|
|
|
|
ok(tmp === 6, "2*3 !== 6");
|
|
|
|
ok(getVT(tmp) === "VT_I4", "getVT(2*3) !== VT_I4");
|
|
|
|
|
|
|
|
tmp = 2*3.5;
|
|
|
|
ok(tmp === 7, "2*3.5 !== 7");
|
|
|
|
ok(getVT(tmp) === "VT_I4", "getVT(2*3.5) !== VT_I4");
|
|
|
|
|
|
|
|
tmp = 2.5*3.5;
|
2010-06-22 12:52:03 +02:00
|
|
|
/* FIXME: the parser loses precision */
|
|
|
|
/* ok(tmp === 8.75, "2.5*3.5 !== 8.75"); */
|
|
|
|
ok(tmp > 8.749999 && tmp < 8.750001, "2.5*3.5 !== 8.75");
|
2008-09-16 20:46:33 +02:00
|
|
|
ok(getVT(tmp) === "VT_R8", "getVT(2.5*3.5) !== VT_R8");
|
|
|
|
|
2016-04-28 11:12:35 +02:00
|
|
|
tmp = 2*.5;
|
|
|
|
ok(tmp === 1, "2*.5 !== 1");
|
|
|
|
ok(getVT(tmp) == "VT_I4", "getVT(2*.5) !== VT_I4");
|
|
|
|
|
2008-09-16 20:47:06 +02:00
|
|
|
tmp = 4/2;
|
|
|
|
ok(tmp === 2, "4/2 !== 2");
|
|
|
|
ok(getVT(tmp) === "VT_I4", "getVT(4/2) !== VT_I4");
|
|
|
|
|
|
|
|
tmp = 4.5/1.5;
|
|
|
|
ok(tmp === 3, "4.5/1.5 !== 3");
|
|
|
|
ok(getVT(tmp) === "VT_I4", "getVT(4.5/1.5) !== VT_I4");
|
|
|
|
|
|
|
|
tmp = 3/2;
|
|
|
|
ok(tmp === 1.5, "3/2 !== 1.5");
|
|
|
|
ok(getVT(tmp) === "VT_R8", "getVT(3/2) !== VT_R8");
|
|
|
|
|
2008-10-09 01:09:17 +02:00
|
|
|
tmp = 3%2;
|
|
|
|
ok(tmp === 1, "3%2 = " + tmp);
|
|
|
|
|
|
|
|
tmp = 4%2;
|
|
|
|
ok(tmp ===0, "4%2 = " + tmp);
|
|
|
|
|
|
|
|
tmp = 3.5%1.5;
|
|
|
|
ok(tmp === 0.5, "3.5%1.5 = " + tmp);
|
|
|
|
|
|
|
|
tmp = 3%true;
|
|
|
|
ok(tmp === 0, "3%true = " + tmp);
|
|
|
|
|
2008-09-10 21:12:45 +02:00
|
|
|
tmp = "ab" + "cd";
|
|
|
|
ok(tmp === "abcd", "\"ab\" + \"cd\" !== \"abcd\"");
|
|
|
|
|
2008-09-11 23:54:45 +02:00
|
|
|
tmp = 1;
|
|
|
|
ok((tmp += 1) === 2, "tmp += 1 !== 2");
|
|
|
|
ok(tmp === 2, "tmp !== 2");
|
|
|
|
|
2008-09-16 20:46:17 +02:00
|
|
|
tmp = 2;
|
|
|
|
ok((tmp -= 1) === 1, "tmp -= 1 !== 1");
|
|
|
|
ok(tmp === 1, "tmp !=== 1");
|
|
|
|
|
2008-09-16 20:46:49 +02:00
|
|
|
tmp = 2;
|
|
|
|
ok((tmp *= 1.5) === 3, "tmp *= 1.5 !== 3");
|
|
|
|
ok(tmp === 3, "tmp !=== 3");
|
|
|
|
|
2008-09-16 20:47:27 +02:00
|
|
|
tmp = 5;
|
|
|
|
ok((tmp /= 2) === 2.5, "tmp /= 2 !== 2.5");
|
|
|
|
ok(tmp === 2.5, "tmp !=== 2.5");
|
|
|
|
|
2008-10-09 01:09:27 +02:00
|
|
|
tmp = 3;
|
|
|
|
ok((tmp %= 2) === 1, "tmp %= 2 !== 1");
|
|
|
|
ok(tmp === 1, "tmp !== 1");
|
|
|
|
|
2008-09-19 00:45:05 +02:00
|
|
|
tmp = 8;
|
|
|
|
ok((tmp <<= 1) === 16, "tmp <<= 1 !== 16");
|
|
|
|
|
2008-09-19 00:45:20 +02:00
|
|
|
tmp = 8;
|
|
|
|
ok((tmp >>= 1) === 4, "tmp >>= 1 !== 4");
|
|
|
|
|
2008-09-19 00:45:35 +02:00
|
|
|
tmp = 8;
|
|
|
|
ok((tmp >>>= 1) === 4, "tmp >>>= 1 !== 4");
|
|
|
|
|
2008-09-11 23:55:14 +02:00
|
|
|
tmp = 3 || ok(false, "second or expression called");
|
|
|
|
ok(tmp === 3, "3 || (...) is not 3");
|
|
|
|
|
|
|
|
tmp = false || 2;
|
|
|
|
ok(tmp === 2, "false || 2 is not 2");
|
|
|
|
|
2008-09-11 23:55:38 +02:00
|
|
|
tmp = 0 && ok(false, "second and expression called");
|
|
|
|
ok(tmp === 0, "0 && (...) is not 0");
|
|
|
|
|
|
|
|
tmp = true && "test";
|
|
|
|
ok(tmp === "test", "true && \"test\" is not \"test\"");
|
|
|
|
|
|
|
|
tmp = true && 0;
|
|
|
|
ok(tmp === 0, "true && 0 is not 0");
|
|
|
|
|
2008-09-17 23:31:02 +02:00
|
|
|
tmp = 3 | 4;
|
|
|
|
ok(tmp === 7, "3 | 4 !== 7");
|
|
|
|
ok(getVT(tmp) === "VT_I4", "getVT(3|4) = " + getVT(tmp));
|
|
|
|
|
|
|
|
tmp = 3.5 | 0;
|
|
|
|
ok(tmp === 3, "3.5 | 0 !== 3");
|
|
|
|
ok(getVT(tmp) === "VT_I4", "getVT(3.5|0) = " + getVT(tmp));
|
|
|
|
|
|
|
|
tmp = -3.5 | 0;
|
|
|
|
ok(tmp === -3, "-3.5 | 0 !== -3");
|
|
|
|
ok(getVT(tmp) === "VT_I4", "getVT(3.5|0) = " + getVT(tmp));
|
|
|
|
|
2009-12-04 02:56:04 +01:00
|
|
|
tmp = 0 | NaN;
|
|
|
|
ok(tmp === 0, "0 | NaN = " + tmp);
|
|
|
|
|
|
|
|
tmp = 0 | Infinity;
|
|
|
|
ok(tmp === 0, "0 | NaN = " + tmp);
|
|
|
|
|
|
|
|
tmp = 0 | (-Infinity);
|
|
|
|
ok(tmp === 0, "0 | NaN = " + tmp);
|
|
|
|
|
2008-09-17 23:31:22 +02:00
|
|
|
tmp = 10;
|
|
|
|
ok((tmp |= 0x10) === 26, "tmp(10) |= 0x10 !== 26");
|
|
|
|
ok(getVT(tmp) === "VT_I4", "getVT(tmp |= 10) = " + getVT(tmp));
|
|
|
|
|
2018-04-11 19:36:00 +02:00
|
|
|
tmp = (123 * Math.pow(2,32) + 2) | 0;
|
|
|
|
ok(tmp === 2, "123*2^32+2 | 0 = " + tmp);
|
|
|
|
|
|
|
|
tmp = (-123 * Math.pow(2,32) + 2) | 0;
|
|
|
|
ok(tmp === 2, "123*2^32+2 | 0 = " + tmp);
|
|
|
|
|
2008-09-17 23:31:38 +02:00
|
|
|
tmp = 3 & 5;
|
|
|
|
ok(tmp === 1, "3 & 5 !== 1");
|
|
|
|
ok(getVT(tmp) === "VT_I4", "getVT(3|5) = " + getVT(tmp));
|
|
|
|
|
|
|
|
tmp = 3.5 & 0xffff;
|
|
|
|
ok(tmp === 3, "3.5 & 0xffff !== 3 ");
|
|
|
|
ok(getVT(tmp) === "VT_I4", "getVT(3.5&0xffff) = " + getVT(tmp));
|
|
|
|
|
|
|
|
tmp = (-3.5) & 0xffffffff;
|
|
|
|
ok(tmp === -3, "-3.5 & 0xffff !== -3");
|
|
|
|
ok(getVT(tmp) === "VT_I4", "getVT(3.5&0xffff) = " + getVT(tmp));
|
|
|
|
|
2008-09-19 00:44:11 +02:00
|
|
|
tmp = 2 << 3;
|
|
|
|
ok(tmp === 16, "2 << 3 = " + tmp);
|
|
|
|
|
|
|
|
tmp = 2 << 35;
|
|
|
|
ok(tmp === 16, "2 << 35 = " + tmp);
|
|
|
|
|
2008-09-19 00:44:29 +02:00
|
|
|
tmp = 8 >> 2;
|
|
|
|
ok(tmp === 2, "8 >> 2 = " + tmp);
|
|
|
|
|
|
|
|
tmp = -64 >> 4;
|
|
|
|
ok(tmp === -4, "-64 >> 4 = " + tmp);
|
|
|
|
|
2008-09-19 00:44:49 +02:00
|
|
|
tmp = 8 >>> 2;
|
|
|
|
ok(tmp === 2, "8 >> 2 = " + tmp);
|
|
|
|
|
|
|
|
tmp = -64 >>> 4;
|
|
|
|
ok(tmp === 0x0ffffffc, "-64 >>> 4 = " + tmp);
|
|
|
|
|
2009-12-04 02:56:04 +01:00
|
|
|
tmp = 4 >>> NaN;
|
|
|
|
ok(tmp === 4, "4 >>> NaN = " + tmp);
|
|
|
|
|
2008-09-17 23:31:54 +02:00
|
|
|
tmp = 10;
|
|
|
|
ok((tmp &= 8) === 8, "tmp(10) &= 8 !== 8");
|
|
|
|
ok(getVT(tmp) === "VT_I4", "getVT(tmp &= 8) = " + getVT(tmp));
|
|
|
|
|
2008-09-17 23:32:11 +02:00
|
|
|
tmp = 0xf0f0^0xff00;
|
|
|
|
ok(tmp === 0x0ff0, "0xf0f0^0xff00 !== 0x0ff0");
|
|
|
|
ok(getVT(tmp) === "VT_I4", "getVT(0xf0f0^0xff00) = " + getVT(tmp));
|
|
|
|
|
2008-09-17 23:32:27 +02:00
|
|
|
tmp = 5;
|
|
|
|
ok((tmp ^= 3) === 6, "tmp(5) ^= 3 !== 6");
|
|
|
|
ok(getVT(tmp) === "VT_I4", "getVT(tmp ^= 3) = " + getVT(tmp));
|
|
|
|
|
2008-09-17 23:32:59 +02:00
|
|
|
tmp = ~1;
|
|
|
|
ok(tmp === -2, "~1 !== -2");
|
|
|
|
ok(getVT(tmp) === "VT_I4", "getVT(~1) = " + getVT(tmp));
|
|
|
|
|
2008-09-17 23:32:43 +02:00
|
|
|
ok((3,4) === 4, "(3,4) !== 4");
|
|
|
|
|
2008-09-17 23:33:15 +02:00
|
|
|
ok(+3 === 3, "+3 !== 3");
|
2008-09-17 23:33:32 +02:00
|
|
|
ok(+true === 1, "+true !== 1");
|
|
|
|
ok(+false === 0, "+false !== 0");
|
|
|
|
ok(+null === 0, "+null !== 0");
|
2008-09-21 19:47:31 +02:00
|
|
|
ok(+"0" === 0, "+'0' !== 0");
|
|
|
|
ok(+"3" === 3, "+'3' !== 3");
|
|
|
|
ok(+"-3" === -3, "+'-3' !== -3");
|
|
|
|
ok(+"0xff" === 255, "+'0xff' !== 255");
|
|
|
|
ok(+"3e3" === 3000, "+'3e3' !== 3000");
|
2008-09-17 23:33:15 +02:00
|
|
|
|
2008-09-25 00:52:10 +02:00
|
|
|
tmp = new Number(1);
|
2009-09-08 23:57:26 +02:00
|
|
|
ok(+tmp === 1, "+(new Number(1)) = " + (+tmp));
|
2010-02-05 23:17:35 +01:00
|
|
|
ok(tmp.constructor === Number, "unexpected tmp.constructor");
|
2008-09-25 00:52:10 +02:00
|
|
|
tmp = new String("1");
|
2009-09-08 23:57:26 +02:00
|
|
|
ok(+tmp === 1, "+(new String('1')) = " + (+tmp));
|
2010-02-05 23:17:35 +01:00
|
|
|
ok(tmp.constructor === String, "unexpected tmp.constructor");
|
2008-09-25 00:52:10 +02:00
|
|
|
|
2008-09-17 23:34:56 +02:00
|
|
|
ok("" + 0 === "0", "\"\" + 0 !== \"0\"");
|
|
|
|
ok("" + 123 === "123", "\"\" + 123 !== \"123\"");
|
|
|
|
ok("" + (-5) === "-5", "\"\" + (-5) !== \"-5\"");
|
2008-09-19 00:46:05 +02:00
|
|
|
ok("" + null === "null", "\"\" + null !== \"null\"");
|
|
|
|
ok("" + undefined === "undefined", "\"\" + undefined !== \"undefined\"");
|
|
|
|
ok("" + true === "true", "\"\" + true !== \"true\"");
|
|
|
|
ok("" + false === "false", "\"\" + false !== \"false\"");
|
2008-09-25 00:50:49 +02:00
|
|
|
ok("" + 0.5 === "0.5", "'' + 0.5 = " + 0.5);
|
|
|
|
ok("" + (-0.5432) === "-0.5432", "'' + (-0.5432) = " + (-0.5432));
|
2008-09-17 23:34:56 +02:00
|
|
|
|
2008-09-11 23:56:03 +02:00
|
|
|
ok(1 < 3.4, "1 < 3.4 failed");
|
|
|
|
ok(!(3.4 < 1), "3.4 < 1");
|
|
|
|
ok("abc" < "abcd", "abc < abcd failed");
|
|
|
|
ok("abcd" < "abce", "abce < abce failed");
|
|
|
|
ok("" < "x", "\"\" < \"x\" failed");
|
|
|
|
ok(!(0 < 0), "0 < 0");
|
|
|
|
|
2008-09-11 23:56:29 +02:00
|
|
|
ok(1 <= 3.4, "1 <= 3.4 failed");
|
|
|
|
ok(!(3.4 <= 1), "3.4 <= 1");
|
|
|
|
ok("abc" <= "abcd", "abc <= abcd failed");
|
|
|
|
ok("abcd" <= "abce", "abce <= abce failed");
|
|
|
|
ok("" <= "x", "\"\" <= \"x\" failed");
|
|
|
|
ok(0 <= 0, "0 <= 0 failed");
|
|
|
|
|
2008-09-11 23:56:51 +02:00
|
|
|
ok(3.4 > 1, "3.4 > 1 failed");
|
|
|
|
ok(!(1 > 3.4), "1 > 3.4");
|
|
|
|
ok("abcd" > "abc", "abc > abcd failed");
|
|
|
|
ok("abce" > "abcd", "abce > abce failed");
|
|
|
|
ok("x" > "", "\"x\" > \"\" failed");
|
|
|
|
ok(!(0 > 0), "0 > 0");
|
|
|
|
|
2008-09-11 23:57:13 +02:00
|
|
|
ok(3.4 >= 1, "3.4 >= 1 failed");
|
|
|
|
ok(!(1 >= 3.4), "1 >= 3.4");
|
|
|
|
ok("abcd" >= "abc", "abc >= abcd failed");
|
|
|
|
ok("abce" >= "abcd", "abce >= abce failed");
|
|
|
|
ok("x" >= "", "\"x\" >= \"\" failed");
|
|
|
|
ok(0 >= 0, "0 >= 0");
|
|
|
|
|
2008-09-11 23:57:40 +02:00
|
|
|
tmp = 1;
|
|
|
|
ok(++tmp === 2, "++tmp (1) is not 2");
|
|
|
|
ok(tmp === 2, "incremented tmp is not 2");
|
2008-09-11 23:58:03 +02:00
|
|
|
ok(--tmp === 1, "--tmp (2) is not 1");
|
|
|
|
ok(tmp === 1, "decremented tmp is not 1");
|
2008-09-11 23:58:28 +02:00
|
|
|
ok(tmp++ === 1, "tmp++ (1) is not 1");
|
|
|
|
ok(tmp === 2, "incremented tmp(1) is not 2");
|
2008-09-11 23:58:48 +02:00
|
|
|
ok(tmp-- === 2, "tmp-- (2) is not 2");
|
|
|
|
ok(tmp === 1, "decremented tmp is not 1");
|
2008-09-11 23:57:40 +02:00
|
|
|
|
2011-12-07 11:01:53 +01:00
|
|
|
tmp = new Object();
|
|
|
|
tmp.iii++;
|
|
|
|
ok(isNaN(tmp.iii), "tmp.iii = " + tmp.iii);
|
|
|
|
|
2008-09-15 20:40:34 +02:00
|
|
|
String.prototype.test = true;
|
2008-09-16 20:45:29 +02:00
|
|
|
ok("".test === true, "\"\".test is not true");
|
|
|
|
|
|
|
|
Boolean.prototype.test = true;
|
|
|
|
ok(true.test === true, "true.test is not true");
|
2008-09-15 20:40:34 +02:00
|
|
|
|
2008-09-16 20:45:45 +02:00
|
|
|
Number.prototype.test = true;
|
|
|
|
ok((0).test === true, "(0).test is not true");
|
|
|
|
ok((0.5).test === true, "(0.5).test is not true");
|
|
|
|
|
2008-09-16 20:44:54 +02:00
|
|
|
var state = "";
|
|
|
|
try {
|
|
|
|
ok(state === "", "try: state = " + state);
|
|
|
|
state = "try";
|
|
|
|
}catch(ex) {
|
|
|
|
ok(false, "unexpected catch");
|
|
|
|
}
|
|
|
|
ok(state === "try", "state = " + state + " expected try");
|
|
|
|
|
|
|
|
state = "";
|
|
|
|
try {
|
|
|
|
ok(state === "", "try: state = " + state);
|
|
|
|
state = "try";
|
|
|
|
}finally {
|
2009-09-08 23:57:26 +02:00
|
|
|
ok(state === "try", "finally: state = " + state);
|
2008-09-16 20:44:54 +02:00
|
|
|
state = "finally";
|
|
|
|
}
|
|
|
|
ok(state === "finally", "state = " + state + " expected finally");
|
|
|
|
|
2011-12-28 12:06:28 +01:00
|
|
|
state = "";
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
throw 0;
|
|
|
|
}finally {
|
|
|
|
state = "finally";
|
|
|
|
}
|
|
|
|
}catch(e) {
|
|
|
|
ok(state === "finally", "state = " + state + " expected finally");
|
|
|
|
state = "catch";
|
|
|
|
}
|
|
|
|
ok(state === "catch", "state = " + state + " expected catch");
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
throw 0;
|
|
|
|
}finally {
|
|
|
|
throw 1;
|
|
|
|
}
|
|
|
|
}catch(e) {
|
|
|
|
ok(e === 1, "e = " + e);
|
|
|
|
}
|
|
|
|
|
2008-09-16 20:44:54 +02:00
|
|
|
state = "";
|
|
|
|
try {
|
|
|
|
ok(state === "", "try: state = " + state);
|
|
|
|
state = "try";
|
|
|
|
}catch(ex) {
|
|
|
|
ok(false, "unexpected catch");
|
|
|
|
}finally {
|
2009-09-08 23:57:26 +02:00
|
|
|
ok(state === "try", "finally: state = " + state);
|
2008-09-16 20:44:54 +02:00
|
|
|
state = "finally";
|
|
|
|
}
|
|
|
|
ok(state === "finally", "state = " + state + " expected finally");
|
|
|
|
|
2008-09-16 20:45:13 +02:00
|
|
|
var state = "";
|
|
|
|
try {
|
|
|
|
ok(state === "", "try: state = " + state);
|
|
|
|
state = "try";
|
|
|
|
throw "except";
|
|
|
|
}catch(ex) {
|
|
|
|
ok(state === "try", "catch: state = " + state);
|
|
|
|
ok(ex === "except", "ex is not \"except\"");
|
|
|
|
state = "catch";
|
|
|
|
}
|
|
|
|
ok(state === "catch", "state = " + state + " expected catch");
|
|
|
|
|
|
|
|
var state = "";
|
|
|
|
try {
|
|
|
|
ok(state === "", "try: state = " + state);
|
|
|
|
state = "try";
|
|
|
|
throw true;
|
|
|
|
}catch(ex) {
|
|
|
|
ok(state === "try", "catch: state = " + state);
|
|
|
|
ok(ex === true, "ex is not true");
|
|
|
|
state = "catch";
|
|
|
|
}finally {
|
2009-09-08 23:57:26 +02:00
|
|
|
ok(state === "catch", "finally: state = " + state);
|
2008-09-16 20:45:13 +02:00
|
|
|
state = "finally";
|
|
|
|
}
|
|
|
|
ok(state === "finally", "state = " + state + " expected finally");
|
|
|
|
|
|
|
|
var state = "";
|
|
|
|
try {
|
|
|
|
ok(state === "", "try: state = " + state);
|
|
|
|
state = "try";
|
|
|
|
try { throw true; } finally {}
|
|
|
|
}catch(ex) {
|
|
|
|
ok(state === "try", "catch: state = " + state);
|
|
|
|
ok(ex === true, "ex is not true");
|
|
|
|
state = "catch";
|
|
|
|
}finally {
|
2009-09-08 23:57:26 +02:00
|
|
|
ok(state === "catch", "finally: state = " + state);
|
2008-09-16 20:45:13 +02:00
|
|
|
state = "finally";
|
|
|
|
}
|
|
|
|
ok(state === "finally", "state = " + state + " expected finally");
|
|
|
|
|
|
|
|
var state = "";
|
|
|
|
try {
|
|
|
|
ok(state === "", "try: state = " + state);
|
|
|
|
state = "try";
|
|
|
|
try { throw "except"; } catch(ex) { throw true; }
|
|
|
|
}catch(ex) {
|
|
|
|
ok(state === "try", "catch: state = " + state);
|
|
|
|
ok(ex === true, "ex is not true");
|
|
|
|
state = "catch";
|
|
|
|
}finally {
|
2009-09-08 23:57:26 +02:00
|
|
|
ok(state === "catch", "finally: state = " + state);
|
2008-09-16 20:45:13 +02:00
|
|
|
state = "finally";
|
|
|
|
}
|
|
|
|
ok(state === "finally", "state = " + state + " expected finally");
|
|
|
|
|
|
|
|
function throwFunc(x) {
|
|
|
|
throw x;
|
|
|
|
}
|
|
|
|
|
|
|
|
var state = "";
|
|
|
|
try {
|
|
|
|
ok(state === "", "try: state = " + state);
|
|
|
|
state = "try";
|
|
|
|
throwFunc(true);
|
|
|
|
}catch(ex) {
|
|
|
|
ok(state === "try", "catch: state = " + state);
|
|
|
|
ok(ex === true, "ex is not true");
|
|
|
|
state = "catch";
|
|
|
|
}finally {
|
2009-09-08 23:57:26 +02:00
|
|
|
ok(state === "catch", "finally: state = " + state);
|
2008-09-16 20:45:13 +02:00
|
|
|
state = "finally";
|
|
|
|
}
|
|
|
|
ok(state === "finally", "state = " + state + " expected finally");
|
|
|
|
|
2008-09-17 23:30:20 +02:00
|
|
|
state = "";
|
|
|
|
switch(1) {
|
|
|
|
case "1":
|
|
|
|
ok(false, "unexpected case \"1\"");
|
|
|
|
case 1:
|
|
|
|
ok(state === "", "case 1: state = " + state);
|
|
|
|
state = "1";
|
|
|
|
default:
|
|
|
|
ok(state === "1", "default: state = " + state);
|
|
|
|
state = "default";
|
|
|
|
case false:
|
|
|
|
ok(state === "default", "case false: state = " + state);
|
|
|
|
state = "false";
|
|
|
|
}
|
|
|
|
ok(state === "false", "state = " + state);
|
|
|
|
|
|
|
|
state = "";
|
|
|
|
switch("") {
|
|
|
|
case "1":
|
|
|
|
case 1:
|
|
|
|
ok(false, "unexpected case 1");
|
|
|
|
default:
|
|
|
|
ok(state === "", "default: state = " + state);
|
|
|
|
state = "default";
|
|
|
|
case false:
|
|
|
|
ok(state === "default", "case false: state = " + state);
|
|
|
|
state = "false";
|
|
|
|
}
|
|
|
|
ok(state === "false", "state = " + state);
|
|
|
|
|
2008-09-17 23:30:37 +02:00
|
|
|
state = "";
|
|
|
|
switch(1) {
|
|
|
|
case "1":
|
|
|
|
ok(false, "unexpected case \"1\"");
|
|
|
|
case 1:
|
|
|
|
ok(state === "", "case 1: state = " + state);
|
|
|
|
state = "1";
|
|
|
|
default:
|
|
|
|
ok(state === "1", "default: state = " + state);
|
|
|
|
state = "default";
|
|
|
|
break;
|
|
|
|
case false:
|
|
|
|
ok(false, "unexpected case false");
|
|
|
|
}
|
|
|
|
ok(state === "default", "state = " + state);
|
|
|
|
|
2012-04-02 13:45:23 +02:00
|
|
|
switch(1) {
|
|
|
|
case 2:
|
|
|
|
ok(false, "unexpected case 2");
|
|
|
|
case 3:
|
|
|
|
ok(false, "unexpected case 3");
|
|
|
|
}
|
|
|
|
|
2012-09-04 15:52:27 +02:00
|
|
|
switch(1) {
|
|
|
|
case 2:
|
|
|
|
ok(false, "unexpected case 2");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* empty default */
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(2) {
|
|
|
|
default:
|
|
|
|
ok(false, "unexpected default");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
/* empty case */
|
|
|
|
};
|
|
|
|
|
|
|
|
switch(2) {
|
|
|
|
default:
|
|
|
|
ok(false, "unexpected default");
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
case 3:
|
|
|
|
/* empty case */
|
|
|
|
};
|
|
|
|
|
2012-04-16 11:25:25 +02:00
|
|
|
(function() {
|
|
|
|
var i=0;
|
|
|
|
|
|
|
|
switch(1) {
|
|
|
|
case 1:
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
return i;
|
|
|
|
})();
|
|
|
|
|
2017-05-01 18:31:13 +02:00
|
|
|
(function() {
|
|
|
|
var ret, x;
|
|
|
|
|
|
|
|
function unreachable() {
|
|
|
|
ok(false, "unreachable");
|
|
|
|
}
|
|
|
|
|
|
|
|
function expect(value, expect_value) {
|
|
|
|
ok(value === expect_value, "got " + value + " expected " + expect_value);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = (function() {
|
|
|
|
try {
|
|
|
|
return "try";
|
|
|
|
unreachable();
|
|
|
|
}catch(e) {
|
|
|
|
unreachable();
|
|
|
|
}finally {
|
|
|
|
return "finally";
|
|
|
|
unreachable();
|
|
|
|
}
|
|
|
|
unreachable();
|
|
|
|
})();
|
|
|
|
expect(ret, "finally");
|
|
|
|
|
|
|
|
x = "";
|
|
|
|
ret = (function() {
|
|
|
|
try {
|
|
|
|
x += "try,";
|
|
|
|
return x;
|
|
|
|
unreachable();
|
|
|
|
}catch(e) {
|
|
|
|
unreachable();
|
|
|
|
}finally {
|
|
|
|
x += "finally,";
|
|
|
|
}
|
|
|
|
unreachable();
|
|
|
|
})();
|
|
|
|
expect(ret, "try,");
|
|
|
|
expect(x, "try,finally,");
|
|
|
|
|
|
|
|
x = "";
|
|
|
|
ret = (function() {
|
|
|
|
try {
|
|
|
|
x += "try,"
|
|
|
|
throw 1;
|
|
|
|
unreachable();
|
|
|
|
}catch(e) {
|
|
|
|
x += "catch,";
|
|
|
|
return "catch";
|
|
|
|
unreachable();
|
|
|
|
}finally {
|
|
|
|
x += "finally,";
|
|
|
|
return "finally";
|
|
|
|
unreachable();
|
|
|
|
}
|
|
|
|
unreachable();
|
|
|
|
})();
|
|
|
|
expect(ret, "finally");
|
|
|
|
expect(x, "try,catch,finally,");
|
|
|
|
|
|
|
|
x = "";
|
|
|
|
ret = (function() {
|
|
|
|
try {
|
|
|
|
x += "try,"
|
|
|
|
throw 1;
|
|
|
|
unreachable();
|
|
|
|
}catch(e) {
|
|
|
|
x += "catch,";
|
|
|
|
return "catch";
|
|
|
|
unreachable();
|
|
|
|
}finally {
|
|
|
|
x += "finally,";
|
|
|
|
}
|
|
|
|
unreachable();
|
|
|
|
})();
|
|
|
|
expect(ret, "catch");
|
|
|
|
expect(x, "try,catch,finally,");
|
|
|
|
|
|
|
|
x = "";
|
|
|
|
ret = (function() {
|
|
|
|
try {
|
|
|
|
x += "try,"
|
|
|
|
try {
|
|
|
|
x += "try2,";
|
|
|
|
return "try2";
|
|
|
|
}catch(e) {
|
|
|
|
unreachable();
|
|
|
|
}finally {
|
|
|
|
x += "finally2,";
|
|
|
|
}
|
|
|
|
unreachable();
|
|
|
|
}catch(e) {
|
|
|
|
unreachable();
|
|
|
|
}finally {
|
|
|
|
x += "finally,";
|
|
|
|
}
|
|
|
|
unreachable();
|
|
|
|
})();
|
|
|
|
expect(ret, "try2");
|
|
|
|
expect(x, "try,try2,finally2,finally,");
|
|
|
|
|
|
|
|
x = "";
|
|
|
|
ret = (function() {
|
|
|
|
while(true) {
|
|
|
|
try {
|
|
|
|
x += "try,"
|
|
|
|
try {
|
|
|
|
x += "try2,";
|
|
|
|
break;
|
|
|
|
}catch(e) {
|
|
|
|
unreachable();
|
|
|
|
}finally {
|
|
|
|
x += "finally2,";
|
|
|
|
}
|
|
|
|
unreachable();
|
|
|
|
}catch(e) {
|
|
|
|
unreachable();
|
|
|
|
}finally {
|
|
|
|
x += "finally,";
|
|
|
|
}
|
|
|
|
unreachable();
|
|
|
|
}
|
|
|
|
x += "ret";
|
|
|
|
return "ret";
|
|
|
|
})();
|
|
|
|
expect(ret, "ret");
|
|
|
|
expect(x, "try,try2,finally2,finally,ret");
|
|
|
|
|
|
|
|
x = "";
|
|
|
|
ret = (function() {
|
|
|
|
while(true) {
|
|
|
|
try {
|
|
|
|
x += "try,"
|
|
|
|
try {
|
|
|
|
x += "try2,";
|
|
|
|
continue;
|
|
|
|
}catch(e) {
|
|
|
|
unreachable();
|
|
|
|
}finally {
|
|
|
|
x += "finally2,";
|
|
|
|
}
|
|
|
|
unreachable();
|
|
|
|
}catch(e) {
|
|
|
|
unreachable();
|
|
|
|
}finally {
|
|
|
|
x += "finally,";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
unreachable();
|
|
|
|
}
|
|
|
|
x += "ret";
|
|
|
|
return "ret";
|
|
|
|
})();
|
|
|
|
expect(ret, "ret");
|
|
|
|
expect(x, "try,try2,finally2,finally,ret");
|
2018-06-12 14:04:11 +02:00
|
|
|
|
|
|
|
ret = (function() {
|
|
|
|
try {
|
|
|
|
return "try";
|
|
|
|
unreachable();
|
|
|
|
}catch(e) {
|
|
|
|
unreachable();
|
|
|
|
}finally {
|
|
|
|
new Object();
|
|
|
|
var tmp = (function() {
|
|
|
|
var s = new String();
|
|
|
|
try {
|
|
|
|
s.length;
|
|
|
|
}finally {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
})();
|
|
|
|
}
|
|
|
|
unreachable();
|
|
|
|
})();
|
|
|
|
expect(ret, "try");
|
2017-05-01 18:31:13 +02:00
|
|
|
})();
|
|
|
|
|
2008-09-17 23:34:05 +02:00
|
|
|
tmp = eval("1");
|
|
|
|
ok(tmp === 1, "eval(\"1\") !== 1");
|
|
|
|
eval("{ ok(tmp === 1, 'eval: tmp !== 1'); } tmp = 2;");
|
|
|
|
ok(tmp === 2, "tmp !== 2");
|
|
|
|
|
|
|
|
ok(eval(false) === false, "eval(false) !== false");
|
|
|
|
ok(eval() === undefined, "eval() !== undefined");
|
|
|
|
|
|
|
|
tmp = eval("1", "2");
|
|
|
|
ok(tmp === 1, "eval(\"1\", \"2\") !== 1");
|
|
|
|
|
|
|
|
var state = "";
|
|
|
|
try {
|
|
|
|
ok(state === "", "try: state = " + state);
|
|
|
|
state = "try";
|
|
|
|
eval("throwFunc(true);");
|
|
|
|
}catch(ex) {
|
|
|
|
ok(state === "try", "catch: state = " + state);
|
|
|
|
ok(ex === true, "ex is not true");
|
|
|
|
state = "catch";
|
|
|
|
}finally {
|
2009-09-08 23:57:26 +02:00
|
|
|
ok(state === "catch", "finally: state = " + state);
|
2008-09-17 23:34:05 +02:00
|
|
|
state = "finally";
|
|
|
|
}
|
|
|
|
ok(state === "finally", "state = " + state + " expected finally");
|
|
|
|
|
2008-09-17 23:34:23 +02:00
|
|
|
tmp = [,,1,2,,,true];
|
|
|
|
ok(tmp.length === 7, "tmp.length !== 7");
|
|
|
|
ok(tmp["0"] === undefined, "tmp[0] is not undefined");
|
|
|
|
ok(tmp["3"] === 2, "tmp[3] !== 2");
|
|
|
|
ok(tmp["6"] === true, "tmp[6] !== true");
|
2008-09-17 23:34:56 +02:00
|
|
|
ok(tmp[2] === 1, "tmp[2] !== 1");
|
2018-03-01 23:58:38 +01:00
|
|
|
ok(!("0" in tmp), "0 found in array");
|
|
|
|
ok(!("1" in tmp), "1 found in array");
|
|
|
|
ok("2" in tmp, "2 not found in array");
|
|
|
|
ok(!("2" in [1,,,,]), "2 found in [1,,,,]");
|
2008-09-17 23:34:23 +02:00
|
|
|
|
2008-09-21 15:38:52 +02:00
|
|
|
ok([1,].length === 2, "[1,].length !== 2");
|
2008-10-07 19:01:06 +02:00
|
|
|
ok([,,].length === 3, "[,,].length !== 3");
|
|
|
|
ok([,].length === 2, "[].length != 2");
|
|
|
|
ok([].length === 0, "[].length != 0");
|
2008-09-21 15:38:52 +02:00
|
|
|
|
2008-09-17 23:35:38 +02:00
|
|
|
tmp = 0;
|
|
|
|
while(tmp < 4) {
|
|
|
|
ok(tmp < 4, "tmp >= 4");
|
|
|
|
tmp++;
|
|
|
|
}
|
|
|
|
ok(tmp === 4, "tmp !== 4");
|
|
|
|
|
|
|
|
tmp = 0;
|
|
|
|
while(true) {
|
|
|
|
ok(tmp < 4, "tmp >= 4");
|
|
|
|
tmp++;
|
|
|
|
if(tmp === 4) {
|
|
|
|
break;
|
|
|
|
ok(false, "break did not break");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ok(tmp === 4, "tmp !== 4");
|
|
|
|
|
|
|
|
tmp = 0;
|
|
|
|
do {
|
|
|
|
ok(tmp < 4, "tmp >= 4");
|
|
|
|
tmp++;
|
|
|
|
} while(tmp < 4);
|
|
|
|
ok(tmp === 4, "tmp !== 4");
|
|
|
|
|
|
|
|
tmp = 0;
|
|
|
|
do {
|
|
|
|
ok(tmp === 0, "tmp !=== 0");
|
|
|
|
tmp++;
|
|
|
|
} while(false);
|
2008-09-19 15:23:12 +02:00
|
|
|
ok(tmp === 1, "tmp !== 1");
|
2008-09-17 23:35:38 +02:00
|
|
|
|
2009-07-06 10:38:23 +02:00
|
|
|
tmp = 0;
|
|
|
|
do {
|
|
|
|
ok(tmp < 4, "tmp >= 4");
|
|
|
|
tmp++;
|
|
|
|
} while(tmp < 4)
|
|
|
|
ok(tmp === 4, "tmp !== 4")
|
|
|
|
|
2008-09-17 23:35:57 +02:00
|
|
|
tmp = 0;
|
|
|
|
while(tmp < 4) {
|
|
|
|
tmp++;
|
|
|
|
if(tmp === 2) {
|
|
|
|
continue;
|
|
|
|
ok(false, "break did not break");
|
|
|
|
}
|
|
|
|
ok(tmp <= 4 && tmp != 2, "tmp = " + tmp);
|
|
|
|
}
|
|
|
|
ok(tmp === 4, "tmp !== 4");
|
|
|
|
|
2008-09-17 23:36:19 +02:00
|
|
|
for(tmp=0; tmp < 4; tmp++)
|
|
|
|
ok(tmp < 4, "tmp = " + tmp);
|
|
|
|
ok(tmp === 4, "tmp !== 4");
|
|
|
|
|
|
|
|
for(tmp=0; tmp < 4; tmp++) {
|
|
|
|
if(tmp === 2)
|
|
|
|
break;
|
|
|
|
ok(tmp < 2, "tmp = " + tmp);
|
|
|
|
}
|
|
|
|
ok(tmp === 2, "tmp !== 2");
|
|
|
|
|
|
|
|
for(tmp=0; tmp < 4; tmp++) {
|
|
|
|
if(tmp === 2)
|
|
|
|
continue;
|
|
|
|
ok(tmp < 4 && tmp != 2, "tmp = " + tmp);
|
|
|
|
}
|
|
|
|
ok(tmp === 4, "tmp !== 4");
|
|
|
|
|
|
|
|
for(var fi=0; fi < 4; fi++)
|
|
|
|
ok(fi < 4, "fi = " + fi);
|
|
|
|
ok(fi === 4, "fi !== 4");
|
|
|
|
|
2011-12-12 14:43:24 +01:00
|
|
|
tmp = true;
|
|
|
|
obj1 = new Object();
|
|
|
|
for(obj1.nonexistent; tmp; tmp = false)
|
|
|
|
ok(!("nonexistent" in obj1), "nonexistent added to obj1");
|
|
|
|
|
2011-12-12 14:43:35 +01:00
|
|
|
obj1 = new Object();
|
|
|
|
for(tmp in obj1.nonexistent)
|
|
|
|
ok(false, "for(tmp in obj1.nonexistent) called with tmp = " + tmp);
|
|
|
|
ok(!("nonexistent" in obj1), "nonexistent added to obj1 by for..in loop");
|
|
|
|
|
2011-12-28 12:07:15 +01:00
|
|
|
|
2012-01-10 16:10:29 +01:00
|
|
|
var i, j;
|
2011-12-28 12:07:15 +01:00
|
|
|
|
2012-01-12 13:43:25 +01:00
|
|
|
/* Previous versions have broken finally block implementation */
|
|
|
|
if(ScriptEngineMinorVersion() >= 8) {
|
|
|
|
tmp = "";
|
|
|
|
i = 0;
|
|
|
|
while(true) {
|
|
|
|
tmp += "1";
|
|
|
|
for(i = 1; i < 3; i++) {
|
|
|
|
switch(i) {
|
|
|
|
case 1:
|
|
|
|
tmp += "2";
|
|
|
|
continue;
|
|
|
|
case 2:
|
|
|
|
tmp += "3";
|
|
|
|
try {
|
|
|
|
throw null;
|
|
|
|
}finally {
|
|
|
|
tmp += "4";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
ok(false, "unexpected state");
|
2011-12-28 12:07:15 +01:00
|
|
|
}
|
2012-01-12 13:43:25 +01:00
|
|
|
tmp += "5";
|
|
|
|
}
|
|
|
|
with({prop: "6"}) {
|
|
|
|
tmp += prop;
|
|
|
|
break;
|
2011-12-28 12:07:15 +01:00
|
|
|
}
|
|
|
|
}
|
2012-01-12 13:43:25 +01:00
|
|
|
ok(tmp === "123456", "tmp = " + tmp);
|
2011-12-28 12:07:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
tmp = "";
|
|
|
|
i = 0;
|
|
|
|
for(j in [1,2,3]) {
|
|
|
|
tmp += "1";
|
|
|
|
for(;;) {
|
|
|
|
with({prop: "2"}) {
|
|
|
|
tmp += prop;
|
|
|
|
try {
|
|
|
|
throw "3";
|
|
|
|
}catch(e) {
|
|
|
|
tmp += e;
|
|
|
|
with([0])
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ok(false, "unexpected state");
|
|
|
|
}
|
|
|
|
while(true) {
|
|
|
|
tmp += "4";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ok(tmp === "1234", "tmp = " + tmp);
|
|
|
|
|
2012-01-10 16:10:29 +01:00
|
|
|
tmp = 0;
|
|
|
|
for(var iter in [1,2,3]) {
|
|
|
|
tmp += +iter;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ok(tmp === 3, "tmp = " + tmp);
|
|
|
|
|
|
|
|
tmp = false;
|
|
|
|
for(var iter in [1,2,3]) {
|
|
|
|
switch(+iter) {
|
|
|
|
case 1:
|
|
|
|
tmp = true;
|
|
|
|
try {
|
|
|
|
continue;
|
|
|
|
}finally {}
|
|
|
|
default:
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ok(tmp, "tmp = " + tmp);
|
2011-12-28 12:07:15 +01:00
|
|
|
|
2012-01-17 12:42:08 +01:00
|
|
|
loop_label:
|
|
|
|
while(true) {
|
|
|
|
while(true)
|
|
|
|
break loop_label;
|
|
|
|
}
|
|
|
|
|
|
|
|
loop_label: {
|
|
|
|
tmp = 0;
|
|
|
|
while(true) {
|
|
|
|
while(true)
|
|
|
|
break loop_label;
|
|
|
|
}
|
|
|
|
ok(false, "unexpected evaluation 1");
|
|
|
|
}
|
|
|
|
|
|
|
|
while(true) {
|
|
|
|
some_label: break;
|
|
|
|
ok(false, "unexpected evaluation 2");
|
|
|
|
}
|
|
|
|
|
|
|
|
just_label: tmp = 1;
|
|
|
|
ok(tmp === 1, "tmp != 1");
|
|
|
|
|
|
|
|
some_label: break some_label;
|
|
|
|
|
|
|
|
other_label: {
|
|
|
|
break other_label;
|
|
|
|
ok(false, "unexpected evaluation 3");
|
|
|
|
}
|
|
|
|
|
|
|
|
loop_label:
|
|
|
|
do {
|
|
|
|
while(true)
|
|
|
|
continue loop_label;
|
|
|
|
}while(false);
|
|
|
|
|
|
|
|
loop_label:
|
|
|
|
for(i = 0; i < 3; i++) {
|
|
|
|
while(true)
|
|
|
|
continue loop_label;
|
|
|
|
}
|
|
|
|
|
|
|
|
loop_label:
|
|
|
|
other_label:
|
|
|
|
for(i = 0; i < 3; i++) {
|
|
|
|
while(true)
|
|
|
|
continue loop_label;
|
|
|
|
}
|
|
|
|
|
|
|
|
loop_label:
|
|
|
|
for(tmp in {prop: false}) {
|
|
|
|
while(true)
|
|
|
|
continue loop_label;
|
|
|
|
}
|
|
|
|
|
2008-09-19 00:42:33 +02:00
|
|
|
ok((void 1) === undefined, "(void 1) !== undefined");
|
|
|
|
|
2008-09-19 00:43:21 +02:00
|
|
|
var inobj = new Object();
|
|
|
|
|
|
|
|
for(var iter in inobj)
|
|
|
|
ok(false, "unexpected iter = " + iter);
|
|
|
|
|
|
|
|
inobj.test = true;
|
|
|
|
tmp = 0;
|
|
|
|
for(iter in inobj) {
|
|
|
|
ok(iter == "test", "unexpected iter = " + iter);
|
|
|
|
tmp++;
|
|
|
|
}
|
|
|
|
ok(tmp === 1, "for..in tmp = " + tmp);
|
|
|
|
|
|
|
|
function forinTestObj() {}
|
|
|
|
|
|
|
|
forinTestObj.prototype.test3 = true;
|
|
|
|
|
|
|
|
var arr = new Array();
|
|
|
|
inobj = new forinTestObj();
|
|
|
|
inobj.test1 = true;
|
|
|
|
inobj.test2 = true;
|
|
|
|
|
|
|
|
tmp = 0;
|
|
|
|
for(iter in inobj) {
|
|
|
|
arr[iter] = true;
|
|
|
|
tmp++;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(tmp === 3, "for..in tmp = " + tmp);
|
|
|
|
ok(arr["test1"] === true, "arr[test1] !== true");
|
|
|
|
ok(arr["test2"] === true, "arr[test2] !== true");
|
|
|
|
ok(arr["test3"] === true, "arr[test3] !== true");
|
|
|
|
|
2008-09-19 00:43:37 +02:00
|
|
|
tmp = new Object();
|
|
|
|
tmp.test = false;
|
|
|
|
ok((delete tmp.test) === true, "delete returned false");
|
|
|
|
ok(typeof(tmp.test) === "undefined", "tmp.test type = " + typeof(tmp.test));
|
2011-11-30 10:14:22 +01:00
|
|
|
ok(!("test" in tmp), "test is still in tmp after delete?");
|
2008-09-19 00:43:37 +02:00
|
|
|
for(iter in tmp)
|
|
|
|
ok(false, "tmp has prop " + iter);
|
2012-12-17 13:36:08 +01:00
|
|
|
ok((delete tmp.test) === true, "deleting test didn't return true");
|
|
|
|
ok((delete tmp.nonexistent) === true, "deleting nonexistent didn't return true");
|
2012-12-17 13:36:18 +01:00
|
|
|
ok((delete nonexistent) === true, "deleting nonexistent didn't return true");
|
2008-09-19 00:43:37 +02:00
|
|
|
|
2011-11-30 10:14:22 +01:00
|
|
|
tmp = new Object();
|
|
|
|
tmp.test = false;
|
|
|
|
ok((delete tmp["test"]) === true, "delete returned false");
|
|
|
|
ok(typeof(tmp.test) === "undefined", "tmp.test type = " + typeof(tmp.test));
|
|
|
|
ok(!("test" in tmp), "test is still in tmp after delete?");
|
|
|
|
|
2008-09-19 00:43:53 +02:00
|
|
|
tmp.testWith = true;
|
|
|
|
with(tmp)
|
|
|
|
ok(testWith === true, "testWith !== true");
|
|
|
|
|
2008-09-30 17:47:40 +02:00
|
|
|
if(false) {
|
|
|
|
var varTest1 = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(varTest1 === undefined, "varTest1 = " + varTest1);
|
|
|
|
ok(varTest2 === undefined, "varTest2 = " + varTest1);
|
|
|
|
|
|
|
|
var varTest2;
|
|
|
|
|
|
|
|
function varTestFunc(varTest3) {
|
|
|
|
var varTest3;
|
|
|
|
|
|
|
|
ok(varTest3 === 3, "varTest3 = " + varTest3);
|
|
|
|
ok(varTest4 === undefined, "varTest4 = " + varTest4);
|
|
|
|
|
|
|
|
var varTest4;
|
|
|
|
}
|
|
|
|
|
2008-10-02 16:22:27 +02:00
|
|
|
varTestFunc(3);
|
|
|
|
|
2008-09-30 17:48:45 +02:00
|
|
|
deleteTest = 1;
|
|
|
|
delete deleteTest;
|
|
|
|
try {
|
|
|
|
tmp = deleteTest;
|
|
|
|
ok(false, "deleteTest not throwed exception?");
|
|
|
|
}catch(ex) {}
|
|
|
|
|
2016-08-05 17:15:20 +02:00
|
|
|
(function() {
|
|
|
|
var to_delete = 2;
|
|
|
|
var r = delete to_delete;
|
|
|
|
ok(r === false, "delete 1 returned " + r);
|
|
|
|
if(r)
|
|
|
|
return;
|
|
|
|
ok(to_delete === 2, "to_delete = " + to_delete);
|
|
|
|
|
|
|
|
to_delete = new Object();
|
|
|
|
r = delete to_delete;
|
|
|
|
ok(r === false, "delete 2 returned " + r);
|
|
|
|
ok(typeof(to_delete) === "object", "typeof(to_delete) = " + typeof(to_delete));
|
|
|
|
})();
|
|
|
|
|
|
|
|
(function(to_delete) {
|
|
|
|
var r = delete to_delete;
|
|
|
|
ok(r === false, "delete 3 returned " + r);
|
|
|
|
ok(to_delete === 2, "to_delete = " + to_delete);
|
|
|
|
|
|
|
|
to_delete = new Object();
|
|
|
|
r = delete to_delete;
|
|
|
|
ok(r === false, "delete 4 returned " + r);
|
|
|
|
ok(typeof(to_delete) === "object", "typeof(to_delete) = " + typeof(to_delete));
|
|
|
|
})(2);
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
with({to_delete: new Object()}) {
|
|
|
|
var r = delete to_delete;
|
|
|
|
ok(r === true, "delete returned " + r);
|
|
|
|
}
|
|
|
|
})();
|
|
|
|
|
2008-10-15 15:10:07 +02:00
|
|
|
if (false)
|
|
|
|
if (true)
|
|
|
|
ok(false, "if evaluated");
|
|
|
|
else
|
|
|
|
ok(false, "else should be associated with nearest if statement");
|
|
|
|
|
|
|
|
if (true)
|
|
|
|
if (false)
|
|
|
|
ok(false, "if evaluated");
|
|
|
|
else
|
|
|
|
ok(true, "else should be associated with nearest if statement");
|
|
|
|
|
2009-08-29 00:01:25 +02:00
|
|
|
function instanceOfTest() {}
|
|
|
|
tmp = new instanceOfTest();
|
|
|
|
|
|
|
|
ok((tmp instanceof instanceOfTest) === true, "tmp is not instance of instanceOfTest");
|
|
|
|
ok((tmp instanceof Object) === true, "tmp is not instance of Object");
|
|
|
|
ok((tmp instanceof String) === false, "tmp is instance of String");
|
|
|
|
|
|
|
|
instanceOfTest.prototype = new Object();
|
|
|
|
ok((tmp instanceof instanceOfTest) === false, "tmp is instance of instanceOfTest");
|
|
|
|
ok((tmp instanceof Object) === true, "tmp is not instance of Object");
|
|
|
|
|
|
|
|
ok((1 instanceof Object) === false, "1 is instance of Object");
|
|
|
|
ok((false instanceof Boolean) === false, "false is instance of Boolean");
|
|
|
|
ok(("" instanceof Object) === false, "'' is instance of Object");
|
|
|
|
|
2009-08-29 00:01:57 +02:00
|
|
|
(function () {
|
|
|
|
ok((arguments instanceof Object) === true, "argument is not instance of Object");
|
|
|
|
ok((arguments instanceof Array) === false, "argument is not instance of Array");
|
|
|
|
ok(arguments.toString() === "[object Object]", "arguments.toString() = " + arguments.toString());
|
|
|
|
})(1,2);
|
|
|
|
|
2009-09-06 19:10:06 +02:00
|
|
|
obj = new String();
|
|
|
|
ok(("length" in obj) === true, "length is not in obj");
|
|
|
|
ok(("isPrototypeOf" in obj) === true, "isPrototypeOf is not in obj");
|
|
|
|
ok(("abc" in obj) === false, "test is in obj");
|
|
|
|
obj.abc = 1;
|
|
|
|
ok(("abc" in obj) === true, "test is not in obj");
|
|
|
|
ok(("1" in obj) === false, "1 is in obj");
|
|
|
|
|
|
|
|
obj = [1,2,3];
|
|
|
|
ok((1 in obj) === true, "1 is not in obj");
|
|
|
|
|
2009-12-06 22:10:44 +01:00
|
|
|
obj = new Object();
|
|
|
|
try {
|
|
|
|
obj.prop["test"];
|
|
|
|
ok(false, "expected exception");
|
|
|
|
}catch(e) {}
|
|
|
|
ok(!("prop" in obj), "prop in obj");
|
|
|
|
|
2012-11-30 13:03:07 +01:00
|
|
|
if(invokeVersion >= 2) {
|
|
|
|
ok("test"[0] === "t", '"test"[0] = ' + test[0]);
|
|
|
|
ok("test"[5] === undefined, '"test"[0] = ' + test[0]);
|
|
|
|
|
|
|
|
tmp = "test";
|
|
|
|
ok(tmp[1] === "e", "tmp[1] = " + tmp[1]);
|
|
|
|
tmp[1] = "x";
|
|
|
|
ok(tmp[1] === "e", "tmp[1] = " + tmp[1]);
|
|
|
|
ok(tmp["1"] === "e", "tmp['1'] = " + tmp["1"]);
|
|
|
|
ok(tmp["0x1"] === undefined, "tmp['0x1'] = " + tmp["0x1"]);
|
|
|
|
}else {
|
|
|
|
ok("test"[0] === undefined, '"test"[0] = ' + test[0]);
|
|
|
|
}
|
|
|
|
|
2008-10-16 01:49:51 +02:00
|
|
|
ok(isNaN(NaN) === true, "isNaN(NaN) !== true");
|
2008-10-14 23:07:01 +02:00
|
|
|
ok(isNaN(0.5) === false, "isNaN(0.5) !== false");
|
2008-10-16 21:31:18 +02:00
|
|
|
ok(isNaN(Infinity) === false, "isNaN(Infinity) !== false");
|
2008-10-14 23:07:01 +02:00
|
|
|
ok(isNaN() === true, "isNaN() !== true");
|
2008-10-16 01:49:51 +02:00
|
|
|
ok(isNaN(NaN, 0) === true, "isNaN(NaN, 0) !== true");
|
|
|
|
ok(isNaN(0.5, NaN) === false, "isNaN(0.5, NaN) !== false");
|
2008-10-16 01:49:59 +02:00
|
|
|
ok(isNaN(+undefined) === true, "isNaN(+undefined) !== true");
|
2008-10-14 23:07:01 +02:00
|
|
|
|
2008-10-16 21:31:18 +02:00
|
|
|
ok(isFinite(0.5) === true, "isFinite(0.5) !== true");
|
2009-09-08 23:57:26 +02:00
|
|
|
ok(isFinite(Infinity) === false, "isFinite(Infinity) !== false");
|
|
|
|
ok(isFinite(-Infinity) === false, "isFinite(Infinity) !== false");
|
2008-10-16 21:31:18 +02:00
|
|
|
ok(isFinite(NaN) === false, "isFinite(NaN) !== false");
|
|
|
|
ok(isFinite(0.5, NaN) === true, "isFinite(0.5, NaN) !== true");
|
|
|
|
ok(isFinite(NaN, 0.5) === false, "isFinite(NaN, 0.5) !== false");
|
|
|
|
ok(isFinite() === false, "isFinite() !== false");
|
|
|
|
|
2008-10-16 21:31:30 +02:00
|
|
|
ok((1 < NaN) === false, "(1 < NaN) !== false");
|
|
|
|
ok((1 > NaN) === false, "(1 > NaN) !== false");
|
|
|
|
ok((1 <= NaN) === false, "(1 <= NaN) !== false");
|
|
|
|
ok((1 >= NaN) === false, "(1 >= NaN) !== false");
|
|
|
|
ok((NaN < 1) === false, "(NaN < 1) !== false");
|
|
|
|
ok((NaN > 1) === false, "(NaN > 1) !== false");
|
|
|
|
ok((NaN <= 1) === false, "(NaN <= 1) !== false");
|
|
|
|
ok((NaN >= 1) === false, "(NaN >= 1) !== false");
|
|
|
|
ok((Infinity < 2) === false, "(Infinity < 2) !== false");
|
|
|
|
ok((Infinity > 2) === true, "(Infinity > 2) !== true");
|
|
|
|
ok((-Infinity < 2) === true, "(-Infinity < 2) !== true");
|
|
|
|
|
2008-10-16 21:31:40 +02:00
|
|
|
ok(isNaN(+"test") === true, "isNaN(+'test') !== true");
|
|
|
|
ok(isNaN(+"123t") === true, "isNaN(+'123t') !== true");
|
|
|
|
ok(isNaN(+"Infinity x") === true, "isNaN(+'Infinity x') !== true");
|
|
|
|
ok(+"Infinity" === Infinity, "+'Infinity' !== Infinity");
|
|
|
|
ok(+" Infinity " === Infinity, "+' Infinity ' !== Infinity");
|
|
|
|
ok(+"-Infinity" === -Infinity, "+'-Infinity' !== -Infinity");
|
|
|
|
|
2008-10-16 21:32:05 +02:00
|
|
|
ok((NaN !== NaN) === true, "(NaN !== NaN) !== true");
|
|
|
|
ok((NaN === NaN) === false, "(NaN === NaN) !== false");
|
|
|
|
ok((Infinity !== NaN) === true, "(Infinity !== NaN) !== true");
|
|
|
|
ok((Infinity !== NaN) === true, "(Infinity !== NaN) !== true");
|
|
|
|
ok((0 === NaN) === false, "(0 === NaN) !== false");
|
|
|
|
|
|
|
|
ok((NaN != NaN) === true, "(NaN !== NaN) != true");
|
|
|
|
ok((NaN == NaN) === false, "(NaN === NaN) != false");
|
|
|
|
ok((Infinity != NaN) === true, "(Infinity != NaN) !== true");
|
|
|
|
ok((Infinity != NaN) === true, "(Infinity != NaN) !== true");
|
|
|
|
ok((0 == NaN) === false, "(0 === NaN) != false");
|
|
|
|
|
2010-12-29 16:01:56 +01:00
|
|
|
// escape tests
|
|
|
|
var escapeTests = [
|
|
|
|
["\'", "\\'", 39],
|
|
|
|
["\"", "\\\"", 34],
|
|
|
|
["\\", "\\\\", 92],
|
|
|
|
["\b", "\\b", 8],
|
|
|
|
["\t", "\\t", 9],
|
|
|
|
["\n", "\\n", 10],
|
|
|
|
["\v", "\\v", 118],
|
|
|
|
["\f", "\\f", 12],
|
|
|
|
["\r", "\\r", 13],
|
|
|
|
["\xf3", "\\xf3", 0xf3],
|
|
|
|
["\u1234", "\\u1234", 0x1234],
|
|
|
|
["\a", "\\a", 97],
|
|
|
|
["\?", "\\?", 63]
|
|
|
|
];
|
|
|
|
|
|
|
|
for(i=0; i<escapeTests.length; i++) {
|
|
|
|
tmp = escapeTests[i][0].charCodeAt(0);
|
|
|
|
ok(tmp === escapeTests[i][2], "escaped '" + escapeTests[i][1] + "' = " + tmp + " expected " + escapeTests[i][2]);
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp = !+"\v1";
|
|
|
|
ok(tmp === true, '!+"\v1" = ' + tmp);
|
2008-10-20 22:12:42 +02:00
|
|
|
|
|
|
|
ok(typeof(testFunc2) === "function", "typeof(testFunc2) = " + typeof(testFunc2));
|
|
|
|
tmp = testFunc2(1);
|
|
|
|
ok(tmp === 2, "testFunc2(1) = " + tmp);
|
|
|
|
function testFunc2(x) { return x+1; }
|
|
|
|
|
|
|
|
ok(typeof(testFunc3) === "function", "typeof(testFunc3) = " + typeof(testFunc3));
|
|
|
|
tmp = testFunc3(1);
|
|
|
|
ok(tmp === 3, "testFunc3(1) = " + tmp);
|
|
|
|
tmp = function testFunc3(x) { return x+2; };
|
|
|
|
|
|
|
|
tmp = testFunc4(1);
|
|
|
|
ok(tmp === 5, "testFunc4(1) = " + tmp);
|
|
|
|
tmp = function testFunc4(x) { return x+3; };
|
|
|
|
tmp = testFunc4(1);
|
|
|
|
testFunc4 = 1;
|
|
|
|
ok(testFunc4 === 1, "testFunc4 = " + testFunc4);
|
|
|
|
ok(tmp === 5, "testFunc4(1) = " + tmp);
|
|
|
|
tmp = function testFunc4(x) { return x+4; };
|
|
|
|
ok(testFunc4 === 1, "testFunc4 = " + testFunc4);
|
|
|
|
|
2012-05-14 01:05:24 +02:00
|
|
|
function testEmbeddedFunctions() {
|
2008-10-20 22:12:42 +02:00
|
|
|
ok(typeof(testFunc5) === "function", "typeof(testFunc5) = " + typeof(testFunc5));
|
|
|
|
tmp = testFunc5(1);
|
|
|
|
ok(tmp === 3, "testFunc5(1) = " + tmp);
|
|
|
|
tmp = function testFunc5(x) { return x+2; };
|
|
|
|
|
|
|
|
tmp = testFunc6(1);
|
|
|
|
ok(tmp === 5, "testFunc6(1) = " + tmp);
|
|
|
|
tmp = function testFunc6(x) { return x+3; };
|
|
|
|
tmp = testFunc6(1);
|
|
|
|
ok(tmp === 5, "testFunc6(1) = " + tmp);
|
|
|
|
tmp = function testFunc6(x) { return x+4; };
|
|
|
|
testFunc6 = 1;
|
|
|
|
ok(testFunc6 === 1, "testFunc4 = " + testFunc6);
|
|
|
|
}
|
|
|
|
|
2012-05-14 01:05:24 +02:00
|
|
|
testEmbeddedFunctions();
|
2008-10-20 22:12:42 +02:00
|
|
|
|
2009-07-08 10:52:56 +02:00
|
|
|
date = new Date();
|
|
|
|
date.toString = function() { return "toString"; }
|
|
|
|
ok(""+date === "toString", "''+date = " + date);
|
|
|
|
date.toString = function() { return this; }
|
|
|
|
ok(""+date === ""+date.valueOf(), "''+date = " + date);
|
|
|
|
|
|
|
|
str = new String("test");
|
|
|
|
str.valueOf = function() { return "valueOf"; }
|
|
|
|
ok(""+str === "valueOf", "''+str = " + str);
|
|
|
|
str.valueOf = function() { return new Date(); }
|
|
|
|
ok(""+str === "test", "''+str = " + str);
|
|
|
|
|
2009-07-14 01:36:27 +02:00
|
|
|
ok((function (){return 1;})() === 1, "(function (){return 1;})() = " + (function (){return 1;})());
|
|
|
|
|
2009-08-27 01:20:37 +02:00
|
|
|
var re = /=(\?|%3F)/g;
|
|
|
|
ok(re.source === "=(\\?|%3F)", "re.source = " + re.source);
|
|
|
|
|
2009-10-14 14:43:01 +02:00
|
|
|
tmp = new Array();
|
|
|
|
for(var i=0; i<2; i++)
|
|
|
|
tmp[i] = /b/;
|
|
|
|
ok(tmp[0] != tmp[1], "tmp[0] == tmp [1]");
|
|
|
|
|
2012-03-28 15:04:28 +02:00
|
|
|
ok(isNullBSTR(getNullBSTR()), "isNullBSTR(getNullBSTR()) failed\n");
|
|
|
|
ok(getNullBSTR() === '', "getNullBSTR() !== ''");
|
|
|
|
ok(+getNullBSTR() === 0 , "+getNullBTR() !=== 0");
|
2009-08-05 23:27:31 +02:00
|
|
|
|
2009-09-08 23:57:26 +02:00
|
|
|
ok(getVT(nullDisp) === "VT_DISPATCH", "getVT(nullDisp) = " + getVT(nullDisp));
|
2009-09-06 19:09:30 +02:00
|
|
|
ok(typeof(nullDisp) === "object", "typeof(nullDisp) = " + typeof(nullDisp));
|
2009-09-11 18:47:14 +02:00
|
|
|
ok(nullDisp === nullDisp, "nullDisp !== nullDisp");
|
|
|
|
ok(nullDisp !== re, "nullDisp === re");
|
|
|
|
ok(nullDisp === null, "nullDisp === null");
|
|
|
|
ok(nullDisp == null, "nullDisp == null");
|
|
|
|
ok(getVT(true && nullDisp) === "VT_DISPATCH",
|
|
|
|
"getVT(0 && nullDisp) = " + getVT(true && nullDisp));
|
|
|
|
ok(!nullDisp === true, "!nullDisp = " + !nullDisp);
|
2009-09-11 18:47:50 +02:00
|
|
|
ok(String(nullDisp) === "null", "String(nullDisp) = " + String(nullDisp));
|
2009-09-17 01:06:13 +02:00
|
|
|
ok(nullDisp != new Object(), "nullDisp == new Object()");
|
|
|
|
ok(new Object() != nullDisp, "new Object() == nullDisp");
|
2009-09-24 00:44:30 +02:00
|
|
|
ok((typeof Object(nullDisp)) === "object", "typeof Object(nullDisp) !== 'object'");
|
|
|
|
tmp = getVT(Object(nullDisp));
|
|
|
|
ok(tmp === "VT_DISPATCH", "getVT(Object(nullDisp) = " + tmp);
|
|
|
|
tmp = Object(nullDisp).toString();
|
|
|
|
ok(tmp === "[object Object]", "Object(nullDisp).toString() = " + tmp);
|
2009-09-06 19:09:30 +02:00
|
|
|
|
2009-08-23 23:38:06 +02:00
|
|
|
function do_test() {}
|
2009-08-27 01:21:03 +02:00
|
|
|
function nosemicolon() {} nosemicolon();
|
|
|
|
function () {} nosemicolon();
|
2009-08-23 23:38:06 +02:00
|
|
|
|
2009-09-23 16:09:43 +02:00
|
|
|
if(false) {
|
|
|
|
function in_if_false() { return true; } ok(false, "!?");
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(in_if_false(), "in_if_false failed");
|
|
|
|
|
2009-08-27 01:22:17 +02:00
|
|
|
(function() { newValue = 1; })();
|
|
|
|
ok(newValue === 1, "newValue = " + newValue);
|
|
|
|
|
2009-12-21 00:24:11 +01:00
|
|
|
obj = {undefined: 3};
|
|
|
|
|
2011-12-16 11:42:57 +01:00
|
|
|
ok(typeof(name_override_func) === "function", "typeof(name_override_func) = " + typeof(name_override_func));
|
|
|
|
name_override_func = 3;
|
|
|
|
ok(name_override_func === 3, "name_override_func = " + name_override_func);
|
|
|
|
function name_override_func() {};
|
|
|
|
ok(name_override_func === 3, "name_override_func = " + name_override_func);
|
|
|
|
|
2012-09-13 14:34:11 +02:00
|
|
|
tmp = (function() {
|
|
|
|
var ret = false;
|
|
|
|
with({ret: true})
|
|
|
|
return ret;
|
|
|
|
})();
|
|
|
|
ok(tmp, "tmp = " + tmp);
|
|
|
|
|
2017-05-01 18:29:53 +02:00
|
|
|
tmp = (function() {
|
|
|
|
for(var iter in [1,2,3,4]) {
|
|
|
|
var ret = false;
|
|
|
|
with({ret: true})
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
})();
|
|
|
|
ok(tmp, "tmp = " + tmp);
|
|
|
|
|
2016-08-05 17:15:20 +02:00
|
|
|
(function() {
|
|
|
|
ok(typeof(func) === "function", "typeof(func) = " + typeof(func));
|
|
|
|
with(new Object()) {
|
|
|
|
var x = false && function func() {};
|
|
|
|
}
|
|
|
|
ok(typeof(func) === "function", "typeof(func) = " + typeof(func));
|
|
|
|
})();
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
ok(x === undefined, "x = " + x); // x is declared, but never initialized
|
|
|
|
with({x: 1}) {
|
|
|
|
ok(x === 1, "x = " + x);
|
|
|
|
var x = 2;
|
|
|
|
ok(x === 2, "x = " + x);
|
|
|
|
}
|
|
|
|
ok(x === undefined, "x = " + x);
|
|
|
|
})();
|
|
|
|
|
2012-09-10 14:44:51 +02:00
|
|
|
/* NoNewline rule parser tests */
|
|
|
|
while(true) {
|
|
|
|
if(true) break
|
|
|
|
tmp = false
|
|
|
|
}
|
|
|
|
|
|
|
|
while(true) {
|
|
|
|
if(true) break /*
|
|
|
|
* no semicolon, but comment present */
|
|
|
|
tmp = false
|
|
|
|
}
|
|
|
|
|
|
|
|
while(true) {
|
|
|
|
if(true) break // no semicolon, but comment present
|
|
|
|
tmp = false
|
|
|
|
}
|
|
|
|
|
2012-09-10 14:45:06 +02:00
|
|
|
while(true) {
|
|
|
|
break
|
|
|
|
continue
|
|
|
|
tmp = false
|
|
|
|
}
|
|
|
|
|
2012-09-10 14:45:23 +02:00
|
|
|
function returnTest() {
|
|
|
|
return
|
|
|
|
true;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(returnTest() === undefined, "returnTest = " + returnTest());
|
|
|
|
|
2014-10-13 12:36:30 +02:00
|
|
|
ActiveXObject = 1;
|
|
|
|
ok(ActiveXObject === 1, "ActiveXObject = " + ActiveXObject);
|
|
|
|
|
2015-02-04 16:03:08 +01:00
|
|
|
Boolean = 1;
|
|
|
|
ok(Boolean === 1, "Boolean = " + Boolean);
|
|
|
|
|
2015-02-05 14:47:44 +01:00
|
|
|
Object = 1;
|
|
|
|
ok(Object === 1, "Object = " + Object);
|
|
|
|
|
|
|
|
Array = 1;
|
|
|
|
ok(Array === 1, "Array = " + Array);
|
|
|
|
|
|
|
|
Date = 1;
|
|
|
|
ok(Date === 1, "Date = " + Date);
|
|
|
|
|
|
|
|
Error = 1;
|
|
|
|
ok(Error === 1, "Error = " + Error);
|
|
|
|
|
2009-12-21 00:24:11 +01:00
|
|
|
/* Keep this test in the end of file */
|
|
|
|
undefined = 6;
|
|
|
|
ok(undefined === 6, "undefined = " + undefined);
|
|
|
|
|
2010-08-02 11:08:57 +02:00
|
|
|
NaN = 6;
|
|
|
|
ok(NaN === 6, "NaN !== 6");
|
|
|
|
|
|
|
|
Infinity = 6;
|
|
|
|
ok(Infinity === 6, "Infinity !== 6");
|
|
|
|
|
|
|
|
Math = 6;
|
|
|
|
ok(Math === 6, "NaN !== 6");
|
|
|
|
|
2008-09-09 01:25:23 +02:00
|
|
|
reportSuccess();
|