https://git.reactos.org/?p=reactos.git;a=commitdiff;h=71cd64d66a20e91af4cf1…
commit 71cd64d66a20e91af4cf1b702607f9ff8e79bf91
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Mon Jul 27 01:11:23 2020 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Wed Aug 19 20:36:01 2020 +0200
[CMD_ROSTEST] Add tests for GOTO label parsing.
---
modules/rostests/win32/cmd/test_goto_call.cmd | 65 +++++++++++++++++++++--
modules/rostests/win32/cmd/test_goto_call.cmd.exp | 7 +++
2 files changed, 69 insertions(+), 3 deletions(-)
diff --git a/modules/rostests/win32/cmd/test_goto_call.cmd
b/modules/rostests/win32/cmd/test_goto_call.cmd
index 6a8d3579bc5..d2356a1b447 100644
--- a/modules/rostests/win32/cmd/test_goto_call.cmd
+++ b/modules/rostests/win32/cmd/test_goto_call.cmd
@@ -11,8 +11,9 @@ setlocal enabledelayedexpansion
:: GOTO/CALL jump to labels present forward to their call-point. Only when
:: the label cannot be found forward, the search is then restarted from the
:: beginning of the batch file onwards up to the original call-point.
-::
-goto :test_start
+
+:: GOTO with a label parameter without ':' works.
+goto test_start
:: Execution must never go there!
:test_goto
@@ -36,7 +37,8 @@ goto :continue
:test_goto
echo Test GOTO ok
-goto :do_test_call
+:: GOTO also understands '+' instead of ':' in its label parameter.
+goto +do_test_call
:test_call
echo Test CALL ok from %0
@@ -44,12 +46,69 @@ echo Test CALL ok from %0
goto :EOF
+::
+:: Next suite of tests.
+::
+
+:: GOTO label search algorithm ignores any whitespace between ':'
+:: and the label name, as well as leading and trailing whitespace.
+ :@tab@continue@space@@space@
+
+
+:: Jumping to a label with escape carets.
+goto :la^^bel2
+
+:la^bel2
+echo Unexpected GOTO jump^^!
+:la^^bel2
+echo GOTO with escape caret worked
+
+
+:: Go to the next tests below.
+goto :continue
+
+
::
:: Next suite of tests.
::
:continue
+::
+:: Extra GOTO syntax checks: separators in the label parameter
+::
+
+:: Whitespace
+goto :testLbl1@tab@ignored
+:testLbl1
+echo Hi there^^!
+
+:: Colon
+goto :testLbl2:ignored
+:testLbl2
+echo Hi there^^!
+
+:: Plus sign
+goto :testLbl3+ignored
+:testLbl3
+echo Hi there^^!
+
+:: Comma
+goto :testLbl4,ignored
+:testLbl4
+echo Hi there^^!
+
+:: Semicolon
+goto :testLbl5;ignored
+:testLbl5
+echo Hi there^^!
+
+:: Equals
+goto :testLbl6;ignored
+:testLbl6
+echo Hi there^^!
+
+
::
:: Testing :EOF support
::
diff --git a/modules/rostests/win32/cmd/test_goto_call.cmd.exp
b/modules/rostests/win32/cmd/test_goto_call.cmd.exp
index f375908a87b..3e94300fd76 100644
--- a/modules/rostests/win32/cmd/test_goto_call.cmd.exp
+++ b/modules/rostests/win32/cmd/test_goto_call.cmd.exp
@@ -2,6 +2,13 @@
Test GOTO ok
--------- Testing CALL within batch ---------
Test CALL ok from :test_call
+GOTO with escape caret worked
+Hi there!
+Hi there!
+Hi there!
+Hi there!
+Hi there!
+Hi there!
--------- Testing :EOF support ---------
OK
OK