Module: wine Branch: master Commit: 7146387dc68534a287f61a5ef5d8c26e6834a1ec URL: http://source.winehq.org/git/wine.git/?a=commit;h=7146387dc68534a287f61a5ef5...
Author: Jacek Caban jacek@codeweavers.com Date: Tue Sep 20 14:59:21 2011 +0200
vbscript: Added support for short if statements.
---
dlls/vbscript/parser.y | 4 +++- dlls/vbscript/tests/lang.vbs | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletions(-)
diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 2d80c40..728bd92 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -198,7 +198,9 @@ DoType IfStatement : tIF Expression tTHEN tNL StatementsNl ElseIfs_opt Else_opt tEND tIF { $$ = new_if_statement(ctx, $2, $5, $6, $7); CHECK_ERROR; } - /* FIXME: short if statement */ + | tIF Expression tTHEN Statement { $$ = new_if_statement(ctx, $2, $4, NULL, NULL); CHECK_ERROR; } + | tIF Expression tTHEN Statement tELSE Statement + { $$ = new_if_statement(ctx, $2, $4, NULL, $6); CHECK_ERROR; }
ElseIfs_opt : /* empty */ { $$ = NULL; } diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 17c92e5..029c5ac 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -164,6 +164,29 @@ Call ok(2^3^2 = 64, "2^3^2 = " & (2^3^2)) Call ok(-3^2 = 9, "-3^2 = " & (-3^2)) Call ok(2*3^2 = 18, "2*3^2 = " & (2*3^2))
+if true then y = true : x = y +ok x, "x is false" + +x = true : if false then x = false +ok x, "x is false, if false called?" + +if not false then x = true +ok x, "x is false, if not false not called?" + +if not false then x = "test" : x = true +ok x, "x is false, if not false not called?" + +if false then x = y : call ok(false, "if false .. : called") + +if false then x = y : call ok(false, "if false .. : called") else x = "else" +Call ok(x = "else", "else not called?") + +if true then x = y else y = x : Call ok(false, "in else?") + +if false then : + +if false then x = y : if true then call ok(false, "embedded if called") + if false then ok false, "if false called" end if