dinput: SetActionMap setting the device buffer.
[wine] / programs / cmd / tests / test_builtins.cmd
1 echo Tests for cmd's builtin commands
2
3 @echo on
4 echo ------------ Testing 'echo' [ON] --------------
5 echo word
6 echo 'singlequotedword'
7 echo "doublequotedword"
8 @echo at-echoed-word
9 echo "/?"
10 echo.
11 echo .
12 echo.word
13 echo .word
14 echo word@space@
15 echo word@space@@space@
16
17 @echo off
18 echo ------------ Testing 'echo' [OFF] --------------
19 echo word
20 echo 'singlequotedword'
21 echo "doublequotedword"
22 @echo at-echoed-word
23 echo "/?"
24 echo.
25 echo .
26 echo.word
27 echo .word
28 echo word@space@
29 echo word@space@@space@
30
31 echo ------------ Testing 'set' --------------
32 echo set "FOO=bar" should not include the quotes in the variable value
33 set "FOO=bar"
34 echo %FOO%
35
36 echo ------------ Testing variable expansion --------------
37 echo ~dp0 should be directory containing batch file
38 echo %~dp0
39 mkdir dummydir
40 cd dummydir
41 echo %~dp0
42 cd ..
43 rmdir dummydir
44 echo CD value %CD%
45 echo %%
46 echo P%
47 echo %P
48 echo %UNKNOWN%S
49 echo P%UNKNOWN%
50 echo P%UNKNOWN%S
51 echo %ERRORLEVEL
52 echo %ERRORLEVEL%
53 echo %ERRORLEVEL%%ERRORLEVEL%
54 echo %ERRORLEVEL%ERRORLEVEL%
55 echo %ERRORLEVEL%%
56 echo %ERRORLEVEL%%%
57 echo P%ERRORLEVEL%
58 echo %ERRORLEVEL%S
59 echo P%ERRORLEVEL%S
60
61 echo ------------ Testing if/else --------------
62 echo if/else should work with blocks
63 if 0 == 0 (
64   echo if seems to work
65 ) else (
66   echo if seems to be broken
67 )
68 if 1 == 0 (
69   echo else seems to be broken
70 ) else (
71   echo else seems to work
72 )
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
80
81 echo -----------Testing del /a-----------
82 del /f/q *.test > nul
83 echo r > r.test
84 attrib +r r.test
85 echo not-r > not-r.test
86
87 if not exist not-r.test echo not-r.test not found before delete, bad
88 del /a:-r *.test
89 if not exist not-r.test echo not-r.test not found after delete, good
90
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
93 del /a:r *.test
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
96
97 echo ------------ Testing del /q --------------
98 mkdir del_q_dir
99 cd del_q_dir
100 echo abc > file1
101 echo abc > file2.dat
102 rem If /q doesn't work, cmd will prompt and the test case should hang
103 del /q * > nul
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
106 cd ..
107 rmdir del_q_dir
108
109 echo ------------ Testing del /s --------------
110 mkdir "foo bar"
111 cd "foo bar"
112 echo hi > file1.dat
113 echo there > file2.dat
114 echo bub > file3.dat
115 echo bye > "file with spaces.dat"
116 cd ..
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
121 cd "foo bar"
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"
126 cd ..
127 rmdir "foo bar"
128
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
132 call :setError 1
133 echo %ErrorLevel%
134 if errorlevel 2 echo errorlevel too high, bad
135 if errorlevel 1 echo errorlevel just right, good
136 call :setError 0
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
141 set errorlevel=7
142 echo %ErrorLevel% should be 7
143 if errorlevel 7 echo setting var worked too well, bad
144 call :setError 3
145 echo %ErrorLevel% should still be 7
146
147 echo -----------Testing GOTO-----------
148 if a==a goto dest1
149 :dest1
150 echo goto with no leading space worked
151 if b==b goto dest2
152  :dest2
153 echo goto with a leading space worked
154 if c==c goto dest3
155         :dest3
156 echo goto with a leading tab worked
157 if d==d goto dest4
158 :dest4@space@
159 echo goto with a following space worked
160
161 echo -----------Done, jumping to EOF-----------
162 goto :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
165 :setError
166 exit /B %1
167 rem This line runs under cmd in windows NT 4, but not in more modern versions.