cmd: Allow GOTO to a label which has a following whitespace, with test.
[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 GOTO-----------
82 if a==a goto dest1
83 :dest1
84 echo goto with no leading space worked
85 if b==b goto dest2
86  :dest2
87 echo goto with a leading space worked
88 if c==c goto dest3
89         :dest3
90 echo goto with a leading tab worked
91 if d==d goto dest4
92 :dest4@space@
93 echo goto with a following space worked