mirror of
https://github.com/reactos/reactos.git
synced 2025-02-20 15:35:04 +00:00
[CMD_ROSTEST] Add tests for GOTO :EOF
This commit is contained in:
parent
f911bb482d
commit
aee1dd2972
2 changed files with 64 additions and 0 deletions
|
@ -50,6 +50,64 @@ goto :EOF
|
|||
:continue
|
||||
|
||||
|
||||
::
|
||||
:: Testing :EOF support
|
||||
::
|
||||
echo --------- Testing :EOF support ---------
|
||||
|
||||
:: Use an auxiliary CMD file to test GOTO :EOF
|
||||
mkdir foobar && cd foobar
|
||||
|
||||
:: GOTO :EOF is available only if commands extensions are enabled
|
||||
echo @echo off> tmp.cmd
|
||||
echo setlocal disableextensions>> tmp.cmd
|
||||
echo goto :eof>> tmp.cmd
|
||||
call :setError 0
|
||||
cmd /c tmp.cmd
|
||||
if %errorlevel% equ 0 (echo Unexpected: GOTO :EOF did not fail^^!) else echo OK
|
||||
|
||||
:: GOTO :EOF is done only if the ":EOF" part is followed by whitespace or ends.
|
||||
:: The following two GOTO's fail because the labels cannot be found.
|
||||
echo @echo off> tmp.cmd
|
||||
echo setlocal enableextensions>> tmp.cmd
|
||||
echo goto :eof,lol>> tmp.cmd
|
||||
echo echo Batch continues^^!>> tmp.cmd
|
||||
call :setError 0
|
||||
cmd /c tmp.cmd
|
||||
if %errorlevel% equ 0 (echo Unexpected: GOTO :eof,lol did not fail^^!) else echo OK
|
||||
|
||||
echo @echo off> tmp.cmd
|
||||
echo setlocal enableextensions>> tmp.cmd
|
||||
echo goto :eof:lol>> tmp.cmd
|
||||
echo echo Batch continues^^!>> tmp.cmd
|
||||
call :setError 0
|
||||
cmd /c tmp.cmd
|
||||
if %errorlevel% equ 0 (echo Unexpected: GOTO :eof:lol did not fail^^!) else echo OK
|
||||
|
||||
:: GOTO :EOF expects at least one whitespace character before anything else.
|
||||
:: Not even '+',':' or other separators are allowed.
|
||||
echo @echo off> tmp.cmd
|
||||
echo setlocal enableextensions>> tmp.cmd
|
||||
echo goto :eof+lol>> tmp.cmd
|
||||
echo echo Batch continues^^!>> tmp.cmd
|
||||
call :setError 0
|
||||
cmd /c tmp.cmd
|
||||
if %errorlevel% equ 0 (echo Unexpected: GOTO :eof+lol did not fail^^!) else echo OK
|
||||
|
||||
:: This GOTO :EOF works.
|
||||
echo @echo off> tmp.cmd
|
||||
echo setlocal enableextensions>> tmp.cmd
|
||||
echo goto :eof@tab@+lol>> tmp.cmd
|
||||
echo echo You should not see this^^!>> tmp.cmd
|
||||
call :setError 0
|
||||
cmd /c tmp.cmd
|
||||
if %errorlevel% neq 0 (echo Unexpected: GOTO :EOF did fail^^!) else echo OK
|
||||
|
||||
|
||||
:: Cleanup
|
||||
cd .. & rd /s/q foobar
|
||||
|
||||
|
||||
::
|
||||
:: Testing GOTO/CALL from and to within parenthesized blocks.
|
||||
::
|
||||
|
|
|
@ -2,6 +2,12 @@
|
|||
Test GOTO ok
|
||||
--------- Testing CALL within batch ---------
|
||||
Test CALL ok from :test_call
|
||||
--------- Testing :EOF support ---------
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
--------- Testing GOTO within block ---------
|
||||
Block-test 1: Single-line
|
||||
Block-test 2: Multi-line
|
||||
|
|
Loading…
Reference in a new issue