Checkpoints by Peter Orme

Version 1.0.220524

A method of using assertions stored in a table to verify your game works as expected.


Chapter 1: The idea

Chapter 2: Using the Table of Checkpoints

Chapter 3: running assertions

Examples
   
A — Bring your own ball
   
B — How to Fix an Airlock


Chapter 1: The idea

One idea is that we want to write a "test me" script for our story, but also have that test script actually perform 'unit testing'-type assertions along the way.

Another idea is to have known "checkpoints" in our story that you can get to, and you want to test that the state of the world is as you think it is at these points.


Chapter 2: Using the Table of Checkpoints

To write assertions, you create a table called Table of Checkpoints (continued) which has exactly three columns: "topic", "assertion" and "message".

The first column, "topic", is a topic column. The easiest thing here is just to type in a single keyword in quotes. Consult section 16.13 in the documentation to read up on more fun you can do with topic columns. You can have the same value in multiple rows of your column, and use these as a way to group test.

The second columnt, "assertion", is a little special. It contains a double-quoted string that should be empty for the assertion to succeed. Just typing in an empty string (just two quotes) will work, but it's not really testing anything, is it. So what we typically do is use bracketed expressions like "[if the ball is red]fail[end if]"

It does not need to say "fail" on failure, it can say anything.

The third column, "message", is just any text that will be shown on failure.


Chapter 3: running assertions

To trigger running all the assertions that match the topic column while playing a game, type in "checkpoint assert xxx" where xxx matches the topic. See example A.

If we must, we can also make in-world games that trigger assertions using something like this:

The button is a thing in the football field.

instead of pushing the button:

try checkpoint-asserting "baller".


A
 Example Bring your own ball

Using checkpoints assertion in a test script.


B
 Example How to Fix an Airlock

Using both checkpoint assertions and a checkpoint script