Skip to content

Commit 02c769a

Browse files
committed
Added Clockhands and Triple (i used c extensions but I don't care, formatters are wack). Also added test.)
1 parent 6394b19 commit 02c769a

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

algol68/clockhands.a68

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FOR i FROM 0 TO 10
2+
DO INT t := (43200 * i + 21600) % 11;
3+
INT h := t % 3600;
4+
INT m := t % 60 %* 60;
5+
INT s := t %* 60;
6+
printf (($2d$, (h = 0 | 12 | h), $a$, ":", $2d$, m, $a$, ":", $2dl$, s))
7+
OD

algol68/test.ps1

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
a68g "$PSScriptRoot\clockhands.a68" |
13+
Compare-Object (Get-Content "$PSScriptRoot\..\test\clockhands_expected") |
14+
Assert-MatchTests &&
15+
a68g "$PSScriptRoot\hello.a68" &&
16+
a68g "$PSScriptRoot\roman.a68" &&
17+
a68g "$PSScriptRoot\triple.a68" |
18+
Compare-Object (Get-Content "$PSScriptRoot\..\test\triple_expected") |
19+
Assert-MatchTests &&
20+
ForEach-Object 'foo';
21+
22+
if ($Error -or !$?) {
23+
"*** ALGOL 68 TESTS FAILED ***"
24+
}
25+
else {
26+
"ALGOL 68 TESTS PASSED"
27+
}
28+
29+

algol68/triple.a68

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FOR c TO 40
2+
DO FOR b TO c
3+
DO FOR a TO b
4+
DO IF a ** 2 + b ** 2 = c ** 2 THEN
5+
printf (($%d$, a, $2a$, ", ", $%d$, b, $2a$, ", ", $%dl$, c))
6+
FI
7+
OD
8+
OD
9+
OD

0 commit comments

Comments
 (0)