Add some rudimentary automated tests.
Cat's Eye Technologies
8 years ago
0 | Tests for ZOWIE | |
1 | =============== | |
2 | ||
3 | -> Tests for functionality "Interpret ZOWIE Program" | |
4 | ||
5 | -> Functionality "Interpret ZOWIE Program" is implemented by | |
6 | -> shell command | |
7 | -> "python src/zowie.py %(test-body-file)" | |
8 | ||
9 | Display the Roman alphabet in reverse. | |
10 | ||
11 | | MOV R10, 90 ; initially it's "Z" | |
12 | | MOV R1, R1 ; BEGIN TRANSACTION for "REPEAT" | |
13 | | MOV R0, R10 ; output character | |
14 | | MOV R8, R10 ; decrement character | |
15 | | MOV R5, 1 | |
16 | | MOV R10, R8 | |
17 | | MOV R8, R10 ; test if character is above "@" | |
18 | | MOV R5, 64 | |
19 | | MOV R3, R8 ; COMMIT AND REPEAT if non-zero | |
20 | = ZYXWVUTSRQPONMLKJIHGFEDCBA | |
21 | ||
22 | Compute a factorial. | |
23 | ||
24 | | MOV R11, 5 ; let's find 5! | |
25 | | MOV R10, 1 ; accumulator | |
26 | | | |
27 | | MOV R8, R11 ; increase multiplicand | |
28 | | MOV R4, 1 | |
29 | | MOV R11, R8 | |
30 | | | |
31 | | MOV R1, R1 ; BEGIN TRANSACTION for "REPEAT" | |
32 | | | |
33 | | MOV R8, R11 ; decrease multiplicand | |
34 | | MOV R5, 1 | |
35 | | MOV R11, R8 | |
36 | | | |
37 | | MOV R1, R1 ; BEGIN TRANSACTION for "IF" | |
38 | | | |
39 | | MOV R8, R10 ; accumulator | |
40 | | MOV R6, R11 ; multiplied | |
41 | | MOV R10, R8 | |
42 | | | |
43 | | MOV R2, R11 ; COMMIT if multiplicand above zero, or ROLLBACK otherwise | |
44 | | MOV R3, R11 ; COMMIT AND REPEAT if multiplicand above zero | |
45 | | | |
46 | | MOV R0, R10 ; output accumulator (as single Unicode character) | |
47 | = x |