Something went wrong. Try again.
Reactos
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313/* * Copyright 2010 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 */
eval("@_jscript_version");
var tmp;
/*@ *///@cc_on @*/
@_jscript_version;
@cc_on@*/
// Standard predefined variabledif(isWin64) { ok(@_win64 === true, "@_win64 = " + @_win64); ok(@_amd64 === true, "@_amd64 = " + @_amd64); ok(isNaN(@_win32), "@_win32 = " + @_win32); ok(isNaN(@_x86), "@_x86 = " + @_x86);}else { ok(@_win32 === true, "@_win32 = " + @_win32); ok(@_x86 === true, "@_x86 = " + @_x86); ok(isNaN(@_win64), "@_win64 = " + @_win64); ok(isNaN(@_amd64), "@_amd64 = " + @_amd64);}
ok(@_jscript === true, "@_jscript = " + @_jscript);ok(@_jscript_build === ScriptEngineBuildVersion(), "@_jscript_build = " + @_jscript_build + " expected " + ScriptEngineBuildVersion());tmp = ScriptEngineMajorVersion() + ScriptEngineMinorVersion()/10;ok(@_jscript_version === tmp, "@_jscript_version = " + @_jscript_version + " expected " + tmp);ok(isNaN(@_win16), "@_win16 = " + @_win16);ok(isNaN(@_mac), "@_mac = " + @_mac);ok(isNaN(@_alpha), "@_alpha = " + @_alpha);ok(isNaN(@_mc680x0), "@_mc680x0 = " + @_mc680x0);ok(isNaN(@_PowerPC), "@_PowerPC = " + @_PowerPC);
// Undefined variableok(isNaN(@xxx), "@xxx = " + @xxx);ok(isNaN(@x$_xx), "@x$_xx = " + @x$_xx);
tmp = false;try { eval("/*@cc_on */");}catch(e) { tmp = true;}ok(tmp, "expected syntax exception");
tmp = false;try { eval("/*@_jscript_version */");}catch(e) { tmp = true;}ok(tmp, "expected syntax exception");
ok(isNaN(@test), "@test = " + @test);
@set @test = 1ok(@test === 1, "@test = " + @test);
@set @test = 0ok(@test === 0, "@test = " + @test);
tmp = false@set @test = @test tmp=trueok(@test === 0, "@test = " + @test);ok(tmp, "expr after @set not evaluated");
@set @test = !@testok(@test === true, "@test = " + @test);
@set @test = (@test+1+true)ok(@test === 3, "@test = " + @test);
@set @test = 2ok(@test === 2, "@test = " + @test);
@set @test = ( 2 + 2 )ok(@test === 4, "@test = " + @test);
@set @test = 2.5ok(@test === 2.5, "@test = " + @test);
@set @test = 0x4ok(@test === 4, "@test = " + @test);
@set @test = (2 + 2/2)ok(@test === 3, "@test = " + @test);
@set @test = (false+false)ok(@test === 0, "@test = " + @test);
@set @test = ((1+1)*((3)+1))ok(@test === 8, "@test = " + @test);
@set @_test = trueok(@_test === true, "@_test = " + @_test);
@set @$test = trueok(@$test === true, "@$test = " + @$test);
@set @newtest = (@newtest != @newtest)ok(@newtest === true, "@newtest = " + @newtest);
@set @test = (false != 0)ok(@test === false, "@test = " + @test);
@set @test = (1 != true)ok(@test === false, "@test = " + @test);
@set @test = (0 != true)ok(@test === true, "@test = " + @test);
@set @test = (true-2)ok(@test === -1, "@test = " + @test);
@set @test = (true-@_jscript)ok(@test === 0, "@test = " + @test);
@set @test = (true==1)ok(@test === true, "@test = " + @test);
@set @test = (1==false+1)ok(@test === true, "@test = " + @test);
function expect(val, exval) { ok(val === exval, "got " + val + " expected " + exval);}
@set @test = (false < 0.5)expect(@test, true);
@set @test = (true == 0 < 0.5)expect(@test, true);
@set @test = (false < 0)expect(@test, false);
@set @test = (false > 0.5)expect(@test, false);
@set @test = (1 < true)expect(@test, false);
@set @test = (1 <= true)expect(@test, true);
@set @test = (1 >= true)expect(@test, true);
@set @test = (1 >= true-1)expect(@test, true);
@if (false) this wouldn not parse"@end
@if (false) "@end
tmp = "@if (false) @end";ok(tmp.length === 16, "tmp.length = " + tmp.length);
@if(true)tmp = true@endok(tmp === true, "tmp = " + tmp);
@if(false)@if this would not CC parsethis will not parse@elif(true)this will also not parse@elsethis also will not parse@if let me complicate things a bit@end enough@end@end
@if(false)this will not parse@elsetmp = 2@elsethis will not be parsed@elsealso this@endok(tmp === 2, "tmp = " + tmp);
@if(true)tmp = 3;@elsejust skip this@endok(tmp === 3, "tmp = " + tmp);
@if(true)tmp = 4;@elif(true)this will not parse@elif nor this@elsejust skip this@endok(tmp === 4, "tmp = " + tmp);
@if(false)this will not parse@elif(false)nor this would@elif(true)tmp = 5;@elif nor this@elsejust skip this@endok(tmp === 5, "tmp = " + tmp);
@if (!@_jscript)this would not parse@if(true)@else@if(false)@end@end@elif (@_jscript)tmp = 6;@elif (true)@if xxx@else@if @elif @elif @else @end@end@elsethis would not parse@endok(tmp === 6, "tmp = " + tmp);
@if(true)@if(false)@elsetmp = 7;@end@elsethis would not parse@endok(tmp === 7, "tmp = " + tmp);
var exception_map = { JS_E_SYNTAX: {type: "SyntaxError", number: -2146827286}, JS_E_MISSING_LBRACKET: {type: "SyntaxError", number: -2146827283}, JS_E_EXPECTED_IDENTIFIER: {type: "SyntaxError", number: -2146827278}, JS_E_EXPECTED_ASSIGN: {type: "SyntaxError", number: -2146827277}, JS_E_EXPECTED_CCEND: {type: "SyntaxError", number: -2146827259}, JS_E_EXPECTED_AT: {type: "SyntaxError", number: -2146827256}};
function testException(src, id) { var ex = exception_map[id]; var ret = "", num = "";
try { eval(src); } catch(e) { ret = e.name; num = e.number; }
ok(ret === ex.type, "Exception test, ret = " + ret + ", expected " + ex.type +". Executed code: " + src); ok(num === ex.number, "Exception test, num = " + num + ", expected " + ex.number + ". Executed function: " + src);}
testException("@set test=true", "JS_E_EXPECTED_AT");testException("@set @1=true", "JS_E_EXPECTED_IDENTIFIER");testException("@set @test x=true", "JS_E_EXPECTED_ASSIGN");testException("@if false\n@end", "JS_E_MISSING_LBRACKET");testException("@if (false)\n", "JS_E_EXPECTED_CCEND");testException("@end\n", "JS_E_SYNTAX");testException("@elif\n", "JS_E_SYNTAX");testException("@else\n", "JS_E_SYNTAX");testException("@if false\n@elif true\n@end", "JS_E_MISSING_LBRACKET");
reportSuccess();