diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/examplefiles/batchfile.bat | 49 | ||||
-rw-r--r-- | tests/examplefiles/example.bat | 205 |
2 files changed, 205 insertions, 49 deletions
diff --git a/tests/examplefiles/batchfile.bat b/tests/examplefiles/batchfile.bat deleted file mode 100644 index 5cdc625c..00000000 --- a/tests/examplefiles/batchfile.bat +++ /dev/null @@ -1,49 +0,0 @@ -rem this is a demo file. -@rem -@echo off - -call c:\temp.bat somearg -call :lab somearg -rem This next one is wrong in the vim lexer! -call c:temp.bat - -echo "Hi!" -echo hi -echo on -echo off -echo. -@echo off -if exist *.log echo The log file has arrived. -rem These are all escapes, also done incorrectly by the vim lexer -echo ^^ ^> ^< ^| - -x=beginning -setlocal -x = new text -endlocal - -echo testrem x -echo test rem x - -for %%var in (*.jpg) do echo %%var -for /D %%var in (a b c) do echo %%var -for /R C:\temp %%var in (*.jpg) do iexplore.exe %%var -rem Vim has this one wrong too. -for /L %%var in (10,-1,1) do echo %%var -for /F %%var in ("hi!") do echo %%var -for /F "eol=c,skip=1,usebackq" %%var in (`command`) do echo %%var %~l %~fl %~dl %~pl %~nl %~xl %~sl %~al %~tl %~zl %~$PATH:l %~dpl %~dp$PATH:l %~ftzal - -echo some file ?! > somefile.txt - -set PATH=%PATH%;c:\windows - -goto answer%errorlevel% - :answer0 - echo Hi it's zero - :answer1 - echo New - -if exist a del a -else echo A is missing! - - diff --git a/tests/examplefiles/example.bat b/tests/examplefiles/example.bat new file mode 100644 index 00000000..bf27673c --- /dev/null +++ b/tests/examplefiles/example.bat @@ -0,0 +1,205 @@ +@ @@ echo off
+::This is an example of the Windows batch language.
+
+setlocal EnableDelayedExpansion
+(cls)
+set/a^
+_te^
+sts^
+=0,^
+_"pa"^
+ssed=0^
+0
+set,/a title= Batch test
+title=%,/a title%
+echo^ %~nx0,^ the>,con comprehensive testing suite
+ver
+echo(
+
+if cmdextversion 2 goto =)
+goto :fail
+
+ :)
+echo Starting tests at:
+date/t & time/t
+echo(
+
+if '%*'=='--help' (
+ echo Usage: %~nx0 [--help]
+ echo --help: Display this help message and quit.
+ shift
+ goto :exit comment) else rem
+
+(call :comments)
+call ::io+x
+call:control:x
+call::internal x
+
+:exit
+if /i !_tests!==!_passed! (
+ color 02
+) else if !*==* (
+ color c
+ if not defined _exit^
+Code set _exit^
+Code=1
+)
+set _percentage=NaN
+if defined _tests (
+ if !_tests! neq 0 (set/a_percentage=100*_passed/_tests)
+)
+echo(
+if !_percentage!==NaN ( echo(There were no tests^^! & color e
+) else ( echo Tests passed: %_passed%/%_tests% (%_percentage%%%^) )
+pause
+color
+title
+endlocal
+exit /b %_exitCode%
+
+x:fail
+rem This should never happen.
+echo Internal error 1>& 269105>>&2
+set /a _exitCode=0x69+(0105*1000)
+break
+goto :exit
+
+:comments
+(rem )/?
+)
+rem "comment^
+(rem.) & set /a _tests+=1
+(rem) & goto :fail
+(rem. ) & (rem. comment ) & echo Test %_tests%: Comments
+rem )
+)
+)|comment
+)(
+:: comment
+goto :comments^^1:comment
+:comments^^1 comment
+if(1==1) goto :comments^
+^1
+rem^ /?
+rem ^
+^
+goto :comments^
+2+comment
+goto :fail
+:comments2
+rem >^
+if 1==1 (goto :comments3)
+:comments3)
+goto :fail
+:comments3
+rem comment^
+goto:fail
+rem.comment comment^
+goto fail
+rem "comment comment"^
+goto fail
+rem comment comment^
+set /a _passed+=1
+GOTO :EOF
+goto :fail
+
+:IO
+SET /A _tests+=1 & Echo Test !_tests:*!==^!: I/O
+verify on
+pushd .
+if exist temp echo temp already exists. & goto :eof
+md temp
+cd temp
+mkdir 2>nul temp
+chdir temp
+>cd echo Checking drive...
+>>cd echo must be C or else this won't work
+for /f "tokens=* usebackq" %%G in ("cd
+) do (<nul set /p="%%G ")
+echo(
+DEL cd
+if not "%cd:~0,3%"=="C:\" (
+ call call echo Wrong drive (should be C^):
+ vol
+ goto :test)
+>test0^
+.bat echo rem Machine-generated; do not edit
+call echo set /a _passed+=1 >>test0.bat
+type test0.bat >"test 1.bat
+ren "test 1.bat" test2.bat
+rename test2.bat test.bat
+caLL ^
+C:test
+del test.bat 2>nul
+2>NUL erase test0.bat
+popd
+rd temp\temp
+rmdir temp
+VERIFY OFF
+goto:eof
+
+:control
+set /a _tests+=1
+echo Test %_tests%: Control statements
+set "_iterations=0">nul
+for %%G in (,+,,-,
+) do @(
+ for /l %%H in (,-1;;-1 -3,) do (
+ for /f tokens^=1-2^,5 %%I in ("2 %%H _ _ 10") do (
+ for /f "tokens=1 usebackq" %%L in ( `echo %%G%%J ``` `
+` ` ) do ( for /f "tokens=2" %%M in ('echo ' %%L0 '
+' ' ) do ( set /a _iterations+=(%%M%%M^)
+ )
+ )
+ )
+ )
+)
+if exist %~nx0 if not exist %~nx0 goto :fail
+if exist %~nx0 (
+ if not exist %~nx0 goto :fail
+) else (
+ if exist %~nx0 goto :fail
+)
+if /i %_iterations% gtr -2 (
+ if /i %_iterations% geq -1 (
+ if /i %_iterations% lss 1 (
+ if /i %_iterations% leq 0 (
+ if /i %_iterations% equ 0 (
+ if 1 equ 01 (
+ if 1 neq "01" (
+ if "1" neq 01 (
+ set /a _passed+=1))))))))
+) comment
+goto :eof
+
+:internal
+set /a _tests+=1
+echo Test %_tests%: Internal commands
+keys on
+mklink 2>nul
+>nul path %path%
+>nul dpath %dpath%
+if not defined prompt prompt $P$G
+prompt !prompt:~!rem/ $H?
+echo on
+rem/?
+@echo off
+rem(/?>nul
+rem )/? >nul
+(rem (/?) >nul
+rem /?>nul
+rem^/?>nul
+if/?>nul || if^/^?>nul || if /?>nul || if x/? >nul
+for/?>nul && for^/^?>nul && for /?>nul && for x/? >nul && for /?x >nul
+goto/?>nul && goto^/? && goto^ /? && goto /^
+? && goto /?>nul && goto:/? >nul && goto ) /? ) >nul && (goto /? )>nul
+=set+;/p extension'),=.bat
+for /f "tokens=2 delims==" %%G in ( 'assoc %+;/p extension'),%'
+ ) do (
+ assoc 2>nul %+;/p extension'),:*.=.%=%%G
+ ftype 1>nul %%G
+) &>nul ver
+if errorlevel 0 if not errorlevel 1 set /a _passed+=1
+goto :eof
+:/?
+goto :fail
|