cmd/tests: Add FOR /A tests.

This commit is contained in:
Frédéric Delanoy 2011-08-04 16:01:48 +02:00 committed by Alexandre Julliard
parent 760faf01a9
commit 28fe027eee
2 changed files with 149 additions and 0 deletions

View File

@ -385,6 +385,85 @@ rem for /L %%i in (1,1,1) do echo %%i
rem for /L %%i in (1,-2,-1) do echo %%i
rem for /L %%i in (-1,-1,-1) do echo %%i
rem for /L %%i in (1,2, 3) do echo %%i
echo ...for /a
rem No output when using "set expr" syntax, unless in interactive mode
rem Need to use "set envvar=expr" to use in a batch script
echo ......individual operations
set var=0
set /a var=1 +2 & echo %var%
set /a var=1 +-2 & echo %var%
set /a var=1 --2 & echo %var%
set /a var=2* 3 & echo %var%
set /a var=-2* -5 & echo %var%
set /a var=12/3 & echo %var%
set /a var=13/3 & echo %var%
set /a var=-13/3 & echo %var%
rem FIXME Divide by zero should return an error, but error messages cannot be tested with current infrastructure
set /a var=5 %% 5 & echo %var%
set /a var=5 %% 3 & echo %var%
set /a var=5 %% -3 & echo %var%
set /a var=-5 %% -3 & echo %var%
set /a var=1 ^<^< 0 & echo %var%
set /a var=1 ^<^< 2 & echo %var%
set /a var=1 ^<^< -2 & echo %var%
set /a var=-1 ^<^< -2 & echo %var%
set /a var=-1 ^<^< 2 & echo %var%
set /a var=9 ^>^> 0 & echo %var%
set /a var=9 ^>^> 2 & echo %var%
set /a var=9 ^>^> -2 & echo %var%
set /a var=-9 ^>^> -2 & echo %var%
set /a var=-9 ^>^> 2 & echo %var%
set /a var=5 ^& 0 & echo %var%
set /a var=5 ^& 1 & echo %var%
set /a var=5 ^& 3 & echo %var%
set /a var=5 ^& 4 & echo %var%
set /a var=5 ^& 1 & echo %var%
set /a var=5 ^| 0 & echo %var%
set /a var=5 ^| 1 & echo %var%
set /a var=5 ^| 3 & echo %var%
set /a var=5 ^| 4 & echo %var%
set /a var=5 ^| 1 & echo %var%
set /a var=5 ^^ 0 & echo %var%
set /a var=5 ^^ 1 & echo %var%
set /a var=5 ^^ 3 & echo %var%
set /a var=5 ^^ 4 & echo %var%
set /a var=5 ^^ 1 & echo %var%
echo ......precedence and grouping
set /a var=4 + 2*3 & echo %var%
set /a var=(4+2)*3 & echo %var%
set /a var=4 * 3/5 & echo %var%
set /a var=(4 * 3)/5 & echo %var%
set /a var=4 * 5 %% 4 & echo %var%
set /a var=4 * (5 %% 4) & echo %var%
set /a var=3 %% (5 + 8 %% 3 ^^ 2) & echo %var%
set /a var=3 %% (5 + 8 %% 3 ^^ -2) & echo %var%
echo ......octal and hexadecimal
set /a var=0xf + 3 & echo %var%
set /a var=0xF + 3 & echo %var%
set /a var=015 + 2 & echo %var%
set /a var=3, 8+3,0 & echo %var%
echo ......variables
set /a var=foo=3, foo+1 & echo %var%
if defined foo (echo %foo%) else (
echo foo not defined
)
set /a var=foo=3, foo+=1 & echo %var%
set /a var=foo=3, bar=1, bar+=foo, bar & echo %var%
set /a var=foo*= foo & echo %var%
set /a var=whateverNonExistingVar & echo %var%
set /a var=whateverNonExistingVar + bar & echo %var%
set /a var=foo -= foo + 7 & echo %var%
set /a var=foo /= 3 + 2 & echo %var%
set /a var=foo=5, foo %%=2 & echo %var%
set /a var=foo ^<^<= 2 & echo %var%
set /a var=foo ^>^>= 2 & echo %var%
set /a var=foo ^&= 2 & echo %var%
set /a var=foo=5, foo ^|= 2 & echo %var%
set /a var=foo=5, foo ^^= 2 & echo %var%
set /a var=foo=19, foo %%= 4 + (bar %%= 7) & echo.
set foo=
set bar=
set var=
echo -----------Testing del /a-----------
del /f/q *.test > nul

View File

@ -253,6 +253,76 @@ bar
-1
@todo_wine@ErrorLevel 0
@todo_wine@ErrorLevel 0
...for /a
......individual operations
0
@todo_wine@3
@todo_wine@-1
@todo_wine@3
@todo_wine@6
@todo_wine@10
@todo_wine@4
@todo_wine@4
@todo_wine@-4
0
@todo_wine@2
@todo_wine@2
@todo_wine@-2
@todo_wine@1
@todo_wine@4
0@or_broken@1073741824
0@or_broken@-1073741824
@todo_wine@-4
@todo_wine@9
@todo_wine@2
0
@todo_wine@-1
@todo_wine@-3
0
@todo_wine@1
@todo_wine@1
@todo_wine@4
@todo_wine@1
@todo_wine@5
@todo_wine@5
@todo_wine@7
@todo_wine@5
@todo_wine@5
@todo_wine@5
@todo_wine@4
@todo_wine@6
@todo_wine@1
......precedence and grouping
@todo_wine@4
@todo_wine@10
@todo_wine@18@or_broken@10
@todo_wine@2@or_broken@0
@todo_wine@2@or_broken@0
0@or_broken@4
@todo_wine@4
@todo_wine@3@or_broken@4
......octal and hexadecimal
@todo_wine@3@or_broken@4
@todo_wine@18
@todo_wine@18
@todo_wine@15
......variables
@todo_wine@3
@todo_wine@3@or_broken@foo not defined
@todo_wine@3@or_broken@0
@todo_wine@3@or_broken@0
@todo_wine@3@or_broken@0
@todo_wine@9@or_broken@0
0
@todo_wine@4@or_broken@0
@todo_wine@-7@or_broken@0
@todo_wine@-1@or_broken@0
@todo_wine@5@or_broken@0
@todo_wine@4@or_broken@0
@todo_wine@1@or_broken@0
0
@todo_wine@5@or_broken@0
-----------Testing del /a-----------
not-r.test not found after delete, good
r.test found before delete, good