File: seplist_trailing__rawhash.t

package info (click to toggle)
libregexp-grammars-perl 1.058-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,328 kB
  • sloc: perl: 53,328; makefile: 2
file content (40 lines) | stat: -rw-r--r-- 873 bytes parent folder | download | duplicates (2)
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
38
39
40
use 5.010;
use warnings;

use Test::More 'no_plan';

use Regexp::Grammars;

my $raw_hash = qr{
    \A
    (?: <solution> | <percentage> | <perl_hash> | <perl_mod> )
    \Z

    <token: percentage>
        \d{1,3} \%\%

    <token: perl_hash>
        \%\% \w+

    <rule: perl_mod>
        <perl_hash> \%\% <percentage>

    <rule: solution>
        \d{1,3} \%\% solution

}xms;

no Regexp::Grammars;

ok +('7%% solution' =~ $raw_hash) => 'Matched <solution>';
ok exists $/{solution}           => '...and matched correct rule';

ok +('7%%' =~ $raw_hash)  => 'Matched <percentage>';
ok exists $/{percentage} => '...and matched correct rule';

ok +('%%foo' =~ $raw_hash)  => 'Matched <perl_hash>';
ok exists $/{perl_hash} => '...and matched correct rule';

ok +('%%bar %% 42%%' =~ $raw_hash)  => 'Matched <perl_mod>';
ok exists $/{perl_mod} => '...and matched correct rule';