mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 08:25:03 +00:00
[CMD_ROSTEST] Add tests for GOTO label parsing.
This commit is contained in:
parent
c5e6e5a19c
commit
71cd64d66a
2 changed files with 69 additions and 3 deletions
|
@ -11,8 +11,9 @@ setlocal enabledelayedexpansion
|
||||||
:: GOTO/CALL jump to labels present forward to their call-point. Only when
|
:: 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
|
:: 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.
|
:: 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!
|
:: Execution must never go there!
|
||||||
:test_goto
|
:test_goto
|
||||||
|
@ -36,7 +37,8 @@ goto :continue
|
||||||
|
|
||||||
:test_goto
|
:test_goto
|
||||||
echo Test GOTO ok
|
echo Test GOTO ok
|
||||||
goto :do_test_call
|
:: GOTO also understands '+' instead of ':' in its label parameter.
|
||||||
|
goto +do_test_call
|
||||||
|
|
||||||
:test_call
|
:test_call
|
||||||
echo Test CALL ok from %0
|
echo Test CALL ok from %0
|
||||||
|
@ -44,12 +46,69 @@ echo Test CALL ok from %0
|
||||||
goto :EOF
|
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.
|
:: Next suite of tests.
|
||||||
::
|
::
|
||||||
:continue
|
: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
|
:: Testing :EOF support
|
||||||
::
|
::
|
||||||
|
|
|
@ -2,6 +2,13 @@
|
||||||
Test GOTO ok
|
Test GOTO ok
|
||||||
--------- Testing CALL within batch ---------
|
--------- Testing CALL within batch ---------
|
||||||
Test CALL ok from :test_call
|
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 ---------
|
--------- Testing :EOF support ---------
|
||||||
OK
|
OK
|
||||||
OK
|
OK
|
||||||
|
|
Loading…
Reference in a new issue