cmd/tests: Add tests for variable delayed expansion.

This commit is contained in:
Frédéric Delanoy 2011-08-01 11:46:53 +02:00 committed by Alexandre Julliard
parent bb44fe5698
commit 3c8674a721
2 changed files with 55 additions and 0 deletions

View File

@ -168,6 +168,46 @@ echo P%ERRORLEVEL%
echo %ERRORLEVEL%S
echo P%ERRORLEVEL%S
echo ------------ Testing variable delayed expansion --------------
rem NT4 doesn't support this
echo ...default mode (load-time expansion)
set FOO=foo
echo %FOO%
echo !FOO!
if %FOO% == foo (
set FOO=bar
if %FOO% == bar (echo bar) else echo foo
)
set FOO=foo
if %FOO% == foo (
set FOO=bar
if !FOO! == bar (echo bar) else echo foo
)
echo ...runtime (delayed) expansion mode
setlocal EnableDelayedExpansion
set FOO=foo
echo %FOO%
echo !FOO!
if %FOO% == foo (
set FOO=bar
if %FOO% == bar (echo bar) else echo foo
)
set FOO=foo
if %FOO% == foo (
set FOO=bar
if !FOO! == bar (echo bar) else echo foo
)
echo %ErrorLevel%
setlocal DisableDelayedExpansion
echo %ErrorLevel%
set FOO=foo
echo %FOO%
echo !FOO!
set FOO=
echo ------------ Testing conditional execution --------------
echo ...unconditional ^&
call :setError 123 & echo foo1

View File

@ -146,6 +146,21 @@ ERRORLEVEL
P0
0S
P0S
------------ Testing variable delayed expansion --------------
...default mode (load-time expansion)
foo
!FOO!
foo
foo
...runtime (delayed) expansion mode
foo
@todo_wine@foo@or_broken@!FOO!
foo
@todo_wine@bar@or_broken@foo
0
0@or_broken@1
foo
!FOO!
------------ Testing conditional execution --------------
@todo_wine@...unconditional &
foo1