git @ Cat's Eye Technologies SixtyPical / f4befb4
Add more tests, which show inconsistent treatment of trashes. Chris Pressey 3 years ago
1 changed file(s) with 89 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
8787 | ld x, 0
8888 | }
8989 = ok
90
91 This is true regardless of whether it's an input or not.
92
93 | routine main
94 | inputs x
95 | {
96 | ld x, 0
97 | }
98 ? ForbiddenWriteError: x in main
99
100 | routine main
101 | inputs x
102 | outputs x, z, n
103 | {
104 | ld x, 0
105 | }
106 = ok
107
108 | routine main
109 | inputs x
110 | trashes x, z, n
111 | {
112 | ld x, 0
113 | }
114 = ok
115
116 If a routine trashes a location, this must be declared.
117
118 | routine foo
119 | trashes x
120 | {
121 | trash x
122 | }
123 = ok
124
125 | routine foo
126 | {
127 | trash x
128 | }
129 ? UnmeaningfulOutputError: x in foo
130
131 | routine foo
132 | outputs x
133 | {
134 | trash x
135 | }
136 ? UnmeaningfulOutputError: x in foo
137
138 If a routine causes a location to be trashed, this must be declared in the caller.
139
140 | routine trash_x
141 | trashes x, z, n
142 | {
143 | ld x, 0
144 | }
145 |
146 | routine foo
147 | trashes x, z, n
148 | {
149 | call trash_x
150 | }
151 = ok
152
153 | routine trash_x
154 | trashes x, z, n
155 | {
156 | ld x, 0
157 | }
158 |
159 | routine foo
160 | trashes z, n
161 | {
162 | call trash_x
163 | }
164 ? UnmeaningfulOutputError: x in foo
165
166 | routine trash_x
167 | trashes x, z, n
168 | {
169 | ld x, 0
170 | }
171 |
172 | routine foo
173 | outputs x
174 | trashes z, n
175 | {
176 | call trash_x
177 | }
178 ? UnmeaningfulOutputError: x in foo
90179
91180 If a routine reads or writes a user-define memory location, it needs to declare that too.
92181