Module: wine Branch: master Commit: 250ce222b97851d1261023018194268119edf753 URL: http://source.winehq.org/git/wine.git/?a=commit;h=250ce222b97851d12610230181...
Author: Frédéric Delanoy frederic.delanoy@gmail.com Date: Wed Nov 7 00:51:17 2012 +0100
cmd/tests: Simplify 'if' comparison tests.
---
programs/cmd/tests/test_builtins.cmd | 91 +++++++++++---------------- programs/cmd/tests/test_builtins.cmd.exp | 100 +++++++++++++++--------------- 2 files changed, 86 insertions(+), 105 deletions(-)
diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd index 7f90549..e7b8516 100644 --- a/programs/cmd/tests/test_builtins.cmd +++ b/programs/cmd/tests/test_builtins.cmd @@ -649,7 +649,6 @@ 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 @@ -662,11 +661,9 @@ 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 +for %%i in (%STR_PARMS%) do ( + for %%j in (%STR_PARMS%) do ( + call :LSStest %%i %%j)) 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 @@ -675,11 +672,9 @@ 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 -for %%i in (%STR_PARMS%) do call :LEQtest %%i A -for %%i in (%STR_PARMS%) do call :LEQtest %%i B -for %%i in (%STR_PARMS%) do call :LEQtest %%i AB -for %%i in (%STR_PARMS%) do call :LEQtest %%i BA -for %%i in (%STR_PARMS%) do call :LEQtest %%i AA +for %%i in (%STR_PARMS%) do ( + for %%j in (%STR_PARMS%) do ( + call :LEQtest %%i %%j)) if b LEQ B (echo b LEQ B) else echo NT4 if /I b LEQ B echo b LEQ B insensitive if b LEQ A echo b LEQ A @@ -688,27 +683,19 @@ if a LEQ B (echo a LEQ B) else echo NT4 if /I a LEQ B echo a LEQ B insensitive if A LEQ b echo A LEQ b if /I A LEQ b echo A LEQ b insensitive -for %%i in (%STR_PARMS%) do call :EQUtest %%i A -for %%i in (%STR_PARMS%) do call :EQUtest %%i B -for %%i in (%STR_PARMS%) do call :EQUtest %%i AB -for %%i in (%STR_PARMS%) do call :EQUtest %%i BA -for %%i in (%STR_PARMS%) do call :EQUtest %%i AA +for %%i in (%STR_PARMS%) do ( + for %%j in (%STR_PARMS%) do ( + call :EQUtest %%i %%j)) if /I A EQU a echo A EQU a insensitive -for %%i in (%STR_PARMS%) do call :NEQtest %%i A -for %%i in (%STR_PARMS%) do call :NEQtest %%i B -for %%i in (%STR_PARMS%) do call :NEQtest %%i AB -for %%i in (%STR_PARMS%) do call :NEQtest %%i BA -for %%i in (%STR_PARMS%) do call :NEQtest %%i AA -for %%i in (%STR_PARMS%) do call :GEQtest %%i A -for %%i in (%STR_PARMS%) do call :GEQtest %%i B -for %%i in (%STR_PARMS%) do call :GEQtest %%i AB -for %%i in (%STR_PARMS%) do call :GEQtest %%i BA -for %%i in (%STR_PARMS%) do call :GEQtest %%i AA -for %%i in (%STR_PARMS%) do call :GTRtest %%i A -for %%i in (%STR_PARMS%) do call :GTRtest %%i B -for %%i in (%STR_PARMS%) do call :GTRtest %%i AB -for %%i in (%STR_PARMS%) do call :GTRtest %%i BA -for %%i in (%STR_PARMS%) do call :GTRtest %%i AA +for %%i in (%STR_PARMS%) do ( + for %%j in (%STR_PARMS%) do ( + call :NEQtest %%i %%j)) +for %%i in (%STR_PARMS%) do ( + for %%j in (%STR_PARMS%) do ( + call :GEQtest %%i %%j)) +for %%i in (%STR_PARMS%) do ( + for %%j in (%STR_PARMS%) do ( + call :GTRtest %%i %%j)) echo ------ for numbers if -1 LSS 1 (echo negative numbers handled) if not -1 LSS -10 (echo negative numbers handled) @@ -718,34 +705,28 @@ 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 -for %%i in (%INT_PARMS%) do call :LEQtest %%i 0 -for %%i in (%INT_PARMS%) do call :LEQtest %%i 1 -for %%i in (%INT_PARMS%) do call :LEQtest %%i 10 -for %%i in (%INT_PARMS%) do call :LEQtest %%i 9 -for %%i in (%INT_PARMS%) do call :EQUtest %%i 0 -for %%i in (%INT_PARMS%) do call :EQUtest %%i 1 -for %%i in (%INT_PARMS%) do call :EQUtest %%i 10 -for %%i in (%INT_PARMS%) do call :EQUtest %%i 9 +for %%i in (%INT_PARMS%) do ( + for %%j in (%INT_PARMS%) do ( + call :LSStest %%i %%j)) +for %%i in (%INT_PARMS%) do ( + for %%j in (%INT_PARMS%) do ( + call :LEQtest %%i %%j)) +for %%i in (%INT_PARMS%) do ( + for %%j in (%INT_PARMS%) do ( + call :EQUtest %%i %%j)) if 011 EQU 9 (echo octal ok) if 0xA1 EQU 161 (echo hexa ok) if 0xA1 EQU "161" (echo hexa should be recognized) else (echo string/hexa compare ok) if "0xA1" EQU 161 (echo hexa should be recognized) else (echo string/hexa compare ok) -for %%i in (%INT_PARMS%) do call :NEQtest %%i 0 -for %%i in (%INT_PARMS%) do call :NEQtest %%i 1 -for %%i in (%INT_PARMS%) do call :NEQtest %%i 10 -for %%i in (%INT_PARMS%) do call :NEQtest %%i 9 -for %%i in (%INT_PARMS%) do call :GEQtest %%i 0 -for %%i in (%INT_PARMS%) do call :GEQtest %%i 1 -for %%i in (%INT_PARMS%) do call :GEQtest %%i 10 -for %%i in (%INT_PARMS%) do call :GEQtest %%i 9 -for %%i in (%INT_PARMS%) do call :GTRtest %%i 0 -for %%i in (%INT_PARMS%) do call :GTRtest %%i 1 -for %%i in (%INT_PARMS%) do call :GTRtest %%i 10 -for %%i in (%INT_PARMS%) do call :GTRtest %%i 9 +for %%i in (%INT_PARMS%) do ( + for %%j in (%INT_PARMS%) do ( + call :NEQtest %%i %%j)) +for %%i in (%INT_PARMS%) do ( + for %%j in (%INT_PARMS%) do ( + call :GEQtest %%i %%j)) +for %%i in (%INT_PARMS%) do ( + for %%j in (%INT_PARMS%) do ( + call :GTRtest %%i %%j)) echo ------ for numbers and stringified numbers if not "1" EQU 1 (echo strings and integers not equal) else echo foo if not 1 EQU "1" (echo strings and integers not equal) else echo foo diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index d3612b6..1d42a96 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -446,15 +446,15 @@ numbers in quotes are handled as strings negative numbers as well@or_broken@NT4 if /i seems to work for LSS A LSS B -AB LSS B -AA LSS B A LSS AB -AA LSS AB A LSS BA +A LSS AA B LSS BA +AB LSS B AB LSS BA +AA LSS B +AA LSS AB AA LSS BA -A LSS AA b LSS B@or_broken@NT4 a LSS B@or_broken@NT4 a LSS B insensitive @@ -462,18 +462,18 @@ A LSS b A LSS b insensitive A LEQ A A LEQ B -B LEQ B -AB LEQ B -AA LEQ B A LEQ AB -AB LEQ AB -AA LEQ AB A LEQ BA +A LEQ AA +B LEQ B B LEQ BA +AB LEQ B +AB LEQ AB AB LEQ BA BA LEQ BA +AA LEQ B +AA LEQ AB AA LEQ BA -A LEQ AA AA LEQ AA b LEQ B@or_broken@NT4 b LEQ B insensitive @@ -487,51 +487,51 @@ AB EQU AB BA EQU BA AA EQU AA A EQU a insensitive -B NEQ A -AB NEQ A -BA NEQ A -AA NEQ A A NEQ B -AB NEQ B -BA NEQ B -AA NEQ B A NEQ AB -B NEQ AB -BA NEQ AB -AA NEQ AB A NEQ BA -B NEQ BA -AB NEQ BA -AA NEQ BA A NEQ AA +B NEQ A +B NEQ AB +B NEQ BA B NEQ AA +AB NEQ A +AB NEQ B +AB NEQ BA AB NEQ AA +BA NEQ A +BA NEQ B +BA NEQ AB BA NEQ AA +AA NEQ A +AA NEQ B +AA NEQ AB +AA NEQ BA A GEQ A B GEQ A -AB GEQ A -BA GEQ A -AA GEQ A B GEQ B -BA GEQ B B GEQ AB +B GEQ AA +AB GEQ A AB GEQ AB +AB GEQ AA +BA GEQ A +BA GEQ B BA GEQ AB BA GEQ BA -B GEQ AA -AB GEQ AA BA GEQ AA +AA GEQ A AA GEQ AA B GTR A +B GTR AB +B GTR AA AB GTR A +AB GTR AA BA GTR A -AA GTR A BA GTR B -B GTR AB BA GTR AB -B GTR AA -AB GTR AA BA GTR AA +AA GTR A ------ for numbers negative numbers handled negative numbers handled @@ -542,19 +542,19 @@ also in negative form 11 LSS 101 0 LSS 1 0 LSS 10 -1 LSS 10 -9 LSS 10 0 LSS 9 +1 LSS 10 1 LSS 9 +9 LSS 10 0 LEQ 0 0 LEQ 1 -1 LEQ 1 0 LEQ 10 +0 LEQ 9 +1 LEQ 1 1 LEQ 10 +1 LEQ 9 10 LEQ 10 9 LEQ 10 -0 LEQ 9 -1 LEQ 9 9 LEQ 9 0 EQU 0 1 EQU 1 @@ -564,34 +564,34 @@ octal ok hexa ok string/hexa compare ok string/hexa compare ok -1 NEQ 0 -10 NEQ 0 -9 NEQ 0 0 NEQ 1 -10 NEQ 1 -9 NEQ 1 0 NEQ 10 -1 NEQ 10 -9 NEQ 10 0 NEQ 9 +1 NEQ 0 +1 NEQ 10 1 NEQ 9 +10 NEQ 0 +10 NEQ 1 10 NEQ 9 +9 NEQ 0 +9 NEQ 1 +9 NEQ 10 0 GEQ 0 1 GEQ 0 -10 GEQ 0 -9 GEQ 0 1 GEQ 1 +10 GEQ 0 10 GEQ 1 -9 GEQ 1 10 GEQ 10 10 GEQ 9 +9 GEQ 0 +9 GEQ 1 9 GEQ 9 1 GTR 0 10 GTR 0 -9 GTR 0 10 GTR 1 -9 GTR 1 10 GTR 9 +9 GTR 0 +9 GTR 1 ------ for numbers and stringified numbers strings and integers not equal strings and integers not equal