1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2024-06-14 23:29:29 +00:00

Improve tests.

This commit is contained in:
Chris Pressey 2018-11-27 17:26:58 +00:00
parent d1befe7123
commit 3814d2624d
2 changed files with 31 additions and 3 deletions

View File

@ -3105,7 +3105,28 @@ routine.
| }
= ok
It is, however, important that the type context at every
Even though `goto` can only appear at the end of a block,
you can still wind up with dead code; the analysis detects
this.
| define bar routine trashes x, z, n {
| ld x, 200
| }
|
| define main routine trashes x, z, n {
| ld x, 0
| if z {
| ld x, 1
| goto bar
| } else {
| ld x, 0
| goto bar
| }
| ld x, 100
| }
? TerminatedContextError
It is important that the type context at every
`goto` is compatible with the type context at the end of
the routine.
@ -3128,7 +3149,7 @@ the routine.
| }
= ok
Here, we try to trash x before gotoing a routine that inputs x.
Here, we try to trash `x` before `goto`ing a routine that inputs `x`.
| define bar routine
| inputs x
@ -3152,7 +3173,7 @@ Here, we try to trash x before gotoing a routine that inputs x.
| }
? UnmeaningfulReadError: x
Here, we declare that main outputs a, but we goto a routine that does not output a.
Here, we declare that main outputs `a`, but we `goto` a routine that does not output `a`.
| define bar routine
| inputs x

View File

@ -551,6 +551,9 @@ goto.
| }
= ok
The label doesn't have to be defined yet at the point
in the program text where it is `goto`d.
| define main routine {
| goto foo
| }
@ -559,6 +562,8 @@ goto.
| }
= ok
Syntactically, you can `goto` a vector.
| vector routine foo
|
| define main routine {
@ -566,6 +571,8 @@ goto.
| }
= ok
But you can't `goto` a label that never gets defined.
| define main routine {
| goto foo
| }