=?UTF-8?Q?Fr=C3=A9d=C3=A9ric=20Delanoy=20?=: cmd/tests: Add tests for LSS comparison operator in "if" statements.
Alexandre Julliard
julliard at winehq.org
Tue Oct 23 13:37:17 CDT 2012
Module: wine
Branch: master
Commit: e3b5b6fd14d4cfa4d83b62c82dfa07b53d6a24ea
URL: http://source.winehq.org/git/wine.git/?a=commit;h=e3b5b6fd14d4cfa4d83b62c82dfa07b53d6a24ea
Author: Frédéric Delanoy <frederic.delanoy at gmail.com>
Date: Tue Oct 23 03:10:23 2012 +0200
cmd/tests: Add tests for LSS comparison operator in "if" statements.
---
programs/cmd/tests/test_builtins.cmd | 63 ++++++++++++++++++++++++++++--
programs/cmd/tests/test_builtins.cmd.exp | 44 +++++++++++++++++++--
2 files changed, 99 insertions(+), 8 deletions(-)
diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd
index fff067c..5039484 100644
--- a/programs/cmd/tests/test_builtins.cmd
+++ b/programs/cmd/tests/test_builtins.cmd
@@ -607,7 +607,7 @@ if exist foo (
cd .. & rd foobar
echo ------------ Testing if/else ------------
-echo if/else should work with blocks
+echo --- if/else should work with blocks
if 0 == 0 (
echo if seems to work
) else (
@@ -623,19 +623,22 @@ if /c==/c (
) else (
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 not bar==BAR echo if seems to default to case sensitivity
if /i foo==FOO echo if /i seems to work
if /i not foo==FOO echo if /i seems to be broken
if /I foo==FOO echo if /I seems to work
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
-echo Testing tabs handling
+
+echo --- tabs handling
if at tab@1==1 echo doom
if @tab at 1==1 echo doom
if 1==1 (echo doom) else at tab@echo quake
@@ -644,6 +647,58 @@ if 1==0 at tab@(echo doom) else echo quake
if 1==0 (echo doom)@tab at else echo quake
if 1==0 (echo doom) else at 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 --- plain FOR
for %%i in (A B C) do echo %%i
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp
index b7e8397..04e2927 100644
--- a/programs/cmd/tests/test_builtins.cmd.exp
+++ b/programs/cmd/tests/test_builtins.cmd.exp
@@ -417,20 +417,20 @@ bar
NUL
@todo_wine at foo created
------------ Testing if/else ------------
-if/else should work with blocks
+--- if/else should work with blocks
if seems to work
else seems to work
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 /i seems to work
if /I seems to work
-Testing string comparisons
+--- string comparisons
equal
non equal
non equal
equal
-Testing tabs handling
+--- tabs handling
doom
doom
doom
@@ -438,6 +438,42 @@ lol
quake
quake
quake
+--- comparison operators
+------ for strings
+LSS string can be used as operand for LSS comparison
+ at todo_wine@floats are handled as strings
+ at todo_wine@numbers in quotes are handled as strings
+ at todo_wine@negative numbers as well at or_broken@NT4
+ at todo_wine@if /i seems to work for LSS
+ at todo_wine@A LSS B
+ at todo_wine@AB LSS B
+ at todo_wine@AA LSS B
+ at todo_wine@A LSS AB
+ at todo_wine@AA LSS AB
+ at todo_wine@A LSS BA
+ at todo_wine@B LSS BA
+ at todo_wine@AB LSS BA
+ at todo_wine@AA LSS BA
+ at todo_wine@A LSS AA
+ at todo_wine@b LSS B at or_broken@NT4
+ at todo_wine@a LSS B at or_broken@NT4
+ at todo_wine@a LSS B insensitive
+ at todo_wine@A LSS b
+ at 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
+ at todo_wine@0 LSS 1
+ at todo_wine@0 LSS 10
+ at todo_wine@1 LSS 10
+ at todo_wine@9 LSS 10
+ at todo_wine@0 LSS 9
+ at todo_wine@1 LSS 9
------------ Testing for ------------
--- plain FOR
A
More information about the wine-cvs
mailing list