File: 150_reason.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 (47 lines) | stat: -rwxr-xr-x 1,243 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
#!/usr/bin/perl

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

use 5.010;

use lib ".";

use Test::Tester;
use Test::Regexp;
use t::Common;

my $match_res;

foreach my $reason (undef, "", 0, "Bla bla bla") {
    foreach my $name ("", "Baz", "Qux Quux") {
        foreach my $match (0, 1) {
            my $pattern = $match ? qr {Foo} : qr {Bar};
            my ($premature, @results) = run_tests sub {
                $match_res = match subject => "Foo",
                                   pattern => $pattern,
                                   match   => $match,
                                   reason  => $reason,
                                   test    => $reason,
                                   name    => $name,
            };

            check results   => \@results,
                  premature => $premature,
                  expected  => $match ? 'PPPP' : 'P',
                  match     => $match,
                  match_res => $match_res,
                  pattern   => $pattern,
                  subject   => "Foo",
                  comment   => $name,
                  keep      => 0,
        $match ? (test      => $reason)
               : (reason    => $reason),
            ;
        }
    }
}


__END__