git @ Cat's Eye Technologies SixtyPical / d598b50
Add more tests. Chris Pressey 3 years ago
1 changed file(s) with 97 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
32223222 | }
32233223 = ok
32243224
3225 Here, we declare that main outputs `a`, and we `goto` two routines, and they both output `a`.
3226
3227 | define bar0 routine
3228 | inputs x
3229 | outputs a
3230 | trashes x, z, n
3231 | {
3232 | ld a, x
3233 | }
3234 |
3235 | define bar1 routine
3236 | inputs x
3237 | outputs a
3238 | trashes x, z, n
3239 | {
3240 | ld a, 200
3241 | }
3242 |
3243 | define main routine
3244 | outputs a
3245 | trashes x, z, n
3246 | {
3247 | ld x, 0
3248 | if z {
3249 | ld x, 1
3250 | goto bar0
3251 | } else {
3252 | ld x, 2
3253 | goto bar1
3254 | }
3255 | }
3256 = ok
3257
3258 Here is like just above, but one routine doesn't output `a`.
3259
3260 | define bar0 routine
3261 | inputs x
3262 | outputs a
3263 | trashes x, z, n
3264 | {
3265 | ld a, x
3266 | }
3267 |
3268 | define bar1 routine
3269 | inputs x
3270 | trashes x, z, n
3271 | {
3272 | ld x, 200
3273 | }
3274 |
3275 | define main routine
3276 | outputs a
3277 | trashes x, z, n
3278 | {
3279 | ld x, 0
3280 | if z {
3281 | ld x, 1
3282 | goto bar0
3283 | } else {
3284 | ld x, 2
3285 | goto bar1
3286 | }
3287 | }
3288 ? InconsistentExitError
3289
3290 Here is like the above, but the two routines have different inputs, and that's OK.
3291
3292 | define bar0 routine
3293 | inputs x
3294 | outputs a
3295 | trashes x, z, n
3296 | {
3297 | ld a, x
3298 | }
3299 |
3300 | define bar1 routine
3301 | outputs a
3302 | trashes x, z, n
3303 | {
3304 | ld a, 200
3305 | }
3306 |
3307 | define main routine
3308 | outputs a
3309 | trashes x, z, n
3310 | {
3311 | ld x, 0
3312 | if z {
3313 | ld x, 1
3314 | goto bar0
3315 | } else {
3316 | ld x, 2
3317 | goto bar1
3318 | }
3319 | }
3320 = ok
3321
32253322 TODO: we should have a lot more test cases for the above, here.
32263323
32273324 Can't `goto` a routine that outputs or trashes more than the current routine.