cmd/tests: Add some tests for "choice".

Signed-off-by: Alexander Coffin <alexcoffin1999@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexander Coffin 2018-12-18 19:25:01 -06:00 committed by Alexandre Julliard
parent 889fe31483
commit fc358a8275
2 changed files with 56 additions and 0 deletions

View File

@ -527,6 +527,48 @@ rmdir "fol;der"
rmdir folder
PATH=%PATH_BACKUP%
echo ------------ Testing 'choice' ------------
rem Windows XP and Windows 2000 do not come with choice
rem echo is used for @or_broken@ formatting
choice /C:ABC /M "Example message" /D A /T:0
if %ERRORLEVEL% EQU 9009 (
echo choice unavailable
)
echo %ERRORLEVEL%
choice /C ABC "/M:Example message" /D:B /T 0
if %ERRORLEVEL% EQU 9009 (
echo choice unavailable
)
echo %ERRORLEVEL%
choice /C def /D:f /T:0
if %ERRORLEVEL% EQU 9009 (
echo choice unavailable
)
echo %ERRORLEVEL%
REM If a pipe fails due to a nonexistent command
REM it will stop the whole program's execution
if %ERRORLEVEL% NEQ 9009 (
echo Y | choice /C ABCXYZ /D A /T 2
)
if %ERRORLEVEL% EQU 9009 (
echo choice unavailable
)
echo %ERRORLEVEL%
choice /C ABC /N /D A /T 0
if %ERRORLEVEL% EQU 9009 (
echo choice unavailable
)
echo %ERRORLEVEL%
choice /C abcABC /CS /D:A /T:0
if %ERRORLEVEL% EQU 9009 (
echo choice unavailable
)
echo %ERRORLEVEL%
rem intentional error
choice /C abcABC /D:A /T:0 >NUL 2>NUL
echo %ERRORLEVEL%
echo ------------ Testing variable expansion ------------
call :setError 0
echo ~p0 should be path containing batch file

View File

@ -479,6 +479,20 @@ foo
I'm here!@space@
I'm here!@space@
I'm here!@space@
------------ Testing 'choice' ------------
@todo_wine@Example message [A,B,C]?A@or_broken@choice unavailable
@todo_wine@1@or_broken@9009
@todo_wine@Example message [A,B,C]?B@or_broken@choice unavailable
@todo_wine@2@or_broken@9009
@todo_wine@[D,E,F]?F@or_broken@choice unavailable
@todo_wine@3@or_broken@9009
@todo_wine@[A,B,C,X,Y,Z]?Y@or_broken@choice unavailable
@todo_wine@5@or_broken@9009
@todo_wine@A@or_broken@choice unavailable
@todo_wine@1@or_broken@9009
@todo_wine@[a,b,c,A,B,C]?A@or_broken@choice unavailable
@todo_wine@4@or_broken@9009
@todo_wine@255@or_broken@9009
------------ Testing variable expansion ------------
~p0 should be path containing batch file
@path@