Frédéric Delanoy : cmd/tests: Add variable substitution tests.

Alexandre Julliard julliard at winehq.org
Fri Aug 26 10:40:53 CDT 2011


Module: wine
Branch: master
Commit: 9b79fd5777fcd2058850aa632746089ea7a6576c
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=9b79fd5777fcd2058850aa632746089ea7a6576c

Author: Frédéric Delanoy <frederic.delanoy at gmail.com>
Date:   Fri Aug 26 01:19:28 2011 +0200

cmd/tests: Add variable substitution tests.

---

 programs/cmd/tests/test_builtins.cmd     |  110 ++++++++++++++++++++++++++++++
 programs/cmd/tests/test_builtins.cmd.exp |   62 +++++++++++++++++
 2 files changed, 172 insertions(+), 0 deletions(-)

diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd
index f5df409..78eea97 100644
--- a/programs/cmd/tests/test_builtins.cmd
+++ b/programs/cmd/tests/test_builtins.cmd
@@ -227,6 +227,116 @@ echo '%VAR:~-2,-4%'
 echo %VAR:~-3,-2%
 set VAR=
 
+echo ------------ Testing variable substitution --------------
+echo ...in FOR variables
+for %%i in ("A B" C) do echo %%i
+rem quotes removal
+for %%i in ("A B" C) do echo '%%~i'
+rem fully qualified path
+for %%f in ("C D" E) do echo %%~ff
+rem drive letter
+for %%i in ("F G" H) do echo %%~di
+rem path
+for %%d in ("I J" K) do echo %%~pd
+rem filename
+for %%i in ("L M" N) do echo %%~ni
+rem file extension
+for %%i in ("O. P.OOL" Q.TABC hello) do echo '%%~xi'
+rem path with short path names
+for %%I in ("R S" T ABCDEFGHIJK.LMNOP) do echo '%%~sI'
+rem file attribute
+for %%i in ("U V" W) do echo '%%~ai'
+echo foo> foo
+for %%i in (foo) do echo '%%~ai'
+del foo
+rem file date/time
+rem Not fully testable, until we can grep dir's output to get foo's creation time in an envvar...
+for %%i in ("a b" c) do echo '%%~ti'
+rem file size
+rem Similar issues as above
+for %%i in ("a b" c) do echo '%%~zi'
+rem combined options
+for %%i in ("d e" f) do echo %%~dpi
+for %%i in ("g h" i) do echo %%~sdi
+for %%i in ("g h" i) do echo %%~dsi
+for %%i in ("j k" l.eh) do echo '%%~xsi'
+
+echo ...in parameters
+for %%i in ("A B" C) do call :echoFun %%i
+rem quotes removal
+for %%i in ("A B" C) do call :echoFunQ %%i
+rem fully qualified path
+for %%f in ("C D" E) do call :echoFunF %%f
+rem drive letter
+for %%i in ("F G" H) do call :echoFunD %%i
+rem path
+for %%d in ("I J" K) do call :echoFunP %%d
+rem filename
+for %%i in ("L M" N) do call :echoFunN %%i
+rem file extension
+for %%i in ("O. P.OOL" Q.TABC hello) do call :echoFunX %%i
+rem path with short path names
+for %%I in ("R S" T ABCDEFGHIJK.LMNOP) do call :echoFunS %%I
+rem NT4 aborts whole script execution when encountering ~a, ~t and ~z substitutions, preventing full testing
+rem combined options
+for %%i in ("d e" f) do call :echoFunDP %%i
+for %%i in ("g h" i) do call :echoFunSD %%i
+for %%i in ("g h" i) do call :echoFunDS %%i
+for %%i in ("j k" l.eh) do call :echoFunXS %%i
+
+goto :endEchoFuns
+:echoFun
+echo %1
+goto :eof
+
+:echoFunQ
+echo '%~1'
+goto :eof
+
+:echoFunF
+echo %~f1
+goto :eof
+
+:echoFunD
+echo %~d1
+goto :eof
+
+:echoFunP
+echo %~p1
+goto :eof
+
+:echoFunN
+echo %~n1
+goto :eof
+
+:echoFunX
+echo '%~x1'
+goto :eof
+
+:echoFunS
+rem some NT4 workaround
+set VAR='%~s1'
+echo %VAR%
+set VAR=
+goto :eof
+
+:echoFunDP
+echo %~dp1
+goto :eof
+
+:echoFunSD
+echo %~sd1
+goto :eof
+
+:echoFunDS
+echo %~ds1
+goto :eof
+
+:echoFunXS
+echo '%~xs1'
+goto :eof
+:endEchoFuns
+
 echo ------------ Testing variable delayed expansion --------------
 rem NT4 doesn't support this
 echo ...default mode (load-time expansion)
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp
index 04e04a7..85afd34 100644
--- a/programs/cmd/tests/test_builtins.cmd.exp
+++ b/programs/cmd/tests/test_builtins.cmd.exp
@@ -213,6 +213,68 @@ ert at or_broken@qwerty
 e at or_broken@qwerty
 ''@or_broken@'qwerty'
 r at or_broken@qwerty
+------------ Testing variable substitution --------------
+...in FOR variables
+ at todo_wine@"A B"
+C
+'A B'@or_broken@''
+'C'@or_broken@''
+ at pwd@\C D at or_broken@%~ff
+ at pwd@\E at or_broken@%~ff
+ at drive@
+ at drive@
+ at path@@or_broken@%~pd
+ at path@@or_broken@%~pd
+L M
+N
+'.OOL'
+'.TABC'
+''
+ at todo_wine@'@drive@@shortpath at R S'@or_broken@''
+ at todo_wine@'@drive@@shortpath at T'@or_broken@''
+ at todo_wine@'@drive@@shortpath at ABCDEFGHIJK.LMNOP'@or_broken@''
+ at todo_wine@''@or_broken@'%~ai'
+ at todo_wine@''@or_broken@'%~ai'
+ at todo_wine@'--a------'@or_broken@'%~ai'
+ at todo_wine@''@or_broken@'%~ti'
+ at todo_wine@''@or_broken@'%~ti'
+ at todo_wine@''@or_broken@'%~zi'
+ at todo_wine@''@or_broken@'%~zi'
+ at drive@@path@
+ at drive@@path@
+ at drive@
+ at drive@
+ at drive@
+ at drive@
+''
+'.eh'
+...in parameters
+ at todo_wine@"A B"
+C
+ at todo_wine@'A B'@or_broken@''
+'C'@or_broken@''
+ at todo_wine@@pwd@\C D
+ at pwd@\E
+ at drive@
+ at drive@
+ at path@
+ at path@
+ at todo_wine@L M
+N
+ at todo_wine@'.OOL'
+'.TABC'
+''
+ at todo_wine@'@drive@@shortpath at R S'@or_broken@''
+ at todo_wine@'@drive@@shortpath at T'@or_broken@''
+ at todo_wine@'@drive@@shortpath at ABCDEFGHIJK.LMNOP'@or_broken@''
+ at drive@@path@
+ at drive@@path@
+ at drive@
+ at drive@
+ at drive@
+ at drive@
+''
+'.eh'@or_broken@''
 ------------ Testing variable delayed expansion --------------
 ...default mode (load-time expansion)
 foo




More information about the wine-cvs mailing list