T3: New Extension

In a thread last year, Ben Cressey and Eric Eve came up with some code that allows T3 authors to create I7-style “test me” scripts. I’m finding this absolutely a joy to use, so I’ve uploaded it as an extension (tests.t) to the if-archive. It’s in programming > tads3 > library > contributions.

The syntax is only slightly more fussy than Inform’s. You use it like this:

Test 'bucket' [ 's', 'w', 'take bucket', 'put bucket in well', 'turn crank', 'x water' ];

In the debug version of the game, “test bucket” will now run those commands. This is sometimes more useful than replaying an entire script, because a script has to start at the top of the game.

Also, I’m not sure how one would capture or invoke scripts if not using Workbench. This extension will work no matter what development environment or OS you’re using.

Thanks for documenting this and uploading it, Jim.

You deserve credit as well; the initial code that gave rise to the extension came from you.

Thanks for putting this extension online Jim (and thanks to Ben Cressey and Eric Eve for helping with the original code). I have been using this extension and have come up with some improvements. I posted a half-baked tests2.t to the ifarchive prematurely now I’m asking for feedback for the next update (the latest version of tests2.t is attached to this post “.t extensions are not allowed to be uploaded”?! Oh well I put it in a zip).

How to use the test2 extension in your TADs game:

[code]define Test objects like so:

foo: Test
testName = ‘foo’
location = livingRoom //the player character will be moved to livingRoom before the test
testList = [ ‘x me’, ‘i’ ]

bar: Test
testName = ‘bar’
testList = [ ‘look’, ‘listen’ ]

//you can use the normal + notation to set the location automatically
randomRoom : Room

+fob: Test //location = randomRoom
testName = ‘fob’
testHolding = [ matches, bread ] //these items will be moved into the player character’s inventory before the test.
testList = [ ‘light fire’, ‘toast bread’ ]

all: Test
testName = ‘all’
testList =
‘test foo’,
‘test bar’,
‘test fob’

Alternatively, you can include the following lines at the head of your file of test scripts: (a header file tests2.h with these lines is included in the zip - you can #include it in all your .t source files)


Test template ‘testName’ [testList] @location? [testHolding]?;
Test template ‘testName’ [testList] [testHolding]? @location?;

…and then use the template structure to create your test objects more conveniently:

someTest: Test ‘foo’ [‘x me’, ‘i’];
someTestInBedroom: Test ‘bedroom’ [‘x bed’, ‘enter bed’] @Bedroom;
someTestWithMobile: Test ‘mobile’ [‘x mobile’, ‘call bob’] [mobile_phone];

Unless you’re planning to refer to the Test object in some other part of your code,
you can save a bit of typing by making it an anonymous object:

Test ‘foo’ [‘x me’, ‘i’];


Modifications to the original test extension:

[]location property - a test can be specified to occur in a specific room. The usual + composition works too.[/]
[]testHolding property - a test can be specified to occur with the player holding a list of game objects (beware that some types of object don’t appear in inventory but you can examine them).[/]
[]Use TemporaryFile for scripts.[/]
[]Eat your own dogfood - now tests2 has it’s own tests - define the symbol TEST_TESTS to enable them.[/]

Thanks again to Jim Aikin for great suggestions and help getting tests2 to work.
tests2.zip (3.08 KB)