Skip to content

Commit 7bd2fe7

Browse files
committed
Added Clockhands and PowerShell test.
1 parent 8eb60ee commit 7bd2fe7

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

lean/ClockHands.lean

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
def printTimes : List (IO Unit) → IO Unit
2+
| [] => pure ()
3+
| act :: actions => do
4+
printTimes actions
5+
act
6+
7+
def pad : Nat → String
8+
| n + 10 => s!"{n + 10}"
9+
| n => s!"0{n}"
10+
11+
def clock (t : Nat) : String :=
12+
s!"{pad (if t / 3600 == 0 then 12 else t / 3600)}:{pad (t / 60 % 60)}:{pad (t % 60)}"
13+
14+
def countdown : Nat → List (IO Unit)
15+
| 0 => []
16+
| n + 1 => IO.println (clock ((43200 * (n) + 21600) / 11)) :: countdown n
17+
18+
def main : IO Unit := printTimes (countdown 11)

lean/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+
lean "$PSScriptRoot\ClockHands.lean" |
13+
Compare-Object (Get-Content "$PSScriptRoot\..\test\clockhands_expected") |
14+
Assert-MatchTests &&
15+
lean "$PSScriptRoot\Hello.lean" &&
16+
ForEach-Object 'foo'
17+
18+
if ($Error -or !$?) {
19+
"*** LEAN TESTS FAILED ***"
20+
}
21+
else {
22+
"LEAN TESTS PASSED"
23+
}

0 commit comments

Comments
 (0)