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

Add more tests, which show inconsistent treatment of trashes.

This commit is contained in:
Chris Pressey 2018-02-08 13:34:03 +00:00
parent cde2824c44
commit f4befb45d3

View File

@ -89,6 +89,95 @@ If a routine modifies a location, it needs to either output it or trash it.
| }
= ok
This is true regardless of whether it's an input or not.
| routine main
| inputs x
| {
| ld x, 0
| }
? ForbiddenWriteError: x in main
| routine main
| inputs x
| outputs x, z, n
| {
| ld x, 0
| }
= ok
| routine main
| inputs x
| trashes x, z, n
| {
| ld x, 0
| }
= ok
If a routine trashes a location, this must be declared.
| routine foo
| trashes x
| {
| trash x
| }
= ok
| routine foo
| {
| trash x
| }
? UnmeaningfulOutputError: x in foo
| routine foo
| outputs x
| {
| trash x
| }
? UnmeaningfulOutputError: x in foo
If a routine causes a location to be trashed, this must be declared in the caller.
| routine trash_x
| trashes x, z, n
| {
| ld x, 0
| }
|
| routine foo
| trashes x, z, n
| {
| call trash_x
| }
= ok
| routine trash_x
| trashes x, z, n
| {
| ld x, 0
| }
|
| routine foo
| trashes z, n
| {
| call trash_x
| }
? UnmeaningfulOutputError: x in foo
| routine trash_x
| trashes x, z, n
| {
| ld x, 0
| }
|
| routine foo
| outputs x
| trashes z, n
| {
| call trash_x
| }
? UnmeaningfulOutputError: x in foo
If a routine reads or writes a user-define memory location, it needs to declare that too.
| byte b1 @ 60000