File: backref_ARG.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 (30 lines) | stat: -rw-r--r-- 843 bytes parent folder | download | duplicates (5)
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
use strict;
use 5.010;

use Test::More 'no_plan';

my $test_grammar = do {
    use Regexp::Grammars;
    qr{
        <keyword=(\w+)>
            <content=(.+?)>
        <end_keyword (:keyword)>

      | <keyword=(\w+)>
            <content=(.+?)>
        <rev_keyword(:keyword)>

        <token: end_keyword>   end_ <\:keyword>
        <token: rev_keyword>        </:keyword>
    }xms;
};

ok 'fooxend_foo' =~ $test_grammar => 'Match end';
is $/{keyword}, 'foo'             => 'Keyword as expected';
is $/{content}, 'x'               => 'Content as expected';
is $/{end_keyword}, 'end_foo'     => 'End_keyword as expected';

ok 'fooxoof' =~ $test_grammar => 'Match rev';
is $/{keyword}, 'foo'         => 'Keyword as expected';
is $/{content}, 'x'           => 'Content as expected';
is $/{rev_keyword}, 'oof'     => 'End_keyword as expected';