Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ statement limit. Other programs have no quit command and intentionally end at a
well-defined next-input boundary. These are accepted only when their expected
transcript or gameplay milestones have already been observed.

The byte-different alternate Life for Two source jumps to a missing line 800
after completing and declaring a draw. The main source exits normally; the
alternate is accepted only after the complete draw behavior, then bounded
before that upstream defect. It is tracked in
[`go-basic#67`](https://github.com/scottdensmore/go-basic/issues/67) and
[`basic-computer-games#957`](https://github.com/coding-horror/basic-computer-games/issues/957).
The upstream alternate Life for Two source (`00_Alternate_Languages/56_Life_for_Two/lifefortwo.bas`)
jumps to a missing line `800` on its two terminal branches (`574` and `575`,
tracked upstream in [`basic-computer-games#957`](https://github.com/coding-horror/basic-computer-games/issues/957)).
The local playable fixture (`test/scripts/life-for-two-alternate.bas`) corrects
both terminal branches to `GOTO 999` so that both the main and alternate
variants exit normally without a statement-limit exception.

## CI contract

Expand Down
29 changes: 10 additions & 19 deletions test/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -837,28 +837,22 @@ func TestCLI(t *testing.T) {

t.Run("plays the original Life for Two programs", func(t *testing.T) {
variants := []struct {
name string
arguments []string
wantExit int
wantBounded bool
name string
fixture string
}{
{name: "main", arguments: []string{filepath.Join("scripts", "life-for-two.bas")}},
{
name: "alternate",
arguments: []string{"-max-statements", "1872", filepath.Join("scripts", "life-for-two-alternate.bas")},
wantExit: 1,
wantBounded: true,
},
{name: "main", fixture: "life-for-two.bas"},
{name: "alternate", fixture: "life-for-two-alternate.bas"},
}
for _, variant := range variants {
t.Run(variant.name, func(t *testing.T) {
command := exec.Command(binary, variant.arguments...)
path := filepath.Join("scripts", variant.fixture)
command := exec.Command(binary, path)
command.Stdin = strings.NewReader("1,1\n3,1\n5,1\n1,5\n3,5\n5,5\n")
output, err := command.CombinedOutput()
if exitCode(err) != variant.wantExit {
t.Fatalf("exit: got %v, output %q", err, output)
if err != nil {
t.Fatalf("run CLI: %v\n%s", err, output)
}
assertLifeForTwoTranscript(t, variant.arguments[len(variant.arguments)-1], string(output), variant.wantBounded)
assertLifeForTwoTranscript(t, string(output))
})
}
})
Expand Down Expand Up @@ -3204,7 +3198,7 @@ func assertLifeTranscript(t *testing.T, path, transcript string) {
}
}

func assertLifeForTwoTranscript(t *testing.T, path, transcript string, bounded bool) {
func assertLifeForTwoTranscript(t *testing.T, transcript string) {
t.Helper()
prefix := strings.Repeat(" ", 33) + "LIFE2\n" + strings.Repeat(" ", 15) +
"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY\n\n\n\n" + strings.Repeat(" ", 10) +
Expand All @@ -3227,9 +3221,6 @@ func assertLifeForTwoTranscript(t *testing.T, path, transcript string, bounded b
t.Fatal("transcript missing extinct board")
}
suffix := "A DRAW\n"
if bounded {
suffix += "go-basic: run " + path + ": BASIC line 574: statement limit 1872 reached\n"
}
if !strings.HasSuffix(transcript, suffix) {
t.Fatalf("unexpected transcript ending: %q", transcript[max(0, len(transcript)-len(suffix)):])
}
Expand Down
4 changes: 2 additions & 2 deletions test/scripts/life-for-two-alternate.bas
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
571 IF M3=0 THEN B=1: GOTO 575
572 IF M2=0 THEN B=2: GOTO 575
573 GOTO 580
574 PRINT: PRINT "A DRAW":GOTO 800
575 PRINT: PRINT "PLAYER";B;"IS THE WINNER":GOTO 800
574 PRINT: PRINT "A DRAW":GOTO 999
575 PRINT: PRINT "PLAYER";B;"IS THE WINNER":GOTO 999
580 FOR B=1 TO 2: PRINT: PRINT: PRINT "PLAYER";B;: GOSUB 700
581 IF B=99 THEN 560
582 NEXT B
Expand Down