1 echo Tests for cmd's builtin commands
4 echo ------------ Testing 'echo' [ON] --------------
6 echo 'singlequotedword'
7 echo "doublequotedword"
15 echo word@space@@space@
18 echo ------------ Testing 'echo' [OFF] --------------
20 echo 'singlequotedword'
21 echo "doublequotedword"
29 echo word@space@@space@
31 echo ------------ Testing 'set' --------------
32 echo set "FOO=bar" should not include the quotes in the variable value
36 echo ------------ Testing variable expansion --------------
37 echo ~dp0 should be directory containing batch file
53 echo %ERRORLEVEL%%ERRORLEVEL%
54 echo %ERRORLEVEL%ERRORLEVEL%
61 echo ------------ Testing if/else --------------
62 echo if/else should work with blocks
66 echo if seems to be broken
69 echo else seems to be broken
71 echo else seems to work
73 echo Testing case sensitivity with and without /i option
74 if bar==BAR echo if does not default to case sensitivity
75 if not bar==BAR echo if seems to default to case sensitivity
76 if /i foo==FOO echo if /i seems to work
77 if /i not foo==FOO echo if /i seems to be broken
78 if /I foo==FOO echo if /I seems to work
79 if /I not foo==FOO echo if /I seems to be broken
81 echo -----------Testing del /a-----------
85 echo not-r > not-r.test
87 if not exist not-r.test echo not-r.test not found before delete, bad
89 if not exist not-r.test echo not-r.test not found after delete, good
91 if not exist r.test echo r.test not found before delete, bad
92 if exist r.test echo r.test found before delete, good
94 if not exist r.test echo r.test not found after delete, good
95 if exist r.test echo r.test found after delete, bad
97 echo ------------ Testing del /q --------------
102 rem If /q doesn't work, cmd will prompt and the test case should hang
104 for %%a in (1 2.dat) do if exist file%%a echo del /q * failed on file%%a
105 for %%a in (1 2.dat) do if not exist file%%a echo del /q * succeeded on file%%a
109 echo ------------ Testing del /s --------------
113 echo there > file2.dat
115 echo bye > "file with spaces.dat"
117 del /s file1.dat > nul
118 del file2.dat /s > nul
119 del "file3.dat" /s > nul
120 del "file with spaces.dat" /s > nul
122 for %%f in (1 2 3) do if exist file%%f.dat echo Del /s failed on file%%f
123 for %%f in (1 2 3) do if exist file%%f.dat del file%%f.dat
124 if exist "file with spaces.dat" echo Del /s failed on "file with spaces.dat"
125 if exist "file with spaces.dat" del "file with spaces.dat"
129 echo -----------Testing Errorlevel-----------
130 rem nt 4.0 doesn't really support a way of setting errorlevel, so this is weak
131 rem See http://www.robvanderwoude.com/exit.php
134 if errorlevel 2 echo errorlevel too high, bad
135 if errorlevel 1 echo errorlevel just right, good
137 echo abc%ErrorLevel%def
138 if errorlevel 1 echo errorlevel nonzero, bad
139 if not errorlevel 1 echo errorlevel zero, good
140 rem Now verify that setting a real variable hides its magic variable
142 echo %ErrorLevel% should be 7
143 if errorlevel 7 echo setting var worked too well, bad
145 echo %ErrorLevel% should still be 7
147 echo -----------Testing GOTO-----------
150 echo goto with no leading space worked
153 echo goto with a leading space worked
156 echo goto with a leading tab worked
159 echo goto with a following space worked
161 echo -----------Done, jumping to EOF-----------
163 rem Subroutine to set errorlevel and return
164 rem in windows nt 4.0, this always sets errorlevel 1, since /b isn't supported
167 rem This line runs under cmd in windows NT 4, but not in more modern versions.