Module: wine Branch: master Commit: 68c61d17e0c5af5251d440efb0ee7c5292b598f5 URL: http://source.winehq.org/git/wine.git/?a=commit;h=68c61d17e0c5af5251d440efb0... Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Oct 1 10:45:21 2014 +0200 jscript: Added tests for @if/@elif/@else/@end. --- dlls/jscript/tests/cc.js | 104 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) diff --git a/dlls/jscript/tests/cc.js b/dlls/jscript/tests/cc.js index b96f21e..32f827e 100644 --- a/dlls/jscript/tests/cc.js +++ b/dlls/jscript/tests/cc.js @@ -140,9 +140,107 @@ ok(@test === false, "@test = " + @test); @set @test = (0 != true) ok(@test === true, "@test = " + @test); +(a)if (false) + this wouldn not parse +"@end + +(a)if (false) "@end + +tmp = "@if (false) @end"; +ok(tmp.length === 16, "tmp.length = " + tmp.length); + +(a)if(true) +tmp = true +(a)end +ok(tmp === true, "tmp = " + tmp); + +(a)if(false) +(a)if this would not CC parse +this will not parse +(a)elif(true) +this will also not parse +(a)else +this also will not parse +(a)if let me complicate things a bit +(a)end enough +(a)end +(a)end + +(a)if(false) +this will not parse +(a)else +tmp = 2 +(a)else +this will not be parsed +(a)else +also this +(a)end +ok(tmp === 2, "tmp = " + tmp); + +(a)if(true) +tmp = 3; +(a)else +just skip this +(a)end +ok(tmp === 3, "tmp = " + tmp); + +(a)if(true) +tmp = 4; +(a)elif(true) +this will not parse +(a)elif nor this +(a)else +just skip this +(a)end +ok(tmp === 4, "tmp = " + tmp); + +(a)if(false) +this will not parse +(a)elif(false) +nor this would +(a)elif(true) +tmp = 5; +(a)elif nor this +(a)else +just skip this +(a)end +ok(tmp === 5, "tmp = " + tmp); + +(a)if (!@_jscript) +this would not parse +(a)if(true) +(a)else +(a)if(false) +(a)end +(a)end +(a)elif (@_jscript) +tmp = 6; +(a)elif (true) +(a)if xxx +(a)else +(a)if @elif @elif @else @end +(a)end +(a)else +this would not parse +(a)end +ok(tmp === 6, "tmp = " + tmp); + +(a)if(true) +(a)if(false) +(a)else +tmp = 7; +(a)end +(a)else +this would not parse +(a)end +ok(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} }; @@ -164,5 +262,11 @@ function testException(src, id) { 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(a)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(a)elif true\n(a)end", "JS_E_MISSING_LBRACKET"); reportSuccess();