PGAS and Games::Golf presentation

So you want to host a Perl golf contest? These games can be quite successful: for example the golf game organised by The Perl Review volume 0 issue 1 had more than 100 players, and a total of 500 entries were submitted.

So you need tools to run one of those fun and successful games.

PGAS (Perl Golf A S) is such a tool. Based on Games::Golf, a serie of modules to help writing tests for golf games, it should make the

Features for the organiser

Features for the referees

Features for the players

Referee: Creating a test suite for use with Games::Golf

The test script used by the players makes use of the methods provided by the Games::Golf::TestSuite object.

A test suite is written in Perl. But since that code is in fact eval()ed somewhere deep in Games::Golf::TestSuite, you really have very little work to do.

A typical test suite will look like this:

# First test: the player script should at least compile
$test->compile;
$test->ioee( << INPUT, << OUTPUT, "", 0 );
This is the input
INPUT
We wait for this output
OUTPUT

Testing a script

Two methods are used only for scripts:

compile
ioee

Testing a sub

Three methods are used only for subs:

makesub
sub
ok

Other available methods

The following methods are used to test the code itself:

not_string
not_match

Placing restrictions on the code

You can force any test to break if some restrictions are not respected. More precisely, you can limit the running time of the script (by a timeout), and the size of stdout and stderr.

Player

Using the test script

Using PGAS

Credits

Games::Golf and PGAS authors

This article's authors