Something went wrong. Try again.
Reactos
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902/* * 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 */
var tmp;
ok(true, "true is not true?");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");
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(1E0 === 1, "1E0 === 1 is false");ok(1000000*1000000 === 1000000000000, "1000000*1000000 === 1000000000000 is false");ok(8.64e15 === 8640000000000000, "8.64e15 !== 8640000000000000");ok(1e2147483648 === Infinity, "1e2147483648 !== Infinity");
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);ok(0xffffffff === 4294967295, "0xffffffff = " + 0xffffffff);tmp = 0x10000000000000000000000000000000000000000000000000000000000000000;ok(tmp === Math.pow(2, 256), "0x1000...00 != 2^256");
ok(1 !== 2, "1 !== 2 is false");ok(null !== undefined, "null !== undefined is false");
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");
ok(1 != 2, "1 != 2 is false");ok(false != 1, "false != 1 is false");
ok(this === test, "this !== test");eval('ok(this === test, "this !== test");');
var trueVar = true;ok(trueVar, "trueVar is not true");
ok(ScriptEngine.length === 0, "ScriptEngine.length is not 0");
function testFunc1(x, y) { ok(this !== undefined, "this is undefined"); ok(x === true, "x is not true"); ok(y === "test", "y is not \"test\""); ok(arguments.length === 2, "arguments.length is not 2"); ok(arguments["0"] === true, "arguments[0] is not true"); ok(arguments["1"] === "test", "arguments[1] is not \"test\""); ok(arguments.callee === testFunc1, "arguments.calee !== testFunc1"); ok(testFunc1.arguments === arguments, "testFunc1.arguments = " + testFunc1.arguments);
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"]);
ok(this === test, "this !== test"); eval('ok(this === test, "this !== test");');
tmp = delete arguments; ok(tmp === false, "arguments deleted"); ok(typeof(arguments) === "object", "typeof(arguments) = " + typeof(arguments));
x = 2; ok(x === 2, "x = " + x); ok(arguments[0] === 2, "arguments[0] = " + arguments[0]);
return true;}
ok(testFunc1.length === 2, "testFunc1.length is not 2");ok(testFunc1.arguments === null, "testFunc1.arguments = " + testFunc1.arguments);
ok(Object.prototype !== undefined, "Object.prototype is undefined");ok(Object.prototype.prototype === undefined, "Object.prototype is not undefined");ok(String.prototype !== undefined, "String.prototype is undefined");ok(Array.prototype !== undefined, "Array.prototype is undefined");ok(Boolean.prototype !== undefined, "Boolean.prototype is undefined");ok(Number.prototype !== undefined, "Number.prototype is undefined");ok(RegExp.prototype !== undefined, "RegExp.prototype is undefined");ok(Math !== undefined, "Math is undefined");ok(Math.prototype === undefined, "Math.prototype is not undefined");ok(Function.prototype !== undefined, "Function.prototype is undefined");ok(Function.prototype.prototype === undefined, "Function.prototype.prototype is not undefined");ok(Date.prototype !== undefined, "Date.prototype is undefined");ok(Date.prototype.prototype === undefined, "Date.prototype is not undefined");
function testConstructor(constr, name, inst) { ok(constr.prototype.constructor === constr, name + ".prototype.constructor !== " + name); 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')");}
testConstructor(Object, "Object");testConstructor(String, "String");testConstructor(Array, "Array");testConstructor(Boolean, "Boolean");testConstructor(Number, "Number");testConstructor(RegExp, "RegExp", /x/);testConstructor(Function, "Function");testConstructor(Date, "Date");testConstructor(VBArray, "VBArray", new VBArray(createArray()));testConstructor(Error, "Error");testConstructor(EvalError, "EvalError");testConstructor(RangeError, "RangeError");testConstructor(ReferenceError, "ReferenceError");testConstructor(RegExpError, "RegExpError");testConstructor(SyntaxError, "SyntaxError");testConstructor(TypeError, "TypeError");testConstructor(URIError, "URIError");
Function.prototype.test = true;ok(testFunc1.test === true, "testFunc1.test !== true");ok(Function.test === true, "Function.test !== true");
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");ok(typeof(this) === "object", "typeof(this) is not object");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);
ok("\0\0x\0\0".length === 5, "\"\\0\\0x\\0\\0\".length = " + "\0\0x\0\0".length);ok("\0\0x\0\0" === String.fromCharCode(0) + "\0x\0" + String.fromCharCode(0), "\"\\0\\0x\\0\\0\" unexpected");
ok(testFunc1(true, "test") === true, "testFunc1 not returned true");
ok(testFunc1.arguments === null, "testFunc1.arguments = " + testFunc1.arguments);
(tmp) = 3;ok(tmp === 3, "tmp = " + tmp);
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);
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"); return 1; });}
argumentsTest();
// 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);})();
(function callAsExprTest() { ok(callAsExprTest.arguments === null, "callAsExprTest.arguments = " + callAsExprTest.arguments);})(1,2);
tmp = (function() {1;})();ok(tmp === undefined, "tmp = " + tmp);tmp = eval("1;");ok(tmp === 1, "tmp = " + tmp);tmp = eval("1,2;");ok(tmp === 2, "tmp = " + tmp);tmp = eval("testNoRes(),2;");ok(tmp === 2, "tmp = " + tmp);tmp = eval("if(true) {3}");ok(tmp === 3, "tmp = " + tmp);eval("testRes(); testRes()");tmp = eval("3; if(false) {4;} else {};;;")ok(tmp === 3, "tmp = " + tmp);tmp = eval("try { 1; } finally { 2; }")ok(tmp === 2, "tmp = " + tmp);
testNoRes();testRes() && testRes();testNoRes(), testNoRes();
(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");})();
tmp = (function(){ return testNoRes(), testRes();})();
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; }})();
var obj1 = new Object();ok(typeof(obj1) === "object", "typeof(obj1) is not object");ok(obj1.constructor === Object, "unexpected obj1.constructor");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"); ok(typeof(arguments.callee) === "function", "typeof(arguments.calee) = " + typeof(arguments.calee));
return "test";};
ok(obj1.func(true) === "test", "obj1.func(true) is not \"test\"");
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"); ok(arguments.callee === testConstr1, "arguments.calee !== testConstr1");
return false;}
testConstr1.prototype.pvar = 1;ok(testConstr1.prototype.constructor === testConstr1, "testConstr1.prototype.constructor !== testConstr1");
var obj2 = new testConstr1(true);ok(typeof(obj2) === "object", "typeof(obj2) is not object");ok(obj2.constructor === testConstr1, "unexpected obj2.constructor");ok(obj2.pvar === 1, "obj2.pvar is not 1");ok(!obj2.hasOwnProperty('constructor'), "obj2.hasOwnProperty('constructor')");
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");
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));
var obj3 = new Object;ok(typeof(obj3) === "object", "typeof(obj3) is not object");
(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);
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);
for(var iter in pureDisp) ok(false, "unexpected forin call in pureDisp object");
tmp = new Object();ok(!tmp.nonexistent, "!tmp.nonexistent = " + !tmp.nonexistent);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")
tmp = new Object();ok(isNaN(+tmp.nonexistent), "!tmp.nonexistent = " + (+tmp.nonexistent));ok(!("nonexistent" in tmp), "nonexistent is in tmp after '+' expression")
tmp = new Object();tmp[tmp.nonexistent];ok(!("nonexistent" in tmp), "nonexistent is in tmp after array expression")
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?");
if(false) {}else {}
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\"");ok(obj3.constructor === Object, "unexpected obj3.constructor");
if(invokeVersion >= 2) { eval("tmp = {prop: 'value',}"); ok(tmp.prop === "value", "tmp.prop = " + tmp.prop); eval("tmp = {prop: 'value',second:2,}"); ok(tmp.prop === "value", "tmp.prop = " + tmp.prop);}else { try { eval("tmp = {prop: 'value',}"); }catch(e) { tmp = true; } ok(tmp === true, "exception not fired");}
{ var blockVar = 1; blockVar = 2;}ok(blockVar === 2, "blockVar !== 2");
ok((true ? 1 : 2) === 1, "conditional expression true is not 1");ok((0 === 2 ? 1 : 2) === 2, "conditional expression true is not 2");
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");ok(getVT(0.5) === "VT_R8", "getVT(0.5) is not VT_R8");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");
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");
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");ok(getVT(tmp) === "VT_R8", "getVT(4.5-2) !== VT_R8");
tmp = -2;ok(tmp === 0-2, "-2 !== 0-2");ok(getVT(tmp) === "VT_I4", "getVT(-2) !== VT_I4");
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;/* 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");ok(getVT(tmp) === "VT_R8", "getVT(2.5*3.5) !== VT_R8");
tmp = 2*.5;ok(tmp === 1, "2*.5 !== 1");ok(getVT(tmp) == "VT_I4", "getVT(2*.5) !== VT_I4");
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");
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);
tmp = "ab" + "cd";ok(tmp === "abcd", "\"ab\" + \"cd\" !== \"abcd\"");
tmp = 1;ok((tmp += 1) === 2, "tmp += 1 !== 2");ok(tmp === 2, "tmp !== 2");
tmp = 2;ok((tmp -= 1) === 1, "tmp -= 1 !== 1");ok(tmp === 1, "tmp !=== 1");
tmp = 2;ok((tmp *= 1.5) === 3, "tmp *= 1.5 !== 3");ok(tmp === 3, "tmp !=== 3");
tmp = 5;ok((tmp /= 2) === 2.5, "tmp /= 2 !== 2.5");ok(tmp === 2.5, "tmp !=== 2.5");
tmp = 3;ok((tmp %= 2) === 1, "tmp %= 2 !== 1");ok(tmp === 1, "tmp !== 1");
tmp = 8;ok((tmp <<= 1) === 16, "tmp <<= 1 !== 16");
tmp = 8;ok((tmp >>= 1) === 4, "tmp >>= 1 !== 4");
tmp = 8;ok((tmp >>>= 1) === 4, "tmp >>>= 1 !== 4");
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");
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");
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));
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);
tmp = 10;ok((tmp |= 0x10) === 26, "tmp(10) |= 0x10 !== 26");ok(getVT(tmp) === "VT_I4", "getVT(tmp |= 10) = " + getVT(tmp));
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);
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));
tmp = 2 << 3;ok(tmp === 16, "2 << 3 = " + tmp);
tmp = 2 << 35;ok(tmp === 16, "2 << 35 = " + tmp);
tmp = 8 >> 2;ok(tmp === 2, "8 >> 2 = " + tmp);
tmp = -64 >> 4;ok(tmp === -4, "-64 >> 4 = " + tmp);
tmp = 8 >>> 2;ok(tmp === 2, "8 >> 2 = " + tmp);
tmp = -64 >>> 4;ok(tmp === 0x0ffffffc, "-64 >>> 4 = " + tmp);
tmp = 4 >>> NaN;ok(tmp === 4, "4 >>> NaN = " + tmp);
tmp = 10;ok((tmp &= 8) === 8, "tmp(10) &= 8 !== 8");ok(getVT(tmp) === "VT_I4", "getVT(tmp &= 8) = " + getVT(tmp));
tmp = 0xf0f0^0xff00;ok(tmp === 0x0ff0, "0xf0f0^0xff00 !== 0x0ff0");ok(getVT(tmp) === "VT_I4", "getVT(0xf0f0^0xff00) = " + getVT(tmp));
tmp = 5;ok((tmp ^= 3) === 6, "tmp(5) ^= 3 !== 6");ok(getVT(tmp) === "VT_I4", "getVT(tmp ^= 3) = " + getVT(tmp));
tmp = ~1;ok(tmp === -2, "~1 !== -2");ok(getVT(tmp) === "VT_I4", "getVT(~1) = " + getVT(tmp));
ok((3,4) === 4, "(3,4) !== 4");
ok(+3 === 3, "+3 !== 3");ok(+true === 1, "+true !== 1");ok(+false === 0, "+false !== 0");ok(+null === 0, "+null !== 0");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");
tmp = new Number(1);ok(+tmp === 1, "+(new Number(1)) = " + (+tmp));ok(tmp.constructor === Number, "unexpected tmp.constructor");tmp = new String("1");ok(+tmp === 1, "+(new String('1')) = " + (+tmp));ok(tmp.constructor === String, "unexpected tmp.constructor");
ok("" + 0 === "0", "\"\" + 0 !== \"0\"");ok("" + 123 === "123", "\"\" + 123 !== \"123\"");ok("" + (-5) === "-5", "\"\" + (-5) !== \"-5\"");ok("" + null === "null", "\"\" + null !== \"null\"");ok("" + undefined === "undefined", "\"\" + undefined !== \"undefined\"");ok("" + true === "true", "\"\" + true !== \"true\"");ok("" + false === "false", "\"\" + false !== \"false\"");ok("" + 0.5 === "0.5", "'' + 0.5 = " + 0.5);ok("" + (-0.5432) === "-0.5432", "'' + (-0.5432) = " + (-0.5432));
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");
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");
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");
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");
tmp = 1;ok(++tmp === 2, "++tmp (1) is not 2");ok(tmp === 2, "incremented tmp is not 2");ok(--tmp === 1, "--tmp (2) is not 1");ok(tmp === 1, "decremented tmp is not 1");ok(tmp++ === 1, "tmp++ (1) is not 1");ok(tmp === 2, "incremented tmp(1) is not 2");ok(tmp-- === 2, "tmp-- (2) is not 2");ok(tmp === 1, "decremented tmp is not 1");
tmp = new Object();tmp.iii++;ok(isNaN(tmp.iii), "tmp.iii = " + tmp.iii);
String.prototype.test = true;ok("".test === true, "\"\".test is not true");
Boolean.prototype.test = true;ok(true.test === true, "true.test is not true");
Number.prototype.test = true;ok((0).test === true, "(0).test is not true");ok((0.5).test === true, "(0.5).test is not true");
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 { ok(state === "try", "finally: state = " + state); state = "finally";}ok(state === "finally", "state = " + state + " expected finally");
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);}
state = "";try { ok(state === "", "try: state = " + state); state = "try";}catch(ex) { ok(false, "unexpected catch");}finally { ok(state === "try", "finally: state = " + state); state = "finally";}ok(state === "finally", "state = " + state + " expected finally");
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 { ok(state === "catch", "finally: state = " + state); 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 { ok(state === "catch", "finally: state = " + state); 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 { ok(state === "catch", "finally: state = " + state); 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 { ok(state === "catch", "finally: state = " + state); state = "finally";}ok(state === "finally", "state = " + state + " expected finally");
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);
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);
switch(1) {case 2: ok(false, "unexpected case 2");case 3: ok(false, "unexpected case 3");}
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 */};
(function() { var i=0;
switch(1) { case 1: i++; } return i;})();
(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");
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");})();
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 { ok(state === "catch", "finally: state = " + state); state = "finally";}ok(state === "finally", "state = " + state + " expected finally");
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");ok(tmp[2] === 1, "tmp[2] !== 1");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,,,,]");
ok([1,].length === 2, "[1,].length !== 2");ok([,,].length === 3, "[,,].length !== 3");ok([,].length === 2, "[].length != 2");ok([].length === 0, "[].length != 0");
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);ok(tmp === 1, "tmp !== 1");
tmp = 0;do { ok(tmp < 4, "tmp >= 4"); tmp++;} while(tmp < 4)ok(tmp === 4, "tmp !== 4")
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");
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");
tmp = true;obj1 = new Object();for(obj1.nonexistent; tmp; tmp = false) ok(!("nonexistent" in obj1), "nonexistent added to obj1");
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");
var i, j;
/* 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"); } tmp += "5"; } with({prop: "6"}) { tmp += prop; break; } } ok(tmp === "123456", "tmp = " + tmp);}
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);
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);
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;}
ok((void 1) === undefined, "(void 1) !== undefined");
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");
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?");for(iter in tmp) ok(false, "tmp has prop " + iter);ok((delete tmp.test) === true, "deleting test didn't return true");ok((delete tmp.nonexistent) === true, "deleting nonexistent didn't return true");ok((delete nonexistent) === true, "deleting nonexistent didn't return true");
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?");
tmp.testWith = true;with(tmp) ok(testWith === true, "testWith !== true");
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;}
varTestFunc(3);
deleteTest = 1;delete deleteTest;try { tmp = deleteTest; ok(false, "deleteTest did not throw an exception?");}catch(ex) {}
(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); }})();
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");
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");
(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);
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");
obj = new Object();try { obj.prop["test"]; ok(false, "expected exception");}catch(e) {}ok(!("prop" in obj), "prop in obj");
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]);}
ok(isNaN(NaN) === true, "isNaN(NaN) !== true");ok(isNaN(0.5) === false, "isNaN(0.5) !== false");ok(isNaN(Infinity) === false, "isNaN(Infinity) !== false");ok(isNaN() === true, "isNaN() !== true");ok(isNaN(NaN, 0) === true, "isNaN(NaN, 0) !== true");ok(isNaN(0.5, NaN) === false, "isNaN(0.5, NaN) !== false");ok(isNaN(+undefined) === true, "isNaN(+undefined) !== true");
ok(isFinite(0.5) === true, "isFinite(0.5) !== true");ok(isFinite(Infinity) === false, "isFinite(Infinity) !== false");ok(isFinite(-Infinity) === false, "isFinite(Infinity) !== false");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");
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");
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");
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");
// escape testsvar 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);
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);
function testEmbeddedFunctions() { 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);}
testEmbeddedFunctions();
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);
ok((function (){return 1;})() === 1, "(function (){return 1;})() = " + (function (){return 1;})());
var re = /=(\?|%3F)/g;ok(re.source === "=(\\?|%3F)", "re.source = " + re.source);
tmp = new Array();for(var i=0; i<2; i++) tmp[i] = /b/;ok(tmp[0] != tmp[1], "tmp[0] == tmp [1]");
ok(isNullBSTR(getNullBSTR()), "isNullBSTR(getNullBSTR()) failed\n");ok(getNullBSTR() === '', "getNullBSTR() !== ''");ok(+getNullBSTR() === 0 , "+getNullBTR() !=== 0");
ok(getVT(nullDisp) === "VT_DISPATCH", "getVT(nullDisp) = " + getVT(nullDisp));ok(typeof(nullDisp) === "object", "typeof(nullDisp) = " + typeof(nullDisp));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);ok(String(nullDisp) === "null", "String(nullDisp) = " + String(nullDisp));ok(nullDisp != new Object(), "nullDisp == new Object()");ok(new Object() != nullDisp, "new Object() == nullDisp");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);
function do_test() {}function nosemicolon() {} nosemicolon();function () {} nosemicolon();
if(false) { function in_if_false() { return true; } ok(false, "!?");}
ok(in_if_false(), "in_if_false failed");
(function() { newValue = 1; })();ok(newValue === 1, "newValue = " + newValue);
obj = {undefined: 3};
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);
tmp = (function() { var ret = false; with({ret: true}) return ret;})();ok(tmp, "tmp = " + tmp);
tmp = (function() { for(var iter in [1,2,3,4]) { var ret = false; with({ret: true}) return ret; }})();ok(tmp, "tmp = " + tmp);
(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);})();
var get, set;
/* 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}
while(true) { break continue tmp = false}
function returnTest() { return true;}
ok(returnTest() === undefined, "returnTest = " + returnTest());
ActiveXObject = 1;ok(ActiveXObject === 1, "ActiveXObject = " + ActiveXObject);
Boolean = 1;ok(Boolean === 1, "Boolean = " + Boolean);
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);
/* Keep this test in the end of file */undefined = 6;ok(undefined === 6, "undefined = " + undefined);
NaN = 6;ok(NaN === 6, "NaN !== 6");
Infinity = 6;ok(Infinity === 6, "Infinity !== 6");
Math = 6;ok(Math === 6, "NaN !== 6");
reportSuccess();