[PATCH v2 0/1] MR10318: Draft: vbscript: Allow End If on the same line as the preceding statement.
Use BodyStatements instead of StatementsNl_opt for If, ElseIf, and Else blocks so the last statement before End If does not require a trailing newline, matching native behavior. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55196 -- v2: vbscript/tests: Add tests for trailing End If in Else and ElseIf blocks. https://gitlab.winehq.org/wine/wine/-/merge_requests/10318
From: Francis De Brabandere <francisdb@gmail.com> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55196 --- dlls/vbscript/tests/lang.vbs | 45 ++++++++++++++++++++++++++++++++++++ dlls/vbscript/tests/run.c | 8 +++++++ 2 files changed, 53 insertions(+) diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 0025bfeddcf..831573fe80f 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -359,6 +359,51 @@ ElseIf not False Then End If Call ok(x, "elseif not called?") +' Else with trailing End If on same line +x = 1 +If false Then + x = 2 +Else x = 3 End If +Call ok(x = 3, "Else with trailing End If failed") + +' Else with colon separator before End If +x = 1 +If false Then + x = 2 +Else x = 3:End If +Call ok(x = 3, "Else with colon before End If failed") + +' Else with colon then statement with trailing End If +x = 1 +If false Then + x = 2 +Else:x = 3 End If +Call ok(x = 3, "Else colon then statement with trailing End If failed") + +' Else with multiple statements and trailing End If +x = 1 +y = 1 +If false Then + x = 2 +Else x = 3:y = 4 End If +Call ok(x = 3, "Else multi-statement trailing End If failed for x") +Call ok(y = 4, "Else multi-statement trailing End If failed for y") + +' Else with body statement on next line with trailing End If +x = 1 +If false Then + x = 2 +Else + x = 3 End If +Call ok(x = 3, "Else body statement with trailing End If failed") + +' ElseIf single-line with trailing End If +x = 1 +If false Then + x = 2 +ElseIf true Then x = 3 End If +Call ok(x = 3, "ElseIf single-line with trailing End If failed") + x = false if 1 then x = true Call ok(x, "if 1 not run?") diff --git a/dlls/vbscript/tests/run.c b/dlls/vbscript/tests/run.c index 8aaafbedf54..6ea45f9757d 100644 --- a/dlls/vbscript/tests/run.c +++ b/dlls/vbscript/tests/run.c @@ -2656,6 +2656,14 @@ static void test_parse_errors(void) " x = 0 End If\n", 1, 10 }, + { + /* ElseIf...End If */ + L"If False Then\n" + " x = 0\n" + "ElseIf True Then\n" + " x = 1 End If\n", + 3, 10 + }, { /* While...End While */ L"While False\n" -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10318
On Fri Mar 13 15:03:15 2026 +0000, Jacek Caban wrote:
`lang.vbs` does not use cscript, it is ran by `dlls/vbscript/tests/run.c` (which also provides things like ok()). To run it manually, you may use something like `wine vbscript_test.exe run` or `make dlls/vbscript/tests/test` to run all vbscript tests. Running tests both on Windows and Linux is a part of CI. Thanks. Closing this thread for now, I'm running some extra tests on ci to see if my manual testing was correct. Will afterwards work on a fix.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10318#note_132201
participants (2)
-
Francis De Brabandere -
Francis De Brabandere (@francisdb)