Commit e3b5b6fd authored by Frédéric Delanoy's avatar Frédéric Delanoy Committed by Alexandre Julliard

cmd/tests: Add tests for LSS comparison operator in "if" statements.

parent 0146b556
...@@ -607,7 +607,7 @@ if exist foo ( ...@@ -607,7 +607,7 @@ if exist foo (
cd .. & rd foobar cd .. & rd foobar
echo ------------ Testing if/else ------------ echo ------------ Testing if/else ------------
echo if/else should work with blocks echo --- if/else should work with blocks
if 0 == 0 ( if 0 == 0 (
echo if seems to work echo if seems to work
) else ( ) else (
...@@ -623,19 +623,22 @@ if /c==/c ( ...@@ -623,19 +623,22 @@ if /c==/c (
) else ( ) else (
echo parameter detection seems to be broken echo parameter detection seems to be broken
) )
echo Testing case sensitivity with and without /i option
echo --- case sensitivity with and without /i option
if bar==BAR echo if does not default to case sensitivity if bar==BAR echo if does not default to case sensitivity
if not bar==BAR echo if seems to default to case sensitivity if not bar==BAR echo if seems to default to case sensitivity
if /i foo==FOO echo if /i seems to work if /i foo==FOO echo if /i seems to work
if /i not foo==FOO echo if /i seems to be broken if /i not foo==FOO echo if /i seems to be broken
if /I foo==FOO echo if /I seems to work if /I foo==FOO echo if /I seems to work
if /I not foo==FOO echo if /I seems to be broken if /I not foo==FOO echo if /I seems to be broken
echo Testing string comparisons
echo --- string comparisons
if abc == abc (echo equal) else echo non equal if abc == abc (echo equal) else echo non equal
if abc =="abc" (echo equal) else echo non equal if abc =="abc" (echo equal) else echo non equal
if "abc"== abc (echo equal) else echo non equal if "abc"== abc (echo equal) else echo non equal
if "abc"== "abc" (echo equal) else echo non equal if "abc"== "abc" (echo equal) else echo non equal
echo Testing tabs handling
echo --- tabs handling
if@tab@1==1 echo doom if@tab@1==1 echo doom
if @tab@1==1 echo doom if @tab@1==1 echo doom
if 1==1 (echo doom) else@tab@echo quake if 1==1 (echo doom) else@tab@echo quake
...@@ -644,6 +647,58 @@ if 1==0@tab@(echo doom) else echo quake ...@@ -644,6 +647,58 @@ if 1==0@tab@(echo doom) else echo quake
if 1==0 (echo doom)@tab@else echo quake if 1==0 (echo doom)@tab@else echo quake
if 1==0 (echo doom) else@tab@echo quake if 1==0 (echo doom) else@tab@echo quake
echo --- comparison operators
rem NT4 misevaluates conditionals in for loops so we have to use subroutines as workarounds
rem Imbricated for loops parameters are currently not expanded correctly; this prevents usage of simpler imbricated for loops in tests
echo ------ for strings
rem NT4 stops processing of the whole batch file as soon as it finds a
rem comparison operator non fully uppercased, such as lss instead of LSS, so we
rem can't test those here.
if LSS LSS LSSfoo (echo LSS string can be used as operand for LSS comparison)
if LSS LSS LSS (echo bar)
if 1.1 LSS 1.10 (echo floats are handled as strings)
if "9" LSS "10" (echo numbers in quotes recognized!) else echo numbers in quotes are handled as strings
if not "-1" LSS "1" (echo negative numbers as well) else echo NT4
if /i foo LSS FoOc echo if /i seems to work for LSS
if /I not foo LSS FOOb echo if /I seems to be broken for LSS
set STR_PARMS=A B AB BA AA
for %%i in (%STR_PARMS%) do call :LSStest %%i A
for %%i in (%STR_PARMS%) do call :LSStest %%i B
for %%i in (%STR_PARMS%) do call :LSStest %%i AB
for %%i in (%STR_PARMS%) do call :LSStest %%i BA
for %%i in (%STR_PARMS%) do call :LSStest %%i AA
if b LSS B (echo b LSS B) else echo NT4
if /I b LSS B echo b LSS B insensitive
if b LSS A echo b LSS A
if /I b LSS A echo b LSS A insensitive
if a LSS B (echo a LSS B) else echo NT4
if /I a LSS B echo a LSS B insensitive
if A LSS b echo A LSS b
if /I A LSS b echo A LSS b insensitive
echo ------ for numbers
if -1 LSS 1 (echo negative numbers handled)
if not -1 LSS -10 (echo negative numbers handled)
if not 9 LSS 010 (echo octal handled)
if not -010 LSS -8 (echo also in negative form)
if 4 LSS 0x5 (echo hexa handled)
if not -1 LSS -0x1A (echo also in negative form)
if 11 LSS 101 (echo 11 LSS 101)
set INT_PARMS=0 1 10 9
for %%i in (%INT_PARMS%) do call :LSStest %%i 0
for %%i in (%INT_PARMS%) do call :LSStest %%i 1
for %%i in (%INT_PARMS%) do call :LSStest %%i 10
for %%i in (%INT_PARMS%) do call :LSStest %%i 9
goto :endIfCompOpsSubroutines
rem IF subroutines helpers
:LSStest
if %1 LSS %2 echo %1 LSS %2
goto :eof
:endIfCompOpsSubroutines
set STR_PARMS=
set INT_PARMS=
echo ------------ Testing for ------------ echo ------------ Testing for ------------
echo --- plain FOR echo --- plain FOR
for %%i in (A B C) do echo %%i for %%i in (A B C) do echo %%i
......
...@@ -417,20 +417,20 @@ bar ...@@ -417,20 +417,20 @@ bar
NUL NUL
@todo_wine@foo created @todo_wine@foo created
------------ Testing if/else ------------ ------------ Testing if/else ------------
if/else should work with blocks --- if/else should work with blocks
if seems to work if seems to work
else seems to work else seems to work
if seems not to detect /c as parameter if seems not to detect /c as parameter
Testing case sensitivity with and without /i option --- case sensitivity with and without /i option
if seems to default to case sensitivity if seems to default to case sensitivity
if /i seems to work if /i seems to work
if /I seems to work if /I seems to work
Testing string comparisons --- string comparisons
equal equal
non equal non equal
non equal non equal
equal equal
Testing tabs handling --- tabs handling
doom doom
doom doom
doom doom
...@@ -438,6 +438,42 @@ lol ...@@ -438,6 +438,42 @@ lol
quake quake
quake quake
quake quake
--- comparison operators
------ for strings
LSS string can be used as operand for LSS comparison
@todo_wine@floats are handled as strings
@todo_wine@numbers in quotes are handled as strings
@todo_wine@negative numbers as well@or_broken@NT4
@todo_wine@if /i seems to work for LSS
@todo_wine@A LSS B
@todo_wine@AB LSS B
@todo_wine@AA LSS B
@todo_wine@A LSS AB
@todo_wine@AA LSS AB
@todo_wine@A LSS BA
@todo_wine@B LSS BA
@todo_wine@AB LSS BA
@todo_wine@AA LSS BA
@todo_wine@A LSS AA
@todo_wine@b LSS B@or_broken@NT4
@todo_wine@a LSS B@or_broken@NT4
@todo_wine@a LSS B insensitive
@todo_wine@A LSS b
@todo_wine@A LSS b insensitive
------ for numbers
negative numbers handled
negative numbers handled
octal handled
also in negative form
hexa handled
also in negative form
11 LSS 101
@todo_wine@0 LSS 1
@todo_wine@0 LSS 10
@todo_wine@1 LSS 10
@todo_wine@9 LSS 10
@todo_wine@0 LSS 9
@todo_wine@1 LSS 9
------------ Testing for ------------ ------------ Testing for ------------
--- plain FOR --- plain FOR
A A
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment