Chapter 24: Testing and Debugging
Section 24.1 Checking against the Index
This section says the index is a convenient way to check if you defined things correctly, like forgetting to make something scenery or accidentally creating two of an item.
I traditionally relied on custom things to do this (like printing out the description of every item), but working through this book has shown me how useful the Index is.)
Section 24.2 is Debugging features to use in source
The TEST command is great. I use this all the time to ensure that my game is still completable after changes.
You make new test commands like this:
Test me with "up / kill captain eo".
Test eo with "zap eo" holding the ray gun.
Test dinner with "eat bread / eat soup / eat butter" in the Ship Cafeteria.
Then you can start the game and type TEST ME or TEST EO, etc.
You can also merge tests:
Test megatest with "test me / test eo".
We can also use ‘showme’ in the middle of phrases to see what’s going on:
To say key score:
let count be the number of keys which are not carried by the player;
showme count;
if count is greater than 2 and the player is timid:
say "You're still missing a lot of keys, bucko!"
I’ve only recently started using SHOWME in this way; I previously would print out stuff like 'The current action is [current action]", or pretty often (I know this is stupide and childish) ‘say “poop”;’, since I knew I’d have to delete that (sorry if that stuck around in any of my games!)
Section 24.3 is High-level debugging commands
This includes SHOWME as an in-game command, which lists tons of stuff like this:
>SHOWME BAT
bat - thing
location: on the table in Locker Room
singular-named, improper-named; unlit, inedible, portable, patterned
printed name: "bat"
printed plural name: none
indefinite article: none
description: none
initial appearance: none
Another useful command I only learned about recently is ACTIONS, which gives output like this:
>ACTIONS
Actions listing on.
>JUMP
[jumping]
You jump on the spot.
[jumping - succeeded]
Something I’ve used for a very long time is RULES, which announces all rules which are running:
>RULES
Rules tracing now switched on. Type "rules off" to switch it off again, or "rules all" to include even rules which do not apply.
>JUMP
[Rule "announce items from multiple object lists rule" applies.]
[Rule "set pronouns from items from multiple object lists rule" applies.]
[Rule "before stage rule" applies.]
[Rule "instead stage rule" applies.]
[Rule "investigate player's awareness before action rule" applies.]
[Rule "player aware of his own actions rule" applies.]
[Rule "check stage rule" applies.]
[Rule "carry out stage rule" applies.]
[Rule "after stage rule" applies.]
[Rule "investigate player's awareness after action rule" applies.]
[Rule "report stage rule" applies.]
[Rule "report jumping rule" applies.]
You jump on the spot.
[Rule "last specific action-processing rule" applies.]
[Rule "A first turn sequence rule" applies.]
[Rule "every turn stage rule" applies.]
[Rule "A last turn sequence rule" applies.]
[Rule "notify score changes rule" applies.]
>
This is very useful in helping to track down problems. For some stuff though it doesn’t print anything, which always frustrated me until I learned (recently) that they are activities, which sadly don’t have an ACTIVITIES command.
Similarly, we have SCENES, which keeps a running list of scenes that are starting, running, or stopping.
RELATIONS and RESPONSES respectively print out all relations (I’ve never used this) and all responses (I use this a ton to figure out what responses to change!)
Finally, RANDOM sets the random generator to a specific seed, which lets the player avoid randomness in testing.
Section 24.4 is Low-level debugging commands
This is stuff like PURLOIN, ABSTRACT, and GONEAR, which respectively move something to the player (purloin sandwich), move something as direction (abstract sandwich to table), and move the player to the location of the object (gonear sandwich).
You can get runtime errors if you type dumb stuff into this.
You can also build-in some of this stuff into testing commands:
Test me with "eat grain" in the Fertile Plain.
(This puts the player in Fertile Plain immediately, like using GONEAR but with less computational power)
Similarly, Test me with "drop table" holding the table. puts the table in the player’s inventory.
VERIFY checks if the storyfile is intact, but it’s pretty rare to use.
TREE lists all object containment. I’ve used it occasionally to check for stray objects that were defined wrong (especially if I mistyped the name and made two of the object).
SCOPE lists objects in scope, which I’m just learning about now.
SHOWHEAP shows how many bytes are free.
TRACE, TRACE 2,…,TRACE 5 give increasingly more detailed info on what the parser is doing when it parses a line (and yet there’s no activity command; why not?)
Section 24.5 is Adding new testing verbs and release for testing
This is just like a brainstorming session for things to add, like jumping to different chapters, status information, and checking which puzzles are satisfied.
If you want testers to have access to testing commands that are pre-made or that you put in ‘not for release’ sections, you can compile Inform with ‘release for testing’, an option in the IDE.
Section 24.6 is Testing for thoroughness, which contains code like I described earlier (I must have borrowed it from here or someone else’s project years ago):
When play begins (this is the run property checks at the start of play rule):
repeat with item running through things:
if description of the item is "":
say "[item] has no description."
It also suggests the Object Response Tests by Juhana Leinonen. I tried downloading it from th public library in the IDE but it doesn’t compile, failing on the phrase ‘try the test-actor taking [the noun]’ and all other similar phrases.
Section 24.7 is Commands for beta-testers:
This just describes the TRANSCRIPT and TRANSCRIPT OFF commands., which allows beta testers to print out their adventures in the game. I know a lot of comp judges like to send in transcripts too, and IFComp automatically records people’s transcripts when people use the default interpreter.
Section 24.8 is Help from the user community, suggesting that people go to th exotic website intfiction.org to get programming advice and find testers. Sounds weird to me.