Help language development. Donate to The Perl Foundation

Test::Grammar zef:jjmerelo last updated on 2022-12-21


Test::Grammar for Raku Test in a Raku container - template

Unit testing for grammars. Because testing is important.


No dependencies, except Test which is a Rakudo core library, so the usual zef install Test::Grammar.


Copied from the source, version there is the single source of truth:

use Test::Grammar;

parses-ok Test-Grammar,"num", 3, "33 parses OK";

my $test-output = q:to/EOC/;
ok 1 - bailout parses OK
ok 2 - «bailout» extracts token

has-tokens Test-Grammar, "test", <nok num description>, $test-output,
    "Complete tests";

token-is Test-Grammar,"bailout", "explanation",
    "Bail out! FOOBAR",
    "«bailout» extracts token";

for <foo bar b3> {
    parses-nok Test-Grammar,"num", $_, "$_ not parsed";

See also

There are very nice testing libraries out there:


(c) JJ Merelo, [email protected], 2022

Licensed under the Artistic 2.0 License (the same as Raku itself).