1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
use 5.010;
use Test::More 'no_plan';
use Regexp::Grammars;
my $grammar_noRG = qr{^a b$};
my $grammar_top = qr{
^ a b $
<rule: unused>
};
my $grammar_rule = qr{
<Rule>
<rule: Rule> ^ a b $
};
my $grammar_token = qr{
<Token>
<token: Token> ^ a b $
};
ok 'ab' !~ $grammar_noRG => 'No RG correctly fails without space';
ok 'a b' =~ $grammar_noRG => 'No RG correctly matches with space';
ok 'ab' =~ $grammar_top => 'Top correctly matches without space';
ok 'a b' !~ $grammar_top => 'Top correctly fails with space';
ok 'ab' =~ $grammar_token => 'Token correctly matches without space';
ok 'a b' !~ $grammar_token => 'Token correctly fails with space';
ok 'ab' =~ $grammar_rule => 'Rule correctly matches without space';
ok 'a b' =~ $grammar_rule => 'Rule correctly matches with space';
|