NAME
Parrot::Test::PGE - test functions for Perl 6 Grammar Engine
SYNOPSIS
In a .t file:
use Parrot::Test tests => 2;
use Parrot::Test::PGE;
p6rule_is('abc', '^abc', 'BOS abc');
p6rule_is(" int argc ",
[
[ type => 'int | double | float | char' ],
[ ident => '\w+' ],
[ _MASTER => ':w<type> <ident>' ],
],
"simple subrules test");
p6rule_isnt('abc', '^bc', 'BOS bc');
p6rule_like('abcdef', 'bcd', qr/0: <bcd @ 1>/, '$0 capture');
DESCRIPTION
Parrot::Test::PGE provides functions for testing the grammar engine and Perl 6 rules.
Functions
p6rule_is($target, $pattern, $description)
-
Runs the target string against the Perl 6 pattern, passing the test if they match. Note that patterns should be specified as strings and without leading/trailing pattern delimiters.
(Hint: if you try using qr// for the $pattern then you're misreading what this does.)
subrules: In addition to a simple scalar string, the pattern can be a reference to an array of arrays. Containing subrules that refer to each other. In this form:
[ [ name1 => 'pattern 1' ], [ name2 => 'pattern 2' ], [ name3 => '<name1> pattern 3' ], [ _MASTER => '<name1> <name2> <name3>' ], ],
The last rule, labelled with _MASTER, is the rule that your target string will be matched against. The 'outer rule' if you will.
p6rule_isnt($target, $pattern, $description)
-
Runs the target string against the Perl 6 pattern, passing the test if they do not match. The same pattern argument syntax above applies here.
p6rule_like($target, $pattern, $expected, $description)
-
Runs the target string against the Perl 6 pattern, passing the test if the output produced by the test code matches the
$expected
parameter. Note that$expected
is a Perl 5 pattern.
AUTHOR
Patrick R. Michaud, pmichaud@pobox.com 18-Nov-2004