Skip to content

Commit ed4b008

Browse files
committed
Added Batch CLockhands
1 parent 4e88542 commit ed4b008

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

batch/clockhands.bat

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@ECHO OFF
2+
FOR /L %%i IN (0, 1, 10) DO CALL :FOO %%i
3+
GOTO :END
4+
5+
:FOO
6+
SETLOCAL ENABLEDELAYEDEXPANSION
7+
SET /A t=(43200 * %1 + 21600) / 11
8+
SET /A h=%t% / 3600
9+
SET /A m=%t% / 60 %% 60
10+
SET /A s=%t% %% 60
11+
IF %h% EQU 0 SET h=12
12+
SET h=0%h%
13+
SET m=0%m%
14+
SET s=0%s%
15+
SET h=!h:~-2!
16+
SET m=!m:~-2!
17+
SET s=!s:~-2!
18+
ECHO %h%:%m%:%s%
19+
ENDLOCAL
20+
:END

batch/test.ps1

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
function Assert-MatchTests {
2+
param (
3+
[Parameter(Mandatory = $true, ValueFromPipeline)] $TestResult
4+
)
5+
6+
if ($TestResult) {
7+
Write-Error "Output does not match expected results."
8+
}
9+
}
10+
11+
$Error.clear()
12+
. "$PSScriptRoot\clockhands.bat" |
13+
Compare-Object (Get-Content "$PSScriptRoot\..\test\clockhands_expected") |
14+
Assert-MatchTests &&
15+
. "$PSScriptRoot\hello.bat" &&
16+
ForEach-Object 'foo'
17+
18+
if ($Error -or !$?) {
19+
"*** BATCH TESTS FAILED ***"
20+
}
21+
else {
22+
"BATCH TESTS PASSED"
23+
}

0 commit comments

Comments
 (0)