File: 211_objects.t

package info (click to toggle)
libtest-regexp-perl 2017040101-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 220 kB
  • sloc: perl: 1,331; makefile: 2
file content (72 lines) | stat: -rwxr-xr-x 1,724 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/perl

use strict;
use warnings;
no  warnings 'syntax';

use 5.010;

use lib ".";

use Test::Tester;
use Test::Regexp import => [];
use t::Common;

my $pattern2 = '(\w+)\s+(\w+)';
my $pattern3 = '(\w+)\s+(\w+)\s+(\w+)';

my $checker2 = Test::Regexp -> new -> init (
    keep_pattern => $pattern2,
);
my $checker3 = Test::Regexp -> new -> init (
    keep_pattern => $pattern3,
);

my @data = (
    ['PFSSSSS',  'PPPPPPP',  [qw [tripoline a punta]]],
    ['PPPPPP',   'FSSSSS',   [qw [cannarozzi rigati]]],
    ['PPPPPP',   'FSSSSS',   [qw [lumache grandi]]],
    ['PFSSSSSS', 'PFSSSSSS', [qw [lasagne festonate a nidi]]],
    ['PFSSSSS',  'PPPPPPP',  [qw [corni di bue]]],
);

foreach my $data (@data) {
    my $expected2 = shift @$data;
    my $expected3 = shift @$data;
    my $captures  = shift @$data;
    my $subject   = join ' ' => @$captures;

    my $match_res;
    my ($premature, @results) = run_tests sub {
        $match_res = $checker2 -> match ($subject, $captures)
    };

    check results   => \@results,
          premature => $premature,
          expected  => $expected2,
          match     =>  1,
          match_res => $match_res,
          pattern   => $pattern2,
          subject   => $subject,
          captures  => $captures,
          keep      =>  1,
    ;

   ($premature, @results) = run_tests sub {
        $match_res = $checker3 -> match ($subject, $captures)
    };

    check results   => \@results,
          premature => $premature,
          expected  => $expected3,
          match     =>  1,
          match_res => $match_res,
          pattern   => $pattern3,
          subject   => $subject,
          captures  => $captures,
          keep      =>  1,
    ;

}

__END__