File: capture.t

package info (click to toggle)
libre-engine-re2-perl 0.18%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 440 kB
  • sloc: cpp: 270; perl: 80; makefile: 2; sh: 1
file content (39 lines) | stat: -rw-r--r-- 717 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
31
32
33
34
35
36
37
38
39
use strict;

use Test::More tests => 20;

use re::engine::RE2;

unless ("eep aoeu 420 eek" =~ /(.)(.)(.)(.) ([0-9]+)/) {
    fail "didn't match";
} else {
    is($`, "eep ");
    is($', " eek");
    is($&, "aoeu 420", '$&');

    is($1, "a", '$1 = a');
    is($2, "o", '$2 = o');
    is($3, "e", '$3 = e');
    is($4, "u", '$4 = u');
    is($5, "420", '$5 = 420');
    is($6, undef, '$6 = undef');
    is($640, undef, '$640 = undef');
}

unless ("aoeuhtns" =~ /(.)(.)(.)(.)/g) {
    fail "didn't match";
} else {
    is($1, "a");
    is($2, "o");
    is($3, "e");
    is($4, "u");
    is($5, undef);
    is($6, undef);
    is($7, undef);
    is($8, undef);
}

my ($a, $b) = "ab" =~ /(.)/g;
is($a, "a");
is($b, "b");