[CMD_WINETEST]
[reactos.git] / rostests / winetests / cmd / test_builtins.cmd
index 54070bc..16fdd43 100644 (file)
@@ -286,10 +286,35 @@ set WINE_FOO=foo@space@
 echo '%WINE_FOO%'
 set WINE_FOO=foo@tab@
 echo '%WINE_FOO%'
+rem Space symbol must appear in `var`
+set WINE_FOO=value@space@
+echo '%WINE_FOO%'
+rem Space symbol must NOT appear in `var`
+set "WINE_FOO=value"@space@
+echo '%WINE_FOO%'
+rem Mixed examples:
+set WINE_FOO=jim fred
+echo '%WINE_FOO%'
+set WINE_FOO="jim" fred
+echo '%WINE_FOO%'
+set "WINE_FOO=jim fred"
+echo '%WINE_FOO%'
+set "WINE_FOO=jim" fred
+echo '%WINE_FOO%'
+rem Only the final quote ends the string
+set "WINE_FOO=apple"banana"grape"orange
+echo '%WINE_FOO%'
 set WINE_FOO=
 
 echo ------------ Testing variable expansion ------------
 call :setError 0
+echo ~p0 should be path containing batch file
+echo %~p0
+mkdir dummydir
+cd dummydir
+echo %~p0
+cd ..
+rmdir dummydir
 echo ~dp0 should be directory containing batch file
 echo %~dp0
 mkdir dummydir
@@ -363,6 +388,7 @@ 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'
+for %%i in ("") do echo '%%~i,%%~fi,%%~di,%%~pi,%%~ni,%%~xi,%%~si,%%~ai,%%~ti,%%~zi'
 
 echo --- in parameters
 for %%i in ("A B" C) do call :echoFun %%i
@@ -998,7 +1024,22 @@ for /R %%i in (baz* fred* jim) do call temp.bat %%i
 call :ValidateExpected
 
 echo for /R passed
-cd .. & rd /s/Q foobar
+echo --- Complex wildcards unix and windows slash
+cd ..
+echo Windows slashs, valid path
+for %%f in (foobar\baz\bazbaz) do echo ASIS: %%f
+for %%f in (foobar\baz\*) do echo WC  : %%f
+echo Windows slashs, invalid path
+for %%f in (foobar\jim\bazbaz) do echo ASIS: %%f
+for %%f in (foobar\jim\*) do echo WC  : %%f
+echo Unix slashs, valid path
+for %%f in (foobar/baz/bazbaz) do echo ASIS: %%f
+for %%f in (foobar/baz/*) do echo WC  : %%f
+echo Unix slashs, invalid path
+for %%f in (foobar/jim/bazbaz) do echo ASIS: %%f
+for %%f in (foobar/jim/*) do echo WC  : %%f
+echo Done
+rd /s/Q foobar
 echo --- for /L
 rem Some cases loop forever writing 0s, like e.g. (1,0,1), (1,a,3) or (a,b,c); those can't be tested here
 for /L %%i in (1,2,0) do echo %%i
@@ -2199,7 +2240,7 @@ rem ******************************************************************
 rem ASCII and BINARY tests
 rem Note: hard coded numbers deliberate because need to ensure whether
 rem an additional EOF has been added or not. There is no way to handle
-rem EOFs in batch, so assume if a single byte appears, its an EOF!
+rem EOFs in batch, so assume if a single byte appears, it's an EOF!
 rem ******************************************************************
 
 rem Confirm original sizes of file1,2,3
@@ -2283,7 +2324,7 @@ call :CheckFileSize file123_mixed_copy4 25
 
 rem -------------------------------------------------------------------------------------------
 rem This shows when concatenating, an ascii destination always adds on an EOF but when we
-rem are not concatenating, its a direct copy regardless of destination if being read as binary
+rem are not concatenating, it's a direct copy regardless of destination if being read as binary
 rem -------------------------------------------------------------------------------------------
 
 rem All 3 have eof's, plus an extra = 6 + 9 + 12 + eof
@@ -2538,17 +2579,72 @@ echo %ErrorLevel% should still be 7
 
 echo ------------ Testing GOTO ------------
 if a==a goto dest1
+echo FAILURE at dest 1
 :dest1
 echo goto with no leading space worked
+if a==a goto :dest1b
+echo FAILURE at dest 1b
+:dest1b
+echo goto with colon and no leading space worked
 if b==b goto dest2
+echo FAILURE at dest 2
  :dest2
 echo goto with a leading space worked
 if c==c goto dest3
+echo FAILURE at dest 3
        :dest3
 echo goto with a leading tab worked
 if d==d goto dest4
+echo FAILURE at dest 4
 :dest4@space@
 echo goto with a following space worked
+if e==e goto dest5
+echo FAILURE at dest 5
+:dest5&& echo FAILURE
+echo goto with following amphersands worked
+
+del failure.txt >nul 2>&1
+if f==f goto dest6
+echo FAILURE at dest 6
+:dest6>FAILURE.TXT
+if exist FAILURE.TXT echo FAILURE at dest 6 as file exists
+echo goto with redirections worked
+del FAILURE.TXT >nul 2>&1
+
+:: some text that is ignored | dir >cmd_output | another test
+if exist cmd_output echo FAILURE at dest 6 as file exists
+echo Ignoring double colons worked
+del cmd_output >nul 2>&1
+
+rem goto a label which does not exist issues an error message and
+rem acts the same as goto :EOF, and ensure ::label is never matched
+del testgoto.bat >nul 2>&1
+echo goto :dest7 ^>nul 2^>^&1 >> testgoto.bat
+echo echo FAILURE at dest 7 - Should have not found label and issued an error plus ended the batch>> testgoto.bat
+echo ::dest7>> testgoto.bat
+echo echo FAILURE at dest 7 - Incorrectly went to label >> testgoto.bat
+call testgoto.bat
+del testgoto.bat >nul 2>&1
+
+del testgoto.bat >nul 2>&1
+echo goto ::dest8 ^>nul 2^>^&1 >> testgoto.bat
+echo echo FAILURE at dest 8 - Should have not found label and issued an error plus ended the batch>> testgoto.bat
+echo ::dest8>> testgoto.bat
+echo echo FAILURE at dest 8 - Incorrectly went to label >> testgoto.bat
+call testgoto.bat
+del testgoto.bat >nul 2>&1
+
+if g==g goto dest9
+echo FAILURE at dest 9
+:dest91
+echo FAILURE at dest 91
+@   :     dest9>rubbish
+echo label with mixed whitespace and no echo worked
+
+if h==h goto :dest10:this is ignored
+echo FAILURE at dest 10
+:dest10:this is also ignored
+echo Correctly ignored trailing information
 
 echo ------------ Testing PATH ------------
 set WINE_backup_path=%path%