mirror of
https://github.com/catseye/SixtyPical.git
synced 2025-04-02 06:31:49 +00:00
Add failing test.
This commit is contained in:
parent
6dbce205d1
commit
0c481845e9
@ -2972,7 +2972,7 @@ Calling the vector does indeed trash the things the vector says it does.
|
||||
| }
|
||||
? UnmeaningfulOutputError: x
|
||||
|
||||
For now at least, you cannot have a `goto` inside a loop.
|
||||
For now at least, you cannot have a `goto` inside a `repeat` loop.
|
||||
|
||||
| define bar routine trashes x, z, n {
|
||||
| ld x, 200
|
||||
@ -2989,78 +2989,130 @@ For now at least, you cannot have a `goto` inside a loop.
|
||||
|
||||
`goto`, as a matter of syntax, can only appear at the end
|
||||
of a block; but it need not be the final instruction in a
|
||||
routine. It is only important that the type context at every
|
||||
routine.
|
||||
|
||||
| define bar routine trashes x, z, n {
|
||||
| ld x, 200
|
||||
| }
|
||||
|
|
||||
| define main routine trashes x, z, n {
|
||||
| ld x, 0
|
||||
| goto bar
|
||||
| }
|
||||
= ok
|
||||
|
||||
| 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
|
||||
| }
|
||||
| }
|
||||
= ok
|
||||
|
||||
| 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
|
||||
| }
|
||||
| goto bar
|
||||
| }
|
||||
= ok
|
||||
|
||||
| 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
|
||||
| }
|
||||
| ld x, 0
|
||||
| }
|
||||
= ok
|
||||
|
||||
| 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
|
||||
| }
|
||||
| }
|
||||
= ok
|
||||
|
||||
| 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
|
||||
| }
|
||||
| }
|
||||
= ok
|
||||
|
||||
| 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
|
||||
| }
|
||||
| ld x, 0
|
||||
| }
|
||||
= ok
|
||||
|
||||
| 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
|
||||
| }
|
||||
= ok
|
||||
|
||||
It is, however, important that the type context at every
|
||||
`goto` is compatible with the type context at the end of
|
||||
the routine.
|
||||
|
||||
| define bar routine trashes x, z, n {
|
||||
| ld x, 200
|
||||
| }
|
||||
|
|
||||
| define main routine trashes x, z, n {
|
||||
| ld x, 0
|
||||
| goto bar
|
||||
| }
|
||||
= ok
|
||||
|
||||
| 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
|
||||
| }
|
||||
| }
|
||||
= ok
|
||||
|
||||
| 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
|
||||
| }
|
||||
| goto bar
|
||||
| }
|
||||
= ok
|
||||
|
||||
| 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
|
||||
| }
|
||||
| ld x, 0
|
||||
| }
|
||||
= ok
|
||||
|
||||
| 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
|
||||
| }
|
||||
| }
|
||||
= ok
|
||||
|
||||
| define bar routine trashes x, z, n {
|
||||
| define bar routine
|
||||
| inputs x
|
||||
| trashes x, z, n
|
||||
| {
|
||||
| ld x, 200
|
||||
| }
|
||||
|
|
||||
@ -3072,40 +3124,59 @@ the routine.
|
||||
| } else {
|
||||
| ld x, 0
|
||||
| }
|
||||
| ld x, 1
|
||||
| }
|
||||
= ok
|
||||
|
||||
| define bar routine trashes x, z, n {
|
||||
Here, we try to trash x before gotoing a routine that inputs x.
|
||||
|
||||
| define bar routine
|
||||
| inputs x
|
||||
| trashes x, z, n
|
||||
| {
|
||||
| ld x, 200
|
||||
| }
|
||||
|
|
||||
| define main routine trashes x, z, n {
|
||||
| define main routine
|
||||
| outputs a
|
||||
| trashes x, z, n
|
||||
| {
|
||||
| ld x, 0
|
||||
| if z {
|
||||
| trash x
|
||||
| goto bar
|
||||
| } else {
|
||||
| trash x
|
||||
| }
|
||||
| ld a, 1
|
||||
| }
|
||||
? UnmeaningfulReadError: x
|
||||
|
||||
Here, we declare that main outputs a, but we goto a routine that does not output a.
|
||||
|
||||
| define bar routine
|
||||
| inputs x
|
||||
| trashes x, z, n
|
||||
| {
|
||||
| ld x, 200
|
||||
| }
|
||||
|
|
||||
| define main routine
|
||||
| outputs a
|
||||
| trashes x, z, n
|
||||
| {
|
||||
| ld x, 0
|
||||
| if z {
|
||||
| ld x, 1
|
||||
| goto bar
|
||||
| } else {
|
||||
| ld x, 0
|
||||
| ld x, 2
|
||||
| }
|
||||
| ld x, 0
|
||||
| ld a, 1
|
||||
| }
|
||||
= ok
|
||||
? UnmeaningfulReadError
|
||||
|
||||
| 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
|
||||
| }
|
||||
= ok
|
||||
TODO: we should have a lot more test cases for the above, here.
|
||||
|
||||
Can't `goto` a routine that outputs or trashes more than the current routine.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user