]> git.vpit.fr Git - perl/modules/re-engine-Plugin.git/blob - t/callbacks/exec.t
Introduce ->callbacks to specify the 'exec' callback individually
[perl/modules/re-engine-Plugin.git] / t / callbacks / exec.t
1 #!perl
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 4 * 2;
7
8 my $count;
9
10 use re::engine::Plugin comp => sub {
11  my ($re) = @_;
12
13  my $pat = $re->pattern;
14
15  $re->callbacks(
16   exec => sub {
17    my ($re, $str) = @_;
18
19    ++$count;
20
21    return $str eq $pat;
22   },
23  );
24 };
25
26 $count = 0;
27
28 ok "foo"  =~ /foo/;
29 is $count, 1;
30 ok "fool" !~ /foo/;
31 is $count, 2;
32
33 my $rx = qr/bar/;
34
35 ok "bar"  =~ $rx;
36 is $count, 3;
37 ok "foo"  !~ $rx;
38 is $count, 4;