cmd/tests: Simplify 'if' comparison tests.
This commit is contained in:
parent
e8b0de1e14
commit
250ce222b9
|
@ -649,7 +649,6 @@ if 1==0 (echo doom) else@tab@echo quake
|
||||||
|
|
||||||
echo --- comparison operators
|
echo --- comparison operators
|
||||||
rem NT4 misevaluates conditionals in for loops so we have to use subroutines as workarounds
|
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
|
echo ------ for strings
|
||||||
rem NT4 stops processing of the whole batch file as soon as it finds a
|
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 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 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
|
if /I not foo LSS FOOb echo if /I seems to be broken for LSS
|
||||||
set STR_PARMS=A B AB BA AA
|
set STR_PARMS=A B AB BA AA
|
||||||
for %%i in (%STR_PARMS%) do call :LSStest %%i A
|
for %%i in (%STR_PARMS%) do (
|
||||||
for %%i in (%STR_PARMS%) do call :LSStest %%i B
|
for %%j in (%STR_PARMS%) do (
|
||||||
for %%i in (%STR_PARMS%) do call :LSStest %%i AB
|
call :LSStest %%i %%j))
|
||||||
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 b LSS B (echo b LSS B) else echo NT4
|
||||||
if /I b LSS B echo b LSS B insensitive
|
if /I b LSS B echo b LSS B insensitive
|
||||||
if b LSS A echo b LSS A
|
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 /I a LSS B echo a LSS B insensitive
|
||||||
if A LSS b echo A LSS b
|
if A LSS b echo A LSS b
|
||||||
if /I A LSS b echo A LSS b insensitive
|
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 (
|
||||||
for %%i in (%STR_PARMS%) do call :LEQtest %%i B
|
for %%j in (%STR_PARMS%) do (
|
||||||
for %%i in (%STR_PARMS%) do call :LEQtest %%i AB
|
call :LEQtest %%i %%j))
|
||||||
for %%i in (%STR_PARMS%) do call :LEQtest %%i BA
|
|
||||||
for %%i in (%STR_PARMS%) do call :LEQtest %%i AA
|
|
||||||
if b LEQ B (echo b LEQ B) else echo NT4
|
if b LEQ B (echo b LEQ B) else echo NT4
|
||||||
if /I b LEQ B echo b LEQ B insensitive
|
if /I b LEQ B echo b LEQ B insensitive
|
||||||
if b LEQ A echo b LEQ A
|
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 /I a LEQ B echo a LEQ B insensitive
|
||||||
if A LEQ b echo A LEQ b
|
if A LEQ b echo A LEQ b
|
||||||
if /I A LEQ b echo A LEQ b insensitive
|
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 (
|
||||||
for %%i in (%STR_PARMS%) do call :EQUtest %%i B
|
for %%j in (%STR_PARMS%) do (
|
||||||
for %%i in (%STR_PARMS%) do call :EQUtest %%i AB
|
call :EQUtest %%i %%j))
|
||||||
for %%i in (%STR_PARMS%) do call :EQUtest %%i BA
|
|
||||||
for %%i in (%STR_PARMS%) do call :EQUtest %%i AA
|
|
||||||
if /I A EQU a echo A EQU a insensitive
|
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 (
|
||||||
for %%i in (%STR_PARMS%) do call :NEQtest %%i B
|
for %%j in (%STR_PARMS%) do (
|
||||||
for %%i in (%STR_PARMS%) do call :NEQtest %%i AB
|
call :NEQtest %%i %%j))
|
||||||
for %%i in (%STR_PARMS%) do call :NEQtest %%i BA
|
for %%i in (%STR_PARMS%) do (
|
||||||
for %%i in (%STR_PARMS%) do call :NEQtest %%i AA
|
for %%j in (%STR_PARMS%) do (
|
||||||
for %%i in (%STR_PARMS%) do call :GEQtest %%i A
|
call :GEQtest %%i %%j))
|
||||||
for %%i in (%STR_PARMS%) do call :GEQtest %%i B
|
for %%i in (%STR_PARMS%) do (
|
||||||
for %%i in (%STR_PARMS%) do call :GEQtest %%i AB
|
for %%j in (%STR_PARMS%) do (
|
||||||
for %%i in (%STR_PARMS%) do call :GEQtest %%i BA
|
call :GTRtest %%i %%j))
|
||||||
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
|
|
||||||
echo ------ for numbers
|
echo ------ for numbers
|
||||||
if -1 LSS 1 (echo negative numbers handled)
|
if -1 LSS 1 (echo negative numbers handled)
|
||||||
if not -1 LSS -10 (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 not -1 LSS -0x1A (echo also in negative form)
|
||||||
if 11 LSS 101 (echo 11 LSS 101)
|
if 11 LSS 101 (echo 11 LSS 101)
|
||||||
set INT_PARMS=0 1 10 9
|
set INT_PARMS=0 1 10 9
|
||||||
for %%i in (%INT_PARMS%) do call :LSStest %%i 0
|
for %%i in (%INT_PARMS%) do (
|
||||||
for %%i in (%INT_PARMS%) do call :LSStest %%i 1
|
for %%j in (%INT_PARMS%) do (
|
||||||
for %%i in (%INT_PARMS%) do call :LSStest %%i 10
|
call :LSStest %%i %%j))
|
||||||
for %%i in (%INT_PARMS%) do call :LSStest %%i 9
|
for %%i in (%INT_PARMS%) do (
|
||||||
for %%i in (%INT_PARMS%) do call :LEQtest %%i 0
|
for %%j in (%INT_PARMS%) do (
|
||||||
for %%i in (%INT_PARMS%) do call :LEQtest %%i 1
|
call :LEQtest %%i %%j))
|
||||||
for %%i in (%INT_PARMS%) do call :LEQtest %%i 10
|
for %%i in (%INT_PARMS%) do (
|
||||||
for %%i in (%INT_PARMS%) do call :LEQtest %%i 9
|
for %%j in (%INT_PARMS%) do (
|
||||||
for %%i in (%INT_PARMS%) do call :EQUtest %%i 0
|
call :EQUtest %%i %%j))
|
||||||
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
|
|
||||||
if 011 EQU 9 (echo octal ok)
|
if 011 EQU 9 (echo octal ok)
|
||||||
if 0xA1 EQU 161 (echo hexa 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)
|
||||||
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 (
|
||||||
for %%i in (%INT_PARMS%) do call :NEQtest %%i 1
|
for %%j in (%INT_PARMS%) do (
|
||||||
for %%i in (%INT_PARMS%) do call :NEQtest %%i 10
|
call :NEQtest %%i %%j))
|
||||||
for %%i in (%INT_PARMS%) do call :NEQtest %%i 9
|
for %%i in (%INT_PARMS%) do (
|
||||||
for %%i in (%INT_PARMS%) do call :GEQtest %%i 0
|
for %%j in (%INT_PARMS%) do (
|
||||||
for %%i in (%INT_PARMS%) do call :GEQtest %%i 1
|
call :GEQtest %%i %%j))
|
||||||
for %%i in (%INT_PARMS%) do call :GEQtest %%i 10
|
for %%i in (%INT_PARMS%) do (
|
||||||
for %%i in (%INT_PARMS%) do call :GEQtest %%i 9
|
for %%j in (%INT_PARMS%) do (
|
||||||
for %%i in (%INT_PARMS%) do call :GTRtest %%i 0
|
call :GTRtest %%i %%j))
|
||||||
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
|
|
||||||
echo ------ for numbers and stringified numbers
|
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
|
||||||
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
|
||||||
|
|
|
@ -446,15 +446,15 @@ numbers in quotes are handled as strings
|
||||||
negative numbers as well@or_broken@NT4
|
negative numbers as well@or_broken@NT4
|
||||||
if /i seems to work for LSS
|
if /i seems to work for LSS
|
||||||
A LSS B
|
A LSS B
|
||||||
AB LSS B
|
|
||||||
AA LSS B
|
|
||||||
A LSS AB
|
A LSS AB
|
||||||
AA LSS AB
|
|
||||||
A LSS BA
|
A LSS BA
|
||||||
B LSS BA
|
|
||||||
AB LSS BA
|
|
||||||
AA LSS BA
|
|
||||||
A LSS AA
|
A LSS AA
|
||||||
|
B LSS BA
|
||||||
|
AB LSS B
|
||||||
|
AB LSS BA
|
||||||
|
AA LSS B
|
||||||
|
AA LSS AB
|
||||||
|
AA LSS BA
|
||||||
b LSS B@or_broken@NT4
|
b LSS B@or_broken@NT4
|
||||||
a LSS B@or_broken@NT4
|
a LSS B@or_broken@NT4
|
||||||
a LSS B insensitive
|
a LSS B insensitive
|
||||||
|
@ -462,18 +462,18 @@ A LSS b
|
||||||
A LSS b insensitive
|
A LSS b insensitive
|
||||||
A LEQ A
|
A LEQ A
|
||||||
A LEQ B
|
A LEQ B
|
||||||
B LEQ B
|
|
||||||
AB LEQ B
|
|
||||||
AA LEQ B
|
|
||||||
A LEQ AB
|
A LEQ AB
|
||||||
AB LEQ AB
|
|
||||||
AA LEQ AB
|
|
||||||
A LEQ BA
|
A LEQ BA
|
||||||
|
A LEQ AA
|
||||||
|
B LEQ B
|
||||||
B LEQ BA
|
B LEQ BA
|
||||||
|
AB LEQ B
|
||||||
|
AB LEQ AB
|
||||||
AB LEQ BA
|
AB LEQ BA
|
||||||
BA LEQ BA
|
BA LEQ BA
|
||||||
|
AA LEQ B
|
||||||
|
AA LEQ AB
|
||||||
AA LEQ BA
|
AA LEQ BA
|
||||||
A LEQ AA
|
|
||||||
AA LEQ AA
|
AA LEQ AA
|
||||||
b LEQ B@or_broken@NT4
|
b LEQ B@or_broken@NT4
|
||||||
b LEQ B insensitive
|
b LEQ B insensitive
|
||||||
|
@ -487,51 +487,51 @@ AB EQU AB
|
||||||
BA EQU BA
|
BA EQU BA
|
||||||
AA EQU AA
|
AA EQU AA
|
||||||
A EQU a insensitive
|
A EQU a insensitive
|
||||||
B NEQ A
|
|
||||||
AB NEQ A
|
|
||||||
BA NEQ A
|
|
||||||
AA NEQ A
|
|
||||||
A NEQ B
|
A NEQ B
|
||||||
AB NEQ B
|
|
||||||
BA NEQ B
|
|
||||||
AA NEQ B
|
|
||||||
A NEQ AB
|
A NEQ AB
|
||||||
B NEQ AB
|
|
||||||
BA NEQ AB
|
|
||||||
AA NEQ AB
|
|
||||||
A NEQ BA
|
A NEQ BA
|
||||||
B NEQ BA
|
|
||||||
AB NEQ BA
|
|
||||||
AA NEQ BA
|
|
||||||
A NEQ AA
|
A NEQ AA
|
||||||
|
B NEQ A
|
||||||
|
B NEQ AB
|
||||||
|
B NEQ BA
|
||||||
B NEQ AA
|
B NEQ AA
|
||||||
|
AB NEQ A
|
||||||
|
AB NEQ B
|
||||||
|
AB NEQ BA
|
||||||
AB NEQ AA
|
AB NEQ AA
|
||||||
|
BA NEQ A
|
||||||
|
BA NEQ B
|
||||||
|
BA NEQ AB
|
||||||
BA NEQ AA
|
BA NEQ AA
|
||||||
|
AA NEQ A
|
||||||
|
AA NEQ B
|
||||||
|
AA NEQ AB
|
||||||
|
AA NEQ BA
|
||||||
A GEQ A
|
A GEQ A
|
||||||
B GEQ A
|
B GEQ A
|
||||||
AB GEQ A
|
|
||||||
BA GEQ A
|
|
||||||
AA GEQ A
|
|
||||||
B GEQ B
|
B GEQ B
|
||||||
BA GEQ B
|
|
||||||
B GEQ AB
|
B GEQ AB
|
||||||
|
B GEQ AA
|
||||||
|
AB GEQ A
|
||||||
AB GEQ AB
|
AB GEQ AB
|
||||||
|
AB GEQ AA
|
||||||
|
BA GEQ A
|
||||||
|
BA GEQ B
|
||||||
BA GEQ AB
|
BA GEQ AB
|
||||||
BA GEQ BA
|
BA GEQ BA
|
||||||
B GEQ AA
|
|
||||||
AB GEQ AA
|
|
||||||
BA GEQ AA
|
BA GEQ AA
|
||||||
|
AA GEQ A
|
||||||
AA GEQ AA
|
AA GEQ AA
|
||||||
B GTR A
|
B GTR A
|
||||||
AB GTR A
|
|
||||||
BA GTR A
|
|
||||||
AA GTR A
|
|
||||||
BA GTR B
|
|
||||||
B GTR AB
|
B GTR AB
|
||||||
BA GTR AB
|
|
||||||
B GTR AA
|
B GTR AA
|
||||||
|
AB GTR A
|
||||||
AB GTR AA
|
AB GTR AA
|
||||||
|
BA GTR A
|
||||||
|
BA GTR B
|
||||||
|
BA GTR AB
|
||||||
BA GTR AA
|
BA GTR AA
|
||||||
|
AA GTR A
|
||||||
------ for numbers
|
------ for numbers
|
||||||
negative numbers handled
|
negative numbers handled
|
||||||
negative numbers handled
|
negative numbers handled
|
||||||
|
@ -542,19 +542,19 @@ also in negative form
|
||||||
11 LSS 101
|
11 LSS 101
|
||||||
0 LSS 1
|
0 LSS 1
|
||||||
0 LSS 10
|
0 LSS 10
|
||||||
1 LSS 10
|
|
||||||
9 LSS 10
|
|
||||||
0 LSS 9
|
0 LSS 9
|
||||||
|
1 LSS 10
|
||||||
1 LSS 9
|
1 LSS 9
|
||||||
|
9 LSS 10
|
||||||
0 LEQ 0
|
0 LEQ 0
|
||||||
0 LEQ 1
|
0 LEQ 1
|
||||||
1 LEQ 1
|
|
||||||
0 LEQ 10
|
0 LEQ 10
|
||||||
|
0 LEQ 9
|
||||||
|
1 LEQ 1
|
||||||
1 LEQ 10
|
1 LEQ 10
|
||||||
|
1 LEQ 9
|
||||||
10 LEQ 10
|
10 LEQ 10
|
||||||
9 LEQ 10
|
9 LEQ 10
|
||||||
0 LEQ 9
|
|
||||||
1 LEQ 9
|
|
||||||
9 LEQ 9
|
9 LEQ 9
|
||||||
0 EQU 0
|
0 EQU 0
|
||||||
1 EQU 1
|
1 EQU 1
|
||||||
|
@ -564,34 +564,34 @@ octal ok
|
||||||
hexa ok
|
hexa ok
|
||||||
string/hexa compare ok
|
string/hexa compare ok
|
||||||
string/hexa compare ok
|
string/hexa compare ok
|
||||||
1 NEQ 0
|
|
||||||
10 NEQ 0
|
|
||||||
9 NEQ 0
|
|
||||||
0 NEQ 1
|
0 NEQ 1
|
||||||
10 NEQ 1
|
|
||||||
9 NEQ 1
|
|
||||||
0 NEQ 10
|
0 NEQ 10
|
||||||
1 NEQ 10
|
|
||||||
9 NEQ 10
|
|
||||||
0 NEQ 9
|
0 NEQ 9
|
||||||
|
1 NEQ 0
|
||||||
|
1 NEQ 10
|
||||||
1 NEQ 9
|
1 NEQ 9
|
||||||
|
10 NEQ 0
|
||||||
|
10 NEQ 1
|
||||||
10 NEQ 9
|
10 NEQ 9
|
||||||
|
9 NEQ 0
|
||||||
|
9 NEQ 1
|
||||||
|
9 NEQ 10
|
||||||
0 GEQ 0
|
0 GEQ 0
|
||||||
1 GEQ 0
|
1 GEQ 0
|
||||||
10 GEQ 0
|
|
||||||
9 GEQ 0
|
|
||||||
1 GEQ 1
|
1 GEQ 1
|
||||||
|
10 GEQ 0
|
||||||
10 GEQ 1
|
10 GEQ 1
|
||||||
9 GEQ 1
|
|
||||||
10 GEQ 10
|
10 GEQ 10
|
||||||
10 GEQ 9
|
10 GEQ 9
|
||||||
|
9 GEQ 0
|
||||||
|
9 GEQ 1
|
||||||
9 GEQ 9
|
9 GEQ 9
|
||||||
1 GTR 0
|
1 GTR 0
|
||||||
10 GTR 0
|
10 GTR 0
|
||||||
9 GTR 0
|
|
||||||
10 GTR 1
|
10 GTR 1
|
||||||
9 GTR 1
|
|
||||||
10 GTR 9
|
10 GTR 9
|
||||||
|
9 GTR 0
|
||||||
|
9 GTR 1
|
||||||
------ for numbers and stringified numbers
|
------ for numbers and stringified numbers
|
||||||
strings and integers not equal
|
strings and integers not equal
|
||||||
strings and integers not equal
|
strings and integers not equal
|
||||||
|
|
Loading…
Reference in New Issue